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