This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 443570 - FEAT: Match the new db schema of bz3.0 [#11 TABLE logincookies]
FEAT: Match the new db schema of bz3.0 [#11 TABLE logincookies]
Status: CLOSED CURRENTRELEASE
Product: Red Hat Hardware Certification Program
Classification: Red Hat
Component: Hardware Catalog (Show other bugs)
5
All Linux
medium Severity medium
: ---
: ---
Assigned To: XINSUN
Yu Shao
:
Depends On:
Blocks: hwcert->BZ3_tracker
  Show dependency treegraph
 
Reported: 2008-04-22 04:49 EDT by XINSUN
Modified: 2008-08-04 13:56 EDT (History)
10 users (show)

See Also:
Fixed In Version: 3.2rh-20080801.1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-08-04 13:56:47 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Patch to convert auth system to use 3.2 style cookies (v1) (26.38 KB, patch)
2008-04-23 15:54 EDT, David Lawrence
no flags Details | Diff
Patch to convert auth system to use 3.2 style cookies (v2) (27.22 KB, patch)
2008-04-24 11:33 EDT, David Lawrence
no flags Details | Diff
For patching operation (25.71 KB, patch)
2008-04-25 10:00 EDT, XINSUN
no flags Details | Diff
patch merge change. (27.28 KB, patch)
2008-07-03 07:40 EDT, XINSUN
no flags Details | Diff

  None (edit)
Description XINSUN 2008-04-22 04:49:02 EDT
11.Relate to TABLE logincookies need to change list below:
    11.1  Added the new field ipaddr
          Added :    FIELD  logincookies.ipaddr
          Removed:    N/A

(Maybe the cookies module will be rewrite or copy from bz3.2. because currently
our hwcert's cookies part doesn't work and cannot save the cookies in the
session cycle of browser on the new schema.)
Comment 1 David Lawrence 2008-04-23 12:08:47 EDT
I did the original conversion of the cookies code when we did the PostgreSQL to
MySQL conversion last august. I can take this task if noone objects.

Dave
Comment 2 XINSUN 2008-04-23 13:05:59 EDT
Hi Dave,
     Thanks a lot. :)
     
    "The hwcert cannot save the cookies in the session cycle of browser on the
new schema" is not caused by "Added the new field ipaddr".
I have spent one night for debug the cookies part codes, and found out the
reason is that the field "logincookies.cookie"'s Type is "varchar(16)" in the
new 3.2 schema while  the field "logincookies.cookie"'s Type is "varchar(40)" in
the old 2.18 schema. In the 2.18's cookie codes,the token is a string which have
40 chars and are generate by func:generate_unique_id (), it is like
("4811fe1c7da89ad71b1bd0799580678352a75a42"). When we turn to the new 3.2 schema
with the 2.18's cookies codes, the 40 char string will be cut to 16 chars and
save into db logincookies.cookie. it is like ("4811fe1c7da89ad7").So they
doesn't match and the authenticate will fail.

Best Regards!
Nicho
Comment 3 David Lawrence 2008-04-23 15:54:55 EDT
Created attachment 303544 [details]
Patch to convert auth system to use 3.2 style cookies (v1)

Attaching a patch that allows hwcert code to use 3.2 style cookies.

Basically I took the older stock 2.18 Bugzilla/Auth.pm,
Bugzilla/Auth/Cookie.pm, and Auth/CGI.pm and put them in place of the current
modules. I then converted the code to use the
Bugzilla::Token::GenerateUniqueToken to create a key that is used in
logincookies.cookie. Also I added code in Bugzilla/Auth.pm that checks for
X_FORWARDED_FOR which allows us to see the clients real ipaddress for
logincookies.ipaddr. I have test this on bugdev and login seems to work
properly. I did have to drop the code in Bugzilla/User.pm that looks for
profiles.refreshed_when in order to test my changes. I think that column is
being worked on in a separate bug.

Please review
Dave
Comment 4 David Lawrence 2008-04-24 11:33:28 EDT
Created attachment 303648 [details]
Patch to convert auth system to use 3.2 style cookies (v2)

New patch that fixes the issue where logincookie entries were not being deleted
properly on logout. Also fixed a few other errors with removing cookies, etc.

Please review.
Dave
Comment 5 XINSUN 2008-04-24 22:39:54 EDT
 This patch works well for me. thanks.
Comment 6 XINSUN 2008-04-25 10:00:18 EDT
Created attachment 303787 [details]
For patching operation

< Index: Bugzilla/User.pm
< ===================================================================
< RCS file: /cvs/qa/hwcert/Bugzilla/User.pm,v
< retrieving revision 1.1.1.1
< diff -u -r1.1.1.1 User.pm
< --- Bugzilla/User.pm	16 Nov 2004 16:42:36 -0000	1.1.1.1
< +++ Bugzilla/User.pm	24 Apr 2008 15:31:37 -0000
< @@ -100,27 +100,6 @@
<
<      bless ($self, $class);
<
< -    # Now update any old group information if needed
< -    my $result = $dbh->selectrow_array(q{SELECT 1
< -					      FROM profiles, groups
< -					     WHERE userid=?
< -					       AND profiles.refreshed_when <=
< -						     groups.last_changed},
< -					  undef,
< -					  $id);
< -
< -    if ($result) {
< -	   my $is_main_db;
< -	   unless ($is_main_db = Bugzilla->dbwritesallowed()) {
< -	       Bugzilla->switch_to_main_db();
< -	   }
< -	   # FIXME Throws error due to unique constraint differences in current
db
< -	   #$self->derive_groups($tables_locked_for_derive_groups);
< -	   unless ($is_main_db) {
< -	       Bugzilla->switch_to_shadow_db();
< -	   }
< -    }
< -
<      return $self;
<  }
<
< @@ -321,14 +300,7 @@
<	       }
<	   }
<      }
< -
< -    $dbh->do(q{UPDATE profiles
< -		     SET refreshed_when = ?
< -		   WHERE userid=?},
< -		undef,
< -		$time,
< -		$id);
< -
< +
<      Bugzilla::DB::UnlockTables() unless $already_locked;
<  }


As all the bug's patch will be patched into one code tree.So above codes have
been moved to bug 443561 and bug 443566's patch.

Best Regards!
Nicho
Comment 7 XINSUN 2008-07-03 07:40:37 EDT
Created attachment 310913 [details]
patch merge change.

Because previous patch (303787) is diffed before adding extra log for cookies
issue into our catalog. So after our pushing that into live site. we need to do
this patch again.  I have tested this patch well. and deploy all the patches of
"the match bz 3.2 db series bugs/feature" on the site:
http://bugdev.devel.redhat.com/hwcert-xisun2/ and test well.

Best Regards!
Nicho
Comment 8 Rob Landry 2008-07-17 17:07:46 EDT
Nicho, so is this patch moved to the other bugs or only updated here or...?
Comment 9 XINSUN 2008-07-18 13:19:16 EDT
Dear Rob,
    This patch(310913) is only updated here. because the original patch (303787)
was worked out and have passed the code review by dkl before adding extra log
for cookies issue #bug431701, after we have fixed #bug431701 and check the
change into cvs and push into live site, we need update the orignal patch
(303787), So this patch(310913) is the update version for this bug/match 3.2
db's logincookies tables' change.

Hope nicho has explained that clearly :)

Best Regards
nicho
Comment 10 Rob Landry 2008-07-18 13:52:54 EDT
are both patches needed or should "Patch to convert auth system to use 3.2 style
cookies (v2)" be obsoleted?
Comment 12 Rob Landry 2008-07-18 14:25:13 EDT
np, can you have eng-ops review the correct patch then, and if accepted and
tested well commit it?
Comment 13 XINSUN 2008-07-20 23:41:18 EDT
The patch's review was passed by Noura, and she advice me to ask Dave to
double-check this patch.

dkl,reference
    Pls help me to review the patch (attach_id: 310913), and Comment #9
explained the reason why we redo this as a new patch (310913) and need u to help
to review it again.

The test instance is http://bugdev.devel.redhat.com/hwcert-xisun2/ . 

Thank you very much in advance. 

Nicho.
Comment 14 XINSUN 2008-07-23 14:40:59 EDT
Checked into cvs.
Comment 15 eric_liu 2008-08-01 07:31:51 EDT
tested and run good 

Note You need to log in before you can comment on or make changes to this bug.