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 |
/*! \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 int |
73 |
m_admin(struct Client *source_p, int parc, char *parv[]) |
74 |
{ |
75 |
static time_t last_used = 0; |
76 |
|
77 |
if ((last_used + ConfigGeneral.pace_wait_simple) > CurrentTime) |
78 |
{ |
79 |
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "ADMIN"); |
80 |
return 0; |
81 |
} |
82 |
|
83 |
last_used = CurrentTime; |
84 |
|
85 |
if (!ConfigServerHide.disable_remote_commands) |
86 |
if (hunt_server(source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME) |
87 |
return 0; |
88 |
|
89 |
do_admin(source_p); |
90 |
return 0; |
91 |
} |
92 |
|
93 |
/*! \brief ADMIN command handler |
94 |
* |
95 |
* \param source_p Pointer to allocated Client struct from which the message |
96 |
* originally comes from. This can be a local or remote client. |
97 |
* \param parc Integer holding the number of supplied arguments. |
98 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
99 |
* pointers. |
100 |
* \note Valid arguments for this command are: |
101 |
* - parv[0] = command |
102 |
* - parv[1] = nickname/servername |
103 |
*/ |
104 |
static int |
105 |
ms_admin(struct Client *source_p, int parc, char *parv[]) |
106 |
{ |
107 |
if (hunt_server(source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME) |
108 |
return 0; |
109 |
|
110 |
do_admin(source_p); |
111 |
return 0; |
112 |
} |
113 |
|
114 |
static struct Message admin_msgtab = |
115 |
{ |
116 |
.cmd = "ADMIN", |
117 |
.args_max = MAXPARA, |
118 |
.handlers[UNREGISTERED_HANDLER] = m_unregistered, |
119 |
.handlers[CLIENT_HANDLER] = m_admin, |
120 |
.handlers[SERVER_HANDLER] = ms_admin, |
121 |
.handlers[ENCAP_HANDLER] = m_ignore, |
122 |
.handlers[OPER_HANDLER] = ms_admin |
123 |
}; |
124 |
|
125 |
static void |
126 |
module_init(void) |
127 |
{ |
128 |
mod_add_cmd(&admin_msgtab); |
129 |
} |
130 |
|
131 |
static void |
132 |
module_exit(void) |
133 |
{ |
134 |
mod_del_cmd(&admin_msgtab); |
135 |
} |
136 |
|
137 |
struct module module_entry = |
138 |
{ |
139 |
.version = "$Revision$", |
140 |
.modinit = module_init, |
141 |
.modexit = module_exit, |
142 |
}; |