1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2020 ircd-hybrid development team |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file m_admin.c |
23 |
* \brief Includes required functions for processing the ADMIN command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "client.h" |
29 |
#include "irc_string.h" |
30 |
#include "ircd.h" |
31 |
#include "numeric.h" |
32 |
#include "conf.h" |
33 |
#include "server.h" |
34 |
#include "send.h" |
35 |
#include "parse.h" |
36 |
#include "modules.h" |
37 |
|
38 |
|
39 |
/*! \brief Sends administrative information about this server. |
40 |
* |
41 |
* \param source_p Pointer to client to report to |
42 |
*/ |
43 |
static void |
44 |
do_admin(struct Client *source_p) |
45 |
{ |
46 |
sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE, |
47 |
"ADMIN requested by %s (%s@%s) [%s]", |
48 |
source_p->name, source_p->username, |
49 |
source_p->host, source_p->servptr->name); |
50 |
|
51 |
sendto_one_numeric(source_p, &me, RPL_ADMINME, me.name); |
52 |
|
53 |
if (!EmptyString(ConfigAdminInfo.name)) |
54 |
sendto_one_numeric(source_p, &me, RPL_ADMINLOC1, ConfigAdminInfo.name); |
55 |
if (!EmptyString(ConfigAdminInfo.description)) |
56 |
sendto_one_numeric(source_p, &me, RPL_ADMINLOC2, ConfigAdminInfo.description); |
57 |
if (!EmptyString(ConfigAdminInfo.email)) |
58 |
sendto_one_numeric(source_p, &me, RPL_ADMINEMAIL, ConfigAdminInfo.email); |
59 |
} |
60 |
|
61 |
/*! \brief ADMIN command handler |
62 |
* |
63 |
* \param source_p Pointer to allocated Client struct from which the message |
64 |
* originally comes from. This can be a local or remote client. |
65 |
* \param parc Integer holding the number of supplied arguments. |
66 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
67 |
* pointers. |
68 |
* \note Valid arguments for this command are: |
69 |
* - parv[0] = command |
70 |
* - parv[1] = nickname/servername |
71 |
*/ |
72 |
static void |
73 |
m_admin(struct Client *source_p, int parc, char *parv[]) |
74 |
{ |
75 |
static uintmax_t last_used = 0; |
76 |
|
77 |
if ((last_used + ConfigGeneral.pace_wait_simple) > event_base->time.sec_monotonic) |
78 |
{ |
79 |
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "ADMIN"); |
80 |
return; |
81 |
} |
82 |
|
83 |
last_used = event_base->time.sec_monotonic; |
84 |
|
85 |
if (ConfigServerHide.disable_remote_commands == 0) |
86 |
if (server_hunt(source_p, ":%s ADMIN :%s", 1, parv)->ret != HUNTED_ISME) |
87 |
return; |
88 |
|
89 |
do_admin(source_p); |
90 |
} |
91 |
|
92 |
/*! \brief ADMIN command handler |
93 |
* |
94 |
* \param source_p Pointer to allocated Client struct from which the message |
95 |
* originally comes from. This can be a local or remote client. |
96 |
* \param parc Integer holding the number of supplied arguments. |
97 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
98 |
* pointers. |
99 |
* \note Valid arguments for this command are: |
100 |
* - parv[0] = command |
101 |
* - parv[1] = nickname/servername |
102 |
*/ |
103 |
static void |
104 |
ms_admin(struct Client *source_p, int parc, char *parv[]) |
105 |
{ |
106 |
if (server_hunt(source_p, ":%s ADMIN :%s", 1, parv)->ret != HUNTED_ISME) |
107 |
return; |
108 |
|
109 |
do_admin(source_p); |
110 |
} |
111 |
|
112 |
static struct Message admin_msgtab = |
113 |
{ |
114 |
.cmd = "ADMIN", |
115 |
.handlers[UNREGISTERED_HANDLER] = { .handler = m_unregistered }, |
116 |
.handlers[CLIENT_HANDLER] = { .handler = m_admin }, |
117 |
.handlers[SERVER_HANDLER] = { .handler = ms_admin }, |
118 |
.handlers[ENCAP_HANDLER] = { .handler = m_ignore }, |
119 |
.handlers[OPER_HANDLER] = { .handler = ms_admin } |
120 |
}; |
121 |
|
122 |
static void |
123 |
module_init(void) |
124 |
{ |
125 |
mod_add_cmd(&admin_msgtab); |
126 |
} |
127 |
|
128 |
static void |
129 |
module_exit(void) |
130 |
{ |
131 |
mod_del_cmd(&admin_msgtab); |
132 |
} |
133 |
|
134 |
struct module module_entry = |
135 |
{ |
136 |
.version = "$Revision$", |
137 |
.modinit = module_init, |
138 |
.modexit = module_exit, |
139 |
}; |