Commit e15776a6 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 354868: Race condition when changing user privs in editusers.cgi - Patch by…

Bug 354868: Race condition when changing user privs in editusers.cgi - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=wicked a=LpSolit
parent 065fa877
...@@ -235,7 +235,10 @@ if ($action eq 'search') { ...@@ -235,7 +235,10 @@ if ($action eq 'search') {
'groups READ', 'groups READ',
'user_group_map WRITE', 'user_group_map WRITE',
'group_group_map READ', 'group_group_map READ',
'group_group_map AS ggm READ'); 'group_group_map AS ggm READ',
'user_group_map AS directmember READ',
'user_group_map AS regexpmember READ',
'user_group_map AS directbless READ');
$editusers || $user->can_see_user($otherUser) $editusers || $user->can_see_user($otherUser)
|| ThrowUserError('auth_failure', {reason => "not_visible", || ThrowUserError('auth_failure', {reason => "not_visible",
...@@ -282,15 +285,16 @@ if ($action eq 'search') { ...@@ -282,15 +285,16 @@ if ($action eq 'search') {
# silently. # silently.
# XXX: checking for existence of each user_group_map entry # XXX: checking for existence of each user_group_map entry
# would allow to display a friendlier error message on page reloads. # would allow to display a friendlier error message on page reloads.
userDataToVars($otherUserID);
my $permissions = $vars->{'permissions'};
foreach (@{$user->bless_groups()}) { foreach (@{$user->bless_groups()}) {
my $id = $$_{'id'}; my $id = $$_{'id'};
my $name = $$_{'name'}; my $name = $$_{'name'};
# Change memberships. # Change memberships.
my $oldgroupid = $cgi->param("oldgroup_$id") || '0'; my $groupid = $cgi->param("group_$id") || 0;
my $groupid = $cgi->param("group_$id") || '0'; if ($groupid != $permissions->{$id}->{'directmember'}) {
if ($groupid ne $oldgroupid) { if (!$groupid) {
if ($groupid eq '0') {
$sth_remove_mapping->execute( $sth_remove_mapping->execute(
$otherUserID, $id, 0, GRANT_DIRECT); $otherUserID, $id, 0, GRANT_DIRECT);
push(@groupsRemovedFrom, $name); push(@groupsRemovedFrom, $name);
...@@ -304,10 +308,9 @@ if ($action eq 'search') { ...@@ -304,10 +308,9 @@ if ($action eq 'search') {
# Only members of the editusers group may change bless grants. # Only members of the editusers group may change bless grants.
# Skip silently if this is not the case. # Skip silently if this is not the case.
if ($editusers) { if ($editusers) {
my $oldgroupid = $cgi->param("oldbless_$id") || '0'; my $groupid = $cgi->param("bless_$id") || 0;
my $groupid = $cgi->param("bless_$id") || '0'; if ($groupid != $permissions->{$id}->{'directbless'}) {
if ($groupid ne $oldgroupid) { if (!$groupid) {
if ($groupid eq '0') {
$sth_remove_mapping->execute( $sth_remove_mapping->execute(
$otherUserID, $id, 1, GRANT_DIRECT); $otherUserID, $id, 1, GRANT_DIRECT);
push(@groupsDeniedRightsToBless, $name); push(@groupsDeniedRightsToBless, $name);
......
...@@ -72,9 +72,7 @@ ...@@ -72,9 +72,7 @@
name="bless_[% group.id %]" name="bless_[% group.id %]"
value="1" value="1"
[% ' checked="checked"' IF perms.directbless %] /> [% ' checked="checked"' IF perms.directbless %] />
[% ']' IF perms.indirectbless %] [% ']' IF perms.indirectbless %]</td>
[% %]<input type="hidden" name="oldbless_[% group.id %]"
value="[% perms.directbless %]" /></td>
[% END %] [% END %]
<td class="checkbox"> <td class="checkbox">
[% '[' IF perms.derivedmember %] [% '[' IF perms.derivedmember %]
...@@ -85,9 +83,7 @@ ...@@ -85,9 +83,7 @@
value="1" value="1"
[% ' checked="checked"' IF perms.directmember %] /> [% ' checked="checked"' IF perms.directmember %] />
[% '*' IF perms.regexpmember %] [% '*' IF perms.regexpmember %]
[% ']' IF perms.derivedmember %] [% ']' IF perms.derivedmember %]</td>
[% %]<input type="hidden" name="oldgroup_[% group.id %]"
value="[% perms.directmember %]" /></td>
<td class="groupname"> <td class="groupname">
<label for="group_[% group.id %]"> <label for="group_[% group.id %]">
<strong>[% group.name FILTER html %]:</strong> <strong>[% group.name FILTER html %]:</strong>
......
...@@ -542,8 +542,6 @@ ...@@ -542,8 +542,6 @@
'admin/users/edit.html.tmpl' => [ 'admin/users/edit.html.tmpl' => [
'otheruser.id', 'otheruser.id',
'group.id', 'group.id',
'perms.directbless',
'perms.directmember',
], ],
'admin/components/edit.html.tmpl' => [ 'admin/components/edit.html.tmpl' => [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment