ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_kline.c
Revision: 605
Committed: Tue May 16 07:05:34 2006 UTC (20 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 25829 byte(s)
Log Message:
- Made find_chasing() only take 3 arguments
- Cleaned up find_person()

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_kline.c: Bans 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 "client.h"
27     #include "common.h"
28     #include "ircd.h"
29     #include "hostmask.h"
30     #include "numeric.h"
31     #include "s_conf.h"
32 db 91 #include "parse_aline.h"
33 adx 30 #include "send.h"
34     #include "hash.h"
35     #include "handlers.h"
36     #include "s_serv.h"
37     #include "msg.h"
38     #include "parse.h"
39 db 470 #include "conf/modules.h"
40 adx 30
41 michael 513 static void me_kline(struct Client *, struct Client *, int, char *[]);
42     static void mo_kline(struct Client *, struct Client *, int, char *[]);
43     static void ms_kline(struct Client *, struct Client *, int, char *[]);
44     static void mo_dline(struct Client *, struct Client *, int, char *[]);
45     static void me_unkline(struct Client *, struct Client *, int, char *[]);
46     static void mo_unkline(struct Client *, struct Client *, int, char *[]);
47     static void ms_unkline(struct Client *, struct Client *, int, char *[]);
48     static void mo_undline(struct Client *, struct Client *, int, char *[]);
49 adx 30
50     #ifndef IPV6
51     static char *make_cidr(char *dlhost, struct Client *);
52     #endif
53    
54     static int remove_tkline_match(const char *, const char *);
55     static int remove_tdline_match(const char *);
56    
57     struct Message kline_msgtab = {
58     "KLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
59 michael 605 { m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore }
60 adx 30 };
61    
62     struct Message dline_msgtab = {
63     "DLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
64 michael 605 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_dline, m_ignore }
65 adx 30 };
66    
67     struct Message unkline_msgtab = {
68     "UNKLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
69     {m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore}
70     };
71    
72     struct Message undline_msgtab = {
73     "UNDLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
74 michael 513 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_undline, m_ignore}
75 adx 30 };
76    
77 adx 442 INIT_MODULE(m_kline, "$Revision$")
78 adx 30 {
79     mod_add_cmd(&kline_msgtab);
80     mod_add_cmd(&unkline_msgtab);
81     mod_add_cmd(&dline_msgtab);
82     mod_add_cmd(&undline_msgtab);
83     add_capability("KLN", CAP_KLN, 1);
84     add_capability("UNKLN", CAP_UNKLN, 1);
85     }
86    
87 adx 442 CLEANUP_MODULE
88 adx 30 {
89     delete_capability("UNKLN");
90     delete_capability("KLN");
91 adx 442 mod_del_cmd(&undline_msgtab);
92     mod_del_cmd(&dline_msgtab);
93     mod_del_cmd(&unkline_msgtab);
94     mod_del_cmd(&kline_msgtab);
95 adx 30 }
96    
97     /* Local function prototypes */
98     static int already_placed_kline(struct Client *, const char *, const char *, int);
99     static void apply_kline(struct Client *, struct ConfItem *, const char *, time_t);
100     static void apply_tkline(struct Client *, struct ConfItem *, int);
101    
102     static char buffer[IRCD_BUFSIZE];
103    
104 michael 350
105     /*! \brief KLINE command handler (called for operators only)
106 adx 30 *
107 michael 350 * \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] = time in minutes
117     * - parv[2] = nick or user@host mask
118     * - parv[3] = reason (optional)
119     * or
120     * - parv[0] = sender prefix
121     * - parv[1] = nick or user@host mask
122     * - parv[2] = reason (optional)
123 adx 30 */
124     static void
125     mo_kline(struct Client *client_p, struct Client *source_p,
126 michael 605 int parc, char **parv)
127 adx 30 {
128     char *reason = NULL;
129     char *oper_reason;
130     char *user = NULL;
131     char *host = NULL;
132     const char *current_date;
133     char *target_server = NULL;
134     struct ConfItem *conf;
135     struct AccessItem *aconf;
136     time_t tkline_time = 0;
137     time_t cur_time;
138    
139     if (!IsOperK(source_p))
140     {
141     sendto_one(source_p, form_str(ERR_NOPRIVS),
142     me.name, source_p->name, "kline");
143     return;
144     }
145    
146     if (parse_aline("KLINE", source_p, parc, parv,
147     AWILD, &user, &host, &tkline_time, &target_server, &reason) < 0)
148     return;
149    
150     if (target_server != NULL)
151     {
152     if (HasID(source_p))
153     {
154 michael 405 sendto_server(NULL, source_p, NULL, CAP_KLN|CAP_TS6, NOCAPS,
155 adx 30 ":%s KLINE %s %lu %s %s :%s",
156     source_p->id, target_server, (unsigned long)tkline_time,
157     user, host, reason);
158 michael 405 sendto_server(NULL, source_p, NULL, CAP_KLN, CAP_TS6,
159 adx 30 ":%s KLINE %s %lu %s %s :%s",
160     source_p->name, target_server, (unsigned long)tkline_time,
161     user, host, reason);
162     }
163     else
164 michael 405 sendto_server(NULL, source_p, NULL, CAP_KLN, NOCAPS,
165 adx 30 ":%s KLINE %s %lu %s %s :%s",
166     source_p->name, target_server, (unsigned long)tkline_time,
167     user, host, reason);
168    
169     /* Allow ON to apply local kline as well if it matches */
170     if (!match(target_server, me.name))
171     return;
172     }
173     else
174     cluster_a_line(source_p, "KLINE", CAP_KLN, SHARED_KLINE,
175 michael 605 "%d %s %s :%s", tkline_time, user, host, reason);
176 adx 30
177     if (already_placed_kline(source_p, user, host, YES))
178     return;
179    
180     /* Look for an oper reason */
181     if ((oper_reason = strchr(reason, '|')) != NULL)
182     *oper_reason++ = '\0';
183    
184     cur_time = CurrentTime;
185     current_date = smalldate(cur_time);
186     conf = make_conf_item(KLINE_TYPE);
187 db 139 aconf = &conf->conf.AccessItem;
188 adx 30
189     DupString(aconf->host, host);
190     DupString(aconf->user, user);
191    
192     if (tkline_time != 0)
193     {
194     ircsprintf(buffer, "Temporary K-line %d min. - %s (%s)",
195     (int)(tkline_time/60), reason, current_date);
196     DupString(aconf->reason, buffer);
197    
198     if (oper_reason != NULL)
199     DupString(aconf->oper_reason, oper_reason);
200     apply_tkline(source_p, conf, tkline_time);
201     }
202     else
203     {
204     ircsprintf(buffer, "%s (%s)", reason, current_date);
205     DupString(aconf->reason, buffer);
206    
207     if (oper_reason != NULL)
208     DupString(aconf->oper_reason, oper_reason);
209     apply_kline(source_p, conf, current_date, cur_time);
210     }
211     }
212    
213     /* me_kline - handle remote kline. no propagation */
214     static void
215     me_kline(struct Client *client_p, struct Client *source_p,
216     int parc, char *parv[])
217     {
218     struct ConfItem *conf=NULL;
219     struct AccessItem *aconf=NULL;
220     int tkline_time;
221     const char* current_date;
222     time_t cur_time;
223     char *kuser, *khost, *kreason, *oper_reason;
224    
225 michael 351 if (parc != 6 || EmptyString(parv[5]))
226 adx 30 return;
227    
228     if (!match(parv[1], me.name))
229     return;
230    
231     tkline_time = valid_tkline(parv[2], TK_SECONDS);
232     kuser = parv[3];
233     khost = parv[4];
234     kreason = parv[5];
235    
236     if ((oper_reason = strchr(kreason, '|')) != NULL)
237     *oper_reason++ = '\0';
238    
239     cur_time = CurrentTime;
240     current_date = smalldate(cur_time);
241    
242     if (find_matching_name_conf(ULINE_TYPE, source_p->servptr->name,
243     source_p->username, source_p->host,
244     SHARED_KLINE))
245     {
246     if (!IsClient(source_p) ||
247     already_placed_kline(source_p, kuser, khost, YES))
248     return;
249    
250     conf = make_conf_item(KLINE_TYPE);
251 db 139 aconf = &conf->conf.AccessItem;
252 adx 30 DupString(aconf->host, khost);
253     DupString(aconf->user, kuser);
254    
255     if (tkline_time != 0)
256     {
257     ircsprintf(buffer, "Temporary K-line %d min. - %s (%s)",
258     (int)(tkline_time/60), kreason, current_date);
259     DupString(aconf->reason, buffer);
260    
261     if (oper_reason != NULL)
262     DupString(aconf->oper_reason, oper_reason);
263     apply_tkline(source_p, conf, tkline_time);
264     }
265     else
266     {
267     ircsprintf(buffer, "%s (%s)", kreason, current_date);
268     DupString(aconf->reason, buffer);
269    
270     if (oper_reason != NULL)
271     DupString(aconf->oper_reason, oper_reason);
272     apply_kline(source_p, conf, current_date, cur_time);
273     }
274     }
275     }
276    
277 michael 350 /*! \brief KLINE command handler (called for remote clients and servers only)
278     *
279     * Returns various information such as maxmimum entries, slots that
280     * are in use and collision count
281     *
282     * \param client_p Pointer to allocated Client struct with physical connection
283     * to this server, i.e. with an open socket connected.
284     * \param source_p Pointer to allocated Client struct from which the message
285     * originally comes from. This can be a local or remote client.
286     * \param parc Integer holding the number of supplied arguments.
287     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
288     * pointers.
289     * \note Valid arguments for this command are:
290     * - parv[0] = sender prefix
291     * - parv[1] = target server (string may include wildcards)
292     * - parv[2] = duration in minutes
293     * - parv[3] = username
294     * - parv[4] = hostname
295     * - parv[5] = reason
296     */
297 adx 30 static void
298     ms_kline(struct Client *client_p, struct Client *source_p,
299 michael 605 int parc, char *parv[])
300 adx 30 {
301 michael 351 if (parc != 6 || EmptyString(parv[5]))
302 adx 30 return;
303    
304     sendto_match_servs(source_p, parv[1], CAP_KLN,
305     "KLINE %s %s %s %s :%s",
306     parv[1], parv[2], parv[3], parv[4], parv[5]);
307    
308     me_kline(client_p, source_p, parc, parv);
309     }
310    
311     /* apply_kline()
312     *
313     * inputs -
314     * output - NONE
315     * side effects - kline as given, is added to the hashtable
316     * and conf file
317     */
318     static void
319     apply_kline(struct Client *source_p, struct ConfItem *conf,
320 michael 605 const char *current_date, time_t cur_time)
321 adx 30 {
322 db 139 struct AccessItem *aconf = &conf->conf.AccessItem;
323 adx 30
324     add_conf_by_address(CONF_KILL, aconf);
325     write_conf_line(source_p, conf, current_date, cur_time);
326     /* Now, activate kline against current online clients */
327     rehashed_klines = 1;
328     }
329    
330     /* apply_tkline()
331     *
332     * inputs -
333     * output - NONE
334     * side effects - tkline as given is placed
335     */
336     static void
337     apply_tkline(struct Client *source_p, struct ConfItem *conf,
338     int tkline_time)
339     {
340     struct AccessItem *aconf;
341    
342 db 139 aconf = &conf->conf.AccessItem;
343 adx 30 aconf->hold = CurrentTime + tkline_time;
344     add_temp_line(conf);
345     sendto_realops_flags(UMODE_ALL, L_ALL,
346     "%s added temporary %d min. K-Line for [%s@%s] [%s]",
347     get_oper_name(source_p), tkline_time/60,
348     aconf->user, aconf->host,
349     aconf->reason);
350     sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]",
351     MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
352     source_p->name, tkline_time/60, aconf->user, aconf->host);
353     ilog(L_TRACE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
354     source_p->name, tkline_time/60,
355     aconf->user, aconf->host, aconf->reason);
356     log_oper_action(LOG_TEMP_KLINE_TYPE, source_p, "[%s@%s] [%s]\n",
357     aconf->user, aconf->host, aconf->reason);
358     rehashed_klines = 1;
359     }
360    
361     /* apply_tdline()
362     *
363     * inputs -
364     * output - NONE
365     * side effects - tkline as given is placed
366     */
367     static void
368     apply_tdline(struct Client *source_p, struct ConfItem *conf,
369 michael 605 const char *current_date, int tkline_time)
370 adx 30 {
371     struct AccessItem *aconf;
372    
373 db 139 aconf = &conf->conf.AccessItem;
374 adx 30 aconf->hold = CurrentTime + tkline_time;
375    
376     add_temp_line(conf);
377     sendto_realops_flags(UMODE_ALL, L_ALL,
378     "%s added temporary %d min. D-Line for [%s] [%s]",
379     get_oper_name(source_p), tkline_time/60,
380     aconf->host, aconf->reason);
381    
382     sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]",
383     MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
384     source_p->name, tkline_time/60, aconf->host);
385     ilog(L_TRACE, "%s added temporary %d min. D-Line for [%s] [%s]",
386     source_p->name, tkline_time/60, aconf->host, aconf->reason);
387     log_oper_action(LOG_TEMP_DLINE_TYPE, source_p, "[%s@%s] [%s]\n",
388     aconf->user, aconf->host, aconf->reason);
389     rehashed_klines = 1;
390     }
391    
392     /* mo_dline()
393     *
394     * inputs - pointer to server
395     * - pointer to client
396     * - parameter count
397     * - parameter list
398     * output -
399     * side effects - D line is added
400     *
401     */
402     static void
403     mo_dline(struct Client *client_p, struct Client *source_p,
404     int parc, char *parv[])
405     {
406     char def_reason[] = "No reason";
407     char *dlhost, *oper_reason, *reason;
408     const char *creason;
409     #ifndef IPV6
410     struct Client *target_p;
411     #endif
412     struct irc_ssaddr daddr;
413     struct ConfItem *conf=NULL;
414     struct AccessItem *aconf=NULL;
415     time_t tkline_time=0;
416     int bits, t;
417     const char* current_date;
418     time_t cur_time;
419    
420     if (!IsOperK(source_p))
421     {
422     sendto_one(source_p, form_str(ERR_NOPRIVS),
423     me.name, source_p->name, "kline");
424     return;
425     }
426    
427     if (parse_aline("DLINE", source_p, parc, parv,
428     AWILD, &dlhost, NULL, &tkline_time, NULL, &reason) < 0)
429     return;
430    
431     if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
432     {
433     #ifdef IPV6
434     sendto_one(source_p, ":%s NOTICE %s :Sorry, please supply an address.",
435     me.name, parv[0]);
436     return;
437     #else
438 michael 605 if ((target_p = find_chasing(source_p, dlhost, NULL)) == NULL)
439 adx 30 return;
440    
441     t = HM_IPV4;
442     if (IsServer(target_p))
443     {
444     sendto_one(source_p,
445     ":%s NOTICE %s :Can't DLINE a server silly",
446     me.name, source_p->name);
447     return;
448     }
449    
450     if (!MyConnect(target_p))
451     {
452     sendto_one(source_p,
453     ":%s NOTICE %s :Can't DLINE nick on another server",
454     me.name, source_p->name);
455     return;
456     }
457    
458     if (IsExemptKline(target_p))
459     {
460     sendto_one(source_p,
461     ":%s NOTICE %s :%s is E-lined",me.name,
462     source_p->name, target_p->name);
463     return;
464     }
465    
466     if ((dlhost = make_cidr(dlhost, target_p)) == NULL)
467     return;
468    
469     bits = 0xFFFFFF00UL;
470     #endif
471     }
472    
473     if (bits < 8)
474     {
475     sendto_one(source_p,
476     ":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.",
477     me.name, source_p->name);
478     return;
479     }
480    
481    
482     #ifdef IPV6
483     if (t == HM_IPV6)
484     t = AF_INET6;
485     else
486     #endif
487     t = AF_INET;
488    
489     parse_netmask(dlhost, &daddr, NULL);
490    
491     if ((aconf = find_dline_conf(&daddr, t)) != NULL)
492     {
493     creason = aconf->reason ? aconf->reason : def_reason;
494     if (IsConfExemptKline(aconf))
495     sendto_one(source_p,
496     ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
497     me.name, source_p->name, dlhost, aconf->host, creason);
498     else
499     sendto_one(source_p,
500     ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
501     me.name, source_p->name, dlhost, aconf->host, creason);
502     return;
503     }
504    
505     cur_time = CurrentTime;
506     current_date = smalldate(cur_time);
507    
508     /* Look for an oper reason */
509     if ((oper_reason = strchr(reason, '|')) != NULL)
510     *oper_reason++ = '\0';
511    
512     if (!valid_comment(source_p, reason, YES))
513     return;
514    
515     conf = make_conf_item(DLINE_TYPE);
516 db 139 aconf = &conf->conf.AccessItem;
517 adx 30 DupString(aconf->host, dlhost);
518    
519     if (tkline_time != 0)
520     {
521     ircsprintf(buffer, "Temporary D-line %d min. - %s (%s)",
522     (int)(tkline_time/60), reason, current_date);
523     DupString(aconf->reason, buffer);
524     if (oper_reason != NULL)
525     DupString(aconf->oper_reason, oper_reason);
526     apply_tdline(source_p, conf, current_date, tkline_time);
527     }
528     else
529     {
530     ircsprintf(buffer, "%s (%s)", reason, current_date);
531     DupString(aconf->reason, buffer);
532     if (oper_reason != NULL)
533     DupString(aconf->oper_reason, oper_reason);
534     add_conf_by_address(CONF_DLINE, aconf);
535     write_conf_line(source_p, conf, current_date, cur_time);
536     }
537    
538     rehashed_klines = 1;
539     } /* mo_dline() */
540    
541    
542     /* already_placed_kline()
543     * inputs - user to complain to, username & host to check for
544     * outputs - returns 1 on existing K-line, 0 if doesn't exist
545     * side effects - notifies source_p if the K-line already exists
546     */
547     /*
548     * Note: This currently works if the new K-line is a special case of an
549     * existing K-line, but not the other way round. To do that we would
550     * have to walk the hash and check every existing K-line. -A1kmm.
551     */
552     static int
553     already_placed_kline(struct Client *source_p, const char *luser, const char *lhost, int warn)
554     {
555     const char *reason;
556     struct irc_ssaddr iphost, *piphost;
557     struct AccessItem *aconf;
558     int t;
559    
560     if ((t = parse_netmask(lhost, &iphost, &t)) != HM_HOST)
561     {
562     #ifdef IPV6
563     if (t == HM_IPV6)
564     t = AF_INET6;
565     else
566     #endif
567     t = AF_INET;
568     piphost = &iphost;
569     }
570     else
571     {
572     t = 0;
573     piphost = NULL;
574     }
575    
576     if ((aconf = find_conf_by_address(lhost, piphost, CONF_KILL, t, luser, NULL)))
577     {
578     if (warn)
579     {
580     reason = aconf->reason ? aconf->reason : "No reason";
581     sendto_one(source_p,
582     ":%s NOTICE %s :[%s@%s] already K-Lined by [%s@%s] - %s",
583     me.name, source_p->name, luser, lhost, aconf->user,
584     aconf->host, reason);
585     }
586     return(1);
587     }
588    
589     return(0);
590     }
591    
592     #ifndef IPV6
593     static char *
594     make_cidr(char *dlhost, struct Client *target_p)
595     {
596     static char cidr_form_host[HOSTLEN + 2];
597     char *p;
598    
599     strlcpy(cidr_form_host, inetntoa((const char *)&target_p->localClient->ip),
600     sizeof(cidr_form_host));
601    
602     if ((p = strchr(cidr_form_host,'.')) == NULL)
603     return(NULL);
604    
605     /* 192. <- p */
606     p++;
607     if ((p = strchr(p,'.')) == NULL)
608     return(NULL);
609    
610     /* 192.168. <- p */
611     p++;
612     if ((p = strchr(p,'.')) == NULL)
613     return(NULL);
614    
615     /* 192.168.0. <- p */
616     p++;
617     *p++ = '0';
618     *p++ = '/';
619     *p++ = '2';
620     *p++ = '4';
621     *p++ = '\0';
622    
623     return(cidr_form_host);
624     }
625     #endif
626    
627     /*
628     ** mo_unkline
629     ** Added Aug 31, 1997
630     ** common (Keith Fralick) fralick@gate.net
631     **
632     ** parv[0] = sender
633     ** parv[1] = address to remove
634     *
635     *
636     */
637     static void
638     mo_unkline(struct Client *client_p,struct Client *source_p,
639     int parc, char *parv[])
640     {
641     char *target_server = NULL;
642     char *user, *host;
643    
644     if (!IsOperUnkline(source_p))
645     {
646     sendto_one(source_p, form_str(ERR_NOPRIVS),
647     me.name, source_p->name, "unkline");
648     return;
649     }
650    
651     if (parc < 2 || EmptyString(parv[1]))
652     {
653     sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
654     me.name, source_p->name, "UNKLINE");
655     return;
656     }
657    
658     if (parse_aline("UNKLINE", source_p, parc, parv, 0, &user,
659     &host, NULL, &target_server, NULL) < 0)
660     return;
661    
662     if (target_server != NULL)
663     {
664     sendto_match_servs(source_p, target_server, CAP_UNKLN,
665     "UNKLINE %s %s %s",
666     target_server, user, host);
667    
668     /* Allow ON to apply local unkline as well if it matches */
669     if (!match(target_server, me.name))
670     return;
671     }
672     else
673     cluster_a_line(source_p, "UNKLINE", CAP_UNKLN, SHARED_UNKLINE,
674     "%s %s", user, host);
675    
676     if (remove_tkline_match(host, user))
677     {
678     sendto_one(source_p,
679     ":%s NOTICE %s :Un-klined [%s@%s] from temporary K-Lines",
680     me.name, source_p->name, user, host);
681     sendto_realops_flags(UMODE_ALL, L_ALL,
682     "%s has removed the temporary K-Line for: [%s@%s]",
683     get_oper_name(source_p), user, host);
684     ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]",
685     source_p->name, user, host);
686     return;
687     }
688    
689     if (remove_conf_line(KLINE_TYPE, source_p, user, host) > 0)
690     {
691     sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
692     me.name, source_p->name, user,host);
693     sendto_realops_flags(UMODE_ALL, L_ALL,
694     "%s has removed the K-Line for: [%s@%s]",
695     get_oper_name(source_p), user, host);
696     ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
697     source_p->name, user, host);
698     }
699     else
700     sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found",
701     me.name, source_p->name, user, host);
702     }
703    
704     /* me_unkline()
705     *
706     * inputs - server
707     * - client
708     * - parc
709     * - parv
710     * outputs - none
711     * side effects - if server is authorized, kline is removed
712     * does not propagate message
713     */
714     static void
715     me_unkline(struct Client *client_p, struct Client *source_p,
716     int parc, char *parv[])
717     {
718     const char *kuser, *khost;
719    
720     if (parc != 4)
721     return;
722    
723     kuser = parv[2];
724     khost = parv[3];
725    
726     if (!IsClient(source_p) || !match(parv[1], me.name))
727     return;
728    
729     if (find_matching_name_conf(ULINE_TYPE,
730     source_p->servptr->name,
731     source_p->username, source_p->host,
732     SHARED_UNKLINE))
733     {
734     if (remove_tkline_match(khost, kuser))
735     {
736     sendto_one(source_p,
737     ":%s NOTICE %s :Un-klined [%s@%s] from temporary K-Lines",
738     me.name, source_p->name, kuser, khost);
739     sendto_realops_flags(UMODE_ALL, L_ALL,
740     "%s has removed the temporary K-Line for: [%s@%s]",
741     get_oper_name(source_p), kuser, khost);
742     ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]",
743     source_p->name, kuser, khost);
744     return;
745     }
746    
747     if (remove_conf_line(KLINE_TYPE, source_p, kuser, khost) > 0)
748     {
749     sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
750     me.name, source_p->name, kuser, khost);
751     sendto_realops_flags(UMODE_ALL, L_ALL,
752     "%s has removed the K-Line for: [%s@%s]",
753     get_oper_name(source_p), kuser, khost);
754    
755     ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
756     source_p->name, kuser, khost);
757     }
758     else
759     sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found",
760     me.name, source_p->name, kuser, khost);
761     }
762     }
763    
764     /* ms_unkline - propagates and handles a remote unkline message */
765     static void
766     ms_unkline(struct Client *client_p, struct Client *source_p,
767     int parc, char *parv[])
768     {
769     if (parc != 4)
770     return;
771    
772     sendto_match_servs(source_p, parv[1], CAP_UNKLN,
773     "UNKLINE %s %s %s",
774     parv[1], parv[2], parv[3]);
775    
776     me_unkline(client_p, source_p, parc, parv);
777     }
778    
779     /* static int remove_tkline_match(const char *host, const char *user)
780     * Input: A hostname, a username to unkline.
781     * Output: returns YES on success, NO if no tkline removed.
782     * Side effects: Any matching tklines are removed.
783     */
784     static int
785     remove_tkline_match(const char *host, const char *user)
786     {
787     struct AccessItem *tk_c;
788     dlink_node *tk_n;
789     struct irc_ssaddr addr, caddr;
790     int nm_t, cnm_t, bits, cbits;
791     nm_t = parse_netmask(host, &addr, &bits);
792    
793     DLINK_FOREACH(tk_n, temporary_klines.head)
794     {
795 db 139 tk_c = &((struct ConfItem *)(tk_n->data))->conf.AccessItem;
796 adx 30 cnm_t = parse_netmask(tk_c->host, &caddr, &cbits);
797     if (cnm_t != nm_t || irccmp(user, tk_c->user))
798     continue;
799     if ((nm_t==HM_HOST && !irccmp(tk_c->host, host)) ||
800     (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
801     #ifdef IPV6
802     || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
803     #endif
804     )
805     {
806     dlinkDelete(tk_n, &temporary_klines);
807     delete_one_address_conf(tk_c->host, tk_c);
808     return(YES);
809     }
810     }
811    
812     return(NO);
813     }
814    
815     /* static int remove_tdline_match(const char *host, const char *user)
816     * Input: An ip to undline.
817     * Output: returns YES on success, NO if no tdline removed.
818     * Side effects: Any matching tdlines are removed.
819     */
820     static int
821     remove_tdline_match(const char *cidr)
822     {
823     struct AccessItem *td_conf;
824     dlink_node *td_node;
825     struct irc_ssaddr addr, caddr;
826     int nm_t, cnm_t, bits, cbits;
827     nm_t = parse_netmask(cidr, &addr, &bits);
828    
829     DLINK_FOREACH(td_node, temporary_dlines.head)
830     {
831 db 139 td_conf = &((struct ConfItem *)(td_node->data))->conf.AccessItem;
832 adx 30 cnm_t = parse_netmask(td_conf->host, &caddr, &cbits);
833    
834     if (cnm_t != nm_t)
835     continue;
836    
837     if((nm_t==HM_HOST && !irccmp(td_conf->host, cidr)) ||
838     (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
839     #ifdef IPV6
840     || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
841     #endif
842     )
843     {
844     dlinkDelete(td_node, &temporary_dlines);
845     delete_one_address_conf(td_conf->host, td_conf);
846     return(YES);
847     }
848     }
849    
850     return(NO);
851     }
852    
853     /*
854     ** m_undline
855     ** added May 28th 2000 by Toby Verrall <toot@melnet.co.uk>
856     ** based totally on m_unkline
857     ** added to hybrid-7 7/11/2000 --is
858     **
859     ** parv[0] = sender nick
860     ** parv[1] = dline to remove
861     */
862     static void
863     mo_undline(struct Client *client_p, struct Client *source_p,
864     int parc, char *parv[])
865     {
866     const char *cidr;
867    
868     if (!IsOperUnkline(source_p))
869     {
870     sendto_one(source_p, form_str(ERR_NOPRIVS),
871     me.name, source_p->name, "undline");
872     return;
873     }
874    
875     cidr = parv[1];
876    
877     if (remove_tdline_match(cidr))
878     {
879     sendto_one(source_p,
880     ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
881     me.name, source_p->name, cidr);
882     sendto_realops_flags(UMODE_ALL, L_ALL,
883     "%s has removed the temporary D-Line for: [%s]",
884     get_oper_name(source_p), cidr);
885     ilog(L_NOTICE, "%s removed temporary D-Line for [%s]", source_p->name, cidr);
886     return;
887     }
888    
889     if (remove_conf_line(DLINE_TYPE, source_p, cidr, NULL) > 0)
890     {
891     sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
892     me.name, source_p->name, cidr);
893     sendto_realops_flags(UMODE_ALL, L_ALL,
894     "%s has removed the D-Line for: [%s]",
895     get_oper_name(source_p), cidr);
896     ilog(L_NOTICE, "%s removed D-Line for [%s]",
897     get_oper_name(source_p), cidr);
898     }
899     else
900     sendto_one(source_p, ":%s NOTICE %s :No D-Line for [%s] found",
901     me.name, source_p->name, cidr);
902     }

Properties

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