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