Kaynağa Gözat

* Rewrote most of cmd_cmdpass

svn: 2059
Bryan Drewery 21 yıl önce
ebeveyn
işleme
d78e596727
4 değiştirilmiş dosya ile 40 ekleme ve 28 silme
  1. 1 2
      doc/UPDATES
  2. 2 2
      misc/help.txt
  3. 35 24
      src/cmds.c
  4. 2 0
      src/mod/server.mod/servmsg.c

+ 1 - 2
doc/UPDATES

@@ -28,7 +28,7 @@ Lines prefixxed with '-' were disabled before release and are not finishsed, or
 * Removed/cleaned up more code left from eggdrop/modules
 * Removed/cleaned up more code left from eggdrop/modules
 * Fixed chanset (manop/mop/mdop/bad-cookie) to accept english parameters: ignore/deop/kick/delete/remove. 
 * Fixed chanset (manop/mop/mdop/bad-cookie) to accept english parameters: ignore/deop/kick/delete/remove. 
 * bots now only kick for -ooo (mdop) if 'mdop' is set with chanset.
 * bots now only kick for -ooo (mdop) if 'mdop' is set with chanset.
-* cmd_cmdpass was not clear on usage.
+* Changed around usage and fixed up help for cmd_cmdpass. Also fixed not being able to set a pass on leaf cmds from hub.
 * Using a cmd with a cmdpass without proper flags now acts as if cmd is not valid (no longer spams wrong pass error)
 * Using a cmd with a cmdpass without proper flags now acts as if cmd is not valid (no longer spams wrong pass error)
 * cmd_deluser change: only allow a |m user to remove users whom they have added.
 * cmd_deluser change: only allow a |m user to remove users whom they have added.
 * Fixed some botnet userfile sharing logs showing up on leaf bots.
 * Fixed some botnet userfile sharing logs showing up on leaf bots.
@@ -104,7 +104,6 @@ Lines prefixxed with '-' were disabled before release and are not finishsed, or
 * During update, bot uplinks aren't permanently changed now.
 * During update, bot uplinks aren't permanently changed now.
 * Bans aren't checked on join anymore if the channel is +take
 * Bans aren't checked on join anymore if the channel is +take
 * Fixed an outstanding bug on linking from a hub to another hub.
 * Fixed an outstanding bug on linking from a hub to another hub.
-* Fixed cmd_cmdpass not knowing leaf cmds from a hub.
 * Added log msg (+w) for when a msg is received when umode +g. (#44)
 * Added log msg (+w) for when a msg is received when umode +g. (#44)
 
 
 1.2.2
 1.2.2

+ 2 - 2
misc/help.txt

@@ -659,7 +659,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> [clear]
+###  $bcmdpass$b <command> <pass> [newpassword]
    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
@@ -672,7 +672,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, specify 'clear' after the pass
+   To remove a cmdpass for a cmd, specify the old pass and do not specify a new 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.                                                 **

+ 35 - 24
src/cmds.c

@@ -402,47 +402,58 @@ static void cmd_cmdpass(int idx, char *par)
   /* cmdpass [command [newpass]] */
   /* cmdpass [command [newpass]] */
   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 : "");
+
+  if (!isowner(dcc[idx].nick)) {
+    putlog(LOG_WARN, "*", "%s attempted to modify command password for %s - not perm owner", dcc[idx].nick, cmd);
+    dprintf(idx, "Perm owners only.\n");
+    return;
+  }
+
   pass = newsplit(&par);
   pass = newsplit(&par);
   if (!cmd || !cmd[0] || !pass || !pass[0]) {
   if (!cmd || !cmd[0] || !pass || !pass[0]) {
-    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");
+    dprintf(idx, "Usage: cmdpass <command> <password> [newpassword]\n");
+    dprintf(idx, "  Specifying the password but not a new one will clear it.\n");
     return;
     return;
   }
   }
 
 
   strtolower(cmd);
   strtolower(cmd);
 
 
   if (!findcmd(cmd, 0)) {
   if (!findcmd(cmd, 0)) {
-    dprintf(idx, "No such DCC command\n");
+    dprintf(idx, "No such DCC command.\n");
     return;
     return;
   }
   }
 
 
-  if (pass[0]) {
-    if (!egg_strcasecmp(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);
+  int has_pass = has_cmd_pass(cmd);
+
+  if (!has_pass && par[0]) {
+    dprintf(idx, "That cmd has no password.\n");
+    return;
+  }
+
+  if (has_pass) {
+    if (!check_cmd_pass(cmd, pass)) {
+      putlog(LOG_WARN, "*", "%s attempted to modify command password for %s - invalid password specified", dcc[idx].nick, cmd);
+      dprintf(idx, "Wrong password.\n");
       return;
       return;
     }
     }
-    char epass[36] = "", tmp[256] = "";
 
 
-    if (!isowner(dcc[idx].nick) && has_cmd_pass(cmd)) {
-      putlog(LOG_MISC, "*", "%s attempted to change command password for %s - not perm owner", dcc[idx].nick, cmd);
-      dprintf(idx, "Perm owners only.\n");
+    if (!par[0]) {
+      set_cmd_pass(cmd, 1);
+      dprintf(idx, "Removed command password for %s\n", cmd);
       return;
       return;
     }
     }
-    encrypt_pass(pass, epass);
-    simple_snprintf(tmp, sizeof tmp, "%s %s", cmd, epass);
-    if (has_cmd_pass(cmd))
-      dprintf(idx, "Changed command password for %s\n", cmd);
-    else
-      dprintf(idx, "Set command password for %s to '%s'\n", cmd, pass);
-    set_cmd_pass(tmp, 1);
-    write_userfile(idx);
   }
   }
+
+  char epass[36] = "", tmp[256] = "";
+
+  encrypt_pass(par[0] ? par : pass, epass);
+  simple_snprintf(tmp, sizeof tmp, "%s %s", cmd, epass);
+  if (has_pass)
+    dprintf(idx, "Changed command password for %s\n", cmd);
+  else
+    dprintf(idx, "Set command password for %s to '%s'\n", cmd, par[0] ? par : pass);
+  set_cmd_pass(tmp, 1);
+  write_userfile(idx);
 }
 }
 
 
 static void cmd_lagged(int idx, char *par)
 static void cmd_lagged(int idx, char *par)

+ 2 - 0
src/mod/server.mod/servmsg.c

@@ -1294,6 +1294,8 @@ static int got718(char *from, char *msg)
   fixcolon(msg);
   fixcolon(msg);
 
 
   putlog(LOG_WALL, "*", "(+g) !%s!%s! %s", nick, uhost, msg);
   putlog(LOG_WALL, "*", "(+g) !%s!%s! %s", nick, uhost, msg);
+
+  return 0;
 }
 }
  
  
 static cmd_t my_raw_binds[] =
 static cmd_t my_raw_binds[] =