diff --git a/include/struct.h b/include/struct.h index 7c3d6c14b..1548c7b82 100644 --- a/include/struct.h +++ b/include/struct.h @@ -1629,7 +1629,6 @@ struct liststruct { #define MODE_RGSTR 0x8000 #define MODE_RGSTRONLY 0x10000 #define MODE_NOCOLOR 0x40000 -#define MODE_ADMONLY 0x100000 #define MODE_NOKICKS 0x200000 #define MODE_STRIP 0x400000 #define MODE_MODREG 0x4000000 diff --git a/modules.conf b/modules.conf index 9f1014779..54ab43ab6 100644 --- a/modules.conf +++ b/modules.conf @@ -123,6 +123,7 @@ loadmodule "modules/chanmodes/delayjoin"; /* +D */ loadmodule "modules/chanmodes/noknock"; /* +K */ loadmodule "modules/chanmodes/noinvite"; /* +V */ loadmodule "modules/chanmodes/operonly"; /* +O */ +loadmodule "modules/chanmodes/adminonly"; /* +A */ /*** User modes ***/ loadmodule "modules/usermodes/noctcp"; /* +T */ diff --git a/src/channel.c b/src/channel.c index 7071ef1ec..61a6a683f 100644 --- a/src/channel.c +++ b/src/channel.c @@ -88,7 +88,6 @@ aCtab cFlagTab[] = { {MODE_RGSTRONLY, 'R', 0, 0}, {MODE_CHANPROT, 'a', 0, 1}, {MODE_CHANOWNER, 'q', 0, 1}, - {MODE_ADMONLY, 'A', 0, 0}, {MODE_NOKICKS, 'Q', 0, 0}, {MODE_BAN, 'b', 1, 1}, {MODE_EXCEPT, 'e', 1, 0}, /* exception ban */ diff --git a/src/modules/chanmodes/Makefile.in b/src/modules/chanmodes/Makefile.in index 314aad304..649ed7593 100644 --- a/src/modules/chanmodes/Makefile.in +++ b/src/modules/chanmodes/Makefile.in @@ -31,7 +31,8 @@ INCLUDES = ../../include/auth.h ../../include/channel.h \ R_MODULES= \ nocolor.so stripcolor.so issecure.so permanent.so jointhrottle.so floodprot.so \ - noctcp.so link.so censor.so delayjoin.so noknock.so noinvite.so operonly.so + noctcp.so link.so censor.so delayjoin.so noknock.so noinvite.so operonly.so \ + adminonly.so MODULES=$(R_MODULES) MODULEFLAGS=@MODULEFLAGS@ @@ -103,4 +104,8 @@ noinvite.so: noinvite.c $(INCLUDES) operonly.so: operonly.c $(INCLUDES) $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ - -o operonly.so operonly.c \ No newline at end of file + -o operonly.so operonly.c + +adminonly.so: adminonly.c $(INCLUDES) + $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ + -o adminonly.so adminonly.c \ No newline at end of file diff --git a/src/modules/chanmodes/adminonly.c b/src/modules/chanmodes/adminonly.c new file mode 100644 index 000000000..84798e3db --- /dev/null +++ b/src/modules/chanmodes/adminonly.c @@ -0,0 +1,128 @@ +/* + * Disallow knocks UnrealIRCd Module (Channel Mode +K) + * (C) Copyright 2014 Travis McArthur (Heero) and the UnrealIRCd team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "config.h" +#include "struct.h" +#include "common.h" +#include "sys.h" +#include "numeric.h" +#include "msg.h" +#include "proto.h" +#include "channel.h" +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#endif +#include +#include "h.h" +#ifdef _WIN32 +#include "version.h" +#endif + +DLLFUNC CMD_FUNC(adminonly); + +ModuleHeader MOD_HEADER(adminonly) + = { + "chanmodes/adminonly", + "$Id$", + "Channel Mode +V", + "3.2-b8-1", + NULL + }; + +Cmode_t EXTCMODE_ADMINONLY; + +#define IsAdminOnly(chptr) (chptr->mode.extmode & EXTCMODE_ADMINONLY) + +DLLFUNC int adminonly_check (aClient *cptr, aChannel *chptr, char *key, char *parv[]); +DLLFUNC int adminonly_topic_allow (aClient *sptr, aChannel *chptr); +DLLFUNC int adminonly_check_ban(aClient *cptr, aChannel *chptr); + +DLLFUNC int MOD_TEST(adminonly)(ModuleInfo *modinfo) +{ + return MOD_SUCCESS; +} + +DLLFUNC int MOD_INIT(adminonly)(ModuleInfo *modinfo) +{ +CmodeInfo req; + + memset(&req, 0, sizeof(req)); + req.paracount = 0; + req.flag = 'A'; + req.is_ok = adminonly_require_oper; + CmodeAdd(modinfo->handle, req, &EXTCMODE_ADMINONLY); + + HookAddEx(modinfo->handle, HOOKTYPE_CAN_JOIN, adminonly_check); + HookAddEx(modinfo->handle, HOOKTYPE_OPER_INVITE_BAN, adminonly_check_ban); + HookAddEx(modinfo->handle, HOOKTYPE_VIEW_TOPIC_OUTSIDE_CHANNEl, adminonly_topic_allow); + + + MARK_AS_OFFICIAL_MODULE(modinfo); + return MOD_SUCCESS; +} + +DLLFUNC int MOD_LOAD(noctcp)(int module_load) +{ + return MOD_SUCCESS; +} + +DLLFUNC int MOD_UNLOAD(noctcp)(int module_unload) +{ + return MOD_SUCCESS; +} + +DLLFUNC int adminonly_check (aClient *cptr, aChannel *chptr, char *key, char *parv[]) +{ + if ((chptr->mode.extmode & EXTCMODE_ADMINONLY) && !IsSkoAdmin(cptr)) + return ERR_ADMONLY; + return 0; +} + + +DLLFUNC int adminonly_check_ban(aClient *cptr, aChannel *chptr) +{ + + if ((chptr->mode.extmode & EXTCMODE_ADMINONLY) && IsAnOper(cptr) && !IsNetAdmin(cptr) && !IsSAdmin(cptr)) + return HOOK_DENY; + + return HOOK_CONTINUE; +} + +DLLFUNC int adminonly_topic_allow (aClient *sptr, aChannel *chptr) +{ + if (chptr->mode.extmode & EXTCMODE_ADMINONLY && !IsAdmin(sptr)) + return HOOK_DENY; + + return HOOK_CONTINUE; +} + +DLLFUNC int adminonly_require_oper(aClient *cptr, aChannel *chptr, char mode, char *para, int checkt, int what) +{ + if (!IsSkoAdmin(cptr) && !IsServer(cptr) + && !IsULine(cptr)) + return EX_ALLOW; + + return EX_DENY; +} + diff --git a/src/modules/m_join.c b/src/modules/m_join.c index 0faf75060..a7f837072 100644 --- a/src/modules/m_join.c +++ b/src/modules/m_join.c @@ -128,10 +128,6 @@ int i,j; return (ERR_SECUREONLYCHAN); } - if ((chptr->mode.mode & MODE_ADMONLY) && !IsSkoAdmin(sptr)) - return (ERR_ADMONLY); - - for (h = Hooks[HOOKTYPE_OPER_INVITE_BAN]; h; h = h->next) { j = (*(h->func.intfunc))(sptr,chptr); @@ -144,11 +140,6 @@ int i,j; if (banned && j == HOOK_DENY) return (ERR_BANNEDFROMCHAN); - /* Only NetAdmin/SAdmin can walk +b in +A */ - if (banned && (chptr->mode.mode & MODE_ADMONLY) && - IsAnOper(sptr) && !IsNetAdmin(sptr) && !IsSAdmin(sptr)) - return (ERR_BANNEDFROMCHAN); - for (lp = sptr->user->invited; lp; lp = lp->next) if (lp->value.chptr == chptr) return 0; diff --git a/src/modules/m_mode.c b/src/modules/m_mode.c index 81e7c286a..1497fb482 100644 --- a/src/modules/m_mode.c +++ b/src/modules/m_mode.c @@ -817,14 +817,6 @@ int do_mode_char(aChannel *chptr, long modetype, char modechar, char *param, } switch (modetype) { - case MODE_ADMONLY: - if (!IsSkoAdmin(cptr) && !IsServer(cptr) - && !IsULine(cptr)) - { - sendto_one(cptr, err_str(ERR_NOPRIVILEGES), me.name, cptr->name); - break; - } - goto setthephuckingmode; case MODE_RGSTR: if (!IsServer(cptr) && !IsULine(cptr)) {