]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_die.cpp
Removed a pointless check in ./configure --clean that made it only work with one...
[user/henk/code/inspircd.git] / src / cmd_die.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "configreader.h"
15 #include "users.h"
16 #include "commands/cmd_die.h"
17
18 extern "C" command_t* init_command(InspIRCd* Instance)
19 {
20         return new cmd_die(Instance);
21 }
22
23 /** Handle /DIE
24  */
25 CmdResult cmd_die::Handle (const char** parameters, int pcnt, userrec *user)
26 {
27         if (!strcmp(parameters[0],ServerInstance->Config->diepass))
28         {
29                 ServerInstance->Log(SPARSE, "/DIE command from %s!%s@%s, terminating in %d seconds...", user->nick, user->ident, user->host, ServerInstance->Config->DieDelay);
30                 
31                 /* This would just be WriteOpers(), but as we just sleep() and then die then the write buffers never get flushed.
32                  * so we iterate the oper list, writing the message and immediately trying to flush their write buffer.
33                  */
34                 
35                 for (std::vector<userrec*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
36                 {
37                         userrec* a = *i;
38                         
39                         if (IS_LOCAL(a) && (a->modes[UM_SERVERNOTICE]))
40                         {
41                                 a->WriteServ("NOTICE %s :*** DIE command from %s!%s@%s, terminating...", a->nick, a->nick, a->ident, a->host);
42                                 a->FlushWriteBuf();
43                         }
44                 }
45                 
46                 sleep(ServerInstance->Config->DieDelay);
47                 InspIRCd::Exit(ERROR);
48         }
49         else
50         {
51                 ServerInstance->Log(SPARSE, "Failed /DIE command from %s!%s@%s", user->nick, user->ident, user->host);
52                 ServerInstance->WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host);
53                 return CMD_FAILURE;
54         }
55         return CMD_SUCCESS;
56 }