summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h3
-rw-r--r--src/mode.cpp19
-rw-r--r--src/modules/m_samode.cpp41
3 files changed, 32 insertions, 31 deletions
diff --git a/include/modules.h b/include/modules.h
index 51cc37f3f..cb8ffdada 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -41,7 +41,8 @@ enum AccessControlType {
AC_HALFOP, // a user is being halfopped
AC_DEHALFOP, // a user is being dehalfopped
AC_INVITE, // a user is being invited
- AC_GENERAL_MODE // a channel mode is being changed
+ AC_GENERAL_MODE, // a channel mode is being changed
+ AC_GENERAL_UMODE // a user mode is being changed
};
/** Used to define a set of behavior bits for a module
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)