]>
Commit | Line | Data |
---|---|---|
212380e3 | 1 | /* modules/m_xline.c |
55abcbb2 | 2 | * |
212380e3 AC |
3 | * Copyright (C) 2002-2003 Lee Hardy <lee@leeh.co.uk> |
4 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are | |
8 | * met: | |
9 | * | |
10 | * 1.Redistributions of source code must retain the above copyright notice, | |
11 | * this list of conditions and the following disclaimer. | |
12 | * 2.Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * 3.The name of the author may not be used to endorse or promote products | |
16 | * derived from this software without specific prior written permission. | |
17 | * | |
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
21 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
27 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
28 | * POSSIBILITY OF SUCH DAMAGE. | |
212380e3 AC |
29 | */ |
30 | ||
31 | #include "stdinc.h" | |
212380e3 AC |
32 | #include "send.h" |
33 | #include "channel.h" | |
34 | #include "client.h" | |
35 | #include "common.h" | |
36 | #include "config.h" | |
37 | #include "class.h" | |
38 | #include "ircd.h" | |
39 | #include "numeric.h" | |
4016731b | 40 | #include "logger.h" |
212380e3 AC |
41 | #include "s_serv.h" |
42 | #include "whowas.h" | |
4562c604 | 43 | #include "match.h" |
212380e3 AC |
44 | #include "hash.h" |
45 | #include "msg.h" | |
46 | #include "parse.h" | |
47 | #include "modules.h" | |
48 | #include "s_conf.h" | |
49 | #include "s_newconf.h" | |
35f6f850 | 50 | #include "reject.h" |
8bbeb278 | 51 | #include "bandbi.h" |
27f616dd | 52 | #include "operhash.h" |
212380e3 | 53 | |
eeabf33a EM |
54 | static const char xline_desc[] = |
55 | "Provides management of GECOS bans via (UN)XLINE command"; | |
56 | ||
3c7d6fcc EM |
57 | static void mo_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); |
58 | static void ms_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); | |
59 | static void me_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); | |
60 | static void mo_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, | |
8bbeb278 | 61 | const char *parv[]); |
3c7d6fcc | 62 | static void ms_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, |
8bbeb278 | 63 | const char *parv[]); |
3c7d6fcc | 64 | static void me_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, |
8bbeb278 | 65 | const char *parv[]); |
212380e3 | 66 | |
3c7d6fcc | 67 | static bool valid_xline(struct Client *, const char *, const char *); |
8bbeb278 | 68 | static void apply_xline(struct Client *client_p, const char *name, |
f66f0baa | 69 | const char *reason, int temp_time, bool propagated); |
212380e3 | 70 | static void propagate_xline(struct Client *source_p, const char *target, |
8bbeb278 | 71 | int temp_time, const char *name, const char *type, const char *reason); |
212380e3 | 72 | static void cluster_xline(struct Client *source_p, int temp_time, |
8bbeb278 | 73 | const char *name, const char *reason); |
212380e3 AC |
74 | |
75 | static void handle_remote_xline(struct Client *source_p, int temp_time, | |
76 | const char *name, const char *reason); | |
77 | static void handle_remote_unxline(struct Client *source_p, const char *name); | |
3cbbfb25 | 78 | static void remove_xline(struct Client *source_p, const char *name, |
f66f0baa | 79 | bool propagated); |
212380e3 | 80 | |
eeabf33a EM |
81 | struct Message xline_msgtab = { |
82 | "XLINE", 0, 0, 0, 0, | |
83 | {mg_unreg, mg_not_oper, {ms_xline, 5}, {ms_xline, 5}, {me_xline, 5}, {mo_xline, 3}} | |
84 | }; | |
85 | ||
86 | struct Message unxline_msgtab = { | |
87 | "UNXLINE", 0, 0, 0, 0, | |
88 | {mg_unreg, mg_not_oper, {ms_unxline, 3}, {ms_unxline, 3}, {me_unxline, 2}, {mo_unxline, 2}} | |
89 | }; | |
90 | ||
91 | mapi_clist_av1 xline_clist[] = { &xline_msgtab, &unxline_msgtab, NULL }; | |
92 | ||
93 | DECLARE_MODULE_AV2(xline, NULL, NULL, xline_clist, NULL, NULL, NULL, NULL, xline_desc); | |
212380e3 AC |
94 | |
95 | /* m_xline() | |
96 | * | |
97 | * parv[1] - thing to xline | |
98 | * parv[2] - optional type/reason | |
99 | * parv[3] - reason | |
100 | */ | |
3c7d6fcc | 101 | static void |
428ca87b | 102 | mo_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
103 | { |
104 | struct ConfItem *aconf; | |
105 | const char *name; | |
106 | const char *reason; | |
107 | const char *target_server = NULL; | |
108 | int temp_time; | |
109 | int loc = 1; | |
f66f0baa | 110 | bool propagated = ConfigFileEntry.use_propagated_bans; |
212380e3 AC |
111 | |
112 | if(!IsOperXline(source_p)) | |
113 | { | |
8bbeb278 | 114 | sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "xline"); |
3c7d6fcc | 115 | return; |
212380e3 AC |
116 | } |
117 | ||
118 | if((temp_time = valid_temp_time(parv[loc])) >= 0) | |
119 | loc++; | |
120 | /* we just set temp_time to -1! */ | |
121 | else | |
122 | temp_time = 0; | |
123 | ||
124 | name = parv[loc]; | |
125 | loc++; | |
126 | ||
127 | /* XLINE <gecos> ON <server> :<reason> */ | |
8bbeb278 | 128 | if(parc >= loc + 2 && !irccmp(parv[loc], "ON")) |
212380e3 AC |
129 | { |
130 | if(!IsOperRemoteBan(source_p)) | |
131 | { | |
132 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
8bbeb278 | 133 | me.name, source_p->name, "remoteban"); |
3c7d6fcc | 134 | return; |
212380e3 AC |
135 | } |
136 | ||
8bbeb278 | 137 | target_server = parv[loc + 1]; |
212380e3 AC |
138 | loc += 2; |
139 | } | |
140 | ||
141 | if(parc <= loc || EmptyString(parv[loc])) | |
142 | { | |
143 | sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), | |
8bbeb278 | 144 | me.name, source_p->name, "XLINE"); |
3c7d6fcc | 145 | return; |
212380e3 AC |
146 | } |
147 | ||
148 | reason = parv[loc]; | |
149 | ||
150 | if(target_server != NULL) | |
151 | { | |
8bbeb278 | 152 | propagate_xline(source_p, target_server, temp_time, name, "2", reason); |
212380e3 AC |
153 | |
154 | if(!match(target_server, me.name)) | |
3c7d6fcc | 155 | return; |
3cbbfb25 JT |
156 | |
157 | /* Set as local-only. */ | |
f66f0baa | 158 | propagated = false; |
212380e3 | 159 | } |
3cbbfb25 | 160 | else if(!propagated && rb_dlink_list_length(&cluster_conf_list) > 0) |
8bbeb278 | 161 | cluster_xline(source_p, temp_time, name, reason); |
212380e3 | 162 | |
8bbeb278 | 163 | if((aconf = find_xline_mask(name)) != NULL) |
212380e3 AC |
164 | { |
165 | sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s", | |
23959371 | 166 | me.name, source_p->name, name, aconf->host, aconf->passwd); |
3c7d6fcc | 167 | return; |
212380e3 AC |
168 | } |
169 | ||
8bbeb278 | 170 | if(!valid_xline(source_p, name, reason)) |
3c7d6fcc | 171 | return; |
212380e3 | 172 | |
3cbbfb25 JT |
173 | if(propagated && temp_time == 0) |
174 | { | |
175 | sendto_one_notice(source_p, ":Cannot set a permanent global ban"); | |
3c7d6fcc | 176 | return; |
3cbbfb25 JT |
177 | } |
178 | ||
179 | apply_xline(source_p, name, reason, temp_time, propagated); | |
212380e3 AC |
180 | } |
181 | ||
182 | /* ms_xline() | |
183 | * | |
184 | * handles a remote xline | |
185 | */ | |
3c7d6fcc | 186 | static void |
428ca87b | 187 | ms_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 | 188 | { |
8bbeb278 AC |
189 | /* parv[0] parv[1] parv[2] parv[3] parv[4] |
190 | * oper target serv xline type reason | |
212380e3 AC |
191 | */ |
192 | propagate_xline(source_p, parv[1], 0, parv[2], parv[3], parv[4]); | |
193 | ||
194 | if(!IsPerson(source_p)) | |
3c7d6fcc | 195 | return; |
212380e3 AC |
196 | |
197 | /* destined for me? */ | |
198 | if(!match(parv[1], me.name)) | |
3c7d6fcc | 199 | return; |
212380e3 AC |
200 | |
201 | handle_remote_xline(source_p, 0, parv[2], parv[4]); | |
212380e3 AC |
202 | } |
203 | ||
3c7d6fcc | 204 | static void |
428ca87b | 205 | me_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
206 | { |
207 | /* time name type :reason */ | |
208 | if(!IsPerson(source_p)) | |
3c7d6fcc | 209 | return; |
212380e3 AC |
210 | |
211 | handle_remote_xline(source_p, atoi(parv[1]), parv[2], parv[4]); | |
212380e3 AC |
212 | } |
213 | ||
214 | static void | |
8bbeb278 | 215 | handle_remote_xline(struct Client *source_p, int temp_time, const char *name, const char *reason) |
212380e3 AC |
216 | { |
217 | struct ConfItem *aconf; | |
218 | ||
219 | if(!find_shared_conf(source_p->username, source_p->host, | |
8bbeb278 AC |
220 | source_p->servptr->name, |
221 | (temp_time > 0) ? SHARED_TXLINE : SHARED_PXLINE)) | |
212380e3 AC |
222 | return; |
223 | ||
8bbeb278 | 224 | if(!valid_xline(source_p, name, reason)) |
212380e3 AC |
225 | return; |
226 | ||
227 | /* already xlined */ | |
0fdb2570 | 228 | if((aconf = find_xline_mask(name)) != NULL) |
212380e3 | 229 | { |
23959371 | 230 | sendto_one_notice(source_p, ":[%s] already X-Lined by [%s] - %s", name, aconf->host, |
8bbeb278 | 231 | aconf->passwd); |
212380e3 AC |
232 | return; |
233 | } | |
234 | ||
f66f0baa | 235 | apply_xline(source_p, name, reason, temp_time, false); |
212380e3 AC |
236 | } |
237 | ||
238 | /* valid_xline() | |
239 | * | |
8bbeb278 | 240 | * inputs - client xlining, gecos, reason and whether to warn |
212380e3 AC |
241 | * outputs - |
242 | * side effects - checks the xline for validity, erroring if needed | |
243 | */ | |
3c7d6fcc | 244 | static bool |
8bbeb278 | 245 | valid_xline(struct Client *source_p, const char *gecos, const char *reason) |
212380e3 AC |
246 | { |
247 | if(EmptyString(reason)) | |
248 | { | |
249 | sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), | |
8bbeb278 | 250 | get_id(&me, source_p), get_id(source_p, source_p), "XLINE"); |
3c7d6fcc | 251 | return false; |
cc169c94 JT |
252 | } |
253 | ||
212380e3 AC |
254 | if(!valid_wild_card_simple(gecos)) |
255 | { | |
256 | sendto_one_notice(source_p, | |
257 | ":Please include at least %d non-wildcard " | |
258 | "characters with the xline", | |
259 | ConfigFileEntry.min_nonwildcard_simple); | |
3c7d6fcc | 260 | return false; |
212380e3 AC |
261 | } |
262 | ||
3c7d6fcc | 263 | return true; |
212380e3 AC |
264 | } |
265 | ||
266 | void | |
f66f0baa | 267 | apply_xline(struct Client *source_p, const char *name, const char *reason, int temp_time, bool propagated) |
212380e3 AC |
268 | { |
269 | struct ConfItem *aconf; | |
270 | ||
271 | aconf = make_conf(); | |
272 | aconf->status = CONF_XLINE; | |
b52c2949 | 273 | aconf->created = rb_current_time(); |
4418166c | 274 | aconf->host = rb_strdup(name); |
8bbeb278 | 275 | aconf->passwd = rb_strdup(reason); |
23959371 | 276 | collapse(aconf->host); |
212380e3 | 277 | |
27f616dd JT |
278 | aconf->info.oper = operhash_add(get_oper_name(source_p)); |
279 | ||
3cbbfb25 JT |
280 | if(propagated) |
281 | { | |
282 | aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY; | |
283 | aconf->hold = rb_current_time() + temp_time; | |
284 | aconf->lifetime = aconf->hold; | |
285 | ||
286 | replace_old_ban(aconf); | |
287 | rb_dlinkAddAlloc(aconf, &prop_bans); | |
288 | ||
289 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
290 | "%s added global %d min. X-Line for [%s] [%s]", | |
291 | get_oper_name(source_p), temp_time / 60, | |
292 | aconf->host, reason); | |
293 | ilog(L_KLINE, "X %s %d %s %s", | |
294 | get_oper_name(source_p), temp_time / 60, name, reason); | |
295 | sendto_one_notice(source_p, ":Added global %d min. X-Line [%s]", | |
296 | temp_time / 60, aconf->host); | |
297 | sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS, | |
298 | ":%s BAN X * %s %lu %d %d * :%s", | |
299 | source_p->id, aconf->host, | |
300 | (unsigned long)aconf->created, | |
301 | (int)(aconf->hold - aconf->created), | |
302 | (int)(aconf->lifetime - aconf->created), | |
303 | reason); | |
304 | } | |
305 | else if(temp_time > 0) | |
212380e3 | 306 | { |
8bbeb278 | 307 | aconf->hold = rb_current_time() + temp_time; |
212380e3 | 308 | |
8bbeb278 AC |
309 | sendto_realops_snomask(SNO_GENERAL, L_ALL, |
310 | "%s added temporary %d min. X-Line for [%s] [%s]", | |
311 | get_oper_name(source_p), temp_time / 60, | |
23959371 | 312 | aconf->host, reason); |
8bbeb278 AC |
313 | ilog(L_KLINE, "X %s %d %s %s", |
314 | get_oper_name(source_p), temp_time / 60, name, reason); | |
315 | sendto_one_notice(source_p, ":Added temporary %d min. X-Line [%s]", | |
23959371 | 316 | temp_time / 60, aconf->host); |
8bbeb278 AC |
317 | } |
318 | else | |
212380e3 | 319 | { |
8bbeb278 | 320 | sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s added X-Line for [%s] [%s]", |
23959371 | 321 | get_oper_name(source_p), aconf->host, aconf->passwd); |
8bbeb278 | 322 | sendto_one_notice(source_p, ":Added X-Line for [%s] [%s]", |
23959371 | 323 | aconf->host, aconf->passwd); |
8bbeb278 | 324 | |
23959371 | 325 | bandb_add(BANDB_XLINE, source_p, aconf->host, NULL, aconf->passwd, NULL, 0); |
f36d4fdd | 326 | ilog(L_KLINE, "X %s 0 %s %s", get_oper_name(source_p), name, aconf->passwd); |
212380e3 | 327 | } |
8bbeb278 AC |
328 | |
329 | rb_dlinkAddAlloc(aconf, &xline_conf_list); | |
330 | check_xlines(); | |
212380e3 AC |
331 | } |
332 | ||
8bbeb278 | 333 | static void |
212380e3 | 334 | propagate_xline(struct Client *source_p, const char *target, |
8bbeb278 | 335 | int temp_time, const char *name, const char *type, const char *reason) |
212380e3 AC |
336 | { |
337 | if(!temp_time) | |
338 | { | |
339 | sendto_match_servs(source_p, target, CAP_CLUSTER, NOCAPS, | |
8bbeb278 | 340 | "XLINE %s %s %s :%s", target, name, type, reason); |
212380e3 | 341 | sendto_match_servs(source_p, target, CAP_ENCAP, CAP_CLUSTER, |
8bbeb278 | 342 | "ENCAP %s XLINE %d %s 2 :%s", target, temp_time, name, reason); |
212380e3 AC |
343 | } |
344 | else | |
345 | sendto_match_servs(source_p, target, CAP_ENCAP, NOCAPS, | |
8bbeb278 AC |
346 | "ENCAP %s XLINE %d %s %s :%s", |
347 | target, temp_time, name, type, reason); | |
212380e3 | 348 | } |
8bbeb278 | 349 | |
212380e3 | 350 | static void |
8bbeb278 | 351 | cluster_xline(struct Client *source_p, int temp_time, const char *name, const char *reason) |
212380e3 AC |
352 | { |
353 | struct remote_conf *shared_p; | |
5b96d9a6 | 354 | rb_dlink_node *ptr; |
212380e3 | 355 | |
5b96d9a6 | 356 | RB_DLINK_FOREACH(ptr, cluster_conf_list.head) |
212380e3 AC |
357 | { |
358 | shared_p = ptr->data; | |
359 | ||
360 | /* old protocol cant handle temps, and we dont really want | |
361 | * to convert them to perm.. --fl | |
362 | */ | |
363 | if(!temp_time) | |
364 | { | |
365 | if(!(shared_p->flags & SHARED_PXLINE)) | |
366 | continue; | |
367 | ||
368 | sendto_match_servs(source_p, shared_p->server, CAP_CLUSTER, NOCAPS, | |
8bbeb278 | 369 | "XLINE %s %s 2 :%s", shared_p->server, name, reason); |
212380e3 | 370 | sendto_match_servs(source_p, shared_p->server, CAP_ENCAP, CAP_CLUSTER, |
8bbeb278 AC |
371 | "ENCAP %s XLINE 0 %s 2 :%s", |
372 | shared_p->server, name, reason); | |
212380e3 AC |
373 | } |
374 | else if(shared_p->flags & SHARED_TXLINE) | |
375 | sendto_match_servs(source_p, shared_p->server, CAP_ENCAP, NOCAPS, | |
8bbeb278 AC |
376 | "ENCAP %s XLINE %d %s 2 :%s", |
377 | shared_p->server, temp_time, name, reason); | |
212380e3 AC |
378 | } |
379 | } | |
380 | ||
381 | /* mo_unxline() | |
382 | * | |
383 | * parv[1] - thing to unxline | |
384 | */ | |
3c7d6fcc | 385 | static void |
428ca87b | 386 | mo_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 | 387 | { |
f66f0baa | 388 | bool propagated = true; |
3cbbfb25 | 389 | |
212380e3 AC |
390 | if(!IsOperXline(source_p)) |
391 | { | |
8bbeb278 | 392 | sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "xline"); |
3c7d6fcc | 393 | return; |
212380e3 AC |
394 | } |
395 | ||
396 | if(parc == 4 && !(irccmp(parv[2], "ON"))) | |
397 | { | |
398 | if(!IsOperRemoteBan(source_p)) | |
399 | { | |
400 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
8bbeb278 | 401 | me.name, source_p->name, "remoteban"); |
3c7d6fcc | 402 | return; |
212380e3 AC |
403 | } |
404 | ||
8bbeb278 | 405 | propagate_generic(source_p, "UNXLINE", parv[3], CAP_CLUSTER, "%s", parv[1]); |
212380e3 AC |
406 | |
407 | if(match(parv[3], me.name) == 0) | |
3c7d6fcc | 408 | return; |
3cbbfb25 | 409 | |
f66f0baa | 410 | propagated = false; |
212380e3 | 411 | } |
3cbbfb25 | 412 | /* cluster{} moved to remove_xline */ |
212380e3 | 413 | |
3cbbfb25 | 414 | remove_xline(source_p, parv[1], propagated); |
212380e3 AC |
415 | } |
416 | ||
417 | /* ms_unxline() | |
418 | * | |
419 | * handles a remote unxline | |
420 | */ | |
3c7d6fcc | 421 | static void |
428ca87b | 422 | ms_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 | 423 | { |
8bbeb278 AC |
424 | /* parv[0] parv[1] parv[2] |
425 | * oper target server gecos | |
212380e3 | 426 | */ |
8bbeb278 | 427 | propagate_generic(source_p, "UNXLINE", parv[1], CAP_CLUSTER, "%s", parv[2]); |
212380e3 AC |
428 | |
429 | if(!match(parv[1], me.name)) | |
3c7d6fcc | 430 | return; |
212380e3 AC |
431 | |
432 | if(!IsPerson(source_p)) | |
3c7d6fcc | 433 | return; |
212380e3 AC |
434 | |
435 | handle_remote_unxline(source_p, parv[2]); | |
212380e3 AC |
436 | } |
437 | ||
3c7d6fcc | 438 | static void |
428ca87b | 439 | me_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
440 | { |
441 | /* name */ | |
442 | if(!IsPerson(source_p)) | |
3c7d6fcc | 443 | return; |
212380e3 AC |
444 | |
445 | handle_remote_unxline(source_p, parv[1]); | |
212380e3 AC |
446 | } |
447 | ||
448 | static void | |
449 | handle_remote_unxline(struct Client *source_p, const char *name) | |
450 | { | |
451 | if(!find_shared_conf(source_p->username, source_p->host, | |
8bbeb278 | 452 | source_p->servptr->name, SHARED_UNXLINE)) |
212380e3 AC |
453 | return; |
454 | ||
f66f0baa | 455 | remove_xline(source_p, name, false); |
212380e3 AC |
456 | } |
457 | ||
60c96e64 | 458 | static void |
5c1dbc3c | 459 | remove_xline(struct Client *source_p, const char *name, bool propagated) |
212380e3 AC |
460 | { |
461 | struct ConfItem *aconf; | |
5b96d9a6 | 462 | rb_dlink_node *ptr; |
483987a4 | 463 | time_t now; |
212380e3 | 464 | |
5b96d9a6 | 465 | RB_DLINK_FOREACH(ptr, xline_conf_list.head) |
212380e3 AC |
466 | { |
467 | aconf = ptr->data; | |
468 | ||
23959371 | 469 | if(!irccmp(aconf->host, name)) |
212380e3 | 470 | { |
3cbbfb25 JT |
471 | if(aconf->lifetime) |
472 | { | |
473 | if(!propagated) | |
474 | { | |
475 | sendto_one_notice(source_p, ":Cannot remove global X-Line %s on specific servers", name); | |
476 | return; | |
477 | } | |
478 | ptr = rb_dlinkFind(aconf, &prop_bans); | |
479 | if(ptr == NULL) | |
480 | return; | |
481 | sendto_one_notice(source_p, ":X-Line for [%s] is removed", name); | |
482 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
483 | "%s has removed the global X-Line for: [%s]", | |
484 | get_oper_name(source_p), name); | |
485 | ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), name); | |
483987a4 JT |
486 | now = rb_current_time(); |
487 | if(aconf->created < now) | |
488 | aconf->created = now; | |
3cbbfb25 JT |
489 | else |
490 | aconf->created++; | |
491 | aconf->hold = aconf->created; | |
492 | operhash_delete(aconf->info.oper); | |
493 | aconf->info.oper = operhash_add(get_oper_name(source_p)); | |
494 | aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY; | |
495 | sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS, | |
496 | ":%s BAN X * %s %lu %d %d * :*", | |
497 | source_p->id, aconf->host, | |
498 | (unsigned long)aconf->created, | |
499 | 0, | |
500 | (int)(aconf->lifetime - aconf->created)); | |
501 | remove_reject_mask(aconf->host, NULL); | |
483987a4 | 502 | deactivate_conf(aconf, ptr, now); |
3cbbfb25 JT |
503 | return; |
504 | } | |
1b5d7c2e | 505 | else if(propagated && rb_dlink_list_length(&cluster_conf_list)) |
3cbbfb25 | 506 | cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name); |
8bbeb278 | 507 | if(!aconf->hold) |
5408b484 | 508 | { |
8bbeb278 AC |
509 | bandb_del(BANDB_XLINE, aconf->host, NULL); |
510 | ||
511 | sendto_one_notice(source_p, ":X-Line for [%s] is removed", aconf->host); | |
512 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
513 | "%s has removed the X-Line for: [%s]", | |
514 | get_oper_name(source_p), aconf->host); | |
515 | ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), aconf->host); | |
5408b484 JT |
516 | } |
517 | else | |
518 | { | |
8bbeb278 | 519 | sendto_one_notice(source_p, ":X-Line for [%s] is removed", name); |
5408b484 | 520 | sendto_realops_snomask(SNO_GENERAL, L_ALL, |
8bbeb278 AC |
521 | "%s has removed the temporary X-Line for: [%s]", |
522 | get_oper_name(source_p), name); | |
523 | ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), name); | |
5408b484 | 524 | } |
8bbeb278 | 525 | |
23959371 | 526 | remove_reject_mask(aconf->host, NULL); |
212380e3 | 527 | free_conf(aconf); |
555ac41f | 528 | rb_dlinkDestroy(ptr, &xline_conf_list); |
60c96e64 | 529 | return; |
212380e3 AC |
530 | } |
531 | } | |
532 | ||
1b5d7c2e | 533 | if(propagated && rb_dlink_list_length(&cluster_conf_list)) |
3cbbfb25 JT |
534 | cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name); |
535 | ||
8bbeb278 | 536 | sendto_one_notice(source_p, ":No X-Line for %s", name); |
212380e3 | 537 | } |