]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Move InspIRCd::SendError() to cmd_die
authorAttila Molnar <attilamolnar@hush.com>
Sun, 17 May 2015 16:13:45 +0000 (18:13 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Sun, 17 May 2015 16:13:45 +0000 (18:13 +0200)
Fix multiple ERROR messages being sent to unregistered users by removing the "Exiting with status..." message

include/inspircd.h
src/coremods/core_oper/cmd_die.cpp
src/coremods/core_oper/cmd_restart.cpp
src/coremods/core_oper/core_oper.h
src/helperfuncs.cpp
src/server.cpp

index b90c0c797d06f68fb07ec43e8198c4bafbde5bc2..d41d2919b5e70ccb8245ebfc303ee95a01c5ea05 100644 (file)
@@ -502,11 +502,6 @@ class CoreExport InspIRCd
        static const char* Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2);
        static const char* Format(va_list &vaList, const char* formatString) CUSTOM_PRINTF(2, 0);
 
-       /** Send an error notice to all local users, opered and unopered
-        * @param s The error string to send
-        */
-       void SendError(const std::string &s);
-
        /** Return true if a nickname is valid
         * @param n A nickname to verify
         * @return True if the nick is valid
index 5e7a6afcfed104f762e4acbdd03a8dbd1dd4829e..4bc6c25dba81221ca87bcbaac29f5baad8caa5f1 100644 (file)
@@ -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();
index 4fad752a221962f083d5d1dea5cff7c0fa589cf4..3e219727f9762070a8b41602c46e80610576957a 100644 (file)
@@ -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.
index 3b3dfd4b26f5adf425e8cd51c441f04049c8a2ea..338a369f518f3ba5cebd5964924ce81ec0ea16be 100644 (file)
@@ -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.
index 5cde46246f3acb7ca6b90995e316b424304540c4..d636e2d8958e20285291960e765ef8f55b836277 100644 (file)
@@ -79,25 +79,6 @@ Channel* InspIRCd::FindChan(const std::string &chan)
        return iter->second;
 }
 
-/* Send an error notice to all users, registered or not */
-void InspIRCd::SendError(const std::string &s)
-{
-       const UserManager::LocalList& list = Users.GetLocalUsers();
-       for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
-       {
-               User* u = *i;
-               if (u->registered == REG_ALL)
-               {
-                       u->WriteNotice(s);
-               }
-               else
-               {
-                       /* Unregistered connections receive ERROR, not a NOTICE */
-                       u->Write("ERROR :" + s);
-               }
-       }
-}
-
 bool InspIRCd::IsValidMask(const std::string &mask)
 {
        const char* dest = mask.c_str();
index 42dce137230ad892c743cb456d94c7a702aa132a..191a3d30ffd21812a8a0e596ac3399ddd34ea4df 100644 (file)
@@ -46,7 +46,6 @@ void InspIRCd::Exit(int status)
 #ifdef _WIN32
        SetServiceStopped(status);
 #endif
-       this->SendError("Exiting with status " + ConvToStr(status) + " (" + std::string(ExitCodes[status]) + ")");
        this->Cleanup();
        ServerInstance = NULL;
        delete this;