Przeglądaj źródła

* cmd_nopass when given any argument will give random passes to users with no password. (#114)

svn: 2224
Bryan Drewery 21 lat temu
rodzic
commit
1b043254fd
3 zmienionych plików z 22 dodań i 6 usunięć
  1. 1 0
      doc/UPDATES
  2. 3 1
      misc/help.txt
  3. 18 5
      src/cmds.c

+ 1 - 0
doc/UPDATES

@@ -20,6 +20,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * When msging bot for op, a NOTICE is sent to user if the channel is set to no manop.
 * Fixed 'chanset *' not working.
 * Fixed bot's not being able to link when the botnick case did not match (userlist vs binary -C).
+* cmd_nopass when given any argument will give random passes to users with no password. (#114)
 
 1.2.3
 

+ 3 - 1
misc/help.txt

@@ -1335,8 +1335,10 @@ See also: w
 ::nick
 See: handle
 :hub:nopass
-###  $bnohelp$b
+###  $bnohelp$b [anything]
    Displays all users who do not have a password set.
+
+   Specify any argument to give random passes to users.
 ::note
 ###  $bnote$b <nickname[@bot]> <message>
    Sends a private note to a user on the partyline. If that user is currently

+ 18 - 5
src/cmds.c

@@ -3040,23 +3040,36 @@ static void cmd_nopass(int idx, char *par)
 {
   int cnt = 0;
   struct userrec *cu = NULL;
-  char *users = (char *) my_calloc(1, 1);
+  char *users = (char *) my_calloc(1, 1), pass[MAXPASSLEN] = "";
+  bool dopass = 0;
 
   putlog(LOG_CMDS, "*", "#%s# nopass %s", dcc[idx].nick, (par && par[0]) ? par : "");
 
+  if (par[0])
+    dopass = 1;
+
   for (cu = userlist; cu; cu = cu->next) {
     if (!cu->bot) {
       if (u_pass_match(cu, "-")) {
         cnt++;
-        users = (char *) my_realloc(users, strlen(users) + strlen(cu->handle) + 1 + 1);
-        strcat(users, cu->handle);
-        strcat(users, " ");
+        if (dopass) {
+          pass[0] = 0;
+          make_rand_str(pass, MAXPASSLEN);
+          set_user(&USERENTRY_PASS, cu, pass);
+        } else {
+          users = (char *) my_realloc(users, strlen(users) + strlen(cu->handle) + 1 + 1);
+          strcat(users, cu->handle);
+          strcat(users, " ");
+        }
       }
     }
   }
   if (!cnt) 
     dprintf(idx, "All users have passwords set.\n");
-  else
+  else if (dopass) {
+    dprintf(idx, "%d users without passwords set to random.\n", cnt);
+    write_userfile(idx);
+  } else
     dprintf(idx, "Users without passwords: %s\n", users);
   free(users);
 }