]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_oper/cmd_restart.cpp
Merge tag 'v2.0.27' into master.
[user/henk/code/inspircd.git] / src / coremods / core_oper / cmd_restart.cpp
index 33627b5405049411f5e44b9262de0b1b48316282..936348f951df3da916871602f180286b0347e874 100644 (file)
 
 
 #include "inspircd.h"
+#include "core_oper.h"
 
-/** Handle /RESTART
- */
-class CommandRestart : public Command
+CommandRestart::CommandRestart(Module* parent)
+       : Command(parent, "RESTART", 1, 1)
 {
- public:
-       /** Constructor for restart.
-        */
-       CommandRestart(Module* parent) : Command(parent,"RESTART",1,1) { flags_needed = 'o'; syntax = "<password>"; }
-       /** Handle command.
-        * @param parameters The parameters to the command
-        * @param user The user issuing the command
-        * @return A value from CmdResult to indicate command success or failure.
-        */
-       CmdResult Handle(const std::vector<std::string>& parameters, User *user);
-};
+       flags_needed = 'o';
+       syntax = "<server>";
+}
 
-CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, User *user)
+CmdResult CommandRestart::Handle(User* user, const Params& parameters)
 {
-       ServerInstance->Logs->Log("COMMAND", LOG_DEFAULT, "Restart: %s",user->nick.c_str());
-       if (ServerInstance->PassCompare(user, ServerInstance->Config->restartpass, parameters[0], ServerInstance->Config->powerhash))
+       ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Restart: %s", user->nick.c_str());
+       if (DieRestart::CheckPass(user, parameters[0], "restartpass"))
        {
                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.
+               /* XXX: This hack sets FD_CLOEXEC on all possible file descriptors, so they're closed if the execvp() below succeeds.
                 * Certainly, this is not a nice way to do things and it's slow when the fd limit is high.
                 *
                 * A better solution would be to set the close-on-exec flag for each fd we create (or create them with O_CLOEXEC),
@@ -60,7 +52,7 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us
                }
 #endif
 
-               execv(ServerInstance->Config->cmdline.argv[0], ServerInstance->Config->cmdline.argv);
+               execvp(ServerInstance->Config->cmdline.argv[0], ServerInstance->Config->cmdline.argv);
                ServerInstance->SNO->WriteGlobalSno('a', "Failed RESTART - could not execute '%s' (%s)",
                        ServerInstance->Config->cmdline.argv[0], strerror(errno));
        }
@@ -70,6 +62,3 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us
        }
        return CMD_FAILURE;
 }
-
-
-COMMAND_INIT(CommandRestart)