ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_capture.c
Revision: 443
Committed: Sat Feb 11 23:37:10 2006 UTC (20 years, 6 months ago) by adx
Content type: text/x-csrc
File size: 7340 byte(s)
Log Message:
+ make it compile
+ fix contrib
+ fixed core when unloading spy_trace_notice, this one should be MFC'd
  (etrace_cb was not unhooked properly)

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_capture.c: Makes a designated client captive
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 "common.h"
27     #include "handlers.h"
28     #include "client.h"
29     #include "hash.h"
30     #include "channel.h"
31     #include "channel_mode.h"
32     #include "hash.h"
33     #include "ircd.h"
34     #include "numeric.h"
35     #include "s_conf.h"
36     #include "s_serv.h"
37     #include "send.h"
38     #include "msg.h"
39     #include "parse.h"
40     #include "modules.h"
41 knight 113 #include "parse_aline.h"
42 adx 30
43     static void mo_capture(struct Client *, struct Client *, int, char *[]);
44     static void mo_uncapture(struct Client *, struct Client *, int, char *[]);
45    
46     struct Message capture_msgtab = {
47     "CAPTURE", 0, 0, 0, 0, MFLG_SLOW, 0,
48 michael 357 { m_unregistered, m_ignore, mo_capture, mo_capture, mo_capture, m_ignore }
49 adx 30 };
50    
51     struct Message uncapture_msgtab = {
52     "UNCAPTURE", 0, 0, 0, 0, MFLG_SLOW, 0,
53 michael 357 { m_unregistered, m_ignore, mo_uncapture, mo_uncapture, mo_uncapture, m_ignore }
54 adx 30 };
55    
56 adx 443 INIT_MODULE(m_capture, "$Revision$")
57 adx 30 {
58     mod_add_cmd(&capture_msgtab);
59     mod_add_cmd(&uncapture_msgtab);
60     }
61    
62 adx 443 CLEANUP_MODULE
63 adx 30 {
64 adx 443 mod_del_cmd(&uncapture_msgtab);
65 adx 30 mod_del_cmd(&capture_msgtab);
66     }
67    
68     /* mo_capture
69     * parv[0] = sender prefix
70     * parv[1] = nickname masklist
71     */
72     static void
73     mo_capture(struct Client *client_p, struct Client *source_p,
74     int parc, char *parv[])
75     {
76     struct Client *target_p = NULL;
77 michael 357 char nick[NICKLEN + 1];
78     char user[USERLEN + 1];
79     char host[HOSTLEN + 1];
80 adx 30 dlink_node *ptr = NULL;
81    
82 michael 357 if (EmptyString(parv[1]))
83 adx 30 {
84     sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
85     me.name, source_p->name);
86     return;
87     }
88    
89     /* XXX Add oper flag in future ? */
90    
91     if (MyClient(source_p) && !IsAdmin(source_p))
92     {
93     sendto_one(source_p, form_str(ERR_NOPRIVS),
94     me.name, source_p->name, "CAPTURE");
95     return;
96     }
97    
98 michael 357 if (strchr(parv[1], '@') == NULL)
99 adx 30 {
100     if ((target_p = find_client(parv[1])) != NULL && IsClient(target_p))
101     {
102     if (MyConnect(target_p) && source_p != target_p)
103     {
104     if (IsOper(target_p))
105     {
106     sendto_one(source_p, form_str(ERR_NOPRIVS),
107     me.name, source_p->name, "CAPTURE");
108     return;
109     }
110    
111     if (!IsCaptured(target_p))
112     {
113     sendto_realops_flags(UMODE_ALL, L_ALL, "Captured %s (%s@%s)",
114     target_p->name, target_p->username,
115     target_p->host);
116     SetCaptured(target_p);
117     }
118    
119     sendto_one(source_p, form_str(RPL_ISCAPTURED),
120     me.name, source_p->name, target_p->name);
121     }
122     else if (IsCapable(target_p->from, CAP_ENCAP))
123     sendto_one(target_p, ":%s ENCAP %s CAPTURE %s",
124     source_p->name, target_p->from->name, target_p->name);
125     }
126     else
127     sendto_one(source_p, form_str(ERR_NOSUCHNICK),
128     me.name, source_p->name, parv[1]);
129     }
130     else
131     {
132     unsigned int matches = 0;
133 michael 357 struct split_nuh_item nuh;
134 adx 30
135 michael 357 nuh.nuhmask = parv[1];
136     nuh.nickptr = nick;
137     nuh.userptr = user;
138     nuh.hostptr = host;
139 adx 30
140 michael 357 nuh.nicksize = sizeof(nick);
141     nuh.usersize = sizeof(user);
142     nuh.hostsize = sizeof(host);
143 adx 30
144 michael 357 split_nuh(&nuh);
145    
146 adx 30 if (!valid_wild_card(source_p, YES, 3, nick, user, host))
147     return;
148    
149     if (IsClient(client_p))
150 michael 405 sendto_server(client_p, NULL, NULL, CAP_ENCAP, 0,
151 adx 30 ":%s ENCAP * CAPTURE %s!%s@%s",
152     source_p->name, nick, user, host);
153    
154     DLINK_FOREACH(ptr, local_client_list.head)
155     {
156     target_p = ptr->data;
157    
158 michael 357 if (source_p == target_p || IsOper(target_p) || IsCaptured(target_p))
159 adx 30 continue;
160    
161     if (match(nick, target_p->name) &&
162     match(host, target_p->host) && match(user, target_p->username))
163     {
164     SetCaptured(target_p);
165     ++matches;
166     }
167     }
168    
169     sendto_realops_flags(UMODE_ALL, L_ALL,
170     "Bulk captured %s!%s@%s, %u local match(es)",
171     nick, user, host, matches);
172     }
173     }
174    
175     /* mo_uncapture
176     * parv[0] = sender prefix
177     * parv[1] = nickname masklist
178     */
179     static void
180     mo_uncapture(struct Client *client_p, struct Client *source_p,
181     int parc, char *parv[])
182     {
183     struct Client *target_p = NULL;
184 michael 357 char nick[NICKLEN + 1];
185     char user[USERLEN + 1];
186     char host[HOSTLEN + 1];
187 adx 30 dlink_node *ptr = NULL;
188    
189     if (MyClient(source_p) && !IsAdmin(source_p))
190     {
191     sendto_one(source_p, form_str(ERR_NOPRIVS),
192     me.name, source_p->name, "CAPTURE");
193     return;
194     }
195    
196 michael 357 if (EmptyString(parv[1]))
197 adx 30 {
198     sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
199     me.name, source_p->name);
200     return;
201     }
202    
203 michael 357 if (strchr(parv[1], '@') == NULL)
204 adx 30 {
205     if ((target_p = find_client(parv[1])) != NULL && IsClient(target_p))
206     {
207     if (MyConnect(target_p))
208     {
209     if (IsCaptured(target_p))
210     {
211     ClearCaptured(target_p);
212    
213     sendto_realops_flags(UMODE_ALL, L_ALL, "Uncaptured %s (%s@%s)",
214     target_p->name, target_p->username,
215     target_p->host);
216     }
217    
218     sendto_one(source_p, form_str(RPL_ISUNCAPTURED),
219     me.name, source_p->name, target_p->name);
220     }
221     else if (IsCapable(target_p->from, CAP_ENCAP))
222     sendto_one(target_p, ":%s ENCAP %s UNCAPTURE %s",
223     source_p->name, target_p->from->name, target_p->name);
224     }
225     else
226     sendto_one(source_p, form_str(ERR_NOSUCHNICK),
227     me.name, source_p->name, parv[1]);
228     }
229     else
230     {
231     unsigned int matches = 0;
232 michael 357 struct split_nuh_item nuh;
233 adx 30
234 michael 357 nuh.nuhmask = parv[1];
235     nuh.nickptr = nick;
236     nuh.userptr = user;
237     nuh.hostptr = host;
238 adx 30
239 michael 357 nuh.nicksize = sizeof(nick);
240     nuh.usersize = sizeof(user);
241     nuh.hostsize = sizeof(host);
242 adx 30
243 michael 357 split_nuh(&nuh);
244    
245 adx 30 if (IsClient(client_p))
246 michael 405 sendto_server(client_p, NULL, NULL, CAP_ENCAP, 0,
247 adx 30 ":%s ENCAP * UNCAPTURE %s!%s@%s",
248     source_p->name, nick, user, host);
249    
250     DLINK_FOREACH(ptr, local_client_list.head)
251     {
252     target_p = ptr->data;
253    
254     if (!IsCaptured(target_p))
255     continue;
256    
257     if (match(nick, target_p->name) &&
258     match(host, target_p->host) && match(user, target_p->username))
259     {
260     ClearCaptured(target_p);
261     ++matches;
262     }
263     }
264    
265     sendto_realops_flags(UMODE_ALL, L_ALL,
266     "Bulk uncaptured %s!%s@%s, %u local match(es)",
267     nick, user, host, matches);
268     }
269     }

Properties

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