2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2018 linuxdaemon <linuxdaemon.irc@gmail.com>
5 * Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2012, 2014-2016, 2018 Attila Molnar <attilamolnar@hush.com>
8 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
9 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10 * Copyright (C) 2008, 2010 Craig Edwards <brain@inspircd.org>
11 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
12 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
14 * This file is part of InspIRCd. InspIRCd is free software: you can
15 * redistribute it and/or modify it under the terms of the GNU General Public
16 * License as published by the Free Software Foundation, version 2.
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 #include "exitcodes.h"
30 #include "core_oper.h"
32 CommandDie::CommandDie(Module* parent, std::string& hashref)
33 : Command(parent, "DIE", 1, 1)
37 syntax = "<servername>";
40 void DieRestart::SendError(const std::string& message)
42 ClientProtocol::Messages::Error errormsg(message);
43 ClientProtocol::Event errorevent(ServerInstance->GetRFCEvents().error, errormsg);
44 const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
45 for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
48 if (user->registered == REG_ALL)
50 user->WriteNotice(message);
54 // Unregistered connections receive ERROR, not a NOTICE
55 user->Send(errorevent);
62 CmdResult CommandDie::Handle(User* user, const Params& parameters)
64 if (ServerInstance->PassCompare(user, password, parameters[0], hash))
67 std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating.";
68 ServerInstance->Logs->Log(MODNAME, LOG_SPARSE, diebuf);
69 DieRestart::SendError(diebuf);
72 ServerInstance->Exit(EXIT_STATUS_DIE);
76 ServerInstance->Logs->Log(MODNAME, LOG_SPARSE, "Failed /DIE command from %s", user->GetFullRealHost().c_str());
77 ServerInstance->SNO->WriteGlobalSno('a', "Failed DIE command from %s.", user->GetFullRealHost().c_str());