1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* |
4 |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
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 "handlers.h" |
29 |
#include "client.h" |
30 |
#include "ircd.h" |
31 |
#include "numeric.h" |
32 |
#include "s_conf.h" |
33 |
#include "s_serv.h" |
34 |
#include "send.h" |
35 |
#include "msg.h" |
36 |
#include "parse.h" |
37 |
#include "modules.h" |
38 |
#include "irc_string.h" |
39 |
|
40 |
|
41 |
|
42 |
/*! \brief Sends administrative information about this server. |
43 |
* |
44 |
* \param source_p Pointer to client to report to |
45 |
*/ |
46 |
static void |
47 |
do_admin(struct Client *source_p) |
48 |
{ |
49 |
const char *me_name; |
50 |
const char *nick; |
51 |
|
52 |
sendto_realops_flags(UMODE_SPY, L_ALL, |
53 |
"ADMIN requested by %s (%s@%s) [%s]", |
54 |
source_p->name, source_p->username, |
55 |
source_p->host, source_p->servptr->name); |
56 |
|
57 |
me_name = ID_or_name(&me, source_p->from); |
58 |
nick = ID_or_name(source_p, source_p->from); |
59 |
|
60 |
sendto_one(source_p, form_str(RPL_ADMINME), |
61 |
me_name, nick, me.name); |
62 |
if (AdminInfo.name != NULL) |
63 |
sendto_one(source_p, form_str(RPL_ADMINLOC1), |
64 |
me_name, nick, AdminInfo.name); |
65 |
if (AdminInfo.description != NULL) |
66 |
sendto_one(source_p, form_str(RPL_ADMINLOC2), |
67 |
me_name, nick, AdminInfo.description); |
68 |
if (AdminInfo.email != NULL) |
69 |
sendto_one(source_p, form_str(RPL_ADMINEMAIL), |
70 |
me_name, nick, AdminInfo.email); |
71 |
} |
72 |
|
73 |
/*! \brief ADMIN command handler (called by unregistered, |
74 |
* locally connected clients) |
75 |
* |
76 |
* \param client_p Pointer to allocated Client struct with physical connection |
77 |
* to this server, i.e. with an open socket connected. |
78 |
* \param source_p Pointer to allocated Client struct from which the message |
79 |
* originally comes from. This can be a local or remote client. |
80 |
* \param parc Integer holding the number of supplied arguments. |
81 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
82 |
* pointers. |
83 |
* \note Valid arguments for this command are: |
84 |
* - parv[0] = sender prefix |
85 |
*/ |
86 |
static void |
87 |
mr_admin(struct Client *client_p, struct Client *source_p, |
88 |
int parc, char *parv[]) |
89 |
{ |
90 |
static time_t last_used = 0; |
91 |
|
92 |
ClearCap(client_p, CAP_TS6); |
93 |
|
94 |
if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
95 |
{ |
96 |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
97 |
me.name, EmptyString(parv[0]) ? "*" : parv[0]); |
98 |
return; |
99 |
} |
100 |
|
101 |
last_used = CurrentTime; |
102 |
|
103 |
do_admin(source_p); |
104 |
} |
105 |
|
106 |
/*! \brief NICK command handler (called by already registered, |
107 |
* locally connected clients) |
108 |
* |
109 |
* \param client_p Pointer to allocated Client struct with physical connection |
110 |
* to this server, i.e. with an open socket connected. |
111 |
* \param source_p Pointer to allocated Client struct from which the message |
112 |
* originally comes from. This can be a local or remote client. |
113 |
* \param parc Integer holding the number of supplied arguments. |
114 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
115 |
* pointers. |
116 |
* \note Valid arguments for this command are: |
117 |
* - parv[0] = sender prefix |
118 |
* - parv[1] = nickname/servername |
119 |
*/ |
120 |
static void |
121 |
m_admin(struct Client *client_p, struct Client *source_p, |
122 |
int parc, char *parv[]) |
123 |
{ |
124 |
static time_t last_used = 0; |
125 |
|
126 |
if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
127 |
{ |
128 |
sendto_one(source_p,form_str(RPL_LOAD2HI), |
129 |
me.name, source_p->name); |
130 |
return; |
131 |
} |
132 |
|
133 |
last_used = CurrentTime; |
134 |
|
135 |
if (!ConfigFileEntry.disable_remote) |
136 |
if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, |
137 |
parc, parv) != HUNTED_ISME) |
138 |
return; |
139 |
|
140 |
do_admin(source_p); |
141 |
} |
142 |
|
143 |
/*! \brief ADMIN command handler (called by operators and |
144 |
* remotely connected clients) |
145 |
* |
146 |
* \param client_p Pointer to allocated Client struct with physical connection |
147 |
* to this server, i.e. with an open socket connected. |
148 |
* \param source_p Pointer to allocated Client struct from which the message |
149 |
* originally comes from. This can be a local or remote client. |
150 |
* \param parc Integer holding the number of supplied arguments. |
151 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
152 |
* pointers. |
153 |
* \note Valid arguments for this command are: |
154 |
* - parv[0] = sender prefix |
155 |
* - parv[1] = nickname/servername |
156 |
*/ |
157 |
static void |
158 |
ms_admin(struct Client *client_p, struct Client *source_p, |
159 |
int parc, char *parv[]) |
160 |
{ |
161 |
if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, |
162 |
parc, parv) != HUNTED_ISME) |
163 |
return; |
164 |
|
165 |
if (IsClient(source_p)) |
166 |
do_admin(source_p); |
167 |
} |
168 |
|
169 |
static struct Message admin_msgtab = { |
170 |
"ADMIN", 0, 0, 0, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0, |
171 |
{mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore} |
172 |
}; |
173 |
|
174 |
static void |
175 |
module_init(void) |
176 |
{ |
177 |
mod_add_cmd(&admin_msgtab); |
178 |
} |
179 |
|
180 |
static void |
181 |
module_exit(void) |
182 |
{ |
183 |
mod_del_cmd(&admin_msgtab); |
184 |
} |
185 |
|
186 |
struct module module_entry = { |
187 |
.node = { NULL, NULL, NULL }, |
188 |
.name = NULL, |
189 |
.version = "$Revision$", |
190 |
.handle = NULL, |
191 |
.modinit = module_init, |
192 |
.modexit = module_exit, |
193 |
.flags = 0 |
194 |
}; |