diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 00:51:33 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 00:51:33 +0000 |
commit | 54e89b822e36b36eb9b080bbb4befe097471cec2 (patch) | |
tree | 8150e55f05808b4fc1b6eb77caf8b11f9786f491 /src | |
parent | 0145d909d207e0117c0d10ee2195b53b4b823fb4 (diff) |
Change SAMODE to source from the acting user, not the server
This is a merge of the OOMODE command into SAMODE.
This fixes SAMODE not working because of mode merging.
An additional access check for umode changes is added for this command.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11647 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/mode.cpp | 19 | ||||
-rw-r--r-- | src/modules/m_samode.cpp | 41 |
2 files changed, 30 insertions, 30 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index 22b1e261f..47d59d85a 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -329,7 +329,7 @@ void ModeParser::DisplayCurrentModes(User *user, User* targetuser, Channel* targ } else { - user->WriteNumeric(ERR_USERSDONTMATCH, "%s :Can't change mode for other users", user->nick.c_str()); + user->WriteNumeric(ERR_USERSDONTMATCH, "%s :Can't view modes for other users", user->nick.c_str()); return; } } @@ -479,27 +479,26 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, { SkipAccessChecks = true; } - else if (targetchannel) + else { /* Overall access control hook for mode change */ + int hook = targetchannel ? AC_GENERAL_MODE : AC_GENERAL_UMODE; + LastParse = mode_sequence; ModResult MOD_RESULT; - FIRST_MOD_RESULT(ServerInstance, OnAccessCheck, MOD_RESULT, (user, NULL, targetchannel, AC_GENERAL_MODE)); + FIRST_MOD_RESULT(ServerInstance, OnAccessCheck, MOD_RESULT, (user, targetuser, targetchannel, hook)); LastParse.clear(); if (MOD_RESULT == MOD_RES_DENY) return; SkipAccessChecks = (MOD_RESULT == MOD_RES_ALLOW); } - else + + if (targetuser && !SkipAccessChecks && user != targetuser) { - if (user != targetuser) - { - user->WriteNumeric(ERR_USERSDONTMATCH, "%s :Can't change mode for other users", user->nick.c_str()); - return; - } + user->WriteNumeric(ERR_USERSDONTMATCH, "%s :Can't change mode for other users", user->nick.c_str()); + return; } - std::string output_mode; std::ostringstream output_parameters; LastParseParams.push_back(output_mode); diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp index ccd40a3e7..584199345 100644 --- a/src/modules/m_samode.cpp +++ b/src/modules/m_samode.cpp @@ -20,34 +20,21 @@ class CommandSamode : public Command { public: + bool active; CommandSamode (InspIRCd* Instance, Module* Creator) : Command(Instance, Creator,"SAMODE", "o", 2, false, 0) { syntax = "<target> <modes> {<mode-parameters>}"; + active = false; } CmdResult Handle (const std::vector<std::string>& parameters, User *user) { - /* - * Handles an SAMODE request. Notifies all +s users. - */ - ServerInstance->SendMode(parameters, ServerInstance->FakeClient); - + this->active = true; + ServerInstance->Parser->CallHandler("MODE", parameters, user); if (ServerInstance->Modes->GetLastParse().length()) - { - ServerInstance->SNO->WriteToSnoMask('a', std::string(user->nick) + " used SAMODE: " + ServerInstance->Modes->GetLastParse()); - ServerInstance->PI->SendSNONotice("A", user->nick + " used SAMODE: " + ServerInstance->Modes->GetLastParse()); - - std::string channel = parameters[0]; - ServerInstance->PI->SendMode(channel, ServerInstance->Modes->GetLastParseParams(), ServerInstance->Modes->GetLastParseTranslate()); - - return CMD_LOCALONLY; - } - else - { - user->WriteServ("NOTICE %s :*** Invalid SAMODE sequence.", user->nick.c_str()); - } - - return CMD_FAILURE; + ServerInstance->SNO->WriteGlobalSno('a', std::string(user->nick) + " used SAMODE: " +ServerInstance->Modes->GetLastParse()); + this->active = false; + return CMD_LOCALONLY; } }; @@ -59,6 +46,7 @@ class ModuleSaMode : public Module : Module(Me), cmd(Me, this) { ServerInstance->AddCommand(&cmd); + ServerInstance->Modules->Attach(I_OnAccessCheck, this); } virtual ~ModuleSaMode() @@ -69,6 +57,19 @@ class ModuleSaMode : public Module { return Version("$Id$", VF_VENDOR, API_VERSION); } + + virtual ModResult OnAccessCheck(User* source,User* dest,Channel* channel,int access_type) + { + if (cmd.active) + return MOD_RES_ALLOW; + return MOD_RES_PASSTHRU; + } + + void Prioritize() + { + Module *override = ServerInstance->Modules->Find("m_override.so"); + ServerInstance->Modules->SetPriority(this, I_OnAccessCheck, PRIORITY_BEFORE, &override); + } }; MODULE_INIT(ModuleSaMode) |