Jelajahi Sumber

* Port [3334] to 1.2.14
* Added 'whois restrictions' to more cmds.



svn: 3335

Bryan Drewery 19 tahun lalu
induk
melakukan
ea8f3c235e
2 mengubah file dengan 24 tambahan dan 39 penghapusan
  1. 1 0
      doc/UPDATES
  2. 23 39
      src/cmds.c

+ 1 - 0
doc/UPDATES

@@ -31,6 +31,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Rewrote op-cookies to be fix a security hole. (They also react to '.set hijack' now)
 * Fixed +voice flaw where users in channels that were +voice AND +private would only be voiced with |v.
 * Added cmd_clearhosts
+* Added 'whois restrictions' to more cmds.
 
 1.2.13 - http://wraith.shatow.net/milestone/1.2.13
 * Fix cmd_chanset accepting invalid flags

+ 23 - 39
src/cmds.c

@@ -1092,8 +1092,8 @@ static void cmd_chhandle(int idx, char *par)
 
   struct userrec *u2 = get_user_by_handle(userlist, hand);
 
-  if (!u2) {
-    dprintf(idx, "No such handle!\n");
+  if (!u2 || (u2 && !whois_access(dcc[idx].user, u2))) {
+    dprintf(idx, "No such user!\n");
     return;
   }
 
@@ -1182,13 +1182,10 @@ static void cmd_chpass(int idx, char *par)
     dprintf(idx, "Usage: chpass <handle> [password]\n");
     return;
   }
-  char *handle = NULL;
-  struct userrec *u = NULL;
+  char *handle = newsplit(&par);
+  struct userrec *u = get_user_by_handle(userlist, handle);
 
-  handle = newsplit(&par);
-  if (!(u = get_user_by_handle(userlist, handle))) 
-    dprintf(idx, "No such user.\n");
-  else if (!whois_access(dcc[idx].user, u))
+  if (!u || (u && !whois_access(dcc[idx].user, u)))
     dprintf(idx, "No such user.\n");
   else if (u->bot)
     dprintf(idx, "Bots do not have passwords.\n");
@@ -1231,13 +1228,10 @@ static void cmd_chsecpass(int idx, char *par)
     dprintf(idx, "Usage: chsecpass <handle> [secpass/rand]\n");
     return;
   }
-  char *handle = NULL;
-  struct userrec *u = NULL;
+  char *handle = newsplit(&par);
+  struct userrec *u = get_user_by_handle(userlist, handle);
 
-  handle = newsplit(&par);
-  if (!(u = get_user_by_handle(userlist, handle))) 
-    dprintf(idx, "No such user.\n");
-  else if (!whois_access(dcc[idx].user, u))
+  if (!u || (u && !whois_access(dcc[idx].user, u)))
     dprintf(idx, "No such user.\n");
   else if (u->bot)
     dprintf(idx, "Bots do not have secpasses.\n");
@@ -1531,14 +1525,11 @@ static void cmd_comment(int idx, char *par)
 
   struct userrec *u1 = get_user_by_handle(userlist, handle);
 
-  if (!u1) {
+  if (!u1 || (u1 && !whois_access(dcc[idx].user, u1))) {
     dprintf(idx, "No such user!\n");
     return;
   }
-  if (!whois_access(dcc[idx].user, u1)) {
-    dprintf(idx, "You can't change comment on higher level users.\n");
-    return;
-  }
+
   putlog(LOG_CMDS, "*", "#%s# comment %s %s", dcc[idx].nick, handle, par);
   if (!egg_strcasecmp(par, "none")) {
     dprintf(idx, "Okay, comment blanked.\n");
@@ -1943,8 +1934,11 @@ static void cmd_simul(int idx, char *par)
     return;
   }
 
-  if (isowner(nick)) {
-    dprintf(idx, "Unable to '.simul' permanent owners.\n");
+
+  struct userrec *u2 = get_user_by_handle(userlist, nick);
+
+  if (!u2 || (u2 && !whois_access(dcc[idx].user, u2))) {
+    dprintf(idx, "No such user.\n");
     return;
   }
 
@@ -2284,7 +2278,7 @@ static void cmd_chattr(int idx, char *par)
   char *hand = newsplit(&par);
   struct userrec *u2 = get_user_by_handle(userlist, hand);
 
-  if (!u2) {
+  if (!u2 || (u2 && !whois_access(dcc[idx].user, u2))) {
     dprintf(idx, "No such user!\n");
     return;
   }
@@ -2984,14 +2978,12 @@ static void cmd_su(int idx, char *par)
 
   if (!par[0])
     dprintf(idx, "Usage: su <user>\n");
-  else if (!u)
+  else if (!u || (u && !whois_access(dcc[idx].user, u)))
     dprintf(idx, "No such user.\n");
   else if (u->bot)
     dprintf(idx, "You can't su to a bot... then again, why would you wanna?\n");
   else if (dcc[idx].u.chat->su_nick)
     dprintf(idx, "You cannot currently double .su; try .su'ing directly.\n");
-  else if (isowner(u->handle) && egg_strcasecmp(dcc[idx].nick, u->handle))
-    dprintf(idx, "You can't su to a permanent bot owner.\n");
   else {
     get_user_flagrec(u, &fr, NULL);
     ok = 1;
@@ -3184,7 +3176,7 @@ static void cmd_nopass(int idx, char *par)
 
   for (cu = userlist; cu; cu = cu->next) {
     if (!cu->bot) {
-      if (u_pass_match(cu, "-")) {
+      if (whois_access(dcc[idx].user, cu) && u_pass_match(cu, "-")) {
         cnt++;
         if (dopass) {
           pass[0] = 0;
@@ -3362,20 +3354,12 @@ static void cmd_mns_user(int idx, char *par)
   }
 
   char *handle = newsplit(&par);
-  struct userrec *u2 = NULL;
+  struct userrec *u2 = get_user_by_handle(userlist, handle);
 
-  if (!(u2 = get_user_by_handle(userlist, handle))) {
+  if (!u2 || (u2 && !whois_access(dcc[idx].user, u2))) {
     dprintf(idx, "No such user!\n");
     return;
   }
-  if (isowner(u2->handle)) {
-    dprintf(idx, "You can't remove a permanent bot owner!\n");
-    return;
-  }
-  if ((u2->flags & USER_ADMIN) && !(isowner(dcc[idx].nick))) {
-    dprintf(idx, "You can't remove an admin!\n");
-    return;
-  }
   if ((u2->flags & USER_OWNER) && !(dcc[idx].user->flags & USER_OWNER)) {
     dprintf(idx, "You can't remove a bot owner!\n");
     return;
@@ -3435,7 +3419,7 @@ static void cmd_pls_host(int idx, char *par)
     handle = dcc[idx].nick;
     u2 = dcc[idx].user;
   }
-  if (!u2 || !dcc[idx].user) {
+  if (!u2 || (u2 && !whois_access(dcc[idx].user, u2))) {
     dprintf(idx, "No such user.\n");
     return;
   }
@@ -3544,7 +3528,7 @@ static void cmd_mns_host(int idx, char *par)
     handle = dcc[idx].nick;
     u2 = dcc[idx].user;
   }
-  if (!u2 || !dcc[idx].user) {
+  if (!u2 || (u2 && !whois_access(dcc[idx].user, u2))) {
     dprintf(idx, "No such user.\n");
     return;
   }
@@ -3622,7 +3606,7 @@ static void cmd_clearhosts(int idx, char *par)
     u2 = dcc[idx].user;
   }
 
-  if (!u2 || !dcc[idx].user) {
+  if (!u2 || (u2 && !whois_access(dcc[idx].user, u2))) {
     dprintf(idx, "No such user.\n");
     return;
   }