From: pk910 Date: Fri, 8 Jul 2011 14:49:55 +0000 (+0200) Subject: added option to force opers to be in staff_auth_channel X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=45fde124458090316c02a542a68d1132f12aca49 added option to force opers to be in staff_auth_channel --- diff --git a/src/chanserv.c b/src/chanserv.c index e160f62..b6da814 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -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; diff --git a/src/chanserv.h b/src/chanserv.h index 8c63e4a..8faad9c 100644 --- a/src/chanserv.h +++ b/src/chanserv.h @@ -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 diff --git a/src/opserv.c b/src/opserv.c index 0702a10..17a67d5 100644 --- a/src/opserv.c +++ b/src/opserv.c @@ -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; diff --git a/src/opserv.h b/src/opserv.h index 630e8b6..fcb9c8d 100644 --- a/src/opserv.h +++ b/src/opserv.h @@ -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 diff --git a/src/proto-common.c b/src/proto-common.c index 89f4ebd..fbd22e3 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -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) diff --git a/src/proto-p10.c b/src/proto-p10.c index 11dfb26..0e4645a 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -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); } diff --git a/srvx.conf.example b/srvx.conf.example index 70e2802..2501d93 100644 --- a/srvx.conf.example +++ b/srvx.conf.example @@ -161,6 +161,11 @@ // 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? @@ -185,6 +190,7 @@ "size" "200"; "drain-rate" "3"; }; + }; "chanserv" {