]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/chmode.c
Merge.
[irc/rqf/shadowircd.git] / src / chmode.c
index cab5b31400989108c9027b59a9ab8bbb72f9660a..132d393648be4b944957eb1104e700d0bf28d89c 100644 (file)
@@ -56,6 +56,7 @@
 #define SM_ERR_NOPRIVS          0x00000400
 #define SM_ERR_RPL_Q            0x00000800
 #define SM_ERR_RPL_F            0x00001000
+#define SM_ERR_MLOCK            0x00002000
 
 #define MAXMODES_SIMPLE 46 /* a-zA-Z except bqeIov */
 
@@ -2086,6 +2087,19 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
                        dir = MODE_QUERY;
                        break;
                default:
+                       /* If this mode char is locked, don't allow local users to change it. */
+                       if (MyClient(source_p) && chptr->mode_lock && strchr(chptr->mode_lock, c))
+                       {
+                               if (!(errors & SM_ERR_MLOCK))
+                                       sendto_one_numeric(source_p,
+                                                       ERR_MLOCKRESTRICTED,
+                                                       form_str(ERR_MLOCKRESTRICTED),
+                                                       chptr->chname,
+                                                       c,
+                                                       chptr->mode_lock);
+                               errors |= SM_ERR_MLOCK;
+                               continue;
+                       }
                        chmode_table[(unsigned char) c].set_func(fakesource_p, chptr, alevel,
                                       parc, &parn, parv,
                                       &errors, dir, c,
@@ -2233,3 +2247,24 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
        if(MyClient(source_p) || rb_dlink_list_length(&serv_list) > 1)
                send_cap_mode_changes(client_p, source_p, chptr, mode_changes, mode_count);
 }
+
+/* set_channel_mlock()
+ *
+ * inputs      - client, source, channel, params
+ * output      - 
+ * side effects - channel mlock is changed / MLOCK is propagated
+ */
+void
+set_channel_mlock(struct Client *client_p, struct Client *source_p,
+                 struct Channel *chptr, const char *newmlock, int propagate)
+{
+       rb_free(chptr->mode_lock);
+       chptr->mode_lock = newmlock ? rb_strdup(newmlock) : NULL;
+
+       if (propagate)
+       {
+               sendto_server(client_p, NULL, CAP_TS6 | CAP_MLOCK, NOCAPS, ":%s MLOCK %ld %s :%s",
+                             source_p->id, (long) chptr->channelts, chptr->chname,
+                             chptr->mode_lock ? chptr->mode_lock : "");
+       }
+}