Debian Codegraph @

modules/operserv/jupe.c

raw
1 /*
2 * Copyright (c) 2005-2006 William Pitcock, et al.
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * Jupiters a server.
6 *
7 */
8
9 #include "atheme.h"
10
11 DECLARE_MODULE_V1
12 (
13 "operserv/jupe", false, _modinit, _moddeinit,
14 PACKAGE_STRING,
15 VENDOR_STRING
16 );
17
18 static void os_cmd_jupe(sourceinfo_t *si, int parc, char *parv[]);
19
20 command_t os_jupe = { "JUPE", N_("Jupiters a server."), PRIV_JUPE, 2, os_cmd_jupe, { .path = "oservice/jupe" } };
21
22 void _modinit(module_t *m)
23 {
24 service_named_bind_command("operserv", &os_jupe);
25 }
26
27 void _moddeinit(module_unload_intent_t intent)
28 {
29 service_named_unbind_command("operserv", &os_jupe);
30 }
31
32 static void os_cmd_jupe(sourceinfo_t *si, int parc, char *parv[])
33 {
34 char *server = parv[0];
35 char *reason = parv[1];
36 char reasonbuf[BUFSIZE];
37
38 if (!server || !reason)
39 {
40 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "JUPE");
41 command_fail(si, fault_needmoreparams, _("Usage: JUPE <server> <reason>"));
42 return;
43 }
44
45 /* Disallow * in a jupe as a minimal sanity check; it makes it hard to
46 * squit safely. */
47 if (!strchr(server, '.') || strchr(server, '*') || strchr(server, '?'))
48 {
49 command_fail(si, fault_badparams, _("\2%s\2 is not a valid server name."), server);
50 return;
51 }
52
53 if (!irccasecmp(server, me.name))
54 {
55 command_fail(si, fault_noprivs, _("\2%s\2 is the services server; it cannot be jupitered!"), server);
56 return;
57 }
58
59 if (!irccasecmp(server, me.actual))
60 {
61 command_fail(si, fault_noprivs, _("\2%s\2 is the current uplink; it cannot be jupitered!"), server);
62 return;
63 }
64
65 logcommand(si, CMDLOG_ADMIN, "JUPE: \2%s\2 (reason: \2%s\2)", server, reason);
66 wallops(_("%s jupitered server \2%s\2 (%s)."), get_oper_name(si),
67 server, reason);
68
69 snprintf(reasonbuf, BUFSIZE, "[%s] %s", get_oper_name(si), reason);
70 jupe(server, reasonbuf);
71
72 command_success_nodata(si, _("\2%s\2 has been jupitered."), server);
73 }
74
75 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
76 * vim:ts=8
77 * vim:sw=8
78 * vim:noexpandtab
79 */