1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2014 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
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(AdminInfo.name)) |
55 |
sendto_one_numeric(source_p, &me, RPL_ADMINLOC1, AdminInfo.name); |
56 |
if (!EmptyString(AdminInfo.description)) |
57 |
sendto_one_numeric(source_p, &me, RPL_ADMINLOC2, AdminInfo.description); |
58 |
if (!EmptyString(AdminInfo.email)) |
59 |
sendto_one_numeric(source_p, &me, RPL_ADMINEMAIL, AdminInfo.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 + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
79 |
{ |
80 |
sendto_one_numeric(source_p, &me, RPL_LOAD2HI); |
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, |
88 |
parc, parv) != HUNTED_ISME) |
89 |
return 0; |
90 |
|
91 |
do_admin(source_p); |
92 |
return 0; |
93 |
} |
94 |
|
95 |
/*! \brief ADMIN command handler |
96 |
* |
97 |
* \param source_p Pointer to allocated Client struct from which the message |
98 |
* originally comes from. This can be a local or remote client. |
99 |
* \param parc Integer holding the number of supplied arguments. |
100 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
101 |
* pointers. |
102 |
* \note Valid arguments for this command are: |
103 |
* - parv[0] = command |
104 |
* - parv[1] = nickname/servername |
105 |
*/ |
106 |
static int |
107 |
ms_admin(struct Client *source_p, int parc, char *parv[]) |
108 |
{ |
109 |
if (hunt_server(source_p, ":%s ADMIN :%s", 1, |
110 |
parc, parv) != HUNTED_ISME) |
111 |
return 0; |
112 |
|
113 |
do_admin(source_p); |
114 |
return 0; |
115 |
} |
116 |
|
117 |
static struct Message admin_msgtab = |
118 |
{ |
119 |
"ADMIN", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
120 |
{ m_unregistered, m_admin, ms_admin, m_ignore, ms_admin, m_ignore } |
121 |
}; |
122 |
|
123 |
static void |
124 |
module_init(void) |
125 |
{ |
126 |
mod_add_cmd(&admin_msgtab); |
127 |
} |
128 |
|
129 |
static void |
130 |
module_exit(void) |
131 |
{ |
132 |
mod_del_cmd(&admin_msgtab); |
133 |
} |
134 |
|
135 |
struct module module_entry = |
136 |
{ |
137 |
.node = { NULL, NULL, NULL }, |
138 |
.name = NULL, |
139 |
.version = "$Revision$", |
140 |
.handle = NULL, |
141 |
.modinit = module_init, |
142 |
.modexit = module_exit, |
143 |
.flags = 0 |
144 |
}; |