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