Debian Codegraph @

modules/operserv/inject.c

raw
1 /*
2 * Copyright (c) 2003-2004 E. Will et al.
3 * Copyright (c) 2005-2006 Atheme Development Group
4 * Rights to this code are documented in doc/LICENSE.
5 *
6 * This file contains functionality which implements the OService INJECT command.
7 *
8 */
9
10 #include "atheme.h"
11 #include "uplink.h"
12
13 DECLARE_MODULE_V1
14 (
15 "operserv/inject", false, _modinit, _moddeinit,
16 PACKAGE_STRING,
17 VENDOR_STRING
18 );
19
20 static void os_cmd_inject(sourceinfo_t *si, int parc, char *parv[]);
21
22 command_t os_inject = { "INJECT", N_("Fakes data from the uplink (debugging tool)."), PRIV_ADMIN, 1, os_cmd_inject, { .path = "oservice/inject" } };
23
24 void _modinit(module_t *m)
25 {
26 service_named_bind_command("operserv", &os_inject);
27 }
28
29 void _moddeinit(module_unload_intent_t intent)
30 {
31 service_named_unbind_command("operserv", &os_inject);
32 }
33
34 static void os_cmd_inject(sourceinfo_t *si, int parc, char *parv[])
35 {
36 char *inject;
37 static bool injecting = false;
38 inject = parv[0];
39
40 if (!config_options.raw)
41 return;
42
43 if (!inject)
44 {
45 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "INJECT");
46 command_fail(si, fault_needmoreparams, _("Syntax: INJECT <parameters>"));
47 return;
48 }
49
50 logcommand(si, CMDLOG_ADMIN, "INJECT: \2%s\2", inject);
51
52 /* looks like someone INJECT'd an INJECT command.
53 * this is probably a bad thing.
54 */
55 if (injecting)
56 {
57 command_fail(si, fault_noprivs, _("You cannot inject an INJECT command."));
58 return;
59 }
60
61 injecting = true;
62 parse(inject);
63 injecting = false;
64 }
65
66 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
67 * vim:ts=8
68 * vim:sw=8
69 * vim:noexpandtab
70 */