]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 129466 - use IP addr (not hostname) in logincookies table
authorbbaetz%student.usyd.edu.au <>
Sat, 16 Mar 2002 14:03:09 +0000 (14:03 +0000)
committerbbaetz%student.usyd.edu.au <>
Sat, 16 Mar 2002 14:03:09 +0000 (14:03 +0000)
r=gerv, justdave

CGI.pl
checksetup.pl

diff --git a/CGI.pl b/CGI.pl
index 76c53627df99b086c046eb90274e4fa5a4ec4b5e..e100c69f37203881ce847af97ea760cda8862600 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -695,15 +695,12 @@ sub quietly_check_login() {
     if (defined $::COOKIE{"Bugzilla_login"} &&
         defined $::COOKIE{"Bugzilla_logincookie"}) {
         ConnectToDatabase();
-        if (!defined $ENV{'REMOTE_HOST'}) {
-            $ENV{'REMOTE_HOST'} = $ENV{'REMOTE_ADDR'};
-        }
         SendSQL("SELECT profiles.userid, profiles.groupset, " .
                 "profiles.login_name, " .
                 "profiles.login_name = " .
                 SqlQuote($::COOKIE{"Bugzilla_login"}) .
-                " AND logincookies.hostname = " .
-                SqlQuote($ENV{"REMOTE_HOST"}) .
+                " AND logincookies.ipaddr = " .
+                SqlQuote($ENV{"REMOTE_ADDR"}) .
                 ", profiles.disabledtext " .
                 " FROM profiles, logincookies WHERE logincookies.cookie = " .
                 SqlQuote($::COOKIE{"Bugzilla_logincookie"}) .
@@ -988,10 +985,7 @@ sub confirm_login {
      # the cookies.
      if($enteredlogin ne "") {
        $::COOKIE{"Bugzilla_login"} = $enteredlogin;
-       if (!defined $ENV{'REMOTE_HOST'}) {
-         $ENV{'REMOTE_HOST'} = $ENV{'REMOTE_ADDR'};
-       }
-       SendSQL("insert into logincookies (userid,hostname) values (@{[DBNameToIdAndCheck($enteredlogin)]}, @{[SqlQuote($ENV{'REMOTE_HOST'})]})");
+       SendSQL("insert into logincookies (userid,ipaddr) values (@{[DBNameToIdAndCheck($enteredlogin)]}, @{[SqlQuote($ENV{'REMOTE_ADDR'})]})");
        SendSQL("select LAST_INSERT_ID()");
        my $logincookie = FetchOneColumn();
 
index ab8b723fabcbf117b1b0d2eb1f9bc6cd5d34f244..ba5d1e08771fd15683aad3cb888930ffb2441d27 100755 (executable)
@@ -1155,11 +1155,10 @@ $table{groups} =
     unique(bit),
     unique(name)';
 
-
 $table{logincookies} =
    'cookie mediumint not null auto_increment primary key,
     userid mediumint not null,
-    hostname varchar(128),
+    ipaddr varchar(40) NOT NULL,
     lastused timestamp,
 
     index(lastused)';
@@ -2706,6 +2705,17 @@ if (GetFieldDef("bugs","qacontact_accessible")) {
     DropField("bugs", "assignee_accessible");
 }
 
+# 2002-03-15 bbaetz@student.usyd.edu.au - bug 129466
+# Use the ip, not the hostname, in the logincookies table
+if (GetFieldDef("logincookies", "hostname")) {
+    # We've changed what we match against, so all entries are now invalid
+    $dbh->do("DELETE FROM logincookies");
+
+    # Now update the logincookies schema
+    DropField("logincookies", "hostname");
+    AddField("logincookies", "ipaddr", "varchar(40) NOT NULL");
+}
+
 # If you had to change the --TABLE-- definition in any way, then add your
 # differential change code *** A B O V E *** this comment.
 #