Changeset 207 for trunk/dns.cgi


Ignore:
Timestamp:
12/19/11 17:20:54 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Fix overloaded-$webvar{action}-related buglet - changing the default
group can cause the page to mutate due to template/page overloading.
Reported by Reid Sutherland on the "Edit user" page, when clicking
a group to change the default group.

Group edit and bulk domain change pages tweaked although the impact
is limited to changing the starting data, not the page operation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r205 r207  
    807807        unless ($permissions{admin} || $permissions{group_create});
    808808
    809   # do.. uhh.. stuff.. if we have no webvar{action}
    810   if ($webvar{action} && $webvar{action} eq 'add') {
     809  # do.. uhh.. stuff.. if we have no webvar{grpaction}
     810  if ($webvar{grpaction} && $webvar{grpaction} eq 'add') {
    811811
    812812    # security check - does the user have permission to access this entity?
     
    901901  }
    902902
    903   if ($webvar{action} eq 'updperms') {
     903  if ($webvar{grpaction} eq 'updperms') {
    904904    # extra safety check;  make sure user can't construct a URL to bypass ACLs
    905905    my %curperms;
     
    994994  }
    995995
    996   if ($webvar{action} eq 'move') {
     996  if ($webvar{bulkaction} eq 'move') {
    997997    changepage(page => "domlist", errmsg => "You are not permitted to bulk-move domains")
    998998        unless ($permissions{admin} || ($permissions{domain_edit} && $permissions{domain_create} && $permissions{domain_delete}));
     
    10291029    $page->param(bulkresults => \@bulkresults);
    10301030
    1031   } elsif ($webvar{action} eq 'deactivate' || $webvar{action} eq 'activate') {
    1032     changepage(page => "domlist", errmsg => "You are not permitted to bulk-$webvar{action} domains")
     1031  } elsif ($webvar{bulkaction} eq 'deactivate' || $webvar{bulkaction} eq 'activate') {
     1032    changepage(page => "domlist", errmsg => "You are not permitted to bulk-$webvar{bulkaction} domains")
    10331033        unless ($permissions{admin} || $permissions{domain_edit});
    1034     $page->param(action => "$webvar{action} domains");
     1034    $page->param(action => "$webvar{bulkaction} domains");
    10351035    my @bulkresults;
    10361036    foreach (keys %webvar) {
     
    10461046      $row{domain} = domainName($dbh,$webvar{$_});
    10471047##fixme:  error handling on status change
    1048       my $stat = domStatus($dbh,$webvar{$_},($webvar{action} eq 'activate' ? 'domon' : 'domoff'));
     1048      my $stat = domStatus($dbh,$webvar{$_},($webvar{bulkaction} eq 'activate' ? 'domon' : 'domoff'));
    10491049      logaction($webvar{$_}, $session->param("username"), parentID($webvar{$_}, 'dom', 'group'),
    10501050                "Changed domain ".domainName($dbh, $webvar{$_})." state to ".($stat ? 'active' : 'inactive'));
     
    10561056    $page->param(bulkresults => \@bulkresults);
    10571057
    1058   } elsif ($webvar{action} eq 'delete') {
     1058  } elsif ($webvar{bulkaction} eq 'delete') {
    10591059    changepage(page => "domlist", errmsg => "You are not permitted to bulk-delete domains")
    10601060        unless ($permissions{admin} || $permissions{domain_delete});
    1061     $page->param(action => "$webvar{action} domains");
     1061    $page->param(action => "$webvar{bulkaction} domains");
    10621062    my @bulkresults;
    10631063    foreach (keys %webvar) {
     
    11551155  $page->param(is_admin => $permissions{admin});
    11561156
    1157   $webvar{action} = '' if !$webvar{action};
    1158 
    1159   if ($webvar{action} eq 'add' or $webvar{action} eq 'update') {
    1160 
    1161     $page->param(add => 1) if $webvar{action} eq 'add';
     1157  $webvar{useraction} = '' if !$webvar{useraction};
     1158
     1159  if ($webvar{useraction} eq 'add' or $webvar{useraction} eq 'update') {
     1160
     1161    $page->param(add => 1) if $webvar{useraction} eq 'add';
    11621162
    11631163    my ($code,$msg);
     
    12081208        $permstring = 'i';
    12091209      }
    1210       if ($webvar{action} eq 'add') {
     1210      if ($webvar{useraction} eq 'add') {
    12111211        changepage(page => "useradmin", errmsg => "You do not have permission to add new users")
    12121212                unless $permissions{admin} || $permissions{user_create};
     
    12441244        changepage(page => "useradmin", warnmsg =>
    12451245                "You can only grant permissions you hold.  $webvar{uname} ".
    1246                 ($webvar{action} eq 'add' ? 'added' : 'updated')." with reduced access.");
     1246                ($webvar{useraction} eq 'add' ? 'added' : 'updated')." with reduced access.");
    12471247      } else {
    12481248        changepage(page => "useradmin", resultmsg => "Successfully ".
    1249                 ($webvar{action} eq 'add' ? 'added' : 'updated')." user $webvar{uname}");
     1249                ($webvar{useraction} eq 'add' ? 'added' : 'updated')." user $webvar{uname}");
    12501250      }
    12511251
     
    12531253    } else {
    12541254      $page->param(add_failed => 1);
    1255       $page->param(action => $webvar{action});
     1255      $page->param(action => $webvar{useraction});
    12561256      $page->param(set_permgroup => 1);
    12571257      if ($webvar{perms_type} eq 'inherit') {   # set permission class radio
     
    12711271      fill_actypelist($webvar{accttype});
    12721272      fill_clonemelist();
    1273       logaction(0, $session->param("username"), $curgroup, "Failed to $webvar{action} user ".
     1273      logaction(0, $session->param("username"), $curgroup, "Failed to $webvar{useraction} user ".
    12741274        "$webvar{uname}: $msg")
    12751275        if $config{log_failures};
    12761276    }
    12771277
    1278   } elsif ($webvar{action} eq 'edit') {
     1278  } elsif ($webvar{useraction} eq 'edit') {
    12791279
    12801280    changepage(page => "useradmin", errmsg => "You do not have permission to edit users")
Note: See TracChangeset for help on using the changeset viewer.