summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-03-07 17:41:20 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-03-07 17:41:20 +0100
commit07f817fd47e2c5f7ca97ab73cef32307d84a6e79 (patch)
treee8f52a4e3028fff069bb7714d24d6761f291ce41
parent9b5a2903faf5cfa9474d53f30da054f9c4a1eb8e (diff)
Read the die and restart password and their hash type on demand
-rw-r--r--include/configreader.h12
-rw-r--r--src/configreader.cpp3
-rw-r--r--src/coremods/core_oper/cmd_die.cpp2
-rw-r--r--src/coremods/core_oper/cmd_restart.cpp2
-rw-r--r--src/coremods/core_oper/core_oper.cpp12
-rw-r--r--src/coremods/core_oper/core_oper.h11
6 files changed, 25 insertions, 17 deletions
diff --git a/include/configreader.h b/include/configreader.h
index e10f361d7..7f9e4a52d 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -312,18 +312,6 @@ class CoreExport ServerConfig
*/
std::string AdminNick;
- /** The admin-configured /DIE password
- */
- std::string diepass;
-
- /** The admin-configured /RESTART password
- */
- std::string restartpass;
-
- /** The hash method for *BOTH* the die and restart passwords.
- */
- std::string powerhash;
-
/** The quit prefix in use, or an empty string
*/
std::string PrefixQuit;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 12670b446..f80764048 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -366,9 +366,6 @@ void ServerConfig::Fill()
if (!nsid.empty() && nsid != sid)
throw CoreException("You must restart to change the server id");
}
- diepass = ConfValue("power")->getString("diepass");
- restartpass = ConfValue("power")->getString("restartpass");
- powerhash = ConfValue("power")->getString("hash");
PrefixQuit = options->getString("prefixquit");
SuffixQuit = options->getString("suffixquit");
FixedQuit = options->getString("fixedquit");
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