summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2016-06-05 14:16:36 +0100
committerRussell King <rmk+kernel@armlinux.org.uk>2016-06-05 17:47:56 +0100
commitbdc20e81e628a5d630f649b2d01fcfc795ca39ea (patch)
treec36e16c3b753c42aa1313f481f45f0db50eb0df2
parent14630f6b4763b34ff96c091c3e55f387862af185 (diff)
Add support for limited temporary Klines
-rw-r--r--include/client.h1
-rw-r--r--include/conf.h1
-rw-r--r--modules/m_kline.c33
-rw-r--r--src/conf.c1
-rw-r--r--src/conf_lexer.l2
-rw-r--r--src/conf_parser.y11
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 f761819..6c05d47 100644
--- a/include/conf.h
+++ b/include/conf.h
@@ -268,6 +268,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);
diff --git a/src/conf.c b/src/conf.c
index 9628962..ecd1d0c 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -1178,6 +1178,7 @@ set_default_conf(void)
ConfigFileEntry.use_egd = 0;
ConfigFileEntry.egdpool_path = NULL;
ConfigFileEntry.throttle_time = 10;
+ 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 a626270..0a71741 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
@@ -1370,6 +1372,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;
};
@@ -2470,6 +2476,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;
@@ -2881,6 +2888,10 @@ general_default_floodcount: DEFAULT_FLOODCOUNT '=' NUMBER ';'
ConfigFileEntry.default_floodcount = $3;
};
+general_tkline_time: TKLINE_TIME '=' timespec ';'
+{
+ ConfigFileEntry.tkline_max = $3;
+};
/***************************************************************************
* section channel