]> jfr.im git - irc/freenode/solanum.git/commitdiff
Send hidden mode changes to auspex:cmodes
authorEd Kellett <redacted>
Sun, 7 Jun 2020 16:36:31 +0000 (17:36 +0100)
committerEd Kellett <redacted>
Tue, 4 Aug 2020 21:58:30 +0000 (22:58 +0100)
include/send.h
ircd/chmode.c
ircd/send.c

index 57d6501c5df61eadd8514dc7c24829b2037277d9..4985b4602e570f31b64578bcd5120851095db571 100644 (file)
@@ -59,6 +59,7 @@ extern void sendto_channel_opmod(struct Client *one, struct Client *source_p,
                                 const char *text);
 
 extern void sendto_channel_local(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5);
+extern void sendto_channel_local_priv(struct Client *, int type, const char *priv, struct Channel *, const char *, ...) AFP(5, 6);
 extern void sendto_channel_local_butone(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5);
 
 extern void sendto_channel_local_with_capability(struct Client *, int type, int caps, int negcaps, struct Channel *, const char *, ...) AFP(6, 7);
index 9cbc7e8d14ff8f079df8b21ce4867a5cfa4a145c..cfc38e9b27ab5d3e5637506c04ccd6fc0a56b1f5 100644 (file)
@@ -1742,7 +1742,13 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
 
        for(j = 0; j < 3; j++)
        {
-               flags = flags_list[j];
+               int send_flags = flags = flags_list[j];
+               const char *priv = "";
+               if (flags == ONLY_OPERS)
+               {
+                       send_flags = ALL_MEMBERS;
+                       priv = "auspex:cmodes";
+               }
                cur_len = mlen;
                mbuf = modebuf + mlen;
                pbuf = parabuf;
@@ -1775,8 +1781,8 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
                                *mbuf = '\0';
 
                                if(cur_len > mlen)
-                                       sendto_channel_local(IsServer(source_p) ? fakesource_p : source_p,
-                                                       flags, chptr, "%s %s", modebuf, parabuf);
+                                       sendto_channel_local_priv(IsServer(source_p) ? fakesource_p : source_p,
+                                                       send_flags, priv, chptr, "%s %s", modebuf, parabuf);
                                else
                                        continue;
 
@@ -1812,8 +1818,8 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
 
                *mbuf = '\0';
                if(cur_len > mlen)
-                       sendto_channel_local(IsServer(source_p) ? fakesource_p : source_p,
-                               flags, chptr, "%s %s", modebuf, parabuf);
+                       sendto_channel_local_priv(IsServer(source_p) ? fakesource_p : source_p,
+                               send_flags, priv, chptr, "%s %s", modebuf, parabuf);
        }
 
        /* only propagate modes originating locally, or if we're hubbing */
index d2a92d16a381c464b7bb5ac9e6f65d96ecd2c9e3..4205276c74ae4fdfea369814ecf3fb229a8e7277 100644 (file)
@@ -675,44 +675,39 @@ sendto_channel_opmod(struct Client *one, struct Client *source_p,
        msgbuf_cache_free(&msgbuf_cache);
 }
 
-/* sendto_channel_local()
+/* _sendto_channel_local
  *
- * inputs      - source, flags to send to, channel to send to, va_args
+ * inputs      - source, flags to send to, privs to send to, channel to send to, va_args
  * outputs     - message to local channel members
  * side effects -
  */
 void
-sendto_channel_local(struct Client *source_p, int type, struct Channel *chptr, const char *pattern, ...)
+_sendto_channel_local(struct Client *source_p, int type, const char *priv, struct Channel *chptr, const char *pattern, va_list *args)
 {
-       va_list args;
        struct membership *msptr;
        struct Client *target_p;
        rb_dlink_node *ptr;
        rb_dlink_node *next_ptr;
        struct MsgBuf msgbuf;
        struct MsgBuf_cache msgbuf_cache;
-       rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
+       rb_strf_t strings = { .format = pattern, .format_args = args, .next = NULL };
 
        build_msgbuf_tags(&msgbuf, source_p);
 
-       va_start(args, pattern);
        msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings);
-       va_end(args);
 
        RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
        {
                msptr = ptr->data;
                target_p = msptr->client_p;
 
-               if(IsIOError(target_p))
+               if (IsIOError(target_p))
                        continue;
 
-               if(type == ONLY_OPERS)
-               {
-                       if (!IsOper(target_p))
-                               continue;
-               }
-               else if(type && ((msptr->flags & type) == 0))
+               if (type && ((msptr->flags & type) == 0))
+                       continue;
+
+               if (priv != NULL && !HasPrivilege(target_p, priv))
                        continue;
 
                _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
@@ -721,6 +716,36 @@ sendto_channel_local(struct Client *source_p, int type, struct Channel *chptr, c
        msgbuf_cache_free(&msgbuf_cache);
 }
 
+/* sendto_channel_local_priv()
+ *
+ * inputs      - source, flags to send to, privs to send to, channel to send to, va_args
+ * outputs     - message to local channel members
+ * side effects -
+ */
+void
+sendto_channel_local_priv(struct Client *source_p, int type, const char *priv, struct Channel *chptr, const char *pattern, ...)
+{
+       va_list args;
+       va_start(args, pattern);
+       _sendto_channel_local(source_p, type, priv, chptr, pattern, &args);
+       va_end(args);
+}
+
+/* sendto_channel_local()
+ *
+ * inputs      - source, flags to send to, channel to send to, va_args
+ * outputs     - message to local channel members
+ * side effects -
+ */
+void
+sendto_channel_local(struct Client *source_p, int type, struct Channel *chptr, const char *pattern, ...)
+{
+       va_list args;
+       va_start(args, pattern);
+       _sendto_channel_local(source_p, type, NULL, chptr, pattern, &args);
+       va_end(args);
+}
+
 /*
  * _sendto_channel_local_with_capability_butone()
  *