From b331d0549be435d77ceb52aee4a58ee4aa40ec7d Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sun, 7 Apr 2013 17:02:37 +0100 Subject: Add . When enabled (the default) this setting prevents the unloading of core modules such as cmd_privmsg. --- src/commands/cmd_unloadmodule.cpp | 9 ++++++++- src/modules/m_globalload.cpp | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/commands/cmd_unloadmodule.cpp b/src/commands/cmd_unloadmodule.cpp index 6d0f5f41c..29f454987 100644 --- a/src/commands/cmd_unloadmodule.cpp +++ b/src/commands/cmd_unloadmodule.cpp @@ -42,12 +42,19 @@ class CommandUnloadmodule : public Command CmdResult CommandUnloadmodule::Handle (const std::vector& parameters, User *user) { + if (!ServerInstance->Config->ConfValue("security")->getBool("allowcoreunload") && + InspIRCd::Match(parameters[0], "cmd_*.so", ascii_case_insensitive_map)) + { + user->WriteNumeric(972, "%s %s :You cannot unload core commands!", user->nick.c_str(), parameters[0].c_str()); + return CMD_FAILURE; + } + if (parameters[0] == "cmd_unloadmodule.so" || parameters[0] == "cmd_loadmodule.so") { user->WriteNumeric(972, "%s %s :You cannot unload module loading commands!", user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } - + Module* m = ServerInstance->Modules->Find(parameters[0]); if (m && ServerInstance->Modules->Unload(m)) { diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp index d623ed262..6c6dd769e 100644 --- a/src/modules/m_globalload.cpp +++ b/src/modules/m_globalload.cpp @@ -79,6 +79,13 @@ class CommandGunloadmodule : public Command CmdResult Handle (const std::vector ¶meters, User *user) { + if (!ServerInstance->Config->ConfValue("security")->getBool("allowcoreunload") && + InspIRCd::Match(parameters[0], "cmd_*.so", ascii_case_insensitive_map)) + { + user->WriteNumeric(972, "%s %s :You cannot unload core commands!", user->nick.c_str(), parameters[0].c_str()); + return CMD_FAILURE; + } + std::string servername = parameters.size() > 1 ? parameters[1] : "*"; if (InspIRCd::Match(ServerInstance->Config->ServerName.c_str(), servername)) -- cgit v1.2.3