fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-12-10 07:05 am

[dw-free] warnings for undefined privarg in priv console command

[commit: http://hg.dwscoalition.org/dw-free/rev/50c3866d1cec]

http://bugs.dwscoalition.org/show_bug.cgi?id=3308

Less warnings.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/Console/Command/Priv.pm
--------------------------------------------------------------------------------
diff -r 05a3090468de -r 50c3866d1cec cgi-bin/LJ/Console/Command/Priv.pm
--- a/cgi-bin/LJ/Console/Command/Priv.pm	Fri Dec 10 15:01:51 2010 +0800
+++ b/cgi-bin/LJ/Console/Command/Priv.pm	Fri Dec 10 15:05:11 2010 +0800
@@ -78,6 +78,7 @@ sub execute {
     my $remote = LJ::get_remote();
     foreach my $pair (@privs) {
         my ($priv, $arg) = @$pair;
+        my $parg = defined $arg ? $arg : '';  # for printing undefs
 
         if ( $action eq "list" ) {
             my $args = LJ::list_valid_args( $priv );
@@ -91,8 +92,8 @@ sub execute {
             next;
         }
 
-        unless ( $remote && ( $remote->has_priv( "admin", "$priv" ) || $remote->has_priv( "admin", "$priv/$arg" ) ) ) {
-            $self->error("You are not permitted to $action $priv:$arg");
+        unless ( $remote && ( $remote->has_priv( "admin", "$priv" ) || $remote->has_priv( "admin", "$priv/$parg" ) ) ) {
+            $self->error("You are not permitted to $action $priv:$parg");
             next;
         }
 
@@ -120,19 +121,19 @@ sub execute {
             my $rv;
             if ($action eq "grant") {
                 if ( $u && $u->has_priv( $priv, $arg ) ) {
-                    $self->error("$user already has $priv:$arg");
+                    $self->error("$user already has $priv:$parg");
                     next;
                 }
                 $rv = $u->grant_priv($priv, $arg);
-                $shmsg = "Granting: '$priv' with arg '$arg'";
+                $shmsg = "Granting: '$priv' with arg '$parg'";
             } elsif ($action eq "revoke") {
                 unless ( $u && $u->has_priv( $priv, $arg ) ) {
-                    $self->error("$user does not have $priv:$arg");
+                    $self->error("$user does not have $priv:$parg");
                     next;
                 }
                 $rv = $u->revoke_priv($priv, $arg);
-                $shmsg = "Denying: '$priv' with arg '$arg'";
-            } else {
+                $shmsg = "Denying: '$priv' with arg '$parg'";
+            } else {  # revoke_all
                 unless ( $u && $u->has_priv( $priv ) ) {
                     $self->error("$user does not have any $priv privs");
                     next;
@@ -141,7 +142,7 @@ sub execute {
                 $shmsg = "Denying: '$priv' with all args";
             }
 
-            return $self->error("Unable to $action $priv:$arg")
+            return $self->error("Unable to $action $priv:$parg")
                 unless $rv;
 
             my $shtype = ($action eq "grant") ? "privadd" : "privdel";
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org