]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * m_admin.c: Sends administrative information to a user. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
212380e3 AC |
23 | */ |
24 | ||
25 | #include "stdinc.h" | |
26 | #include "client.h" | |
27 | #include "ircd.h" | |
28 | #include "numeric.h" | |
29 | #include "s_conf.h" | |
30 | #include "s_serv.h" | |
31 | #include "send.h" | |
32 | #include "msg.h" | |
33 | #include "parse.h" | |
34 | #include "hook.h" | |
35 | #include "modules.h" | |
36 | ||
eeabf33a EM |
37 | const char admin_desc[] = |
38 | "Provides the ADMIN command to show server administrator information"; | |
39 | ||
3c7d6fcc EM |
40 | static void m_admin(struct MsgBuf *, struct Client *, struct Client *, int, const char **); |
41 | static void mr_admin(struct MsgBuf *, struct Client *, struct Client *, int, const char **); | |
42 | static void ms_admin(struct MsgBuf *, struct Client *, struct Client *, int, const char **); | |
212380e3 AC |
43 | static void do_admin(struct Client *source_p); |
44 | ||
45 | static void admin_spy(struct Client *); | |
46 | ||
47 | struct Message admin_msgtab = { | |
7baa37a9 | 48 | "ADMIN", 0, 0, 0, 0, |
212380e3 AC |
49 | {{mr_admin, 0}, {m_admin, 0}, {ms_admin, 0}, mg_ignore, mg_ignore, {ms_admin, 0}} |
50 | }; | |
51 | ||
52 | int doing_admin_hook; | |
53 | ||
54 | mapi_clist_av1 admin_clist[] = { &admin_msgtab, NULL }; | |
55abcbb2 | 55 | mapi_hlist_av1 admin_hlist[] = { |
212380e3 AC |
56 | { "doing_admin", &doing_admin_hook }, |
57 | { NULL, NULL } | |
58 | }; | |
59 | ||
3c88406e | 60 | DECLARE_MODULE_AV2(admin, NULL, NULL, admin_clist, admin_hlist, NULL, NULL, NULL, admin_desc); |
212380e3 AC |
61 | |
62 | /* | |
63 | * mr_admin - ADMIN command handler | |
55abcbb2 | 64 | * parv[1] = servername |
212380e3 | 65 | */ |
3c7d6fcc | 66 | static void |
428ca87b | 67 | mr_admin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
68 | { |
69 | static time_t last_used = 0L; | |
70 | ||
e3354945 | 71 | if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) |
212380e3 | 72 | { |
55abcbb2 KB |
73 | sendto_one(source_p, form_str(RPL_LOAD2HI), |
74 | me.name, | |
75 | EmptyString(source_p->name) ? "*" : source_p->name, | |
212380e3 | 76 | "ADMIN"); |
3c7d6fcc | 77 | return; |
212380e3 AC |
78 | } |
79 | else | |
e3354945 | 80 | last_used = rb_current_time(); |
212380e3 AC |
81 | |
82 | do_admin(source_p); | |
212380e3 AC |
83 | } |
84 | ||
85 | /* | |
86 | * m_admin - ADMIN command handler | |
212380e3 AC |
87 | * parv[1] = servername |
88 | */ | |
3c7d6fcc | 89 | static void |
428ca87b | 90 | m_admin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
91 | { |
92 | static time_t last_used = 0L; | |
93 | ||
94 | if(parc > 1) | |
95 | { | |
e3354945 | 96 | if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) |
212380e3 AC |
97 | { |
98 | sendto_one(source_p, form_str(RPL_LOAD2HI), | |
99 | me.name, source_p->name, "ADMIN"); | |
3c7d6fcc | 100 | return; |
212380e3 AC |
101 | } |
102 | else | |
e3354945 | 103 | last_used = rb_current_time(); |
55abcbb2 | 104 | |
212380e3 | 105 | if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME) |
3c7d6fcc | 106 | return; |
212380e3 AC |
107 | } |
108 | ||
109 | do_admin(source_p); | |
212380e3 AC |
110 | } |
111 | ||
112 | ||
113 | /* | |
114 | * ms_admin - ADMIN command handler, used for OPERS as well | |
212380e3 AC |
115 | * parv[1] = servername |
116 | */ | |
3c7d6fcc | 117 | static void |
428ca87b | 118 | ms_admin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
119 | { |
120 | if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME) | |
3c7d6fcc | 121 | return; |
212380e3 AC |
122 | |
123 | do_admin(source_p); | |
212380e3 AC |
124 | } |
125 | ||
126 | ||
127 | /* | |
128 | * do_admin | |
129 | * | |
130 | * inputs - pointer to client to report to | |
131 | * output - none | |
132 | * side effects - admin info is sent to client given | |
133 | */ | |
134 | static void | |
135 | do_admin(struct Client *source_p) | |
136 | { | |
212380e3 AC |
137 | if(IsPerson(source_p)) |
138 | admin_spy(source_p); | |
139 | ||
88520303 | 140 | sendto_one_numeric(source_p, RPL_ADMINME, form_str(RPL_ADMINME), me.name); |
212380e3 | 141 | if(AdminInfo.name != NULL) |
88520303 | 142 | sendto_one_numeric(source_p, RPL_ADMINLOC1, form_str(RPL_ADMINLOC1), AdminInfo.name); |
212380e3 | 143 | if(AdminInfo.description != NULL) |
88520303 | 144 | sendto_one_numeric(source_p, RPL_ADMINLOC2, form_str(RPL_ADMINLOC2), AdminInfo.description); |
212380e3 | 145 | if(AdminInfo.email != NULL) |
88520303 | 146 | sendto_one_numeric(source_p, RPL_ADMINEMAIL, form_str(RPL_ADMINEMAIL), AdminInfo.email); |
212380e3 AC |
147 | } |
148 | ||
149 | /* admin_spy() | |
150 | * | |
151 | * input - pointer to client | |
152 | * output - none | |
153 | * side effects - event doing_admin is called | |
154 | */ | |
155 | static void | |
156 | admin_spy(struct Client *source_p) | |
157 | { | |
158 | hook_data hd; | |
159 | ||
160 | hd.client = source_p; | |
161 | hd.arg1 = hd.arg2 = NULL; | |
162 | ||
163 | call_hook(doing_admin_hook, &hd); | |
164 | } |