Move some permission checks from set_user_mode() to its callers.
authorMichael Poole <mdpoole@troilus.org>
Sun, 1 Apr 2007 02:14:59 +0000 (02:14 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sun, 1 Apr 2007 02:14:59 +0000 (02:14 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1795 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/m_mode.c
ircd/s_user.c

index d56740cfa783c53b9e3a18192b8465d2f9af1c7a..9a2ba7edd99f4bdc38fa642a99bf9f8081b945c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-03-31  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/m_mode.c (m_mode): Check and report target/source
+       violations before calling set_user_mode().
+       (ms_mode): Likewise.
+
+       * ircd/s_user.c (set_user_mode): Remove those checks from here.
+
 2007-03-31  Michael Poole <mdpoole@troilus.org>
 
        * include/ircd_events.h (struct Generators): Convert elements to
index cb27ee5fb4dd37c9a53c291165a5b47f6681a67b..8b91fd58e56cf4e1b0a00feb60002e2995b4d1d3 100644 (file)
@@ -113,7 +113,22 @@ m_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     return need_more_params(sptr, "MODE");
 
   if (!IsChannelName(parv[1]) || !(chptr = FindChannel(parv[1])))
+  {
+    struct Client *acptr;
+
+    acptr = FindUser(parv[1]);
+    if (!acptr)
+    {
+      send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
+      return 0;
+    }
+    else if (sptr != acptr)
+    {
+      send_reply(sptr, ERR_USERSDONTMATCH);
+      return 0;
+    }
     return set_user_mode(cptr, sptr, parc, parv);
+  }
 
   ClrFlag(sptr, FLAG_TS8);
 
@@ -168,7 +183,23 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     return 0;
 
   if (!(chptr = FindChannel(parv[1])))
+  {
+    struct Client *acptr;
+
+    acptr = FindUser(parv[1]);
+    if (!acptr)
+    {
+      return 0;
+    }
+    else if (sptr != acptr)
+    {
+      sendwallto_group_butone(&me, WALL_WALLOPS, 0, 
+                              "MODE for User %s from %s!%s", parv[1],
+                              cli_name(cptr), cli_name(sptr));
+      return 0;
+    }
     return set_user_mode(cptr, sptr, parc, parv);
+  }
 
   ClrFlag(sptr, FLAG_TS8);
 
index ecedb0629085a789566bed87b7aab699568ac1be..a21f5e2b791db8a316ba33eb1df43d9185c8d1f5 100644 (file)
@@ -984,7 +984,6 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv
 {
   char** p;
   char*  m;
-  struct Client *acptr;
   int what;
   int i;
   struct Flags setflags;
@@ -996,27 +995,6 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv
 
   what = MODE_ADD;
 
-  if (parc < 2)
-    return need_more_params(sptr, "MODE");
-
-  if (!(acptr = FindUser(parv[1])))
-  {
-    if (MyConnect(sptr))
-      send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
-    return 0;
-  }
-
-  if (IsServer(sptr) || sptr != acptr)
-  {
-    if (IsServer(cptr))
-      sendwallto_group_butone(&me, WALL_WALLOPS, 0, 
-                           "MODE for User %s from %s!%s", parv[1],
-                            cli_name(cptr), cli_name(sptr));
-    else
-      send_reply(sptr, ERR_USERSDONTMATCH);
-    return 0;
-  }
-
   if (parc < 3)
   {
     m = buf;