1 /* {{{ irc-seven: Cows like it.
3 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
4 * Copyright (C) 1996-2002 Hybrid Development Team
5 * Copyright (C) 2002-2005 ircd-ratbox development team
6 * Copyright (c) 2006 Elfyn McBratney.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to:
21 * Free Software Foundation, Inc.
22 * 51 Franklin St - Fifth Floor
23 * Boston, MA 02110-1301
33 #include "irc_string.h"
38 #include "s_newconf.h"
47 static int mo_die (struct Client
*, struct Client
*, int, const char **);
48 static int me_die (struct Client
*, struct Client
*, int, const char **);
50 static int do_die (struct Client
*, const char *, uint8_t);
52 /* {{{ static struct Message die_msgtab = { ... } */
53 static struct Message die_msgtab
=
55 "DIE", 0, 0, 0, MFLG_SLOW
,
57 mg_unreg
, mg_not_oper
, mg_ignore
,
58 mg_ignore
, {me_die
, 0}, {mo_die
, 0},
63 mapi_clist_av1 die_clist
[] =
69 /* {{{ DECLARE_MODULE_AV1(...) */
84 * DIE message handler.
93 mo_die (struct Client
*client_p
, struct Client
*source_p
, int parc
, const char **parv
)
97 if (!IsOperDie(source_p
))
99 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
100 source_p
->name
, "die");
103 else if (parc
< 2 || EmptyString(parv
[1]))
105 sendto_one(source_p
, form_str(ERR_NEEDMOREPARAMS
), me
.name
,
106 source_p
->name
, "DIE");
109 else if (strchr(parv
[1], '?') || strchr(parv
[1], '*'))
112 ":%s NOTICE %s :Argument to DIE cannot contain wildcards",
113 me
.name
, source_p
->name
);
116 else if (!find_server(source_p
, parv
[1]))
118 sendto_one_numeric(source_p
, ERR_NOSUCHSERVER
,
119 form_str(ERR_NOSUCHSERVER
), parv
[1]);
123 is_me
= irccmp(parv
[1], me
.name
) == 0 ? 1 : 0;
124 if (!is_me
&& !ConfigFileEntry
.remote_die
)
127 ":%s NOTICE %s :Argument to DIE must local server name (%s)",
128 me
.name
, source_p
->name
, me
.name
);
132 return do_die(source_p
, parv
[1], !is_me
);
138 * DIE ENCAP message handler.
143 me_die (struct Client
*client_p
, struct Client
*source_p
, int parc
, const char **parv
)
145 if (!IsPerson(source_p
) || !ConfigFileEntry
.remote_die
)
147 if (!find_client_shared_conf(source_p
, SHARED_DIE
))
150 return do_die(source_p
, NULL
, 0);
156 * Restart local server or request that a remote server restart.
159 do_die (struct Client
*source_p
, const char *target
, uint8_t remote
)
161 dlink_node
*cur
= NULL
;
162 struct Client
*target_p
= NULL
;
166 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
167 "%s is requesting shutdown of %s",
168 get_oper_name(source_p
), target
);
169 sendto_match_servs(source_p
, target
, CAP_ENCAP
, NOCAPS
,
170 "ENCAP %s DIE", target
);
175 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
, "%s is shutting down %s...",
176 get_oper_name(source_p
), me
.name
);
178 DLINK_FOREACH (cur
, lclient_list
.head
)
180 target_p
= cur
->data
;
182 ":%s NOTICE %s :Server Terminating.",
183 me
.name
, target_p
->name
);
186 DLINK_FOREACH (cur
, serv_list
.head
)
188 target_p
= cur
->data
;
189 sendto_one(target_p
, ":%s ERROR :Terminated by %s",
190 me
.name
, get_client_name(source_p
, HIDE_IP
));
193 ilog(L_MAIN
, "Server terminated by %s", get_oper_name(source_p
));
203 * vim: ts=8 sw=8 noet fdm=marker tw=80