Avoid unwanted races for mode handling during burst processing.
[ircu2.10.12-pk.git] / ircd / m_mode.c
index c0b514893078f9ed420ebb758b902cba165b26d2..ca366ccd65bf243b430c84e6174f1016fac6af48 100644 (file)
@@ -86,6 +86,8 @@
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_features.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "msg.h"
@@ -96,7 +98,7 @@
 #include "s_user.h"
 #include "send.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <stdlib.h>
 #include <string.h>
 
@@ -110,8 +112,6 @@ m_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   if (parc < 2)
     return need_more_params(sptr, "MODE");
 
-  clean_channelname(parv[1]);
-
   if (!IsChannelName(parv[1]) || !(chptr = FindChannel(parv[1])))
     return set_user_mode(cptr, sptr, parc, parv);
 
@@ -178,14 +178,18 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
                   (MODEBUF_DEST_CHANNEL | /* Send mode to clients */
                    MODEBUF_DEST_SERVER  | /* Send mode to servers */
                    MODEBUF_DEST_HACK4));  /* Send a HACK(4) message */
+    else if (!feature_bool(FEAT_OPLEVELS))
+      modebuf_init(&mbuf, sptr, cptr, chptr,
+                  (MODEBUF_DEST_CHANNEL | /* Send mode to clients */
+                   MODEBUF_DEST_SERVER  | /* Send mode to servers */
+                   MODEBUF_DEST_HACK3));  /* Send a HACK(3) message */
     else
       /* Servers need to be able to op people who join using the Apass
-       * or upass, therefore we accept modes for channels with an Apass
-       * without generating a HACK3. */
+       * or upass, as well as people joining a zannel, therefore we do
+       * not generate HACK3 when oplevels are on. */
       modebuf_init(&mbuf, sptr, cptr, chptr,
                   (MODEBUF_DEST_CHANNEL | /* Send mode to clients */
-                   MODEBUF_DEST_SERVER |   /* Send mode to servers */
-                   (*chptr->mode.apass ? 0 : MODEBUF_DEST_HACK3)));
+                   MODEBUF_DEST_SERVER));   /* Send mode to servers */
 
     mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
               (MODE_PARSE_SET    | /* Set the mode */
@@ -193,7 +197,7 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
                MODE_PARSE_FORCE),  /* And force it to be accepted */
                NULL);
   } else {
-    if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) {
+    if (!(member = find_member_link(chptr, sptr))) {
       modebuf_init(&mbuf, sptr, cptr, chptr,
                   (MODEBUF_DEST_SERVER |  /* Send mode to server */
                    MODEBUF_DEST_HACK2  |  /* Send a HACK(2) message */