diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-03-07 17:41:20 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-03-07 17:41:20 +0100 |
commit | 07f817fd47e2c5f7ca97ab73cef32307d84a6e79 (patch) | |
tree | e8f52a4e3028fff069bb7714d24d6761f291ce41 /src/coremods | |
parent | 9b5a2903faf5cfa9474d53f30da054f9c4a1eb8e (diff) |
Read the die and restart password and their hash type on demand
Diffstat (limited to 'src/coremods')
-rw-r--r-- | src/coremods/core_oper/cmd_die.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_oper/cmd_restart.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_oper/core_oper.cpp | 12 | ||||
-rw-r--r-- | src/coremods/core_oper/core_oper.h | 11 |
4 files changed, 25 insertions, 2 deletions
diff --git a/src/coremods/core_oper/cmd_die.cpp b/src/coremods/core_oper/cmd_die.cpp index 16603d73e..5a9415915 100644 --- a/src/coremods/core_oper/cmd_die.cpp +++ b/src/coremods/core_oper/cmd_die.cpp @@ -33,7 +33,7 @@ CommandDie::CommandDie(Module* parent) */ CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User *user) { - if (ServerInstance->PassCompare(user, ServerInstance->Config->diepass, parameters[0], ServerInstance->Config->powerhash)) + if (DieRestart::CheckPass(user, parameters[0], "diepass")) { { std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating."; diff --git a/src/coremods/core_oper/cmd_restart.cpp b/src/coremods/core_oper/cmd_restart.cpp index 39fbd8140..4fad752a2 100644 --- a/src/coremods/core_oper/cmd_restart.cpp +++ b/src/coremods/core_oper/cmd_restart.cpp @@ -31,7 +31,7 @@ CommandRestart::CommandRestart(Module* parent) CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, User *user) { ServerInstance->Logs->Log("COMMAND", LOG_DEFAULT, "Restart: %s",user->nick.c_str()); - if (ServerInstance->PassCompare(user, ServerInstance->Config->restartpass, parameters[0], ServerInstance->Config->powerhash)) + if (DieRestart::CheckPass(user, parameters[0], "restartpass")) { ServerInstance->SNO->WriteGlobalSno('a', "RESTART command from %s, restarting server.", user->GetFullRealHost().c_str()); diff --git a/src/coremods/core_oper/core_oper.cpp b/src/coremods/core_oper/core_oper.cpp index f94681138..0fc82df8f 100644 --- a/src/coremods/core_oper/core_oper.cpp +++ b/src/coremods/core_oper/core_oper.cpp @@ -20,6 +20,18 @@ #include "inspircd.h" #include "core_oper.h" +namespace DieRestart +{ + bool CheckPass(User* user, const std::string& inputpass, const char* confentry) + { + ConfigTag* tag = ServerInstance->Config->ConfValue("power"); + // The hash method for *BOTH* the die and restart passwords + const std::string hash = tag->getString("hash"); + const std::string correctpass = tag->getString(confentry); + return ServerInstance->PassCompare(user, correctpass, inputpass, hash); + } +} + class CoreModOper : public Module { CommandDie cmddie; diff --git a/src/coremods/core_oper/core_oper.h b/src/coremods/core_oper/core_oper.h index 2e2a152a0..3b3dfd4b2 100644 --- a/src/coremods/core_oper/core_oper.h +++ b/src/coremods/core_oper/core_oper.h @@ -21,6 +21,17 @@ #include "inspircd.h" +namespace DieRestart +{ + /** Checks a die or restart password + * @param user The user executing /DIE or /RESTART + * @param inputpass The password given by the user + * @param confkey The name of the key in the power tag containing the correct password + * @return True if the given password was correct, false if it was not + */ + bool CheckPass(User* user, const std::string& inputpass, const char* confkey); +} + /** Handle /DIE. */ class CommandDie : public Command |