ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_admin.c
Revision: 589
Committed: Mon May 8 18:40:00 2006 UTC (19 years, 3 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/modules/m_admin.c
File size: 4622 byte(s)
Log Message:
- Clear the TS6 CAPAB bit possibly set on an unregistered client connection
  in mr_motd(), mr_admin() and register_local_user(). This is a kludge for now.

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_admin.c: Sends administrative information to a user.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "handlers.h"
27     #include "client.h"
28     #include "ircd.h"
29     #include "numeric.h"
30     #include "s_conf.h"
31     #include "s_serv.h"
32     #include "send.h"
33     #include "msg.h"
34     #include "parse.h"
35     #include "hook.h"
36     #include "modules.h"
37     #include "irc_string.h"
38    
39 michael 589 static void m_admin(struct Client *, struct Client *, int, char *[]);
40     static void mr_admin(struct Client *, struct Client *, int, char *[]);
41     static void ms_admin(struct Client *, struct Client *, int, char *[]);
42 adx 30 static void do_admin(struct Client *);
43    
44     struct Message admin_msgtab = {
45     "ADMIN", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
46     {mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore}
47     };
48    
49     #ifndef STATIC_MODULES
50     static struct Callback *admin_cb;
51 knight 31 const char *_version = "$Revision$";
52 adx 30
53     static void *
54     va_admin(va_list args)
55     {
56     do_admin(va_arg(args, struct Client *));
57     return NULL;
58     }
59    
60     void
61     _modinit(void)
62     {
63     admin_cb = register_callback("doing_admin", va_admin);
64     mod_add_cmd(&admin_msgtab);
65     }
66    
67     void
68     _moddeinit(void)
69     {
70     mod_del_cmd(&admin_msgtab);
71     uninstall_hook(admin_cb, va_admin);
72     }
73     #endif
74    
75     /*
76     * mr_admin - ADMIN command handler
77     * parv[0] = sender prefix
78     * parv[1] = servername
79     */
80     static void
81     mr_admin(struct Client *client_p, struct Client *source_p,
82     int parc, char *parv[])
83     {
84     static time_t last_used = 0;
85 adx 269
86 michael 589 ClearCap(client_p, CAP_TS6);
87    
88 adx 269 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
89 adx 30 {
90     sendto_one(source_p, form_str(RPL_LOAD2HI),
91     me.name, EmptyString(parv[0]) ? "*" : parv[0]);
92     return;
93     }
94    
95 michael 589 last_used = CurrentTime;
96    
97 adx 30 #ifdef STATIC_MODULES
98     do_admin(client_p);
99     #else
100     execute_callback(admin_cb, source_p, parc, parv);
101     #endif
102     }
103    
104     /*
105     * m_admin - ADMIN command handler
106     * parv[0] = sender prefix
107     * parv[1] = servername
108     */
109     static void
110     m_admin(struct Client *client_p, struct Client *source_p,
111     int parc, char *parv[])
112     {
113     static time_t last_used = 0;
114    
115 adx 269 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
116 adx 30 {
117     sendto_one(source_p,form_str(RPL_LOAD2HI),
118     me.name, source_p->name);
119     return;
120     }
121    
122 michael 589 last_used = CurrentTime;
123    
124 adx 30 if (!ConfigFileEntry.disable_remote)
125 michael 589 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
126     parc, parv) != HUNTED_ISME)
127 adx 30 return;
128    
129     #ifdef STATIC_MODULES
130     do_admin(client_p);
131     #else
132     execute_callback(admin_cb, source_p, parc, parv);
133     #endif
134     }
135    
136     /*
137     * ms_admin - ADMIN command handler, used for OPERS as well
138     * parv[0] = sender prefix
139     * parv[1] = servername
140     */
141     static void
142     ms_admin(struct Client *client_p, struct Client *source_p,
143     int parc, char *parv[])
144     {
145 michael 589 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv)
146     != HUNTED_ISME)
147 adx 30 return;
148    
149     if (IsClient(source_p))
150     #ifdef STATIC_MODULES
151     do_admin(source_p);
152     #else
153     execute_callback(admin_cb, source_p, parc, parv);
154     #endif
155     }
156    
157     /* do_admin()
158     *
159     * inputs - pointer to client to report to
160     * output - none
161     * side effects - admin info is sent to client given
162     */
163     static void
164     do_admin(struct Client *source_p)
165     {
166     const char *me_name;
167     const char *nick;
168    
169     me_name = ID_or_name(&me, source_p->from);
170     nick = ID_or_name(source_p, source_p->from);
171    
172     sendto_one(source_p, form_str(RPL_ADMINME),
173     me_name, nick, me.name);
174     if (AdminInfo.name != NULL)
175     sendto_one(source_p, form_str(RPL_ADMINLOC1),
176     me_name, nick, AdminInfo.name);
177     if (AdminInfo.description != NULL)
178     sendto_one(source_p, form_str(RPL_ADMINLOC2),
179     me_name, nick, AdminInfo.description);
180     if (AdminInfo.email != NULL)
181     sendto_one(source_p, form_str(RPL_ADMINEMAIL),
182     me_name, nick, AdminInfo.email);
183     }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision