1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2015 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 |
|
40 |
/*! \brief Sends administrative information about this server. |
41 |
* |
42 |
* \param source_p Pointer to client to report to |
43 |
*/ |
44 |
static void |
45 |
do_admin(struct Client *source_p) |
46 |
{ |
47 |
sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE, |
48 |
"ADMIN requested by %s (%s@%s) [%s]", |
49 |
source_p->name, source_p->username, |
50 |
source_p->host, source_p->servptr->name); |
51 |
|
52 |
sendto_one_numeric(source_p, &me, RPL_ADMINME, me.name); |
53 |
|
54 |
if (!EmptyString(ConfigAdminInfo.name)) |
55 |
sendto_one_numeric(source_p, &me, RPL_ADMINLOC1, ConfigAdminInfo.name); |
56 |
if (!EmptyString(ConfigAdminInfo.description)) |
57 |
sendto_one_numeric(source_p, &me, RPL_ADMINLOC2, ConfigAdminInfo.description); |
58 |
if (!EmptyString(ConfigAdminInfo.email)) |
59 |
sendto_one_numeric(source_p, &me, RPL_ADMINEMAIL, ConfigAdminInfo.email); |
60 |
} |
61 |
|
62 |
/*! \brief ADMIN command handler |
63 |
* |
64 |
* \param source_p Pointer to allocated Client struct from which the message |
65 |
* originally comes from. This can be a local or remote client. |
66 |
* \param parc Integer holding the number of supplied arguments. |
67 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
68 |
* pointers. |
69 |
* \note Valid arguments for this command are: |
70 |
* - parv[0] = command |
71 |
* - parv[1] = nickname/servername |
72 |
*/ |
73 |
static int |
74 |
m_admin(struct Client *source_p, int parc, char *parv[]) |
75 |
{ |
76 |
static time_t last_used = 0; |
77 |
|
78 |
if ((last_used + ConfigGeneral.pace_wait_simple) > CurrentTime) |
79 |
{ |
80 |
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "ADMIN"); |
81 |
return 0; |
82 |
} |
83 |
|
84 |
last_used = CurrentTime; |
85 |
|
86 |
if (!ConfigServerHide.disable_remote_commands) |
87 |
if (hunt_server(source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME) |
88 |
return 0; |
89 |
|
90 |
do_admin(source_p); |
91 |
return 0; |
92 |
} |
93 |
|
94 |
/*! \brief ADMIN command handler |
95 |
* |
96 |
* \param source_p Pointer to allocated Client struct from which the message |
97 |
* originally comes from. This can be a local or remote client. |
98 |
* \param parc Integer holding the number of supplied arguments. |
99 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
100 |
* pointers. |
101 |
* \note Valid arguments for this command are: |
102 |
* - parv[0] = command |
103 |
* - parv[1] = nickname/servername |
104 |
*/ |
105 |
static int |
106 |
ms_admin(struct Client *source_p, int parc, char *parv[]) |
107 |
{ |
108 |
if (hunt_server(source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME) |
109 |
return 0; |
110 |
|
111 |
do_admin(source_p); |
112 |
return 0; |
113 |
} |
114 |
|
115 |
static struct Message admin_msgtab = |
116 |
{ |
117 |
.cmd = "ADMIN", |
118 |
.args_max = MAXPARA, |
119 |
.handlers[UNREGISTERED_HANDLER] = m_unregistered, |
120 |
.handlers[CLIENT_HANDLER] = m_admin, |
121 |
.handlers[SERVER_HANDLER] = ms_admin, |
122 |
.handlers[ENCAP_HANDLER] = m_ignore, |
123 |
.handlers[OPER_HANDLER] = ms_admin |
124 |
}; |
125 |
|
126 |
static void |
127 |
module_init(void) |
128 |
{ |
129 |
mod_add_cmd(&admin_msgtab); |
130 |
} |
131 |
|
132 |
static void |
133 |
module_exit(void) |
134 |
{ |
135 |
mod_del_cmd(&admin_msgtab); |
136 |
} |
137 |
|
138 |
struct module module_entry = |
139 |
{ |
140 |
.version = "$Revision$", |
141 |
.modinit = module_init, |
142 |
.modexit = module_exit, |
143 |
}; |