]> jfr.im git - irc/rqf/shadowircd.git/blob - modules/m_kline.c
Generate the "Temporary K-line %d min" part from aconf->hold - aconf->created.
[irc/rqf/shadowircd.git] / modules / m_kline.c
1 /*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_kline.c: Bans/unbans 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
23 *
24 * $Id$
25 */
26
27 #include "stdinc.h"
28 #include "channel.h"
29 #include "class.h"
30 #include "client.h"
31 #include "common.h"
32 #include "match.h"
33 #include "ircd.h"
34 #include "hostmask.h"
35 #include "numeric.h"
36 #include "s_conf.h"
37 #include "s_newconf.h"
38 #include "logger.h"
39 #include "send.h"
40 #include "hash.h"
41 #include "s_serv.h"
42 #include "msg.h"
43 #include "parse.h"
44 #include "modules.h"
45 #include "reject.h"
46 #include "bandbi.h"
47
48 static int mo_kline(struct Client *, struct Client *, int, const char **);
49 static int ms_kline(struct Client *, struct Client *, int, const char **);
50 static int me_kline(struct Client *, struct Client *, int, const char **);
51 static int mo_unkline(struct Client *, struct Client *, int, const char **);
52 static int ms_unkline(struct Client *, struct Client *, int, const char **);
53 static int me_unkline(struct Client *, struct Client *, int, const char **);
54
55 struct Message kline_msgtab = {
56 "KLINE", 0, 0, 0, MFLG_SLOW,
57 {mg_unreg, mg_not_oper, {ms_kline, 5}, {ms_kline, 5}, {me_kline, 5}, {mo_kline, 3}}
58 };
59
60 struct Message unkline_msgtab = {
61 "UNKLINE", 0, 0, 0, MFLG_SLOW,
62 {mg_unreg, mg_not_oper, {ms_unkline, 4}, {ms_unkline, 4}, {me_unkline, 3}, {mo_unkline, 2}}
63 };
64
65 mapi_clist_av1 kline_clist[] = { &kline_msgtab, &unkline_msgtab, NULL };
66
67 DECLARE_MODULE_AV1(kline, NULL, NULL, kline_clist, NULL, NULL, "$Revision$");
68
69 /* Local function prototypes */
70 static int find_user_host(struct Client *source_p, const char *userhost, char *user, char *host);
71 static int valid_comment(struct Client *source_p, char *comment);
72 static int valid_user_host(struct Client *source_p, const char *user, const char *host);
73 static int valid_wild_card(struct Client *source_p, const char *user, const char *host);
74
75 static void handle_remote_kline(struct Client *source_p, int tkline_time,
76 const char *user, const char *host, const char *reason);
77 static void apply_kline(struct Client *source_p, struct ConfItem *aconf,
78 const char *reason, const char *oper_reason);
79 static void apply_tkline(struct Client *source_p, struct ConfItem *aconf,
80 const char *, const char *, int);
81 static int already_placed_kline(struct Client *, const char *, const char *, int);
82
83 static void handle_remote_unkline(struct Client *source_p, const char *user, const char *host);
84 static void remove_permkline_match(struct Client *, struct ConfItem *);
85 static int remove_temp_kline(struct Client *, struct ConfItem *);
86
87 /* mo_kline()
88 *
89 * parv[1] - temp time or user@host
90 * parv[2] - user@host, "ON", or reason
91 * parv[3] - "ON", reason, or server to target
92 * parv[4] - server to target, or reason
93 * parv[5] - reason
94 */
95 static int
96 mo_kline(struct Client *client_p, struct Client *source_p, int parc, const char **parv)
97 {
98 char def[] = "No Reason";
99 char user[USERLEN + 2];
100 char host[HOSTLEN + 2];
101 char *reason = def;
102 char *oper_reason;
103 const char *target_server = NULL;
104 struct ConfItem *aconf;
105 int tkline_time = 0;
106 int loc = 1;
107
108 if(!IsOperK(source_p))
109 {
110 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "kline");
111 return 0;
112 }
113
114 if((tkline_time = valid_temp_time(parv[loc])) >= 0)
115 loc++;
116 /* we just set tkline_time to -1! */
117 else
118 tkline_time = 0;
119
120 if(find_user_host(source_p, parv[loc], user, host) == 0)
121 return 0;
122
123 loc++;
124
125 if(parc >= loc + 2 && !irccmp(parv[loc], "ON"))
126 {
127 if(!IsOperRemoteBan(source_p))
128 {
129 sendto_one(source_p, form_str(ERR_NOPRIVS),
130 me.name, source_p->name, "remoteban");
131 return 0;
132 }
133
134 target_server = parv[loc + 1];
135 loc += 2;
136 }
137
138 if(parc <= loc || EmptyString(parv[loc]))
139 {
140 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
141 me.name, source_p->name, "KLINE");
142 return 0;
143 }
144
145 reason = LOCAL_COPY(parv[loc]);
146
147 if(target_server != NULL)
148 {
149 propagate_generic(source_p, "KLINE", target_server, CAP_KLN,
150 "%d %s %s :%s", tkline_time, user, host, reason);
151
152 /* If we are sending it somewhere that doesnt include us, stop */
153 if(!match(target_server, me.name))
154 return 0;
155 }
156 /* if we have cluster servers, send it to them.. */
157 else if(rb_dlink_list_length(&cluster_conf_list) > 0)
158 cluster_generic(source_p, "KLINE",
159 (tkline_time > 0) ? SHARED_TKLINE : SHARED_PKLINE, CAP_KLN,
160 "%lu %s %s :%s", tkline_time, user, host, reason);
161
162 if(!valid_user_host(source_p, user, host) ||
163 !valid_wild_card(source_p, user, host) || !valid_comment(source_p, reason))
164 return 0;
165
166 if(already_placed_kline(source_p, user, host, tkline_time))
167 return 0;
168
169 rb_set_time();
170 aconf = make_conf();
171 aconf->status = CONF_KILL;
172 aconf->created = rb_current_time();
173 aconf->host = rb_strdup(host);
174 aconf->user = rb_strdup(user);
175 aconf->port = 0;
176 aconf->passwd = rb_strdup(reason);
177
178 /* Look for an oper reason */
179 if((oper_reason = strchr(reason, '|')) != NULL)
180 {
181 *oper_reason = '\0';
182 oper_reason++;
183
184 if(!EmptyString(oper_reason))
185 aconf->spasswd = rb_strdup(oper_reason);
186 }
187
188 if(tkline_time > 0)
189 apply_tkline(source_p, aconf, reason, oper_reason, tkline_time);
190 else
191 apply_kline(source_p, aconf, reason, oper_reason);
192
193 if(ConfigFileEntry.kline_delay)
194 {
195 if(kline_queued == 0)
196 {
197 rb_event_addonce("check_klines", check_klines_event, NULL,
198 ConfigFileEntry.kline_delay);
199 kline_queued = 1;
200 }
201 }
202 else
203 check_klines();
204
205 return 0;
206 }
207
208 /* ms_kline()
209 *
210 * parv[1] - server targeted at
211 * parv[2] - tkline time (0 if perm)
212 * parv[3] - user
213 * parv[4] - host
214 * parv[5] - reason
215 */
216 static int
217 ms_kline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
218 {
219 int tkline_time = atoi(parv[2]);
220
221 /* 1.5-3 and earlier contains a bug that allows remote klines to be
222 * sent with an empty reason field. This is a protocol violation,
223 * but its not worth dropping the link over.. --anfl
224 */
225 if(parc < 6 || EmptyString(parv[5]))
226 return 0;
227
228 propagate_generic(source_p, "KLINE", parv[1], CAP_KLN,
229 "%d %s %s :%s", tkline_time, parv[3], parv[4], parv[5]);
230
231 if(!match(parv[1], me.name))
232 return 0;
233
234 if(!IsPerson(source_p))
235 return 0;
236
237 handle_remote_kline(source_p, tkline_time, parv[3], parv[4], parv[5]);
238 return 0;
239 }
240
241 static int
242 me_kline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
243 {
244 /* <tkline_time> <user> <host> :<reason> */
245 if(!IsPerson(source_p))
246 return 0;
247
248 handle_remote_kline(source_p, atoi(parv[1]), parv[2], parv[3], parv[4]);
249 return 0;
250 }
251
252 static void
253 handle_remote_kline(struct Client *source_p, int tkline_time,
254 const char *user, const char *host, const char *kreason)
255 {
256 char *reason = LOCAL_COPY(kreason);
257 struct ConfItem *aconf = NULL;
258 char *oper_reason;
259
260 if(!find_shared_conf(source_p->username, source_p->host,
261 source_p->servptr->name,
262 (tkline_time > 0) ? SHARED_TKLINE : SHARED_PKLINE))
263 return;
264
265 if(!valid_user_host(source_p, user, host) ||
266 !valid_wild_card(source_p, user, host) || !valid_comment(source_p, reason))
267 return;
268
269 if(already_placed_kline(source_p, user, host, tkline_time))
270 return;
271
272 aconf = make_conf();
273
274 aconf->status = CONF_KILL;
275 aconf->created = rb_current_time();
276 aconf->user = rb_strdup(user);
277 aconf->host = rb_strdup(host);
278 aconf->passwd = rb_strdup(reason);
279
280 /* Look for an oper reason */
281 if((oper_reason = strchr(reason, '|')) != NULL)
282 {
283 *oper_reason = '\0';
284 oper_reason++;
285
286 if(!EmptyString(oper_reason))
287 aconf->spasswd = rb_strdup(oper_reason);
288 }
289
290 if(tkline_time > 0)
291 apply_tkline(source_p, aconf, reason, oper_reason, tkline_time);
292 else
293 apply_kline(source_p, aconf, reason, oper_reason);
294
295 if(ConfigFileEntry.kline_delay)
296 {
297 if(kline_queued == 0)
298 {
299 rb_event_addonce("check_klines", check_klines_event, NULL,
300 ConfigFileEntry.kline_delay);
301 kline_queued = 1;
302 }
303 }
304 else
305 check_klines();
306
307 return;
308 }
309
310 /* mo_unkline()
311 *
312 * parv[1] - kline to remove
313 * parv[2] - optional "ON"
314 * parv[3] - optional target server
315 */
316 static int
317 mo_unkline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
318 {
319 const char *user;
320 char *host;
321 char splat[] = "*";
322 char *h = LOCAL_COPY(parv[1]);
323 struct ConfItem *aconf;
324
325 if(!IsOperUnkline(source_p))
326 {
327 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "unkline");
328 return 0;
329 }
330
331 if((host = strchr(h, '@')) || *h == '*' || strchr(h, '.') || strchr(h, ':'))
332 {
333 /* Explicit user@host mask given */
334
335 if(host) /* Found user@host */
336 {
337 *host++ = '\0';
338
339 /* check for @host */
340 if(*h)
341 user = h;
342 else
343 user = splat;
344
345 /* check for user@ */
346 if(!*host)
347 host = splat;
348 }
349 else
350 {
351 user = splat; /* no @ found, assume its *@somehost */
352 host = h;
353 }
354 }
355 else
356 {
357 sendto_one_notice(source_p, ":Invalid parameters");
358 return 0;
359 }
360
361 /* possible remote kline.. */
362 if((parc > 3) && (irccmp(parv[2], "ON") == 0))
363 {
364 if(!IsOperRemoteBan(source_p))
365 {
366 sendto_one(source_p, form_str(ERR_NOPRIVS),
367 me.name, source_p->name, "remoteban");
368 return 0;
369 }
370
371 propagate_generic(source_p, "UNKLINE", parv[3], CAP_UNKLN, "%s %s", user, host);
372
373 if(match(parv[3], me.name) == 0)
374 return 0;
375 }
376 else if(rb_dlink_list_length(&cluster_conf_list) > 0)
377 cluster_generic(source_p, "UNKLINE", SHARED_UNKLINE, CAP_UNKLN,
378 "%s %s", user, host);
379
380 aconf = find_exact_conf_by_address(host, CONF_KILL, user);
381 if(aconf == NULL)
382 {
383 sendto_one_notice(source_p, ":No K-Line for %s@%s", user, host);
384 return 0;
385 }
386
387 if(remove_temp_kline(source_p, aconf))
388 return 0;
389
390 remove_permkline_match(source_p, aconf);
391
392 return 0;
393 }
394
395 /* ms_unkline()
396 *
397 * parv[1] - target server
398 * parv[2] - user to unkline
399 * parv[3] - host to unkline
400 */
401 static int
402 ms_unkline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
403 {
404 /* parv[0] parv[1] parv[2] parv[3]
405 * oper target server user host */
406 propagate_generic(source_p, "UNKLINE", parv[1], CAP_UNKLN, "%s %s", parv[2], parv[3]);
407
408 if(!match(parv[1], me.name))
409 return 0;
410
411 if(!IsPerson(source_p))
412 return 0;
413
414 handle_remote_unkline(source_p, parv[2], parv[3]);
415 return 0;
416 }
417
418 static int
419 me_unkline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
420 {
421 /* user host */
422 if(!IsPerson(source_p))
423 return 0;
424
425 handle_remote_unkline(source_p, parv[1], parv[2]);
426 return 0;
427 }
428
429 static void
430 handle_remote_unkline(struct Client *source_p, const char *user, const char *host)
431 {
432 struct ConfItem *aconf;
433
434 if(!find_shared_conf(source_p->username, source_p->host,
435 source_p->servptr->name, SHARED_UNKLINE))
436 return;
437
438 aconf = find_exact_conf_by_address(host, CONF_KILL, user);
439 if(aconf == NULL)
440 {
441 sendto_one_notice(source_p, ":No K-Line for %s@%s", user, host);
442 return;
443 }
444
445 if(remove_temp_kline(source_p, aconf))
446 return;
447
448 remove_permkline_match(source_p, aconf);
449 }
450
451 /* apply_kline()
452 *
453 * inputs -
454 * output - NONE
455 * side effects - kline as given, is added to the hashtable
456 * and conf file
457 */
458 static void
459 apply_kline(struct Client *source_p, struct ConfItem *aconf,
460 const char *reason, const char *oper_reason)
461 {
462 add_conf_by_address(aconf->host, CONF_KILL, aconf->user, NULL, aconf);
463 bandb_add(BANDB_KLINE, source_p, aconf->user, aconf->host,
464 reason, EmptyString(oper_reason) ? NULL : oper_reason, 0);
465
466 /* no oper reason.. */
467 if(EmptyString(oper_reason))
468 {
469 sendto_realops_snomask(SNO_GENERAL, L_ALL,
470 "%s added K-Line for [%s@%s] [%s]",
471 get_oper_name(source_p), aconf->user, aconf->host, reason);
472 ilog(L_KLINE, "K %s 0 %s %s %s",
473 get_oper_name(source_p), aconf->user, aconf->host, reason);
474 }
475 else
476 {
477 sendto_realops_snomask(SNO_GENERAL, L_ALL,
478 "%s added K-Line for [%s@%s] [%s|%s]",
479 get_oper_name(source_p), aconf->user, aconf->host,
480 reason, oper_reason);
481 ilog(L_KLINE, "K %s 0 %s %s %s|%s",
482 get_oper_name(source_p), aconf->user, aconf->host, reason, oper_reason);
483 }
484
485 sendto_one_notice(source_p, ":Added K-Line [%s@%s]",
486 aconf->user, aconf->host);
487 }
488
489 /* apply_tkline()
490 *
491 * inputs -
492 * output - NONE
493 * side effects - tkline as given is placed
494 */
495 static void
496 apply_tkline(struct Client *source_p, struct ConfItem *aconf,
497 const char *reason, const char *oper_reason, int tkline_time)
498 {
499 aconf->hold = rb_current_time() + tkline_time;
500 add_temp_kline(aconf);
501
502 /* no oper reason.. */
503 if(EmptyString(oper_reason))
504 {
505 sendto_realops_snomask(SNO_GENERAL, L_ALL,
506 "%s added temporary %d min. K-Line for [%s@%s] [%s]",
507 get_oper_name(source_p), tkline_time / 60,
508 aconf->user, aconf->host, reason);
509 ilog(L_KLINE, "K %s %d %s %s %s",
510 get_oper_name(source_p), tkline_time / 60, aconf->user, aconf->host, reason);
511 }
512 else
513 {
514 sendto_realops_snomask(SNO_GENERAL, L_ALL,
515 "%s added temporary %d min. K-Line for [%s@%s] [%s|%s]",
516 get_oper_name(source_p), tkline_time / 60,
517 aconf->user, aconf->host, reason, oper_reason);
518 ilog(L_KLINE, "K %s %d %s %s %s|%s",
519 get_oper_name(source_p), tkline_time / 60,
520 aconf->user, aconf->host, reason, oper_reason);
521 }
522
523 sendto_one_notice(source_p, ":Added temporary %d min. K-Line [%s@%s]",
524 tkline_time / 60, aconf->user, aconf->host);
525 }
526
527 /* find_user_host()
528 *
529 * inputs - client placing kline, user@host, user buffer, host buffer
530 * output - 0 if not ok to kline, 1 to kline i.e. if valid user host
531 * side effects -
532 */
533 static int
534 find_user_host(struct Client *source_p, const char *userhost, char *luser, char *lhost)
535 {
536 char *hostp;
537
538 hostp = strchr(userhost, '@');
539
540 if(hostp != NULL) /* I'm a little user@host */
541 {
542 *(hostp++) = '\0'; /* short and squat */
543 if(*userhost)
544 rb_strlcpy(luser, userhost, USERLEN + 1); /* here is my user */
545 else
546 strcpy(luser, "*");
547 if(*hostp)
548 rb_strlcpy(lhost, hostp, HOSTLEN + 1); /* here is my host */
549 else
550 strcpy(lhost, "*");
551 }
552 else
553 {
554 /* no '@', no '.', so its not a user@host or host, therefore
555 * its a nick, which support was removed for.
556 */
557 if(strchr(userhost, '.') == NULL && strchr(userhost, ':') == NULL)
558 {
559 sendto_one_notice(source_p, ":K-Line must be a user@host or host");
560 return 0;
561 }
562
563 luser[0] = '*'; /* no @ found, assume its *@somehost */
564 luser[1] = '\0';
565 rb_strlcpy(lhost, userhost, HOSTLEN + 1);
566 }
567
568 return 1;
569 }
570
571 /* valid_user_host()
572 *
573 * inputs - user buffer, host buffer
574 * output - 0 if invalid, 1 if valid
575 * side effects -
576 */
577 static int
578 valid_user_host(struct Client *source_p, const char *luser, const char *lhost)
579 {
580 /* # is invalid, as are '!' (n!u@h kline) and '@' (u@@h kline) */
581 if(strchr(lhost, '#') || strchr(luser, '#') || strchr(luser, '!') || strchr(lhost, '@'))
582 {
583 sendto_one_notice(source_p, ":Invalid K-Line");
584 return 0;
585 }
586
587 return 1;
588 }
589
590 /* valid_wild_card()
591 *
592 * input - user buffer, host buffer
593 * output - 0 if invalid, 1 if valid
594 * side effects -
595 */
596 static int
597 valid_wild_card(struct Client *source_p, const char *luser, const char *lhost)
598 {
599 const char *p;
600 char tmpch;
601 int nonwild = 0;
602 int bitlen;
603
604 /* user has no wildcards, always accept -- jilles */
605 if(!strchr(luser, '?') && !strchr(luser, '*'))
606 return 1;
607
608 /* check there are enough non wildcard chars */
609 p = luser;
610 while((tmpch = *p++))
611 {
612 if(!IsKWildChar(tmpch))
613 {
614 /* found enough chars, return */
615 if(++nonwild >= ConfigFileEntry.min_nonwildcard)
616 return 1;
617 }
618 }
619
620 /* try host, as user didnt contain enough */
621 /* special case for cidr masks -- jilles */
622 if((p = strrchr(lhost, '/')) != NULL && IsDigit(p[1]))
623 {
624 bitlen = atoi(p + 1);
625 /* much like non-cidr for ipv6, rather arbitrary for ipv4 */
626 if(bitlen > 0
627 && bitlen >=
628 (strchr(lhost, ':') ? 4 * (ConfigFileEntry.min_nonwildcard - nonwild) : 6 -
629 2 * nonwild))
630 return 1;
631 }
632 else
633 {
634 p = lhost;
635 while((tmpch = *p++))
636 {
637 if(!IsKWildChar(tmpch))
638 if(++nonwild >= ConfigFileEntry.min_nonwildcard)
639 return 1;
640 }
641 }
642
643 sendto_one_notice(source_p,
644 ":Please include at least %d non-wildcard "
645 "characters with the user@host", ConfigFileEntry.min_nonwildcard);
646 return 0;
647 }
648
649 /*
650 * valid_comment
651 * inputs - pointer to client
652 * - pointer to comment
653 * output - 0 if no valid comment, 1 if valid
654 * side effects - NONE
655 */
656 static int
657 valid_comment(struct Client *source_p, char *comment)
658 {
659 if(strchr(comment, '"'))
660 {
661 sendto_one_notice(source_p, ":Invalid character '\"' in comment");
662 return 0;
663 }
664
665 if(strlen(comment) > BANREASONLEN)
666 comment[BANREASONLEN] = '\0';
667
668 return 1;
669 }
670
671 /* already_placed_kline()
672 *
673 * inputs - source to notify, user@host to check, tkline time
674 * outputs - 1 if a perm kline or a tkline when a tkline is being
675 * set exists, else 0
676 * side effects - notifies source_p kline exists
677 */
678 /* Note: This currently works if the new K-line is a special case of an
679 * existing K-line, but not the other way round. To do that we would
680 * have to walk the hash and check every existing K-line. -A1kmm.
681 */
682 static int
683 already_placed_kline(struct Client *source_p, const char *luser, const char *lhost, int tkline)
684 {
685 const char *reason, *p;
686 struct rb_sockaddr_storage iphost, *piphost;
687 struct ConfItem *aconf;
688 int t, bits;
689
690 aconf = find_exact_conf_by_address(lhost, CONF_KILL, luser);
691 if(aconf == NULL && ConfigFileEntry.non_redundant_klines)
692 {
693 bits = 0;
694 if((t = parse_netmask(lhost, (struct sockaddr *) &iphost, &bits)) != HM_HOST)
695 {
696 #ifdef RB_IPV6
697 if(t == HM_IPV6)
698 t = AF_INET6;
699 else
700 #endif
701 t = AF_INET;
702
703 piphost = &iphost;
704 }
705 else
706 piphost = NULL;
707
708 aconf = find_conf_by_address(lhost, NULL, NULL, (struct sockaddr *) piphost,
709 CONF_KILL, t, luser, NULL);
710 if(aconf != NULL)
711 {
712 /* The above was really a lookup of a single IP,
713 * so check if the new kline is wider than the
714 * existing one.
715 * -- jilles
716 */
717 p = strchr(aconf->host, '/');
718 if(bits > 0 && (p == NULL || bits < atoi(p + 1)))
719 aconf = NULL;
720 }
721 }
722 if(aconf != NULL)
723 {
724 /* setting a tkline, or existing one is perm */
725 if(tkline || ((aconf->flags & CONF_FLAGS_TEMPORARY) == 0))
726 {
727 reason = aconf->passwd ? aconf->passwd : "<No Reason>";
728
729 sendto_one_notice(source_p,
730 ":[%s@%s] already K-Lined by [%s@%s] - %s",
731 luser, lhost, aconf->user, aconf->host, reason);
732 return 1;
733 }
734 }
735
736 return 0;
737 }
738
739 /* remove_permkline_match()
740 *
741 * hunts for a permanent kline, and removes it.
742 */
743 static void
744 remove_permkline_match(struct Client *source_p, struct ConfItem *aconf)
745 {
746 sendto_one_notice(source_p, ":K-Line for [%s@%s] is removed", aconf->user, aconf->host);
747
748 sendto_realops_snomask(SNO_GENERAL, L_ALL,
749 "%s has removed the K-Line for: [%s@%s]",
750 get_oper_name(source_p), aconf->user, aconf->host);
751
752 ilog(L_KLINE, "UK %s %s %s", get_oper_name(source_p), aconf->user, aconf->host);
753
754 remove_reject_mask(aconf->user, aconf->host);
755 bandb_del(BANDB_KLINE, aconf->user, aconf->host);
756 delete_one_address_conf(aconf->host, aconf);
757
758 return;
759 }
760
761 /* remove_temp_kline()
762 *
763 * inputs - username, hostname to unkline
764 * outputs -
765 * side effects - tries to unkline anything that matches
766 */
767 static int
768 remove_temp_kline(struct Client *source_p, struct ConfItem *aconf)
769 {
770 rb_dlink_node *ptr;
771 int i;
772
773 for(i = 0; i < LAST_TEMP_TYPE; i++)
774 {
775 RB_DLINK_FOREACH(ptr, temp_klines[i].head)
776 {
777 if(aconf == ptr->data)
778 {
779 sendto_one_notice(source_p,
780 ":Un-klined [%s@%s] from temporary k-lines",
781 aconf->user, aconf->host);
782 sendto_realops_snomask(SNO_GENERAL, L_ALL,
783 "%s has removed the temporary K-Line for: [%s@%s]",
784 get_oper_name(source_p), aconf->user,
785 aconf->host);
786
787 ilog(L_KLINE, "UK %s %s %s",
788 get_oper_name(source_p), aconf->user, aconf->host);
789 rb_dlinkDestroy(ptr, &temp_klines[i]);
790 remove_reject_mask(aconf->user, aconf->host);
791 delete_one_address_conf(aconf->host, aconf);
792 return YES;
793 }
794 }
795 }
796
797 return NO;
798 }