X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_override.cpp;h=0f8922854cb451eed08318ae49c0e113a31700da;hb=e6d000042ea75d4e0485bec9564b47163a3ca414;hp=026b2798d7c13af4ec863e4b5ce1e7412c1dec4e;hpb=3a7dd5b129450b94e0a87b8ad5009da70905b8e5;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 026b2798d..0f8922854 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -2,22 +2,15 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * - * - * - * Written by Craig Edwards, Craig McLure, and others. + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ -#include "users.h" -#include "channels.h" -#include "modules.h" -#include "configreader.h" #include "inspircd.h" #include "wildcard.h" @@ -36,16 +29,16 @@ class ModuleOverride : public Module public: ModuleOverride(InspIRCd* Me) - : Module::Module(Me) + : Module(Me) { // read our config options (main config file) - OnRehash(""); + OnRehash(NULL,""); ServerInstance->SNO->EnableSnomask('O',"OVERRIDE"); OverriddenMode = false; OverOps = OverDeops = OverVoices = OverDevoices = OverHalfops = OverDehalfops = 0; } - virtual void OnRehash(const std::string ¶meter) + virtual void OnRehash(userrec* user, const std::string ¶meter) { // on a rehash we delete our classes for good measure and create them again. ConfigReader* Conf = new ConfigReader(ServerInstance); @@ -93,24 +86,24 @@ class ModuleOverride : public Module output.append(" OVERRIDE"); } - virtual bool CanOverride(userrec* source, char* token) + virtual bool CanOverride(userrec* source, const char* token) { // checks to see if the oper's type has override_t::iterator j = overrides.find(source->oper); - + if (j != overrides.end()) { - // its defined, return its value as a boolean for if the token is set - return (j->second.find(token, 0) != std::string::npos); + // its defined or * is set, return its value as a boolean for if the token is set + return ((j->second.find(token, 0) != std::string::npos) || (j->second.find("*", 0) != std::string::npos)); } - + // its not defined at all, count as false return false; } virtual int OnUserPreKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { - if ((*source->oper) && (CanOverride(source,"KICK"))) + if (IS_OPER(source) && CanOverride(source,"KICK")) { if (((chan->GetStatus(source) == STATUS_HOP) && (chan->GetStatus(user) == STATUS_OP)) || (chan->GetStatus(source) < STATUS_VOICE)) { @@ -124,7 +117,7 @@ class ModuleOverride : public Module virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) { - if (*source->oper) + if (IS_OPER(source)) { if (source && channel) { @@ -134,7 +127,6 @@ class ModuleOverride : public Module switch (access_type) { case AC_DEOP: - ServerInstance->Log(DEBUG,"Override access check AC_DEOP"); if (CanOverride(source,"MODEDEOP")) { if (NoisyOverride) @@ -148,7 +140,6 @@ class ModuleOverride : public Module } break; case AC_OP: - ServerInstance->Log(DEBUG,"Override access check AC_OP"); if (CanOverride(source,"MODEOP")) { if (NoisyOverride) @@ -162,7 +153,6 @@ class ModuleOverride : public Module } break; case AC_VOICE: - ServerInstance->Log(DEBUG,"Override access check AC_VOICE"); if (CanOverride(source,"MODEVOICE")) { if (NoisyOverride) @@ -176,7 +166,6 @@ class ModuleOverride : public Module } break; case AC_DEVOICE: - ServerInstance->Log(DEBUG,"Override access check AC_DEVOICE"); if (CanOverride(source,"MODEDEVOICE")) { if (NoisyOverride) @@ -190,7 +179,6 @@ class ModuleOverride : public Module } break; case AC_HALFOP: - ServerInstance->Log(DEBUG,"Override access check AC_HALFOP"); if (CanOverride(source,"MODEHALFOP")) { if (NoisyOverride) @@ -204,7 +192,6 @@ class ModuleOverride : public Module } break; case AC_DEHALFOP: - ServerInstance->Log(DEBUG,"Override access check AC_DEHALFOP"); if (CanOverride(source,"MODEDEHALFOP")) { if (NoisyOverride) @@ -224,7 +211,6 @@ class ModuleOverride : public Module if (NoisyOverride) if ((!channel->HasUser(source)) || (mode < STATUS_OP)) { - ServerInstance->Log(DEBUG,"Overridden mode"); OverriddenMode = true; OverOps = OverDeops = OverVoices = OverDevoices = OverHalfops = OverDehalfops = 0; } @@ -240,28 +226,26 @@ class ModuleOverride : public Module return ACR_DEFAULT; } - virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) + virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs) { - if (*user->oper) + if (IS_OPER(user)) { if (chan) { if ((chan->modes[CM_INVITEONLY]) && (CanOverride(user,"INVITE"))) { - if (NoisyOverride) + irc::string x = chan->name; + if (!user->IsInvited(x)) { - irc::string x = chan->name; - if (!user->IsInvited(x)) - { - /* XXX - Ugly cast for a parameter that isn't used? :< - Om */ + /* XXX - Ugly cast for a parameter that isn't used? :< - Om */ + if (NoisyOverride) chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper-override to bypass invite-only", cname, user->nick); - } + ServerInstance->SNO->WriteToSnoMask('O',std::string(user->nick)+" used operoverride to bypass +i on "+std::string(cname)); } - ServerInstance->SNO->WriteToSnoMask('O',std::string(user->nick)+" used operoverride to bypass +i on "+std::string(cname)); return -1; } - if ((chan->key[0]) && (CanOverride(user,"KEY"))) + if ((*chan->key) && (CanOverride(user,"KEY"))) { if (NoisyOverride) chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper-override to bypass the channel key", cname, user->nick); @@ -282,10 +266,8 @@ class ModuleOverride : public Module if (chan->IsBanned(user)) { if (NoisyOverride) - { chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper-override to bypass channel ban", cname, user->nick); - ServerInstance->SNO->WriteToSnoMask('O',"%s used oper-override to bypass channel ban", cname, user->nick); - } + ServerInstance->SNO->WriteToSnoMask('O',"%s used oper-override to bypass channel ban on %s", user->nick, cname); } return -1; } @@ -301,31 +283,8 @@ class ModuleOverride : public Module virtual Version GetVersion() { - return Version(1,0,0,1,VF_VENDOR); + return Version(1,1,0,1,VF_VENDOR,API_VERSION); } }; - -class ModuleOverrideFactory : public ModuleFactory -{ - public: - ModuleOverrideFactory() - { - } - - ~ModuleOverrideFactory() - { - } - - virtual Module * CreateModule(InspIRCd* Me) - { - return new ModuleOverride(Me); - } - -}; - - -extern "C" void * init_module( void ) -{ - return new ModuleOverrideFactory; -} +MODULE_INIT(ModuleOverride)