]> jfr.im git - solanum.git/blame - modules/m_resv.c
Fix a warning about const with forward channels.
[solanum.git] / modules / m_resv.c
CommitLineData
212380e3
AC
1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_resv.c: Reserves(jupes) a nickname or channel.
4 *
5 * Copyright (C) 2001-2002 Hybrid Development Team
6 * Copyright (C) 2002-2005 ircd-ratbox development team
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 * USA
22 *
8bbeb278 23 * $Id$
212380e3
AC
24 */
25
26#include "stdinc.h"
27#include "client.h"
28#include "channel.h"
29#include "ircd.h"
30#include "numeric.h"
31#include "s_serv.h"
32#include "send.h"
33#include "msg.h"
34#include "parse.h"
35#include "modules.h"
36#include "s_conf.h"
37#include "s_newconf.h"
38#include "hash.h"
4016731b 39#include "logger.h"
8bbeb278 40#include "bandbi.h"
27f616dd 41#include "operhash.h"
212380e3
AC
42
43static int mo_resv(struct Client *, struct Client *, int, const char **);
44static int ms_resv(struct Client *, struct Client *, int, const char **);
45static int me_resv(struct Client *, struct Client *, int, const char **);
46static int mo_unresv(struct Client *, struct Client *, int, const char **);
47static int ms_unresv(struct Client *, struct Client *, int, const char **);
48static int me_unresv(struct Client *, struct Client *, int, const char **);
49
50struct Message resv_msgtab = {
51 "RESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
52 {mg_ignore, mg_not_oper, {ms_resv, 4}, {ms_resv, 4}, {me_resv, 5}, {mo_resv, 3}}
53};
8bbeb278 54
212380e3
AC
55struct Message unresv_msgtab = {
56 "UNRESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
57 {mg_ignore, mg_not_oper, {ms_unresv, 3}, {ms_unresv, 3}, {me_unresv, 2}, {mo_unresv, 2}}
58};
59
8bbeb278
AC
60mapi_clist_av1 resv_clist[] = { &resv_msgtab, &unresv_msgtab, NULL };
61
62DECLARE_MODULE_AV1(resv, NULL, NULL, resv_clist, NULL, NULL, "$Revision$");
212380e3
AC
63
64static void parse_resv(struct Client *source_p, const char *name,
dca9e552 65 const char *reason, int temp_time, int propagated);
212380e3 66static void propagate_resv(struct Client *source_p, const char *target,
8bbeb278
AC
67 int temp_time, const char *name, const char *reason);
68static void cluster_resv(struct Client *source_p, int temp_time,
69 const char *name, const char *reason);
212380e3
AC
70
71static void handle_remote_unresv(struct Client *source_p, const char *name);
dca9e552 72static void remove_resv(struct Client *source_p, const char *name, int propagated);
212380e3
AC
73
74/*
75 * mo_resv()
8bbeb278 76 * parv[0] = sender prefix
212380e3
AC
77 * parv[1] = channel/nick to forbid
78 * parv[2] = reason
79 */
80static int
81mo_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
82{
83 const char *name;
84 const char *reason;
85 const char *target_server = NULL;
86 int temp_time;
87 int loc = 1;
dca9e552 88 int propagated = ConfigFileEntry.use_propagated_bans;
212380e3 89
1ebe6ffc
JT
90 if(!IsOperResv(source_p))
91 {
8bbeb278 92 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "resv");
1ebe6ffc
JT
93 return 0;
94 }
95
212380e3
AC
96 /* RESV [time] <name> [ON <server>] :<reason> */
97
98 if((temp_time = valid_temp_time(parv[loc])) >= 0)
99 loc++;
100 /* we just set temp_time to -1! */
101 else
102 temp_time = 0;
103
104 name = parv[loc];
105 loc++;
106
8bbeb278 107 if((parc >= loc + 2) && (irccmp(parv[loc], "ON") == 0))
212380e3
AC
108 {
109 if(!IsOperRemoteBan(source_p))
110 {
111 sendto_one(source_p, form_str(ERR_NOPRIVS),
8bbeb278 112 me.name, source_p->name, "remoteban");
212380e3
AC
113 return 0;
114 }
115
8bbeb278 116 target_server = parv[loc + 1];
212380e3 117 loc += 2;
dca9e552
JT
118
119 /* Set as local-only. */
120 propagated = 0;
212380e3
AC
121 }
122
123 if(parc <= loc || EmptyString(parv[loc]))
124 {
8bbeb278 125 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "RESV");
212380e3
AC
126 return 0;
127 }
128
129 reason = parv[loc];
130
131 /* remote resv.. */
132 if(target_server)
133 {
134 propagate_resv(source_p, target_server, temp_time, name, reason);
135
136 if(match(target_server, me.name) == 0)
137 return 0;
138 }
dca9e552 139 else if(!propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
212380e3
AC
140 cluster_resv(source_p, temp_time, name, reason);
141
dca9e552
JT
142 if(propagated && temp_time == 0)
143 {
144 sendto_one_notice(source_p, ":Cannot set a permanent global ban");
145 return 0;
146 }
147
148 parse_resv(source_p, name, reason, temp_time, propagated);
212380e3
AC
149
150 return 0;
151}
152
153/* ms_resv()
8bbeb278 154 * parv[0] = sender prefix
212380e3
AC
155 * parv[1] = target server
156 * parv[2] = channel/nick to forbid
157 * parv[3] = reason
158 */
159static int
8bbeb278 160ms_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3 161{
8bbeb278
AC
162 /* parv[0] parv[1] parv[2] parv[3]
163 * oper target server resv reason
212380e3
AC
164 */
165 propagate_resv(source_p, parv[1], 0, parv[2], parv[3]);
166
167 if(!match(parv[1], me.name))
168 return 0;
169
170 if(!IsPerson(source_p))
171 return 0;
172
dca9e552 173 parse_resv(source_p, parv[2], parv[3], 0, 0);
212380e3
AC
174 return 0;
175}
176
177static int
8bbeb278 178me_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
179{
180 /* time name 0 :reason */
181 if(!IsPerson(source_p))
182 return 0;
183
dca9e552 184 parse_resv(source_p, parv[2], parv[4], atoi(parv[1]), 0);
212380e3
AC
185 return 0;
186}
187
188/* parse_resv()
189 *
190 * inputs - source_p if error messages wanted
191 * - thing to resv
192 * - reason for resv
193 * outputs -
194 * side effects - will parse the resv and create it if valid
195 */
196static void
dca9e552 197parse_resv(struct Client *source_p, const char *name, const char *reason, int temp_time, int propagated)
212380e3
AC
198{
199 struct ConfItem *aconf;
200
8bbeb278 201 if(!MyClient(source_p) &&
212380e3 202 !find_shared_conf(source_p->username, source_p->host,
8bbeb278
AC
203 source_p->servptr->name,
204 (temp_time > 0) ? SHARED_TRESV : SHARED_PRESV))
212380e3
AC
205 return;
206
207 if(IsChannelName(name))
208 {
209 if(hash_find_resv(name))
210 {
211 sendto_one_notice(source_p,
8bbeb278 212 ":A RESV has already been placed on channel: %s", name);
212380e3
AC
213 return;
214 }
215
216 if(strlen(name) > CHANNELLEN)
217 {
8bbeb278 218 sendto_one_notice(source_p, ":Invalid RESV length: %s", name);
b0f30fa1
JT
219 return;
220 }
212380e3 221
212380e3
AC
222 aconf = make_conf();
223 aconf->status = CONF_RESV_CHANNEL;
224 aconf->port = 0;
b52c2949 225 aconf->created = rb_current_time();
23959371 226 aconf->host = rb_strdup(name);
47a03750 227 aconf->passwd = rb_strdup(reason);
27f616dd 228 aconf->info.oper = operhash_add(get_oper_name(source_p));
212380e3 229
dca9e552
JT
230 if(propagated)
231 {
232 aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
233 aconf->hold = rb_current_time() + temp_time;
234 aconf->lifetime = aconf->hold;
235 replace_old_ban(aconf);
236 rb_dlinkAddAlloc(aconf, &prop_bans);
237
238 sendto_realops_snomask(SNO_GENERAL, L_ALL,
239 "%s added global %d min. RESV for [%s] [%s]",
240 get_oper_name(source_p), temp_time / 60,
241 name, reason);
242 ilog(L_KLINE, "R %s %d %s %s",
243 get_oper_name(source_p), temp_time / 60, name, reason);
244 sendto_one_notice(source_p, ":Added global %d min. RESV [%s]",
245 temp_time / 60, name);
246 sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
247 ":%s BAN R * %s %lu %d %d * :%s",
248 source_p->id, aconf->host,
249 (unsigned long)aconf->created,
250 (int)(aconf->hold - aconf->created),
251 (int)(aconf->lifetime - aconf->created),
252 reason);
253 }
254 else if(temp_time > 0)
212380e3 255 {
e3354945 256 aconf->hold = rb_current_time() + temp_time;
212380e3
AC
257
258 sendto_realops_snomask(SNO_GENERAL, L_ALL,
8bbeb278
AC
259 "%s added temporary %d min. RESV for [%s] [%s]",
260 get_oper_name(source_p), temp_time / 60,
261 name, reason);
212380e3 262 ilog(L_KLINE, "R %s %d %s %s",
8bbeb278 263 get_oper_name(source_p), temp_time / 60, name, reason);
212380e3 264 sendto_one_notice(source_p, ":Added temporary %d min. RESV [%s]",
8bbeb278 265 temp_time / 60, name);
212380e3
AC
266 }
267 else
00c036b1
AC
268 {
269 sendto_realops_snomask(SNO_GENERAL, L_ALL,
270 "%s added RESV for [%s] [%s]",
271 get_oper_name(source_p), name, reason);
272 ilog(L_KLINE, "R %s 0 %s %s",
273 get_oper_name(source_p), name, reason);
274 sendto_one_notice(source_p, ":Added RESV [%s]", name);
275
23959371 276 bandb_add(BANDB_RESV, source_p, aconf->host, NULL, aconf->passwd, NULL, 0);
00c036b1 277 }
dca9e552
JT
278
279 add_to_resv_hash(aconf->host, aconf);
280 resv_chan_forcepart(aconf->host, aconf->passwd, temp_time);
212380e3
AC
281 }
282 else if(clean_resv_nick(name))
283 {
8bbeb278 284 if(strlen(name) > NICKLEN * 2)
212380e3 285 {
8bbeb278 286 sendto_one_notice(source_p, ":Invalid RESV length: %s", name);
212380e3
AC
287 return;
288 }
289
212380e3
AC
290 if(!valid_wild_card_simple(name))
291 {
292 sendto_one_notice(source_p,
8bbeb278
AC
293 ":Please include at least %d non-wildcard "
294 "characters with the resv",
295 ConfigFileEntry.min_nonwildcard_simple);
212380e3
AC
296 return;
297 }
298
0fdb2570 299 if(find_nick_resv_mask(name))
212380e3
AC
300 {
301 sendto_one_notice(source_p,
8bbeb278 302 ":A RESV has already been placed on nick: %s", name);
212380e3
AC
303 return;
304 }
305
306 aconf = make_conf();
307 aconf->status = CONF_RESV_NICK;
308 aconf->port = 0;
b52c2949 309 aconf->created = rb_current_time();
23959371 310 aconf->host = rb_strdup(name);
47a03750 311 aconf->passwd = rb_strdup(reason);
27f616dd 312 aconf->info.oper = operhash_add(get_oper_name(source_p));
212380e3 313
dca9e552
JT
314 if(propagated)
315 {
316 aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
317 aconf->hold = rb_current_time() + temp_time;
318 aconf->lifetime = aconf->hold;
319 replace_old_ban(aconf);
320 rb_dlinkAddAlloc(aconf, &prop_bans);
321
322 sendto_realops_snomask(SNO_GENERAL, L_ALL,
323 "%s added global %d min. RESV for [%s] [%s]",
324 get_oper_name(source_p), temp_time / 60,
325 name, reason);
326 ilog(L_KLINE, "R %s %d %s %s",
327 get_oper_name(source_p), temp_time / 60, name, reason);
328 sendto_one_notice(source_p, ":Added global %d min. RESV [%s]",
329 temp_time / 60, name);
330 sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
331 ":%s BAN R * %s %lu %d %d * :%s",
332 source_p->id, aconf->host,
333 (unsigned long)aconf->created,
334 (int)(aconf->hold - aconf->created),
335 (int)(aconf->lifetime - aconf->created),
336 reason);
337 }
338 else if(temp_time > 0)
212380e3 339 {
e3354945 340 aconf->hold = rb_current_time() + temp_time;
212380e3
AC
341
342 sendto_realops_snomask(SNO_GENERAL, L_ALL,
8bbeb278
AC
343 "%s added temporary %d min. RESV for [%s] [%s]",
344 get_oper_name(source_p), temp_time / 60,
345 name, reason);
212380e3 346 ilog(L_KLINE, "R %s %d %s %s",
8bbeb278 347 get_oper_name(source_p), temp_time / 60, name, reason);
212380e3 348 sendto_one_notice(source_p, ":Added temporary %d min. RESV [%s]",
8bbeb278 349 temp_time / 60, name);
212380e3
AC
350 }
351 else
00c036b1
AC
352 {
353 sendto_realops_snomask(SNO_GENERAL, L_ALL,
354 "%s added RESV for [%s] [%s]",
355 get_oper_name(source_p), name, reason);
356 ilog(L_KLINE, "R %s 0 %s %s",
357 get_oper_name(source_p), name, reason);
358 sendto_one_notice(source_p, ":Added RESV [%s]", name);
359
23959371 360 bandb_add(BANDB_RESV, source_p, aconf->host, NULL, aconf->passwd, NULL, 0);
00c036b1 361 }
dca9e552
JT
362
363 rb_dlinkAddAlloc(aconf, &resv_conf_list);
212380e3
AC
364 }
365 else
8bbeb278 366 sendto_one_notice(source_p, ":You have specified an invalid resv: [%s]", name);
212380e3
AC
367}
368
8bbeb278 369static void
212380e3 370propagate_resv(struct Client *source_p, const char *target,
8bbeb278 371 int temp_time, const char *name, const char *reason)
212380e3
AC
372{
373 if(!temp_time)
374 {
375 sendto_match_servs(source_p, target,
8bbeb278 376 CAP_CLUSTER, NOCAPS, "RESV %s %s :%s", target, name, reason);
212380e3 377 sendto_match_servs(source_p, target,
8bbeb278
AC
378 CAP_ENCAP, CAP_CLUSTER,
379 "ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason);
212380e3
AC
380 }
381 else
382 sendto_match_servs(source_p, target,
8bbeb278
AC
383 CAP_ENCAP, NOCAPS,
384 "ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason);
212380e3
AC
385}
386
387static void
8bbeb278 388cluster_resv(struct Client *source_p, int temp_time, const char *name, const char *reason)
212380e3
AC
389{
390 struct remote_conf *shared_p;
5b96d9a6 391 rb_dlink_node *ptr;
212380e3 392
5b96d9a6 393 RB_DLINK_FOREACH(ptr, cluster_conf_list.head)
212380e3
AC
394 {
395 shared_p = ptr->data;
396
397 /* old protocol cant handle temps, and we dont really want
398 * to convert them to perm.. --fl
399 */
400 if(!temp_time)
401 {
402 if(!(shared_p->flags & SHARED_PRESV))
403 continue;
404
405 sendto_match_servs(source_p, shared_p->server,
8bbeb278
AC
406 CAP_CLUSTER, NOCAPS,
407 "RESV %s %s :%s", shared_p->server, name, reason);
212380e3 408 sendto_match_servs(source_p, shared_p->server,
8bbeb278
AC
409 CAP_ENCAP, CAP_CLUSTER,
410 "ENCAP %s RESV 0 %s 0 :%s",
411 shared_p->server, name, reason);
212380e3
AC
412 }
413 else if(shared_p->flags & SHARED_TRESV)
414 sendto_match_servs(source_p, shared_p->server,
8bbeb278
AC
415 CAP_ENCAP, NOCAPS,
416 "ENCAP %s RESV %d %s 0 :%s",
417 shared_p->server, temp_time, name, reason);
212380e3
AC
418 }
419}
420
421
422/*
423 * mo_unresv()
8bbeb278 424 * parv[0] = sender prefix
212380e3
AC
425 * parv[1] = channel/nick to unforbid
426 */
427static int
428mo_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
429{
dca9e552
JT
430 int propagated = 1;
431
1ebe6ffc
JT
432 if(!IsOperResv(source_p))
433 {
8bbeb278 434 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "resv");
1ebe6ffc
JT
435 return 0;
436 }
437
212380e3
AC
438 if((parc == 4) && (irccmp(parv[2], "ON") == 0))
439 {
440 if(!IsOperRemoteBan(source_p))
441 {
442 sendto_one(source_p, form_str(ERR_NOPRIVS),
8bbeb278 443 me.name, source_p->name, "remoteban");
212380e3
AC
444 return 0;
445 }
446
8bbeb278 447 propagate_generic(source_p, "UNRESV", parv[3], CAP_CLUSTER, "%s", parv[1]);
212380e3
AC
448
449 if(match(parv[3], me.name) == 0)
450 return 0;
dca9e552
JT
451
452 propagated = 0;
212380e3 453 }
dca9e552 454#if 0
5b96d9a6 455 else if(rb_dlink_list_length(&cluster_conf_list) > 0)
8bbeb278 456 cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", parv[1]);
dca9e552
JT
457#endif
458 /* cluster{} moved to remove_resv */
212380e3 459
dca9e552 460 remove_resv(source_p, parv[1], propagated);
212380e3
AC
461 return 0;
462}
463
464/* ms_unresv()
8bbeb278 465 * parv[0] = sender prefix
212380e3
AC
466 * parv[1] = target server
467 * parv[2] = resv to remove
468 */
469static int
470ms_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
471{
8bbeb278
AC
472 /* parv[0] parv[1] parv[2]
473 * oper target server resv to remove
212380e3 474 */
8bbeb278 475 propagate_generic(source_p, "UNRESV", parv[1], CAP_CLUSTER, "%s", parv[2]);
212380e3
AC
476
477 if(!match(parv[1], me.name))
478 return 0;
479
480 if(!IsPerson(source_p))
481 return 0;
482
483 handle_remote_unresv(source_p, parv[2]);
484 return 0;
485}
486
487static int
488me_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
489{
490 /* name */
491 if(!IsPerson(source_p))
492 return 0;
493
494 handle_remote_unresv(source_p, parv[1]);
495 return 0;
496}
497
498static void
499handle_remote_unresv(struct Client *source_p, const char *name)
500{
501 if(!find_shared_conf(source_p->username, source_p->host,
8bbeb278 502 source_p->servptr->name, SHARED_UNRESV))
212380e3
AC
503 return;
504
dca9e552 505 remove_resv(source_p, name, 0);
212380e3
AC
506
507 return;
508}
509
1328da86 510static void
dca9e552 511remove_resv(struct Client *source_p, const char *name, int propagated)
212380e3
AC
512{
513 struct ConfItem *aconf = NULL;
dca9e552 514 rb_dlink_node *ptr;
212380e3
AC
515
516 if(IsChannelName(name))
517 {
518 if((aconf = hash_find_resv(name)) == NULL)
1328da86 519 {
dca9e552 520 if(propagated && rb_dlink_list_length(&cluster_conf_list))
22204726 521 cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
dca9e552 522
1328da86
JT
523 sendto_one_notice(source_p, ":No RESV for %s", name);
524 return;
525 }
212380e3 526
dca9e552
JT
527 if(aconf->lifetime)
528 {
529 if(!propagated)
530 {
531 sendto_one_notice(source_p, ":Cannot remove global RESV %s on specific servers", name);
532 return;
533 }
534 ptr = rb_dlinkFind(aconf, &prop_bans);
535 if(ptr == NULL)
536 return;
537 sendto_one_notice(source_p, ":RESV for [%s] is removed", name);
538 sendto_realops_snomask(SNO_GENERAL, L_ALL,
539 "%s has removed the global RESV for: [%s]",
540 get_oper_name(source_p), name);
541 ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
542 if(aconf->created < rb_current_time())
543 aconf->created = rb_current_time();
544 else
545 aconf->created++;
546 aconf->hold = aconf->created;
547 operhash_delete(aconf->info.oper);
548 aconf->info.oper = operhash_add(get_oper_name(source_p));
549 aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
550 sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
551 ":%s BAN R * %s %lu %d %d * :*",
552 source_p->id, aconf->host,
553 (unsigned long)aconf->created,
554 0,
555 (int)(aconf->lifetime - aconf->created));
556 deactivate_conf(aconf, ptr);
557 return;
558 }
559 else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
560 cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
561
a990586f
JT
562 sendto_one_notice(source_p, ":RESV for [%s] is removed", name);
563 ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
212380e3 564 if(!aconf->hold)
1a9ea263 565 {
8bbeb278 566 bandb_del(BANDB_RESV, aconf->host, NULL);
1a9ea263
JT
567 sendto_realops_snomask(SNO_GENERAL, L_ALL,
568 "%s has removed the RESV for: [%s]",
569 get_oper_name(source_p), name);
1a9ea263 570 }
1328da86
JT
571 else
572 {
1328da86 573 sendto_realops_snomask(SNO_GENERAL, L_ALL,
a990586f 574 "%s has removed the temporary RESV for: [%s]",
8bbeb278 575 get_oper_name(source_p), name);
1328da86 576 }
212380e3 577 del_from_resv_hash(name, aconf);
212380e3
AC
578 }
579 else
580 {
5b96d9a6 581 RB_DLINK_FOREACH(ptr, resv_conf_list.head)
212380e3
AC
582 {
583 aconf = ptr->data;
584
23959371 585 if(irccmp(aconf->host, name))
212380e3
AC
586 aconf = NULL;
587 else
588 break;
589 }
590
591 if(aconf == NULL)
1328da86 592 {
dca9e552 593 if(propagated && rb_dlink_list_length(&cluster_conf_list))
22204726 594 cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
dca9e552 595
1328da86
JT
596 sendto_one_notice(source_p, ":No RESV for %s", name);
597 return;
598 }
212380e3 599
dca9e552
JT
600 if(aconf->lifetime)
601 {
602 if(!propagated)
603 {
604 sendto_one_notice(source_p, ":Cannot remove global RESV %s on specific servers", name);
605 return;
606 }
607 ptr = rb_dlinkFind(aconf, &prop_bans);
608 if(ptr == NULL)
609 return;
610 sendto_one_notice(source_p, ":RESV for [%s] is removed", name);
611 sendto_realops_snomask(SNO_GENERAL, L_ALL,
612 "%s has removed the global RESV for: [%s]",
613 get_oper_name(source_p), name);
614 ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
615 if(aconf->created < rb_current_time())
616 aconf->created = rb_current_time();
617 else
618 aconf->created++;
619 aconf->hold = aconf->created;
620 operhash_delete(aconf->info.oper);
621 aconf->info.oper = operhash_add(get_oper_name(source_p));
622 aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
623 sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
624 ":%s BAN R * %s %lu %d %d * :*",
625 source_p->id, aconf->host,
626 (unsigned long)aconf->created,
627 0,
628 (int)(aconf->lifetime - aconf->created));
629 deactivate_conf(aconf, ptr);
630 return;
631 }
632 else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
633 cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
634
5bd874eb
JT
635 sendto_one_notice(source_p, ":RESV for [%s] is removed", name);
636 ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
212380e3 637 if(!aconf->hold)
5bd874eb 638 {
8bbeb278 639 bandb_del(BANDB_RESV, aconf->host, NULL);
5bd874eb
JT
640 sendto_realops_snomask(SNO_GENERAL, L_ALL,
641 "%s has removed the RESV for: [%s]",
642 get_oper_name(source_p), name);
643 }
1328da86
JT
644 else
645 {
1328da86 646 sendto_realops_snomask(SNO_GENERAL, L_ALL,
5bd874eb 647 "%s has removed the temporary RESV for: [%s]",
8bbeb278 648 get_oper_name(source_p), name);
1328da86 649 }
212380e3 650 /* already have ptr from the loop above.. */
555ac41f 651 rb_dlinkDestroy(ptr, &resv_conf_list);
212380e3 652 }
1328da86 653 free_conf(aconf);
212380e3 654
1328da86 655 return;
212380e3 656}