Administrative setpassword command, fix flushurls, fix grammar in password.
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 7 Apr 2008 19:18:14 +0000 (19:18 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 7 Apr 2008 19:18:14 +0000 (19:18 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@42 088b83a4-0077-4247-935c-42ec02c2848b

commands.yaml

index 73b1802..784fa28 100644 (file)
@@ -8,13 +8,13 @@ LINK: |-
   sub {
     my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
     my( $whom, $target ) = split( / /, $what, 2 );
-
+  
     unless( exists( $heap->{ 'useraccess' }->{ uc( $target ) } ) ) {
       $kernel->post( $src, $replypath, "'$target' has no access; link not allowed.", $dest );
       return;
     }
-
-    if( access2( $heap->{ 'useraccess' }, $target, {} ) > accessLevel( $kernel, $heap, $who ) ) {
+  
+    if( access2( $heap->{ 'useraccess' }, $target, {} ) > accessLevel( $kernel, $heap, $who, $src ) ) {
       $kernel->post( $src, $replypath, "You may not grant access exceeding your own.", $dest );
       return;
     }
@@ -277,7 +277,7 @@ PASSWORD: |-
       if( $heap->{ 'users' }->{ uc( $who ) } eq md5_hex( $old ) ) {
         $heap->{ 'users' }->{ uc( $who ) } = md5_hex( $new );
            DumpFile( "users.yaml", $heap->{ 'users' } );
-        $kernel->post( $src, $replypath, "Passwords changed.", $dest );
+        $kernel->post( $src, $replypath, "Password changed.", $dest );
       } else {
         $kernel->post( $src, $replypath, "Old passwords do not match.", $dest );
       }
@@ -286,6 +286,25 @@ PASSWORD: |-
     }
   }
 
+SETPASSWORD: |-
+  sub {
+    use Digest::MD5 qw( md5_hex );
+    my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+    my @args = split( / /, $what );
+    if( $#args != 1 ) {
+      $kernel->post( $src, $replypath, "USAGE: SETPASSWORD <user> <pass>", $dest );
+      return;
+    }
+    my( $whom, $pass ) = split( / /, $what );
+    if( exists( $heap->{ 'users' }->{ uc( $whom ) } ) ) {
+      $heap->{ 'users' }->{ uc( $who ) } = md5_hex( $pass );
+      DumpFile( "users.yaml", $heap->{ 'users' } );
+      $kernel->post( $src, $replypath, "Password changed.", $dest );
+    } else {
+      $kernel->post( $src, $replypath, "'$whom' is not registered.", $dest );
+    }
+  }
+
 CONFIG: |-
   sub {
     my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
@@ -1473,6 +1492,7 @@ TINYURL: |-
   }
 FLUSHURLS: |-
   sub {
+    my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
        $heap->{ 'urls' } = {};
        $kernel->post( $src, $replypath, "URL cache flushed.", $dest );
   }