Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_opmode.c
index 2fd38712d5bbb0d16c39f465ecc559521bc6ec72..af9b03f5e12dd2c0ace4a895a497961767dd9f85 100644 (file)
@@ -92,6 +92,7 @@
 #include "channel.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_features.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "msg.h"
@@ -116,13 +117,14 @@ int ms_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     return 0;
 
   if ('#' != *parv[1] || !(chptr = FindChannel(parv[1])))
-    return send_error_to_client(sptr, ERR_NOSUCHCHANNEL, parv[1]);
+    return send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
 
   modebuf_init(&mbuf, sptr, cptr, chptr,
               (MODEBUF_DEST_CHANNEL | /* Send MODE to channel */
                MODEBUF_DEST_SERVER  | /* And to server */
                MODEBUF_DEST_OPMODE  | /* Use OPMODE */
-               MODEBUF_DEST_HACK4));  /* Generate a HACK(4) notice */
+               MODEBUF_DEST_HACK4   | /* Generate a HACK(4) notice */
+               MODEBUF_DEST_LOG));    /* Log the mode changes to OPATH */
 
   mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
             (MODE_PARSE_SET    | /* Set the modes on the channel */
@@ -143,20 +145,30 @@ int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   struct ModeBuf mbuf;
   struct Membership *member;
 
+  if (!feature_bool(FEAT_CONFIG_OPERCMDS))
+    return send_reply(sptr, ERR_DISABLED, "OPMODE");
+
   if (parc < 3)
     return need_more_params(sptr, "OPMODE");
 
+  clean_channelname(parv[1]);
+
+  if (!HasPriv(sptr,
+              IsLocalChannel(parv[1]) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE))
+    return send_reply(sptr, ERR_NOPRIVILEGES);
+
   if (('#' != *parv[1] && '&' != *parv[1]) || !(chptr = FindChannel(parv[1])))
-    return send_error_to_client(sptr, ERR_NOSUCHCHANNEL, parv[1]);
+    return send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
 
   if (!(member = find_member_link(chptr, sptr)))
-    return send_error_to_client(sptr, ERR_NOTONCHANNEL, chptr->chname);
+    return send_reply(sptr, ERR_NOTONCHANNEL, chptr->chname);
 
   modebuf_init(&mbuf, sptr, cptr, chptr,
               (MODEBUF_DEST_CHANNEL | /* Send MODE to channel */
                MODEBUF_DEST_SERVER  | /* And to server */
                MODEBUF_DEST_OPMODE  | /* Use OPMODE */
-               MODEBUF_DEST_HACK4));  /* Generate a HACK(4) notice */
+               MODEBUF_DEST_HACK4   | /* Generate a HACK(4) notice */
+               MODEBUF_DEST_LOG));    /* Log the mode changes to OPATH */
 
   mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
             (MODE_PARSE_SET |    /* set the modes on the channel */