summaryrefslogtreecommitdiff
path: root/src/coremods
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-05-17 18:13:45 +0200
committerAttila Molnar <attilamolnar@hush.com>2015-05-17 18:13:45 +0200
commit33137bba446212f89f7b94f50ace20db19b6d009 (patch)
tree525dcd06178f675011ad49a2f68da5a48c9a4d8c /src/coremods
parentc715182bf86532d767c939a344bd4f304d25df09 (diff)
Move InspIRCd::SendError() to cmd_die
Fix multiple ERROR messages being sent to unregistered users by removing the "Exiting with status..." message
Diffstat (limited to 'src/coremods')
-rw-r--r--src/coremods/core_oper/cmd_die.cpp21
-rw-r--r--src/coremods/core_oper/cmd_restart.cpp2
-rw-r--r--src/coremods/core_oper/core_oper.h5
3 files changed, 26 insertions, 2 deletions
diff --git a/src/coremods/core_oper/cmd_die.cpp b/src/coremods/core_oper/cmd_die.cpp
index 5e7a6afcf..4bc6c25db 100644
--- a/src/coremods/core_oper/cmd_die.cpp
+++ b/src/coremods/core_oper/cmd_die.cpp
@@ -37,6 +37,25 @@ static void QuitAll()
ServerInstance->Users.QuitUser(list.front(), quitmsg);
}
+void DieRestart::SendError(const std::string& message)
+{
+ const std::string unregline = "ERROR :" + message;
+ const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+ for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
+ {
+ LocalUser* user = *i;
+ if (user->registered == REG_ALL)
+ {
+ user->WriteNotice(message);
+ }
+ else
+ {
+ // Unregistered connections receive ERROR, not a NOTICE
+ user->Write(unregline);
+ }
+ }
+}
+
/** Handle /DIE
*/
CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User *user)
@@ -46,7 +65,7 @@ CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User *
{
std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating.";
ServerInstance->Logs->Log("COMMAND", LOG_SPARSE, diebuf);
- ServerInstance->SendError(diebuf);
+ DieRestart::SendError(diebuf);
}
QuitAll();
diff --git a/src/coremods/core_oper/cmd_restart.cpp b/src/coremods/core_oper/cmd_restart.cpp
index 4fad752a2..3e219727f 100644
--- a/src/coremods/core_oper/cmd_restart.cpp
+++ b/src/coremods/core_oper/cmd_restart.cpp
@@ -35,7 +35,7 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us
{
ServerInstance->SNO->WriteGlobalSno('a', "RESTART command from %s, restarting server.", user->GetFullRealHost().c_str());
- ServerInstance->SendError("Server restarting.");
+ DieRestart::SendError("Server restarting.");
#ifndef _WIN32
/* XXX: This hack sets FD_CLOEXEC on all possible file descriptors, so they're closed if the execv() below succeeds.
diff --git a/src/coremods/core_oper/core_oper.h b/src/coremods/core_oper/core_oper.h
index 3b3dfd4b2..338a369f5 100644
--- a/src/coremods/core_oper/core_oper.h
+++ b/src/coremods/core_oper/core_oper.h
@@ -30,6 +30,11 @@ namespace DieRestart
* @return True if the given password was correct, false if it was not
*/
bool CheckPass(User* user, const std::string& inputpass, const char* confkey);
+
+ /** Send an ERROR to unregistered users and a NOTICE to all registered local users
+ * @param message Message to send
+ */
+ void SendError(const std::string& message);
}
/** Handle /DIE.