2 * ircd-ratbox: A slightly useful ircd.
3 * m_kline.c: Bans/unbans a user.
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
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.
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.
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
34 #include "s_newconf.h"
46 static const char kline_desc
[] = "Provides the KLINE facility to ban users via hostmask";
48 static void mo_kline(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
49 static void ms_kline(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
50 static void me_kline(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
51 static void mo_unkline(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
52 static void ms_unkline(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
53 static void me_unkline(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
55 struct Message kline_msgtab
= {
57 {mg_unreg
, mg_not_oper
, {ms_kline
, 5}, {ms_kline
, 5}, {me_kline
, 5}, {mo_kline
, 3}}
60 struct Message unkline_msgtab
= {
61 "UNKLINE", 0, 0, 0, 0,
62 {mg_unreg
, mg_not_oper
, {ms_unkline
, 4}, {ms_unkline
, 4}, {me_unkline
, 3}, {mo_unkline
, 2}}
65 mapi_clist_av1 kline_clist
[] = { &kline_msgtab
, &unkline_msgtab
, NULL
};
67 DECLARE_MODULE_AV2(kline
, NULL
, NULL
, kline_clist
, NULL
, NULL
, NULL
, NULL
, kline_desc
);
69 /* Local function prototypes */
70 static bool find_user_host(struct Client
*source_p
, const char *userhost
, char *user
, char *host
);
71 static bool valid_user_host(struct Client
*source_p
, const char *user
, const char *host
);
73 static void handle_remote_kline(struct Client
*source_p
, int tkline_time
,
74 const char *user
, const char *host
, const char *reason
);
75 static void apply_kline(struct Client
*source_p
, struct ConfItem
*aconf
,
76 const char *reason
, const char *oper_reason
);
77 static void apply_tkline(struct Client
*source_p
, struct ConfItem
*aconf
,
78 const char *, const char *, int);
79 static void apply_prop_kline(struct Client
*source_p
, struct ConfItem
*aconf
,
80 const char *, const char *, int);
81 static bool already_placed_kline(struct Client
*, const char *, const char *, int);
83 static void handle_remote_unkline(struct Client
*source_p
, const char *user
, const char *host
);
84 static void remove_superseded_klines(const char *user
, const char *host
);
85 static void remove_permkline_match(struct Client
*, struct ConfItem
*);
86 static bool remove_temp_kline(struct Client
*, struct ConfItem
*);
87 static void remove_prop_kline(struct Client
*, struct ConfItem
*);
90 is_local_kline(struct ConfItem
*aconf
)
92 return aconf
->lifetime
== 0;
96 is_temporary_kline(struct ConfItem
*aconf
)
98 return aconf
->lifetime
== 0 && (aconf
->flags
& CONF_FLAGS_TEMPORARY
);
104 * parv[1] - temp time or user@host
105 * parv[2] - user@host, "ON", or reason
106 * parv[3] - "ON", reason, or server to target
107 * parv[4] - server to target, or reason
111 mo_kline(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char **parv
)
113 char def
[] = "No Reason";
114 char user
[USERLEN
+ 2];
115 char host_buf
[HOSTLEN
+ 3], *host
= host_buf
+ 1;
118 const char *target_server
= NULL
;
119 struct ConfItem
*aconf
;
122 bool propagated
= ConfigFileEntry
.use_propagated_bans
;
124 if(!IsOperK(source_p
))
126 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
, source_p
->name
, "kline");
130 if((tkline_time
= valid_temp_time(parv
[loc
])) >= 0)
132 /* we just set tkline_time to -1! */
136 if(find_user_host(source_p
, parv
[loc
], user
, host
) == 0)
147 if(parc
>= loc
+ 2 && !irccmp(parv
[loc
], "ON"))
149 if(!IsOperRemoteBan(source_p
))
151 sendto_one(source_p
, form_str(ERR_NOPRIVS
),
152 me
.name
, source_p
->name
, "remoteban");
156 target_server
= parv
[loc
+ 1];
160 if(parc
<= loc
|| EmptyString(parv
[loc
]))
162 sendto_one(source_p
, form_str(ERR_NEEDMOREPARAMS
),
163 me
.name
, source_p
->name
, "KLINE");
167 reason
= LOCAL_COPY(parv
[loc
]);
168 if(strlen(reason
) > BANREASONLEN
)
170 sendto_one_notice(source_p
, ":K-Line reason exceeds %d characters", BANREASONLEN
);
174 if(parse_netmask_strict(host
, NULL
, NULL
) == HM_ERROR
)
176 sendto_one_notice(source_p
,
177 ":[%s@%s] looks like an ill-formed IP K-line, refusing to set it",
182 if(target_server
!= NULL
)
185 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
186 "%s is adding a temporary %d min. K-Line for [%s@%s] on %s [%s]",
187 get_oper_name(source_p
), tkline_time
/ 60, user
, host
, target_server
, reason
);
189 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
190 "%s is adding a K-Line for [%s@%s] on %s [%s]",
191 get_oper_name(source_p
), user
, host
, target_server
, reason
);
193 propagate_generic(source_p
, "KLINE", target_server
, CAP_KLN
,
194 "%d %s %s :%s", tkline_time
, user
, host
, reason
);
196 /* If we are sending it somewhere that doesnt include us, stop */
197 if(!match(target_server
, me
.name
))
200 /* Set as local-only. */
203 /* if we have cluster servers, send it to them.. */
204 else if(!propagated
&& rb_dlink_list_length(&cluster_conf_list
) > 0)
205 cluster_generic(source_p
, "KLINE",
206 (tkline_time
> 0) ? SHARED_TKLINE
: SHARED_PKLINE
, CAP_KLN
,
207 "%lu %s %s :%s", tkline_time
, user
, host
, reason
);
209 if(!valid_user_host(source_p
, user
, host
))
212 if(!valid_wild_card(user
, host
))
214 sendto_one_notice(source_p
,
215 ":Please include at least %d non-wildcard "
216 "characters with the user@host",
217 ConfigFileEntry
.min_nonwildcard
);
221 if(propagated
&& tkline_time
== 0)
223 sendto_one_notice(source_p
, ":Cannot set a permanent global ban");
227 if(already_placed_kline(source_p
, user
, host
, tkline_time
))
231 remove_superseded_klines(user
, host
);
235 aconf
->status
= CONF_KILL
;
236 aconf
->created
= rb_current_time();
237 aconf
->host
= rb_strdup(host
);
238 aconf
->user
= rb_strdup(user
);
240 aconf
->info
.oper
= operhash_add(get_oper_name(source_p
));
242 /* Look for an oper reason */
243 if((oper_reason
= strchr(reason
, '|')) != NULL
)
248 if(!EmptyString(oper_reason
))
249 aconf
->spasswd
= rb_strdup(oper_reason
);
251 aconf
->passwd
= rb_strdup(reason
);
254 apply_prop_kline(source_p
, aconf
, reason
, oper_reason
, tkline_time
);
255 else if(tkline_time
> 0)
256 apply_tkline(source_p
, aconf
, reason
, oper_reason
, tkline_time
);
258 apply_kline(source_p
, aconf
, reason
, oper_reason
);
260 check_one_kline(aconf
);
265 * parv[1] - server targeted at
266 * parv[2] - tkline time (0 if perm)
272 ms_kline(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
274 int tkline_time
= atoi(parv
[2]);
276 /* 1.5-3 and earlier contains a bug that allows remote klines to be
277 * sent with an empty reason field. This is a protocol violation,
278 * but its not worth dropping the link over.. --anfl
280 if(parc
< 6 || EmptyString(parv
[5]))
283 propagate_generic(source_p
, "KLINE", parv
[1], CAP_KLN
,
284 "%d %s %s :%s", tkline_time
, parv
[3], parv
[4], parv
[5]);
286 if(!match(parv
[1], me
.name
))
289 if(!IsPerson(source_p
))
292 handle_remote_kline(source_p
, tkline_time
, parv
[3], parv
[4], parv
[5]);
296 me_kline(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
298 /* <tkline_time> <user> <host> :<reason> */
299 if(!IsPerson(source_p
))
302 handle_remote_kline(source_p
, atoi(parv
[1]), parv
[2], parv
[3], parv
[4]);
306 handle_remote_kline(struct Client
*source_p
, int tkline_time
,
307 const char *user
, const char *host
, const char *kreason
)
309 char *reason
= LOCAL_COPY(kreason
);
310 struct ConfItem
*aconf
= NULL
;
313 if(!valid_user_host(source_p
, user
, host
))
316 if(!valid_wild_card(user
, host
))
318 sendto_one_notice(source_p
,
319 ":Please include at least %d non-wildcard "
320 "characters with the user@host",
321 ConfigFileEntry
.min_nonwildcard
);
325 if(already_placed_kline(source_p
, user
, host
, tkline_time
))
328 remove_superseded_klines(user
, host
);
332 aconf
->status
= CONF_KILL
;
333 aconf
->created
= rb_current_time();
334 aconf
->user
= rb_strdup(user
);
335 aconf
->host
= rb_strdup(host
);
336 aconf
->info
.oper
= operhash_add(get_oper_name(source_p
));
338 if(strlen(reason
) > BANREASONLEN
)
339 reason
[BANREASONLEN
] = '\0';
341 /* Look for an oper reason */
342 if((oper_reason
= strchr(reason
, '|')) != NULL
)
347 if(!EmptyString(oper_reason
))
348 aconf
->spasswd
= rb_strdup(oper_reason
);
350 aconf
->passwd
= rb_strdup(reason
);
353 apply_tkline(source_p
, aconf
, reason
, oper_reason
, tkline_time
);
355 apply_kline(source_p
, aconf
, reason
, oper_reason
);
357 check_one_kline(aconf
);
362 * parv[1] - kline to remove
363 * parv[2] - optional "ON"
364 * parv[3] - optional target server
367 mo_unkline(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
372 char *h
= LOCAL_COPY(parv
[1]);
373 struct ConfItem
*aconf
;
374 bool propagated
= true;
376 if(!IsOperUnkline(source_p
))
378 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
, source_p
->name
, "unkline");
382 if((host
= strchr(h
, '@')) || *h
== '*' || strchr(h
, '.') || strchr(h
, ':'))
384 /* Explicit user@host mask given */
386 if(host
) /* Found user@host */
390 /* check for @host */
396 /* check for user@ */
402 user
= splat
; /* no @ found, assume its *@somehost */
408 sendto_one_notice(source_p
, ":Invalid parameters");
412 /* possible remote kline.. */
413 if((parc
> 3) && (irccmp(parv
[2], "ON") == 0))
415 if(!IsOperRemoteBan(source_p
))
417 sendto_one(source_p
, form_str(ERR_NOPRIVS
),
418 me
.name
, source_p
->name
, "remoteban");
422 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
, "%s is removing the K-Line for [%s@%s] on %s",
423 get_oper_name(source_p
), user
, host
, parv
[3]);
425 propagate_generic(source_p
, "UNKLINE", parv
[3], CAP_UNKLN
, "%s %s", user
, host
);
427 if(match(parv
[3], me
.name
) == 0)
433 aconf
= find_exact_conf_by_address(host
, CONF_KILL
, user
);
435 /* No clustering for removing a propagated kline */
436 if(propagated
&& (aconf
== NULL
|| !aconf
->lifetime
) &&
437 rb_dlink_list_length(&cluster_conf_list
) > 0)
438 cluster_generic(source_p
, "UNKLINE", SHARED_UNKLINE
, CAP_UNKLN
,
439 "%s %s", user
, host
);
441 bool removed_kline
= false;
443 while (aconf
= find_exact_conf_by_address_filtered(host
, CONF_KILL
, user
, is_local_kline
), aconf
!= NULL
)
445 removed_kline
= true;
447 if(remove_temp_kline(source_p
, aconf
))
450 remove_permkline_match(source_p
, aconf
);
453 aconf
= find_exact_conf_by_address(host
, CONF_KILL
, user
);
457 remove_prop_kline(source_p
, aconf
);
459 sendto_one_notice(source_p
, ":Cannot remove global K-Line %s@%s on specific servers", user
, host
);
461 else if (!removed_kline
)
463 sendto_one_notice(source_p
, ":No K-Line for %s@%s", user
, host
);
469 * parv[1] - target server
470 * parv[2] - user to unkline
471 * parv[3] - host to unkline
474 ms_unkline(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
476 /* parv[0] parv[1] parv[2] parv[3]
477 * oper target server user host */
478 propagate_generic(source_p
, "UNKLINE", parv
[1], CAP_UNKLN
, "%s %s", parv
[2], parv
[3]);
480 if(!match(parv
[1], me
.name
))
483 if(!IsPerson(source_p
))
486 handle_remote_unkline(source_p
, parv
[2], parv
[3]);
490 me_unkline(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
493 if(!IsPerson(source_p
))
496 handle_remote_unkline(source_p
, parv
[1], parv
[2]);
500 handle_remote_unkline(struct Client
*source_p
, const char *user
, const char *host
)
502 struct ConfItem
*aconf
;
503 bool removed_kline
= false;
505 while (aconf
= find_exact_conf_by_address_filtered(host
, CONF_KILL
, user
, is_local_kline
), aconf
!= NULL
)
507 removed_kline
= true;
509 if(remove_temp_kline(source_p
, aconf
))
512 remove_permkline_match(source_p
, aconf
);
515 if (find_exact_conf_by_address(host
, CONF_KILL
, user
))
516 sendto_one_notice(source_p
, ":Cannot remove global K-Line %s@%s on specific servers", user
, host
);
517 else if (!removed_kline
)
518 sendto_one_notice(source_p
, ":No K-Line for %s@%s", user
, host
);
525 * side effects - kline as given, is added to the hashtable
529 apply_kline(struct Client
*source_p
, struct ConfItem
*aconf
,
530 const char *reason
, const char *oper_reason
)
532 add_conf_by_address(aconf
->host
, CONF_KILL
, aconf
->user
, NULL
, aconf
);
533 bandb_add(BANDB_KLINE
, source_p
, aconf
->user
, aconf
->host
,
534 reason
, EmptyString(oper_reason
) ? NULL
: oper_reason
, 0);
536 /* no oper reason.. */
537 if(EmptyString(oper_reason
))
539 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
540 "%s added K-Line for [%s@%s] [%s]",
541 get_oper_name(source_p
), aconf
->user
, aconf
->host
, reason
);
542 ilog(L_KLINE
, "K %s 0 %s %s %s",
543 get_oper_name(source_p
), aconf
->user
, aconf
->host
, reason
);
547 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
548 "%s added K-Line for [%s@%s] [%s|%s]",
549 get_oper_name(source_p
), aconf
->user
, aconf
->host
,
550 reason
, oper_reason
);
551 ilog(L_KLINE
, "K %s 0 %s %s %s|%s",
552 get_oper_name(source_p
), aconf
->user
, aconf
->host
, reason
, oper_reason
);
555 sendto_one_notice(source_p
, ":Added K-Line [%s@%s]",
556 aconf
->user
, aconf
->host
);
563 * side effects - tkline as given is placed
566 apply_tkline(struct Client
*source_p
, struct ConfItem
*aconf
,
567 const char *reason
, const char *oper_reason
, int tkline_time
)
569 aconf
->hold
= rb_current_time() + tkline_time
;
570 add_temp_kline(aconf
);
572 /* no oper reason.. */
573 if(EmptyString(oper_reason
))
575 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
576 "%s added temporary %d min. K-Line for [%s@%s] [%s]",
577 get_oper_name(source_p
), tkline_time
/ 60,
578 aconf
->user
, aconf
->host
, reason
);
579 ilog(L_KLINE
, "K %s %d %s %s %s",
580 get_oper_name(source_p
), tkline_time
/ 60, aconf
->user
, aconf
->host
, reason
);
584 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
585 "%s added temporary %d min. K-Line for [%s@%s] [%s|%s]",
586 get_oper_name(source_p
), tkline_time
/ 60,
587 aconf
->user
, aconf
->host
, reason
, oper_reason
);
588 ilog(L_KLINE
, "K %s %d %s %s %s|%s",
589 get_oper_name(source_p
), tkline_time
/ 60,
590 aconf
->user
, aconf
->host
, reason
, oper_reason
);
593 sendto_one_notice(source_p
, ":Added temporary %d min. K-Line [%s@%s]",
594 tkline_time
/ 60, aconf
->user
, aconf
->host
);
598 apply_prop_kline(struct Client
*source_p
, struct ConfItem
*aconf
,
599 const char *reason
, const char *oper_reason
, int tkline_time
)
601 aconf
->flags
|= CONF_FLAGS_MYOPER
| CONF_FLAGS_TEMPORARY
;
602 aconf
->hold
= rb_current_time() + tkline_time
;
603 aconf
->lifetime
= aconf
->hold
;
605 replace_old_ban(aconf
);
608 add_conf_by_address(aconf
->host
, CONF_KILL
, aconf
->user
, NULL
, aconf
);
610 /* no oper reason.. */
611 if(EmptyString(oper_reason
))
613 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
614 "%s added global %d min. K-Line for [%s@%s] [%s]",
615 get_oper_name(source_p
), tkline_time
/ 60,
616 aconf
->user
, aconf
->host
, reason
);
617 ilog(L_KLINE
, "K %s %d %s %s %s",
618 get_oper_name(source_p
), tkline_time
/ 60, aconf
->user
, aconf
->host
, reason
);
622 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
623 "%s added global %d min. K-Line for [%s@%s] [%s|%s]",
624 get_oper_name(source_p
), tkline_time
/ 60,
625 aconf
->user
, aconf
->host
, reason
, oper_reason
);
626 ilog(L_KLINE
, "K %s %d %s %s %s|%s",
627 get_oper_name(source_p
), tkline_time
/ 60,
628 aconf
->user
, aconf
->host
, reason
, oper_reason
);
631 sendto_one_notice(source_p
, ":Added global %d min. K-Line [%s@%s]",
632 tkline_time
/ 60, aconf
->user
, aconf
->host
);
634 sendto_server(NULL
, NULL
, CAP_BAN
|CAP_TS6
, NOCAPS
,
635 ":%s BAN K %s %s %lu %d %d * :%s%s%s",
636 source_p
->id
, aconf
->user
, aconf
->host
,
637 (unsigned long)aconf
->created
,
638 (int)(aconf
->hold
- aconf
->created
),
639 (int)(aconf
->lifetime
- aconf
->created
),
641 oper_reason
? "|" : "",
642 oper_reason
? oper_reason
: "");
647 * inputs - client placing kline, user@host, user buffer, host buffer
648 * output - false if not ok to kline, true to kline i.e. if valid user host
652 find_user_host(struct Client
*source_p
, const char *userhost
, char *luser
, char *lhost
)
656 hostp
= strchr(userhost
, '@');
658 if(hostp
!= NULL
) /* I'm a little user@host */
660 *(hostp
++) = '\0'; /* short and squat */
662 rb_strlcpy(luser
, userhost
, USERLEN
+ 1); /* here is my user */
666 rb_strlcpy(lhost
, hostp
, HOSTLEN
+ 1); /* here is my host */
672 /* no '@', no '.', so its not a user@host or host, therefore
673 * its a nick, which support was removed for.
675 if(strchr(userhost
, '.') == NULL
&& strchr(userhost
, ':') == NULL
)
677 sendto_one_notice(source_p
, ":K-Line must be a user@host or host");
681 luser
[0] = '*'; /* no @ found, assume its *@somehost */
683 rb_strlcpy(lhost
, userhost
, HOSTLEN
+ 1);
686 /* would break the protocol */
687 if (*luser
== ':' || *lhost
== ':')
689 sendto_one_notice(source_p
, ":Invalid K-Line");
698 * inputs - user buffer, host buffer
699 * output - false if invalid, true if valid
703 valid_user_host(struct Client
*source_p
, const char *luser
, const char *lhost
)
705 /* # is invalid, as are '!' (n!u@h kline) and '@' (u@@h kline) */
706 if(strchr(lhost
, '#') || strchr(luser
, '#') || strchr(luser
, '!') || strchr(lhost
, '@'))
708 sendto_one_notice(source_p
, ":Invalid K-Line");
715 /* already_placed_kline()
717 * inputs - source to notify, user@host to check, tkline time
718 * outputs - true if a perm kline or a tkline when a tkline is being
719 * set exists, else false
720 * side effects - notifies source_p kline exists
722 /* Note: This currently works if the new K-line is a special case of an
723 * existing K-line, but not the other way round. To do that we would
724 * have to walk the hash and check every existing K-line. -A1kmm.
727 already_placed_kline(struct Client
*source_p
, const char *luser
, const char *lhost
, int tkline
)
729 const char *reason
, *p
;
730 struct rb_sockaddr_storage iphost
, *piphost
;
731 struct ConfItem
*aconf
;
734 aconf
= find_exact_conf_by_address(lhost
, CONF_KILL
, luser
);
735 if(aconf
== NULL
&& ConfigFileEntry
.non_redundant_klines
)
738 t
= parse_netmask_strict(lhost
, &iphost
, &bits
);
742 else if (t
== HM_IPV6
)
747 aconf
= find_conf_by_address(lhost
, NULL
, NULL
, (struct sockaddr
*) piphost
,
748 CONF_KILL
, t
, luser
, NULL
);
751 /* The above was really a lookup of a single IP,
752 * so check if the new kline is wider than the
756 p
= strchr(aconf
->host
, '/');
757 if(bits
> 0 && (p
== NULL
|| bits
< atoi(p
+ 1)))
765 /* allow klines to be duplicated by longer ones */
766 if ((aconf
->flags
& CONF_FLAGS_TEMPORARY
) &&
767 (tkline
== 0 || tkline
> aconf
->hold
- rb_current_time()))
770 reason
= aconf
->passwd
? aconf
->passwd
: "<No Reason>";
772 sendto_one_notice(source_p
,
773 ":[%s@%s] already K-Lined by [%s@%s] - %s",
774 luser
, lhost
, aconf
->user
, aconf
->host
, reason
);
779 remove_superseded_klines(const char *user
, const char *host
)
781 struct ConfItem
*aconf
;
783 while (aconf
= find_exact_conf_by_address_filtered(host
, CONF_KILL
, user
, is_temporary_kline
), aconf
!= NULL
)
788 for (i
= 0; i
< LAST_TEMP_TYPE
; i
++)
790 RB_DLINK_FOREACH(ptr
, temp_klines
[i
].head
)
792 if (aconf
== ptr
->data
)
794 rb_dlinkDestroy(ptr
, &temp_klines
[i
]);
795 delete_one_address_conf(aconf
->host
, aconf
);
803 /* remove_permkline_match()
805 * hunts for a permanent kline, and removes it.
808 remove_permkline_match(struct Client
*source_p
, struct ConfItem
*aconf
)
810 sendto_one_notice(source_p
, ":K-Line for [%s@%s] is removed", aconf
->user
, aconf
->host
);
812 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
813 "%s has removed the K-Line for: [%s@%s]",
814 get_oper_name(source_p
), aconf
->user
, aconf
->host
);
816 ilog(L_KLINE
, "UK %s %s %s", get_oper_name(source_p
), aconf
->user
, aconf
->host
);
818 remove_reject_mask(aconf
->user
, aconf
->host
);
819 bandb_del(BANDB_KLINE
, aconf
->user
, aconf
->host
);
820 delete_one_address_conf(aconf
->host
, aconf
);
823 /* remove_temp_kline()
825 * inputs - username, hostname to unkline
827 * side effects - tries to unkline anything that matches
830 remove_temp_kline(struct Client
*source_p
, struct ConfItem
*aconf
)
835 for(i
= 0; i
< LAST_TEMP_TYPE
; i
++)
837 RB_DLINK_FOREACH(ptr
, temp_klines
[i
].head
)
839 if(aconf
== ptr
->data
)
841 sendto_one_notice(source_p
,
842 ":Un-klined [%s@%s] from temporary k-lines",
843 aconf
->user
, aconf
->host
);
844 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
845 "%s has removed the temporary K-Line for: [%s@%s]",
846 get_oper_name(source_p
), aconf
->user
,
849 ilog(L_KLINE
, "UK %s %s %s",
850 get_oper_name(source_p
), aconf
->user
, aconf
->host
);
851 rb_dlinkDestroy(ptr
, &temp_klines
[i
]);
852 remove_reject_mask(aconf
->user
, aconf
->host
);
853 delete_one_address_conf(aconf
->host
, aconf
);
863 remove_prop_kline(struct Client
*source_p
, struct ConfItem
*aconf
)
867 if (!lookup_prop_ban(aconf
))
869 sendto_one_notice(source_p
,
870 ":Un-klined [%s@%s] from global k-lines",
871 aconf
->user
, aconf
->host
);
872 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
873 "%s has removed the global K-Line for: [%s@%s]",
874 get_oper_name(source_p
), aconf
->user
,
877 ilog(L_KLINE
, "UK %s %s %s",
878 get_oper_name(source_p
), aconf
->user
, aconf
->host
);
879 now
= rb_current_time();
880 if(aconf
->created
< now
)
881 aconf
->created
= now
;
884 aconf
->hold
= aconf
->created
;
885 operhash_delete(aconf
->info
.oper
);
886 aconf
->info
.oper
= operhash_add(get_oper_name(source_p
));
887 aconf
->flags
|= CONF_FLAGS_MYOPER
| CONF_FLAGS_TEMPORARY
;
888 sendto_server(NULL
, NULL
, CAP_BAN
|CAP_TS6
, NOCAPS
,
889 ":%s BAN K %s %s %lu %d %d * :*",
890 source_p
->id
, aconf
->user
, aconf
->host
,
891 (unsigned long)aconf
->created
,
893 (int)(aconf
->lifetime
- aconf
->created
));
894 remove_reject_mask(aconf
->user
, aconf
->host
);
895 deactivate_conf(aconf
, now
);