From d295a3986d7bb97c3b36facb1c1d94cbc35d50a5 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Sun, 8 Nov 2020 09:50:17 -0800 Subject: [PATCH] Stop using chm_nosuch as a sentinel value (#53) Remove chmode compat modules This removes the need for chm_nosuch as well. Unknown mode detection happens in mode parsing now. --- doc/ircd.conf.example | 3 -- doc/reference.conf | 6 ---- extensions/Makefile.am | 3 -- extensions/chm_operonly_compat.c | 46 ------------------------------ extensions/chm_quietunreg_compat.c | 45 ----------------------------- extensions/chm_sslonly_compat.c | 44 ---------------------------- include/chmode.h | 1 - ircd/chmode.c | 22 ++------------ 8 files changed, 2 insertions(+), 168 deletions(-) delete mode 100644 extensions/chm_operonly_compat.c delete mode 100644 extensions/chm_quietunreg_compat.c delete mode 100644 extensions/chm_sslonly_compat.c diff --git a/doc/ircd.conf.example b/doc/ircd.conf.example index 9de66cbb..159ddf74 100644 --- a/doc/ircd.conf.example +++ b/doc/ircd.conf.example @@ -9,9 +9,6 @@ /* Extensions */ #loadmodule "extensions/chm_nonotice"; -#loadmodule "extensions/chm_operonly_compat"; -#loadmodule "extensions/chm_quietunreg_compat"; -#loadmodule "extensions/chm_sslonly_compat"; #loadmodule "extensions/chm_operpeace"; #loadmodule "extensions/createauthonly"; #loadmodule "extensions/extb_account"; diff --git a/doc/reference.conf b/doc/reference.conf index 22ba0160..1d2fdc94 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -47,9 +47,6 @@ * Channel mode +-T (blocks notices) -- chm_nonotice * Channel mode +-O (oper only) -- chm_operonly * Channel mode +-S (ssl only) -- chm_sslonly - * Emulates channel mode +-O (oper only) (+-iI $o) -- chm_operonly_compat - * Emulates channel mode +-R (quiet unreg) (+-q $~a) -- chm_quietunreg_compat - * Emulates channel mode +-S (ssl only) (+-b $~z) -- chm_sslonly_compat * Channel mode +-M (disallow KICK on IRC ops) -- chm_operpeace * Restrict channel creation to logged in users -- createauthonly * Account bans (+b $a[:mask]) -- extb_account @@ -84,9 +81,6 @@ #loadmodule "extensions/chm_nonotice"; #loadmodule "extensions/chm_operonly"; #loadmodule "extensions/chm_sslonly"; -#loadmodule "extensions/chm_operonly_compat"; -#loadmodule "extensions/chm_quietunreg_compat"; -#loadmodule "extensions/chm_sslonly_compat"; #loadmodule "extensions/chm_operpeace"; #loadmodule "extensions/createauthonly"; #loadmodule "extensions/extb_account"; diff --git a/extensions/Makefile.am b/extensions/Makefile.am index fc35db8f..27a922b5 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -12,13 +12,10 @@ extension_LTLIBRARIES = \ chantype_dummy.la \ chm_adminonly.la \ chm_operonly.la \ - chm_operonly_compat.la \ chm_insecure.la \ chm_nonotice.la \ chm_operpeace.la \ - chm_quietunreg_compat.la \ chm_sslonly.la \ - chm_sslonly_compat.la \ createauthonly.la \ createoperonly.la \ extb_account.la \ diff --git a/extensions/chm_operonly_compat.c b/extensions/chm_operonly_compat.c deleted file mode 100644 index 719e66ef..00000000 --- a/extensions/chm_operonly_compat.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Treat cmode +-O as +-iI $o. - */ - -#include "stdinc.h" -#include "modules.h" -#include "client.h" -#include "hook.h" -#include "ircd.h" -#include "chmode.h" - -static const char chm_operonly_compat[] = - "Adds an emulated channel mode +O which is converted into mode +i and +I $o"; - -static int _modinit(void); -static void _moddeinit(void); -static ChannelModeFunc chm_operonly; - -DECLARE_MODULE_AV2(chm_operonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_operonly_compat); - -static int -_modinit(void) -{ - chmode_table['O'] = (struct ChannelMode){chm_operonly, 0, 0}; - return 0; -} - -static void -_moddeinit(void) -{ - chmode_table['O'] = (struct ChannelMode){chm_nosuch, 0, 0}; -} - -static void -chm_operonly(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type) -{ - if (MyClient(source_p)) { - chm_simple(source_p, chptr, alevel, NULL, - errors, dir, 'i', MODE_INVITEONLY); - chm_ban(source_p, chptr, alevel, "$o", - errors, dir, 'I', CHFL_INVEX); - } else - chm_nosuch(source_p, chptr, alevel, NULL, - errors, dir, c, mode_type); -} diff --git a/extensions/chm_quietunreg_compat.c b/extensions/chm_quietunreg_compat.c deleted file mode 100644 index fd08e570..00000000 --- a/extensions/chm_quietunreg_compat.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Treat cmode +-R as +-q $~a. - * -- jilles - */ - -#include "stdinc.h" -#include "modules.h" -#include "client.h" -#include "hook.h" -#include "ircd.h" -#include "chmode.h" - -static const char chm_quietunreg_compat_desc[] = - "Adds an emulated channel mode +R which is converted into mode +q $~a"; - -static int _modinit(void); -static void _moddeinit(void); -static ChannelModeFunc chm_quietunreg; - -DECLARE_MODULE_AV2(chm_quietunreg_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_quietunreg_compat_desc); - -static int -_modinit(void) -{ - chmode_table['R'] = (struct ChannelMode){ chm_quietunreg, 0, 0 }; - return 0; -} - -static void -_moddeinit(void) -{ - chmode_table['R'] = (struct ChannelMode){ chm_nosuch, 0, 0 }; -} - -static void -chm_quietunreg(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type) -{ - if (MyClient(source_p)) - chm_ban(source_p, chptr, alevel, "$~a", - errors, dir, 'q', CHFL_QUIET); - else - chm_nosuch(source_p, chptr, alevel, NULL, - errors, dir, c, mode_type); -} diff --git a/extensions/chm_sslonly_compat.c b/extensions/chm_sslonly_compat.c deleted file mode 100644 index be9d178b..00000000 --- a/extensions/chm_sslonly_compat.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Treat cmode +-S as +-b $~z. - */ - -#include "stdinc.h" -#include "modules.h" -#include "client.h" -#include "hook.h" -#include "ircd.h" -#include "chmode.h" - -static const char chm_sslonly_compat_desc[] = - "Adds an emulated channel mode +S which is converted into mode +b $~z"; - -static int _modinit(void); -static void _moddeinit(void); -static ChannelModeFunc chm_sslonly; - -DECLARE_MODULE_AV2(chm_sslonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_sslonly_compat_desc); - -static int -_modinit(void) -{ - chmode_table['S'] = (struct ChannelMode){ chm_sslonly, 0, 0 }; - return 0; -} - -static void -_moddeinit(void) -{ - chmode_table['S'] = (struct ChannelMode){ chm_nosuch, 0, 0 }; -} - -static void -chm_sslonly(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type) -{ - if (MyClient(source_p)) - chm_ban(source_p, chptr, alevel, "$~z", - errors, dir, 'b', CHFL_BAN); - else - chm_nosuch(source_p, chptr, alevel, NULL, - errors, dir, c, mode_type); -} diff --git a/include/chmode.h b/include/chmode.h index 2ead3df9..7fae18af 100644 --- a/include/chmode.h +++ b/include/chmode.h @@ -34,7 +34,6 @@ extern int chmode_flags[256]; -extern ChannelModeFunc chm_nosuch; extern ChannelModeFunc chm_orphaned; extern ChannelModeFunc chm_simple; extern ChannelModeFunc chm_ban; diff --git a/ircd/chmode.c b/ircd/chmode.c index 8ed74ded..78f9f55a 100644 --- a/ircd/chmode.c +++ b/ircd/chmode.c @@ -118,7 +118,6 @@ construct_cflags_strings(void) /* Should we leave orphaned check here? -- dwr */ if (chmode_table[i].set_func != NULL && - chmode_table[i].set_func != chm_nosuch && chmode_table[i].set_func != chm_orphaned) { *ptr2++ = (char) i; @@ -157,11 +156,10 @@ cflag_add(char c_, ChannelModeFunc function) int c = (unsigned char)c_; if (chmode_table[c].set_func != NULL && - chmode_table[c].set_func != chm_nosuch && chmode_table[c].set_func != chm_orphaned) return 0; - if (chmode_table[c].set_func == NULL || chmode_table[c].set_func == chm_nosuch) + if (chmode_table[c].set_func == NULL) chmode_table[c].mode_type = find_cflag_slot(); if (chmode_table[c].mode_type == 0) return 0; @@ -575,20 +573,6 @@ fix_key_remote(char *arg) return arg; } -/* chm_*() - * - * The handlers for each specific mode. - */ -void -chm_nosuch(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type) -{ - if(*errors & SM_ERR_UNKNOWN) - return; - *errors |= SM_ERR_UNKNOWN; - sendto_one(source_p, form_str(ERR_UNKNOWNMODE), me.name, source_p->name, c); -} - void chm_simple(struct Client *source_p, struct Channel *chptr, int alevel, const char *arg, int *errors, int dir, char c, long mode_type) @@ -1434,7 +1418,7 @@ set_channel_mode(struct Client *client_p, struct Client *source_p, bool use_arg = dir == MODE_ADD ? cm->flags & CHM_ARG_SET : dir == MODE_DEL ? cm->flags & CHM_ARG_DEL : false; - if (cm->set_func == NULL || cm->set_func == chm_nosuch) + if (cm->set_func == NULL) { sendto_one(source_p, form_str(ERR_UNKNOWNMODE), me.name, source_p->name, c); return; @@ -1513,8 +1497,6 @@ set_channel_mode(struct Client *client_p, struct Client *source_p, for (ms = modesets; ms < mend; ms++) { ChannelModeFunc *set_func = ms->cm->set_func; - if (set_func == NULL) - set_func = chm_nosuch; set_func(fakesource_p, chptr, alevel, ms->arg, &errors, ms->dir, ms->mode, ms->cm->mode_type); }