Bladeren bron

* Require old pass to clear a cmdpass

svn: 1501
Bryan Drewery 21 jaren geleden
bovenliggende
commit
419284a328
3 gewijzigde bestanden met toevoegingen van 16 en 14 verwijderingen
  1. 1 0
      doc/UPDATES
  2. 2 3
      misc/help.txt
  3. 13 11
      src/cmds.c

+ 1 - 0
doc/UPDATES

@@ -62,6 +62,7 @@ This is a summary of ChangeLog basically.
 * All dns resolving is now asynchronous, all dns bugs now fixed.
 * All dns resolving is now asynchronous, all dns bugs now fixed.
 * Check server lag every 30 seconds, not every 5 minutes.
 * Check server lag every 30 seconds, not every 5 minutes.
 * +v users are no longer enforced if opped.
 * +v users are no longer enforced if opped.
+* cmdpasses now require that the old pass be used to clear old pass.
 
 
 1.1.9
 1.1.9
 
 

+ 2 - 3
misc/help.txt

@@ -656,7 +656,7 @@ See also: chhandle, chpass
 ###  $bclearqueue$b <queue>
 ###  $bclearqueue$b <queue>
    removes all msgs from the specified queue (mode/server/help/all)
    removes all msgs from the specified queue (mode/server/help/all)
 :hub:cmdpass:
 :hub:cmdpass:
-###  $bcmdpass$b <command> <pass>
+###  $bcmdpass$b <command> <pass> [clear]
    Places the specified pass on the cmd so that the cmd will need to be 
    Places the specified pass on the cmd so that the cmd will need to be 
    followed by the specified pass whenever it is called. For example:
    followed by the specified pass whenever it is called. For example:
     !cmdpass whoami BLAH
     !cmdpass whoami BLAH
@@ -669,8 +669,7 @@ See also: chhandle, chpass
      You are bryan@hub.
      You are bryan@hub.
      [19:33] #bryan# whoami
      [19:33] #bryan# whoami
  
  
-   To remove a cmdpass for a cmd, simply don't include the pass argument for
-   a cmd.
+   To remove a cmdpass for a cmd, specify 'clear' after the pass
  
  
    ** Only permanent owners specified in the binary COMPILE config file **
    ** Only permanent owners specified in the binary COMPILE config file **
    ** can use this cmd.                                                 **
    ** can use this cmd.                                                 **

+ 13 - 11
src/cmds.c

@@ -424,9 +424,9 @@ static void cmd_cmdpass(int idx, char *par)
   cmd = newsplit(&par);
   cmd = newsplit(&par);
   putlog(LOG_CMDS, "*", "#%s# cmdpass %s ...", dcc[idx].nick, cmd[0] ? cmd : "");
   putlog(LOG_CMDS, "*", "#%s# cmdpass %s ...", dcc[idx].nick, cmd[0] ? cmd : "");
   pass = newsplit(&par);
   pass = newsplit(&par);
-  if (!cmd[0] || par[0]) {
-    dprintf(idx, "Usage: %scmdpass <command> [password]\n", settings.dcc_prefix);
-    dprintf(idx, "  if no password is specified, the commands password is reset\n");
+  if (!cmd || !pass) {
+    dprintf(idx, "Usage: %scmdpass <command> <password> [clear]\n", settings.dcc_prefix);
+    dprintf(idx, "  if the password is specified and 'clear' after it, the command's password is cleared\n");
     return;
     return;
   }
   }
   for (i = 0; cmd[i]; i++)
   for (i = 0; cmd[i]; i++)
@@ -452,6 +452,16 @@ static void cmd_cmdpass(int idx, char *par)
   }
   }
 
 
   if (pass[0]) {
   if (pass[0]) {
+    if (!egg_strcasemp(par, "clear")) {
+      if (!isowner(dcc[idx].nick)) {
+        putlog(LOG_MISC, "*", "%s attempted to remove command password for %s - not perm owner", dcc[idx].nick, cmd);
+        dprintf(idx, "Perm owners only.\n");
+        return;
+      }
+      set_cmd_pass(cmd, 1);
+      dprintf(idx, "Removed command password for %s\n", cmd);
+      return;
+    }
     char epass[36] = "", tmp[256] = "";
     char epass[36] = "", tmp[256] = "";
 
 
     if (!isowner(dcc[idx].nick) && has_cmd_pass(cmd)) {
     if (!isowner(dcc[idx].nick) && has_cmd_pass(cmd)) {
@@ -466,14 +476,6 @@ static void cmd_cmdpass(int idx, char *par)
     else
     else
       dprintf(idx, "Set command password for %s to '%s'\n", cmd, pass);
       dprintf(idx, "Set command password for %s to '%s'\n", cmd, pass);
     set_cmd_pass(tmp, 1);
     set_cmd_pass(tmp, 1);
-  } else {
-    if (!isowner(dcc[idx].nick)) {
-      putlog(LOG_MISC, "*", "%s attempted to remove command password for %s - not perm owner", dcc[idx].nick, cmd);
-      dprintf(idx, "Perm owners only.\n");
-      return;
-    }
-    set_cmd_pass(cmd, 1);
-    dprintf(idx, "Removed command password for %s\n", cmd);
   }
   }
 #ifdef HUB
 #ifdef HUB
   write_userfile(idx);
   write_userfile(idx);