added option to force opers to be in staff_auth_channel
authorpk910 <philipp@zoelle1.de>
Fri, 8 Jul 2011 14:49:55 +0000 (16:49 +0200)
committerpk910 <philipp@zoelle1.de>
Fri, 8 Jul 2011 15:32:44 +0000 (17:32 +0200)
src/chanserv.c
src/chanserv.h
src/opserv.c
src/opserv.h
src/proto-common.c
src/proto-p10.c
srvx.conf.example

index e160f620231427109ad6aa7c147de10a2ede7395..b6da8147f7daaa2bfe241871472b455f44d3183b 100644 (file)
@@ -3614,7 +3614,7 @@ static CHANSERV_FUNC(cmd_addtimedban)
     return eject_user(CSFUNC_ARGS, ACTION_KICK | ACTION_BAN | ACTION_ADD_BAN | ACTION_ADD_TIMED_BAN);
 }
 
-static struct mod_chanmode *
+struct mod_chanmode *
 find_matching_bans(struct banList *bans, struct userNode *actee, const char *mask)
 {
     struct mod_chanmode *change;
index 8c63e4a5f9ea57a46277b99c96e673eff185f671..8faad9c99034882c4237b620ea42443aa3a3a5f9 100644 (file)
@@ -198,5 +198,6 @@ struct channelList *chanserv_support_channels(void);
 unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
 struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
 int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
+struct mod_chanmode *find_matching_bans(struct banList *bans, struct userNode *actee, const char *mask);
 
 #endif
index 0702a1072e9cebbf1783cc85429df6ab2271c1df..17a67d50c44bf16058caffb3caab59bd20ea3252 100644 (file)
@@ -22,6 +22,7 @@
 #include "gline.h"
 #include "global.h"
 #include "nickserv.h"
+#include "chanserv.h"
 #include "modcmd.h"
 #include "opserv.h"
 #include "timeq.h"
@@ -72,6 +73,7 @@
 #define KEY_EXPIRES "expires"
 #define KEY_STAFF_AUTH_CHANNEL "staff_auth_channel"
 #define KEY_STAFF_AUTH_CHANNEL_MODES "staff_auth_channel_modes"
+#define KEY_STAFF_AUTH_FORCE_OPS "staff_auth_force_opers"
 #define KEY_CLONE_GLINE_DURATION "clone_gline_duration"
 #define KEY_BLOCK_GLINE_DURATION "block_gline_duration"
 #define KEY_ISSUER "issuer"
@@ -323,6 +325,7 @@ static struct {
     struct chanNode *debug_channel;
     struct chanNode *alert_channel;
     struct chanNode *staff_auth_channel;
+    int staff_auth_force;
     struct policer_params *join_policer_params;
     struct policer new_user_policer;
     unsigned long untrusted_max;
@@ -4696,6 +4699,30 @@ struct devnull_class*
     return dict_find(opserv_devnull_classes, name, NULL);
 }
 
+void operpart(struct chanNode *chan, struct userNode *user)
+{
+    if(opserv_conf.alert_channel && opserv_conf.staff_auth_force > 0 &&
+      !(irccasecmp(chan->name,opserv_conf.alert_channel->name))) {
+        struct mod_chanmode *change;
+        change = find_matching_bans(&chan->banlist, user, NULL); //don't join them if they're banned (exceptions from forced join)
+        if(change)
+            return;
+        irc_svsjoin(opserv,user,chan);
+    }
+}
+
+void operadd(struct userNode *user)
+{
+    if(opserv_conf.alert_channel && opserv_conf.staff_auth_force > 0)
+        irc_svsjoin(opserv,user,opserv_conf.alert_channel);
+}
+
+void operdel(struct userNode *user)
+{
+    if(opserv_conf.alert_channel && opserv_conf.staff_auth_force == 2)
+        irc_kick(opserv, user, opserv_conf.alert_channel, "mode -o");
+}
+
 static void
 opserv_conf_read(void)
 {
@@ -4738,8 +4765,11 @@ opserv_conf_read(void)
             str2 = "+timns";
         opserv_conf.staff_auth_channel = AddChannel(str, now, str2, NULL);
         AddChannelUser(opserv, opserv_conf.staff_auth_channel)->modes |= MODE_CHANOP;
+        str2 = database_get_data(conf_node, KEY_STAFF_AUTH_FORCE_OPS, RECDB_QSTRING);
+        opserv_conf.staff_auth_force = str2 ? atoi(str2) : 0;
     } else {
         opserv_conf.staff_auth_channel = NULL;
+        opserv_conf.staff_auth_force = 0;
     }
     str = database_get_data(conf_node, KEY_UNTRUSTED_MAX, RECDB_QSTRING);
     opserv_conf.untrusted_max = str ? strtoul(str, NULL, 0) : 5;
index 630e8b6ce890caca21922fd78580a15f22b8fe14..fcb9c8d0780ec014118fad065246bfb8903b5bf6 100644 (file)
@@ -58,5 +58,8 @@ void devnull_rename(const char *oldauth, const char *newauth);
 int devnull_check(const char *name);
 struct devnull_class* devnull_get(const char *name);
 struct userNode* GetOpServ(void);
+void operpart(struct chanNode *chan, struct userNode *user);
+void operadd(struct userNode *user);
+void operdel(struct userNode *user);
 
 #endif
index 89f4ebd0fca34aef9c68f557cb30e5ce0c4956a0..fbd22e304e5348cf8501d6163d8af278aa04b211 100644 (file)
@@ -482,6 +482,8 @@ part_helper(struct chanNode *cn, void *data)
 {
     struct part_desc *desc = data;
     DelChannelUser(desc->user, cn, desc->text, false);
+    if (IsOper(desc->user))
+        operpart(cn, desc->user);
 }
 
 static CMD_FUNC(cmd_part)
index 11dfb267fc22a6ec5de2feb2cca6f9bc246a39b6..0e4645a02e672d467bbc9884be8da07260d4f98e 100644 (file)
@@ -1587,6 +1587,8 @@ static CMD_FUNC(cmd_kick)
 {
     if (argc < 3)
         return 0;
+    if (GetUserN(argv[2]) && IsOper(GetUserN(argv[2])))
+        operpart(GetChannel(argv[1]), GetUserN(argv[2]));
     ChannelUserKicked(GetUserH(origin), GetUserN(argv[2]), GetChannel(argv[1]));
     return 1;
 }
@@ -2413,8 +2415,10 @@ void mod_usermode(struct userNode *user, const char *mode_change) {
         case 'o':
             do_user_mode(FLAGS_OPER);
             if (!add) {
+                operdel(user);
                 userList_remove(&curr_opers, user);
             } else if (!userList_contains(&curr_opers, user)) {
+                operadd(user);
                 userList_append(&curr_opers, user);
                 call_oper_funcs(user);
             }
index 70e2802084b5a8347ad93bbb9da7f74b38cfe098..2501d93a7b208a5e57aa612e8351ee310250d6c7 100644 (file)
         // who to tell about staff auths?
         "staff_auth_channel" "#opserv";
         "staff_auth_channel_modes" "+tinms";
+        // Force Opers to be in staff_auth_channel
+        // 0 = don't force opers to be in the channel
+        // 1 = force opers to be in the channel
+        // 2 = force opers to be in the channel but kick them if they get mode -o set (deoper)
+        "staff_auth_force_opers" "2";
         // how many clones to allow from an untrusted host?
         "untrusted_max" "4";
         // how long of a g-line should be issued if the max hosts is exceeded?
             "size" "200";
             "drain-rate" "3";
         };
+        
     };
 
     "chanserv" {