From 890e4c9acdd07bbaf0e83d499c8db9d0ee7e513c Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Mon, 26 Aug 2019 18:22:12 +0200 Subject: [PATCH] Set set::modes-on-join to +nt by default and also put it in the example.conf. Leaving it empty by default is strange and contrasts with our "secure by default" principle. --- doc/RELEASE-NOTES | 1 + doc/conf/examples/example.conf | 8 +++----- src/conf.c | 26 ++++++++++++++++++-------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/RELEASE-NOTES b/doc/RELEASE-NOTES index 99e6fd51e..9d3e60dba 100644 --- a/doc/RELEASE-NOTES +++ b/doc/RELEASE-NOTES @@ -161,6 +161,7 @@ Changed in case of a bug and also more control for admins at runtime. Only <5 modules out of 173 are permanent now. * User mode +T now blocks channel CTCPs as well. +* set::modes-on-join is now +nt by default. * The authprompt module is now loaded by default. This means that if you do a soft kline on someone (eg: KLINE %*@*.badisp) then the user has a chance to authenticate to services, even without SASL, and diff --git a/doc/conf/examples/example.conf b/doc/conf/examples/example.conf index b2d56c0e1..9ea80bf7d 100644 --- a/doc/conf/examples/example.conf +++ b/doc/conf/examples/example.conf @@ -452,7 +452,8 @@ set { set { kline-address "set.this.to.email.address"; /* e-mail or URL shown when a user is banned */ modes-on-connect "+ixw"; /* when users connect, they will get these user modes */ - modes-on-oper "+xwgs"; /* when someone becomes IRCOp they'll get these modes */ + modes-on-oper "+xwgs"; /* when someone becomes IRCOp they'll get these modes */ + modes-on-join "+nt"; /* default channel modes when a new channel is created */ oper-auto-join "#opers"; /* IRCOps are auto-joined to this channel */ options { hide-ulines; /* hide U-lines in /MAP and /LINKS */ @@ -472,13 +473,10 @@ set { /* static-part does the same for /PART */ /* static-part yes; */ - /* how fast the server must reply to PING before sending a warning to opers. */ - ping-warning 15; - /* Which /STATS to restrict to opers only. We suggest to leave it to * (ALL) */ oper-only-stats "*"; - /* Anti flood protection */ + /* Flood protection */ anti-flood { nick-flood 3:60; /* 3 nick changes per 60 seconds (the default) */ connect-flood 3:60; /* 3 connection attempts per 60 seconds (the default) */ diff --git a/src/conf.c b/src/conf.c index 0c4c5d4f2..019ae6196 100644 --- a/src/conf.c +++ b/src/conf.c @@ -474,7 +474,17 @@ long config_checkval(char *orig, unsigned short flags) { return ret; } -void set_channelmodes(char *modes, struct ChMode *store, int warn) +/** Free configuration setting for set::modes-on-join */ +void free_conf_channelmodes(struct ChMode *store) +{ + int i; + + for (i = 0; i < EXTCMODETABLESZ; i++) + safefree(iConf.modes_on_join.extparams[i]); +} + +/* Set configuration, used for set::modes-on-join */ +void conf_channelmodes(char *modes, struct ChMode *store, int warn) { aCtab *tab; char *params = strchr(modes, ' '); @@ -484,6 +494,9 @@ void set_channelmodes(char *modes, struct ChMode *store, int warn) warn = 0; // warn is broken + /* Free existing parameters first (no inheritance) */ + free_conf_channelmodes(store); + if (params) { params++; @@ -1487,6 +1500,7 @@ void config_setdefaultsettings(aConfiguration *i) i->maxchannelsperuser = 10; i->maxdccallow = 10; i->channel_command_prefix = strdup("`!."); + conf_channelmodes("+nt", &i->modes_on_join, 0); i->check_target_nick_bans = 1; i->maxbans = 60; i->maxbanlength = 2048; @@ -2425,11 +2439,7 @@ void config_rehash() } conf_sni = NULL; - for (i = 0; i < EXTCMODETABLESZ; i++) - { - if (iConf.modes_on_join.extparams[i]) - free(iConf.modes_on_join.extparams[i]); - } + free_conf_channelmodes(&iConf.modes_on_join); /* reset conf_files -- should this be in its own function? no, because @@ -7345,7 +7355,7 @@ int _conf_set(ConfigFile *conf, ConfigEntry *ce) tempiConf.oper_modes = (long) set_usermode(cep->ce_vardata); } else if (!strcmp(cep->ce_varname, "modes-on-join")) { - set_channelmodes(cep->ce_vardata, &tempiConf.modes_on_join, 0); + conf_channelmodes(cep->ce_vardata, &tempiConf.modes_on_join, 0); } else if (!strcmp(cep->ce_varname, "snomask-on-oper")) { safestrdup(tempiConf.oper_snomask, cep->ce_vardata); @@ -7945,7 +7955,7 @@ int _test_set(ConfigFile *conf, ConfigEntry *ce) break; } } - set_channelmodes(cep->ce_vardata, &temp, 1); + conf_channelmodes(cep->ce_vardata, &temp, 1); if (temp.mode & MODE_SECRET && temp.mode & MODE_PRIVATE) { config_error("%s:%i: set::modes-on-join has both +s and +p",