diff options
author | jocuri%softhome.net <> | 2004-12-26 04:16:04 +0100 |
---|---|---|
committer | jocuri%softhome.net <> | 2004-12-26 04:16:04 +0100 |
commit | 420dc4dfe566902d417462a30038f9484c746d7c (patch) | |
tree | f788999b72756313bfdaefc22ac0a1f9da401d43 | |
parent | e6ad3b4b5a110816ccdfc70df4c643651f0f7561 (diff) | |
download | bugzilla-420dc4dfe566902d417462a30038f9484c746d7c.tar.gz bugzilla-420dc4dfe566902d417462a30038f9484c746d7c.tar.xz |
Patch for bug 264160: Make all default groups inherit the admin group on a new install; patch by Marc Schumann <wurblzap@gmail.com>, r=mkanat, r=travis, a=justdave.
-rwxr-xr-x | checksetup.pl | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/checksetup.pl b/checksetup.pl index 1052d8f02..18c65ba98 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -4466,30 +4466,24 @@ if ($sth->rows == 0) { $sth->execute(); my ($userid) = $sth->fetchrow_array(); - foreach my $group (@groups) { - my $query = "SELECT user_id FROM user_group_map - WHERE group_id = $group AND user_id = $userid - AND isbless = 0"; - $sth = $dbh->prepare($query); - $sth->execute(); - if ( !$sth->fetchrow_array() ) { - $dbh->do("INSERT INTO user_group_map - (user_id, group_id, isbless, grant_type) - VALUES ($userid, $group, 0, " . GRANT_DIRECT . ")"); - } - } - # the admin also gets an explicit bless capability for the admin group - my $sth = $dbh->prepare("SELECT id FROM groups - WHERE name = 'admin'"); - $sth->execute(); - my ($id) = $sth->fetchrow_array(); + # Admins get explicit membership and bless capability for the admin group + my ($admingroupid) = $dbh->selectrow_array("SELECT id FROM groups + WHERE name = 'admin'"); $dbh->do("INSERT INTO user_group_map (user_id, group_id, isbless, grant_type) - VALUES ($userid, $id, 1, " . GRANT_DIRECT . ")"); + VALUES ($userid, $admingroupid, 0, " . GRANT_DIRECT . ")"); + $dbh->do("INSERT INTO user_group_map + (user_id, group_id, isbless, grant_type) + VALUES ($userid, $admingroupid, 1, " . GRANT_DIRECT . ")"); + + # Admins get inherited membership and bless capability for all groups foreach my $group ( @groups ) { $dbh->do("INSERT INTO group_group_map (member_id, grantor_id, grant_type) - VALUES ($id, $group, " . GROUP_BLESS . ")"); + VALUES ($admingroupid, $group, " . GROUP_MEMBERSHIP . ")"); + $dbh->do("INSERT INTO group_group_map + (member_id, grantor_id, grant_type) + VALUES ($admingroupid, $group, " . GROUP_BLESS . ")"); } print "\n$login is now set up as an administrator account.\n"; |