diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-01-22 15:02:37 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-01-22 15:02:37 +0000 |
commit | 6a88b90b036f3cfc21d45eb76d1ae3e767b8ac5c (patch) | |
tree | 8f1a4e27b8491e69163b32e6688e8e7e7efee362 /src/modules | |
parent | c68d2cb200c01b95017cf88d8b4f0fb96d5e97b8 (diff) |
Fix bug #659, #524 and others: Allow operoverride to set +qa. Based on patch by Phoenix. Note that this is currently untested, feedback is very welcome.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10979 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_chanprotect.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_override.cpp | 20 | ||||
-rwxr-xr-x | src/modules/m_override.h | 13 |
3 files changed, 55 insertions, 4 deletions
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index cbb59948d..892c18bd1 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -12,6 +12,7 @@ */ #include "inspircd.h" +#include "m_override.h" /* $ModDesc: Provides channel modes +a and +q */ @@ -193,13 +194,23 @@ class ChanFounder : public ModeHandler, public FounderProtectBase { return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); } + + char isoverride=0; + Module *Override = ServerInstance->Modules->FindFeature("Override"); + if (Override) + { + OVRrequest ovr(NULL,Override,source,"OTHERMODE"); + const char * tmp = ovr.Send(); + isoverride = tmp[0]; + } // source is a server, or ulined, we'll let them +-q the user. if (source == ServerInstance->FakeClient || ((source == theuser) && (!adding) && (FounderProtectBase::remove_own_privs)) || (ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server) || - (!IS_LOCAL(source))) + (!IS_LOCAL(source)) || + isoverride) { return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); } @@ -259,6 +270,15 @@ class ChanProtect : public ModeHandler, public FounderProtectBase { return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); } + + char isoverride=0; + Module *Override = ServerInstance->Modules->FindFeature("Override"); + if (Override) + { + OVRrequest ovr(NULL,Override,source,"OTHERMODE"); + const char * tmp = ovr.Send(); + isoverride = tmp[0]; + } // source has +q, is a server, or ulined, we'll let them +-a the user. if (source == ServerInstance->FakeClient || ((source == theuser) && (!adding) && (FounderProtectBase::remove_own_privs)) || @@ -266,7 +286,9 @@ class ChanProtect : public ModeHandler, public FounderProtectBase (ServerInstance->ULine(source->server)) || (!*source->server) || (source->GetExt(founder)) || - (!IS_LOCAL(source))) + (!IS_LOCAL(source)) || + isoverride + ) { return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); } diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 083d220f7..c5f1cc11c 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -12,6 +12,7 @@ */ #include "inspircd.h" +#include "m_override.h" /* $ModDesc: Provides support for unreal-style oper-override */ @@ -34,9 +35,13 @@ class ModuleOverride : public Module OnRehash(NULL,""); ServerInstance->SNO->EnableSnomask('G', "GODMODE"); OverriddenMode = false; + if (!ServerInstance->Modules->PublishFeature("Override", this)) + { + throw ModuleException("m_override: Unable to publish feature 'Override'"); + } OverOps = OverDeops = OverVoices = OverDevoices = OverHalfops = OverDehalfops = 0; - Implementation eventlist[] = { I_OnRehash, I_OnAccessCheck, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPostCommand, I_OnLocalTopicChange }; - ServerInstance->Modules->Attach(eventlist, this, 7); + Implementation eventlist[] = { I_OnRehash, I_OnAccessCheck, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPostCommand, I_OnLocalTopicChange, I_OnRequest }; + ServerInstance->Modules->Attach(eventlist, this, 8); } virtual void OnRehash(User* user, const std::string ¶meter) @@ -313,8 +318,19 @@ class ModuleOverride : public Module return 0; } + virtual const char* OnRequest(Request* request) + { + if(strcmp(OVRREQID, request->GetId()) == 0) + { + OVRrequest* req = static_cast<OVRrequest*>(request); + return this->CanOverride(req->requser,req->reqtoken.c_str()) ? "yes":""; + } + return NULL; + } + virtual ~ModuleOverride() { + ServerInstance->Modules->UnpublishFeature("Override"); ServerInstance->SNO->DisableSnomask('G'); } diff --git a/src/modules/m_override.h b/src/modules/m_override.h new file mode 100755 index 000000000..f17e78e76 --- /dev/null +++ b/src/modules/m_override.h @@ -0,0 +1,13 @@ +#include "modules.h" +#define OVRREQID "Override Request" +class OVRrequest : public Request +{ +public: +User * requser; +std::string reqtoken; +OVRrequest(Module* s, Module* d, User* src, const std::string &token) + : Request(s, d, OVRREQID), reqtoken(token) + { + requser = src; + } +}; |