/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" /* $ModDesc: Provides support for unreal-style oper-override */ class ModuleOverride : public Module { bool RequireKey; bool NoisyOverride; public: void init() { // read our config options (main config file) OnRehash(NULL); ServerInstance->SNO->EnableSnomask('v', "OVERRIDE"); Implementation eventlist[] = { I_OnRehash, I_On005Numeric, I_OnUserPreJoin, I_OnPermissionCheck }; ServerInstance->Modules->Attach(eventlist, this, 4); } void OnRehash(User* user) { ConfigReader Conf; // re-read our config options on a rehash NoisyOverride = Conf.ReadFlag("override", "noisy", 0); RequireKey = Conf.ReadFlag("override", "requirekey", 0); } void On005Numeric(std::string &output) { output.append(" OVERRIDE"); } void OnPermissionCheck(PermissionData& perm) { if (IS_LOCAL(perm.source) && perm.source->HasPrivPermission("override/" + perm.name)) { ServerInstance->SNO->WriteGlobalSno('v',perm.source->nick+" used oper override for "+perm.name+" on "+ (perm.chan ? perm.chan->name : "")); perm.result = MOD_RES_ALLOW; } } ModResult OnUserPreJoin(User* user, Channel* chan, const std::string& cname, std::string &privs, const std::string &keygiven) { if (IS_LOCAL(user) && IS_OPER(user)) { if (chan) { if (chan->IsModeSet('i') && user->HasPrivPermission("override/invite")) { irc::string x(chan->name.c_str()); if (!IS_LOCAL(user)->IsInvited(x)) { if (RequireKey && keygiven != "override") { // Can't join normally -- must use a special key to bypass restrictions user->WriteServ("NOTICE %s :*** You may not join normally. You must join with a key of 'override' to oper override.", user->nick.c_str()); return MOD_RES_PASSTHRU; } if (NoisyOverride) chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass invite-only", cname.c_str(), user->nick.c_str()); ServerInstance->SNO->WriteGlobalSno('v', user->nick+" used oper override to bypass +i on "+std::string(cname)); } return MOD_RES_ALLOW; } if (chan->IsModeSet('k') && user->HasPrivPermission("override/key") && keygiven != chan->GetModeParameter('k')) { if (RequireKey && keygiven != "override") { // Can't join normally -- must use a special key to bypass restrictions user->WriteServ("NOTICE %s :*** You may not join normally. You must join with a key of 'override' to oper override.", user->nick.c_str()); return MOD_RES_PASSTHRU; } if (NoisyOverride) chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass the channel key", cname.c_str(), user->nick.c_str()); ServerInstance->SNO->WriteGlobalSno('v', user->nick+" used oper override to bypass +k on "+std::string(cname)); return MOD_RES_ALLOW; } if (chan->IsModeSet('l') && (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str())) && user->HasPrivPermission("override/limit")) { if (RequireKey && keygiven != "override") { // Can't join normally -- must use a special key to bypass restrictions user->WriteServ("NOTICE %s :*** You may not join normally. You must join with a key of 'override' to oper override.", user->nick.c_str()); return MOD_RES_PASSTHRU; } if (NoisyOverride) chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass the channel limit", cname.c_str(), user->nick.c_str()); ServerInstance->SNO->WriteGlobalSno('v', user->nick+" used oper override to bypass +l on "+std::string(cname)); return MOD_RES_ALLOW; } if (chan->IsBanned(user) && user->HasPrivPermission("override/ban")) { if (RequireKey && keygiven != "override") { // Can't join normally -- must use a special key to bypass restrictions user->WriteServ("NOTICE %s :*** You may not join normally. You must join with a key of 'override' to oper override.", user->nick.c_str()); return MOD_RES_PASSTHRU; } if (NoisyOverride) chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass channel ban", cname.c_str(), user->nick.c_str()); ServerInstance->SNO->WriteGlobalSno('v',"%s used oper override to bypass channel ban on %s", user->nick.c_str(), cname.c_str()); return MOD_RES_ALLOW; } } } return MOD_RES_PASSTHRU; } Version GetVersion() { return Version("Provides support for unreal-style oper-override",VF_VENDOR); } }; MODULE_INIT(ModuleOverride)