Bug 443570

Summary: FEAT: Match the new db schema of bz3.0 [#11 TABLE logincookies]
Product: [Retired] Red Hat Hardware Certification Program Reporter: XINSUN <xisun>
Component: Hardware CatalogAssignee: XINSUN <xisun>
Status: CLOSED CURRENTRELEASE QA Contact: Yu Shao <yshao>
Severity: medium Docs Contact:
Priority: medium    
Version: 5CC: bxu, dkl, efeng, kbaker, nelhawar, rlandry, tfu, xiqin, ykun, yshao
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 3.2rh-20080801.1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-08-04 17:56:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 443456    
Attachments:
Description Flags
Patch to convert auth system to use 3.2 style cookies (v1)
none
Patch to convert auth system to use 3.2 style cookies (v2)
none
For patching operation
none
patch merge change. none

Description XINSUN 2008-04-22 08:49:02 UTC
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 16:08:47 UTC
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 17:05:59 UTC
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 19:54:55 UTC
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 15:33:28 UTC
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-25 02:39:54 UTC
 This patch works well for me. thanks.

Comment 6 XINSUN 2008-04-25 14:00:18 UTC
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 11:40:37 UTC
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 21:07:46 UTC
Nicho, so is this patch moved to the other bugs or only updated here or...?

Comment 9 XINSUN 2008-07-18 17:19:16 UTC
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 17:52:54 UTC
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 18:25:13 UTC
np, can you have eng-ops review the correct patch then, and if accepted and
tested well commit it?

Comment 13 XINSUN 2008-07-21 03:41:18 UTC
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 18:40:59 UTC
Checked into cvs.

Comment 15 eric_liu 2008-08-01 11:31:51 UTC
tested and run good