diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2016-06-05 14:16:36 +0100 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2019-07-21 20:59:35 +0100 |
commit | 83edbefbaabb2b17c84ac803131dc1a549da6964 (patch) | |
tree | 32cb5123307ee3e3b59dedf191fd5776ea5b7062 | |
parent | 7f273676eb203a1be6ca179c6ee1b3d3a4e81a78 (diff) |
Add support for limited temporary Klines
-rw-r--r-- | include/client.h | 1 | ||||
-rw-r--r-- | include/conf.h | 1 | ||||
-rw-r--r-- | modules/m_kline.c | 33 | ||||
-rw-r--r-- | src/conf.c | 1 | ||||
-rw-r--r-- | src/conf_lexer.l | 2 | ||||
-rw-r--r-- | src/conf_parser.y | 11 |
6 files changed, 42 insertions, 7 deletions
diff --git a/include/client.h b/include/client.h index a983cd5..cd1b4cd 100644 --- a/include/client.h +++ b/include/client.h @@ -210,6 +210,7 @@ struct MaskItem; #define OPER_FLAG_WALLOPS 0x00200000 /**< Oper can do WALLOPS */ #define OPER_FLAG_LOCOPS 0x00400000 /**< Oper can do LOCOPS */ #define OPER_FLAG_UNXLINE 0x00800000 /**< Oper can unxline */ +#define OPER_FLAG_TKLINE 0x01000000 /**< Oper can temp kill/kline */ #define HasOFlag(x, y) (MyConnect(x) ? (x)->localClient->operflags & (y) : 0) diff --git a/include/conf.h b/include/conf.h index b2e47f5..e06ac4d 100644 --- a/include/conf.h +++ b/include/conf.h @@ -265,6 +265,7 @@ struct config_file_entry int ping_cookie; int disable_auth; int cycle_on_host_change; + time_t tkline_max; }; struct config_channel_entry diff --git a/modules/m_kline.c b/modules/m_kline.c index 9b4392f..10b23c0 100644 --- a/modules/m_kline.c +++ b/modules/m_kline.c @@ -236,7 +236,7 @@ mo_kline(struct Client *client_p, struct Client *source_p, time_t tkline_time = 0; time_t cur_time; - if (!HasOFlag(source_p, OPER_FLAG_K)) + if (!HasOFlag(source_p, OPER_FLAG_K | OPER_FLAG_TKLINE)) { sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "kline"); @@ -247,6 +247,23 @@ mo_kline(struct Client *client_p, struct Client *source_p, &tkline_time, &target_server, &reason) < 0) return 0; + if (!HasOFlag(source_p, OPER_FLAG_K)) + { + if (tkline_time == 0 || tkline_time > ConfigFileEntry.tkline_max) + { + sendto_one(source_p, ":%s NOTICE %s :Refused to set kline - must be temporary < %u min", + me.name, source_p->name, ConfigFileEntry.tkline_max / 60); + return 0; + } + + if (user[0] == '*') + { + sendto_one(source_p, ":%s NOTICE %s :Refused to set kline - must give ~ or ^ user prefix", + me.name, source_p->name); + return 0; + } + } + if (target_server != NULL) { sendto_match_servs(source_p, target_server, CAP_KLN, "KLINE %s %lu %s %s :%s", @@ -272,10 +289,11 @@ mo_kline(struct Client *client_p, struct Client *source_p, conf->user = xstrdup(user); if (tkline_time != 0) - snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)", - (int)(tkline_time/60), reason, current_date); + snprintf(buffer, sizeof(buffer), "Temporary K-line %d min by %s - %s (%s)", + (int)(tkline_time/60), source_p->name, reason, current_date); else - snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date); + snprintf(buffer, sizeof(buffer), "K-line by %s - %s (%s)", + source_p->name, reason, current_date); conf->reason = xstrdup(buffer); m_kline_add_kline(source_p, conf, tkline_time); @@ -322,10 +340,11 @@ me_kline(struct Client *client_p, struct Client *source_p, conf->user = xstrdup(kuser); if (tkline_time != 0) - snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)", - (int)(tkline_time/60), kreason, current_date); + snprintf(buffer, sizeof(buffer), "Temporary K-line %d min by %s - %s (%s)", + (int)(tkline_time/60), source_p->name, kreason, current_date); else - snprintf(buffer, sizeof(buffer), "%s (%s)", kreason, current_date); + snprintf(buffer, sizeof(buffer), "K-line by %s - %s (%s)", + source_p->name, kreason, current_date); conf->reason = xstrdup(buffer); m_kline_add_kline(source_p, conf, tkline_time); @@ -1176,6 +1176,7 @@ set_default_conf(void) ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_OPERWALL | UMODE_WALLOP; ConfigFileEntry.throttle_time = 1; + ConfigFileEntry.tkline_max = 24 * 3600; } static void diff --git a/src/conf_lexer.l b/src/conf_lexer.l index 88fb7d0..a94c44a 100644 --- a/src/conf_lexer.l +++ b/src/conf_lexer.l @@ -332,7 +332,9 @@ stats_o_oper_only { return STATS_O_OPER_ONLY; } stats_P_oper_only { return STATS_P_OPER_ONLY; } stats_u_oper_only { return STATS_U_OPER_ONLY; } throttle_time { return THROTTLE_TIME; } +tkline { return TKLINE; } tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; } +tkline_time { return TKLINE_TIME; } tlsv1 { return T_TLSV1; } topiclimit { return T_TOPICLIMIT; } true_no_oper_flood { return TRUE_NO_OPER_FLOOD; } diff --git a/src/conf_parser.y b/src/conf_parser.y index 4274b6a..9d4c28a 100644 --- a/src/conf_parser.y +++ b/src/conf_parser.y @@ -355,7 +355,9 @@ reset_block_state(void) %token T_WEBIRC %token TBOOL %token THROTTLE_TIME +%token TKLINE %token TKLINE_EXPIRE_NOTICES +%token TKLINE_TIME %token TMASKED %token TRUE_NO_OPER_FLOOD %token TS_MAX_DELTA @@ -1377,6 +1379,10 @@ oper_flags_item: KILL ':' REMOTE { if (conf_parser_ctx.pass == 2) block_state.port.value |= OPER_FLAG_MODULE; +} | TKLINE +{ + if (conf_parser_ctx.pass == 2) + block_state.port.value |= OPER_FLAG_TKLINE; }; @@ -2476,6 +2482,7 @@ general_item: general_hide_spoof_ips | general_ignore_bogus_ts | general_stats_e_disabled | general_max_watch | general_services_name | general_cycle_on_host_change | + general_tkline_time | error; @@ -2873,6 +2880,10 @@ general_default_floodcount: DEFAULT_FLOODCOUNT '=' NUMBER ';' ConfigFileEntry.default_floodcount = $3; }; +general_tkline_time: TKLINE_TIME '=' timespec ';' +{ + ConfigFileEntry.tkline_max = $3; +}; /*************************************************************************** * section channel |