From 9ace21a74d5fca9d936fd7120e7088fca386df38 Mon Sep 17 00:00:00 2001 From: JD Horelick Date: Tue, 2 Mar 2010 20:33:58 -0500 Subject: [PATCH] First step of expiry of +p crap. --- doc/example.conf | 1 + doc/reference.conf | 5 +++++ include/s_conf.h | 1 + modules/m_info.c | 6 ++++++ src/newconf.c | 1 + src/s_conf.c | 1 + src/s_user.c | 12 ++++++++++++ 7 files changed, 27 insertions(+) diff --git a/doc/example.conf b/doc/example.conf index acf1750..325afc1 100755 --- a/doc/example.conf +++ b/doc/example.conf @@ -529,6 +529,7 @@ general { reject_duration = 5 minutes; throttle_duration = 60; throttle_count = 4; + expire_override_time = 5 minutes; }; modules { diff --git a/doc/reference.conf b/doc/reference.conf index 7978cb4..87912d1 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -1334,6 +1334,11 @@ general { /* throttle_count: Number of connections within throttle_duration that it takes * for throttling to take effect */ throttle_count = 4; + + /* expire_override_time: User mode +p will be automatically unset + * this long after it is set. 0 disables this. Default is 5 minutes. + */ + expire_override_time = 5 minutes; }; modules { diff --git a/include/s_conf.h b/include/s_conf.h index 10f6601..84d47bd 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -218,6 +218,7 @@ struct config_file_entry int global_snotices; int operspy_dont_care_user_info; int secret_channels_in_whois; + int expire_override_time; }; struct config_channel_entry diff --git a/modules/m_info.c b/modules/m_info.c index e697547..0f1dad8 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -181,6 +181,12 @@ static struct InfoStruct info_table[] = { &ConfigFileEntry.dots_in_ident, "Number of permissable dots in an ident" }, + { + "expire_override_time", + OUTPUT_DECIMAL, + &ConfigFileEntry.expire_override_time, + "Period of time after which to unset user mode +p" + }, { "failed_oper_notice", OUTPUT_BOOLEAN, diff --git a/src/newconf.c b/src/newconf.c index ebe7437..93a48f6 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -2213,6 +2213,7 @@ static struct ConfEntry conf_general_table[] = { "ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta }, { "use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually }, { "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline }, + { "expire_override_time", CF_TIME, NULL, 0, &ConfigFileEntry.expire_override_time}, { "\0", 0, NULL, 0, NULL } }; diff --git a/src/s_conf.c b/src/s_conf.c index b0e07e6..bbe78c4 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -798,6 +798,7 @@ set_default_conf(void) ConfigFileEntry.reject_duration = 120; ConfigFileEntry.throttle_count = 4; ConfigFileEntry.throttle_duration = 60; + ConfigFileEntry.expire_override_time = 300; ServerInfo.default_max_clients = MAXCONNECTIONS; diff --git a/src/s_user.c b/src/s_user.c index c1ec57d..345c7c5 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -905,6 +905,14 @@ show_other_user_mode(struct Client *source_p, struct Client *target_p) target_p->name, buf); } +static void +expire_umode_p(void *data) +{ + struct Client *source_p = data; + char *parv[4] = {source_p->name, source_p->name, "-p", NULL}; + user_mode(source_p, source_p, 3, parv); +} + /* * user_mode - set get current users mode * @@ -979,6 +987,10 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char sendto_one_numeric(source_p, RPL_SNOMASK, form_str(RPL_SNOMASK), construct_snobuf(source_p->snomask)); + /* If we're setting +p, expire it */ + if(ConfigFileEntry.expire_override_time && (source_p->umodes & ~setflags) & UMODE_OVERRIDE) + rb_event_addonce("expire_override", expire_umode_p, source_p, ConfigFileEntry.expire_override_time); + return 0; }