Move some permission checks from set_user_mode() to its callers.
[ircu2.10.12-pk.git] / ircd / m_mode.c
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);