29 |
|
#include "irc_string.h" |
30 |
|
#include "sprintf_irc.h" |
31 |
|
#include "ircd.h" |
32 |
+ |
#include "conf.h" |
33 |
|
#include "hostmask.h" |
34 |
|
#include "numeric.h" |
35 |
|
#include "fdlist.h" |
36 |
|
#include "s_bsd.h" |
36 |
– |
#include "conf.h" |
37 |
|
#include "log.h" |
38 |
|
#include "s_misc.h" |
39 |
|
#include "send.h" |
42 |
|
#include "parse.h" |
43 |
|
#include "modules.h" |
44 |
|
#include "resv.h" |
45 |
+ |
#include "conf_db.h" |
46 |
+ |
#include "memory.h" |
47 |
|
|
48 |
|
|
49 |
|
static int valid_xline(struct Client *, char *, char *, int); |
50 |
|
static void write_xline(struct Client *, char *, char *, time_t); |
51 |
|
static void remove_xline(struct Client *, char *); |
52 |
< |
static int remove_txline_match(const char *); |
52 |
> |
static int remove_xline_match(const char *); |
53 |
|
|
54 |
|
static void relay_xline(struct Client *, char *[]); |
55 |
|
|
69 |
|
{ |
70 |
|
char *reason = NULL; |
71 |
|
char *gecos = NULL; |
72 |
< |
struct ConfItem *conf = NULL; |
71 |
< |
struct MatchItem *match_item = NULL; |
72 |
> |
struct MaskItem *conf = NULL; |
73 |
|
char *target_server = NULL; |
74 |
|
time_t tkline_time = 0; |
75 |
|
|
101 |
|
target_server, gecos, (int)tkline_time, reason); |
102 |
|
|
103 |
|
/* Allow ON to apply local xline as well if it matches */ |
104 |
< |
if (!match(target_server, me.name)) |
104 |
> |
if (match(target_server, me.name)) |
105 |
|
return; |
106 |
|
} |
107 |
|
else |
117 |
|
if (!valid_xline(source_p, gecos, reason, 0)) |
118 |
|
return; |
119 |
|
|
120 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, gecos, |
120 |
> |
if ((conf = find_matching_name_conf(CONF_XLINE, gecos, |
121 |
|
NULL, NULL, 0)) != NULL) |
122 |
|
{ |
122 |
– |
match_item = map_to_conf(conf); |
123 |
– |
|
123 |
|
sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s", |
124 |
|
me.name, source_p->name, gecos, |
125 |
< |
conf->name, match_item->reason); |
125 |
> |
conf->name, conf->reason); |
126 |
|
return; |
127 |
|
} |
128 |
|
|
182 |
|
static void |
183 |
|
relay_xline(struct Client *source_p, char *parv[]) |
184 |
|
{ |
185 |
< |
struct ConfItem *conf; |
187 |
< |
struct MatchItem *match_item; |
185 |
> |
struct MaskItem *conf = NULL; |
186 |
|
int t_sec; |
187 |
|
|
188 |
|
t_sec = atoi(parv[3]); |
194 |
|
"XLINE %s %s %s :%s", |
195 |
|
parv[1], parv[2], parv[3], parv[4]); |
196 |
|
|
197 |
< |
if (!match(parv[1], me.name)) |
197 |
> |
if (match(parv[1], me.name)) |
198 |
|
return; |
199 |
|
|
200 |
< |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, source_p->servptr->name, |
200 |
> |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name, |
201 |
|
source_p->username, source_p->host, |
202 |
|
SHARED_XLINE)) |
203 |
|
{ |
204 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, parv[2], |
204 |
> |
if ((conf = find_matching_name_conf(CONF_XLINE, parv[2], |
205 |
|
NULL, NULL, 0)) != NULL) |
206 |
|
{ |
209 |
– |
match_item = map_to_conf(conf); |
207 |
|
sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s", |
208 |
|
ID_or_name(&me, source_p->from), |
209 |
|
ID_or_name(source_p, source_p->from), |
210 |
< |
parv[2], conf->name, match_item->reason); |
210 |
> |
parv[2], conf->name, conf->reason); |
211 |
|
return; |
212 |
|
} |
213 |
|
|
249 |
|
"UNXLINE %s %s", target_server, gecos); |
250 |
|
|
251 |
|
/* Allow ON to apply local unxline as well if it matches */ |
252 |
< |
if (!match(target_server, me.name)) |
252 |
> |
if (match(target_server, me.name)) |
253 |
|
return; |
254 |
|
} |
255 |
|
else |
278 |
|
sendto_match_servs(source_p, parv[1], CAP_CLUSTER, |
279 |
|
"UNXLINE %s %s", parv[1], parv[2]); |
280 |
|
|
281 |
< |
if (!match(parv[1], me.name)) |
281 |
> |
if (match(parv[1], me.name)) |
282 |
|
return; |
283 |
|
|
284 |
< |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, source_p->servptr->name, |
284 |
> |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name, |
285 |
|
source_p->username, source_p->host, |
286 |
|
SHARED_UNXLINE)) |
287 |
|
remove_xline(source_p, parv[2]); |
304 |
|
return 0; |
305 |
|
} |
306 |
|
|
310 |
– |
if (strchr(gecos, '"')) |
311 |
– |
{ |
312 |
– |
sendto_one(source_p, ":%s NOTICE %s :Invalid character '\"'", |
313 |
– |
me.name, source_p->name); |
314 |
– |
return 0; |
315 |
– |
} |
316 |
– |
|
307 |
|
if (!valid_wild_card_simple(gecos)) |
308 |
|
{ |
309 |
|
if (warn) |
326 |
|
write_xline(struct Client *source_p, char *gecos, char *reason, |
327 |
|
time_t tkline_time) |
328 |
|
{ |
329 |
< |
struct ConfItem *conf; |
340 |
< |
struct MatchItem *match_item; |
329 |
> |
struct MaskItem *conf; |
330 |
|
const char *current_date; |
331 |
|
time_t cur_time; |
332 |
|
|
333 |
< |
conf = make_conf_item(XLINE_TYPE); |
345 |
< |
match_item = map_to_conf(conf); |
333 |
> |
conf = conf_make(CONF_XLINE); |
334 |
|
|
335 |
|
collapse(gecos); |
336 |
< |
DupString(conf->name, gecos); |
337 |
< |
DupString(match_item->reason, reason); |
350 |
< |
DupString(match_item->oper_reason, ""); /* XXX */ |
336 |
> |
conf->name = xstrdup(gecos); |
337 |
> |
conf->reason = xstrdup(reason); |
338 |
|
cur_time = CurrentTime; |
339 |
|
current_date = smalldate(cur_time); |
340 |
+ |
conf->setat = CurrentTime; |
341 |
+ |
|
342 |
+ |
SetConfDatabase(conf); |
343 |
|
|
344 |
|
if (tkline_time != 0) |
345 |
|
{ |
346 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
346 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
347 |
|
"%s added temporary %d min. X-Line for [%s] [%s]", |
348 |
|
get_oper_name(source_p), (int)tkline_time/60, |
349 |
< |
conf->name, match_item->reason); |
349 |
> |
conf->name, conf->reason); |
350 |
|
sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. X-Line [%s]", |
351 |
|
MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), |
352 |
|
source_p->name, (int)tkline_time/60, conf->name); |
353 |
|
ilog(LOG_TYPE_KLINE, "%s added temporary %d min. X-Line for [%s] [%s]", |
354 |
|
source_p->name, (int)tkline_time/60, |
355 |
< |
conf->name, match_item->reason); |
356 |
< |
match_item->hold = CurrentTime + tkline_time; |
367 |
< |
add_temp_line(conf); |
355 |
> |
conf->name, conf->reason); |
356 |
> |
conf->until = CurrentTime + tkline_time; |
357 |
|
} |
358 |
|
else |
359 |
< |
write_conf_line(source_p, conf, current_date, cur_time); |
359 |
> |
{ |
360 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
361 |
> |
"%s added X-Line for [%s] [%s]", |
362 |
> |
get_oper_name(source_p), conf->name, |
363 |
> |
conf->reason); |
364 |
> |
sendto_one(source_p, |
365 |
> |
":%s NOTICE %s :Added X-Line [%s] [%s]", |
366 |
> |
MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), |
367 |
> |
source_p->name, conf->name, conf->reason); |
368 |
> |
ilog(LOG_TYPE_IRCD, "%s added X-Line for [%s] [%s]", |
369 |
> |
get_oper_name(source_p), conf->name, conf->reason); |
370 |
> |
} |
371 |
> |
|
372 |
|
rehashed_klines = 1; |
373 |
|
} |
374 |
|
|
375 |
|
static void |
376 |
|
remove_xline(struct Client *source_p, char *gecos) |
377 |
|
{ |
378 |
< |
/* XXX use common temporary un function later */ |
378 |
< |
if (remove_txline_match(gecos)) |
378 |
> |
if (remove_xline_match(gecos)) |
379 |
|
{ |
380 |
|
sendto_one(source_p, |
381 |
< |
":%s NOTICE %s :Un-xlined [%s] from temporary X-Lines", |
381 |
> |
":%s NOTICE %s :X-Line for [%s] is removed", |
382 |
|
me.name, source_p->name, gecos); |
383 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
384 |
< |
"%s has removed the temporary X-Line for: [%s]", |
385 |
< |
get_oper_name(source_p), gecos); |
386 |
< |
ilog(LOG_TYPE_KLINE, "%s removed temporary X-Line for [%s]", |
387 |
< |
source_p->name, gecos); |
388 |
< |
return; |
389 |
< |
} |
390 |
< |
|
391 |
< |
if (remove_conf_line(XLINE_TYPE, source_p, gecos, NULL) > 0) |
392 |
< |
{ |
393 |
< |
sendto_one(source_p, ":%s NOTICE %s :X-Line for [%s] is removed", |
394 |
< |
me.name, source_p->name, gecos); |
395 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
383 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
384 |
|
"%s has removed the X-Line for: [%s]", |
385 |
|
get_oper_name(source_p), gecos); |
386 |
|
ilog(LOG_TYPE_KLINE, "%s removed X-Line for [%s]", |
387 |
< |
get_oper_name(source_p), gecos); |
387 |
> |
source_p->name, gecos); |
388 |
|
} |
389 |
|
else |
390 |
|
sendto_one(source_p, ":%s NOTICE %s :No X-Line for %s", |
398 |
|
* Side effects: Any matching tklines are removed. |
399 |
|
*/ |
400 |
|
static int |
401 |
< |
remove_txline_match(const char *gecos) |
401 |
> |
remove_xline_match(const char *gecos) |
402 |
|
{ |
403 |
|
dlink_node *ptr = NULL, *next_ptr = NULL; |
416 |
– |
struct ConfItem *conf = NULL; |
404 |
|
|
405 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, temporary_xlines.head) |
405 |
> |
DLINK_FOREACH_SAFE(ptr, next_ptr, xconf_items.head) |
406 |
|
{ |
407 |
< |
conf = ptr->data; |
407 |
> |
struct MaskItem *conf = ptr->data; |
408 |
|
|
409 |
< |
if (irccmp(gecos, conf->name) == 0) |
410 |
< |
{ |
424 |
< |
dlinkDelete(ptr, &temporary_xlines); |
425 |
< |
free_dlink_node(ptr); |
426 |
< |
delete_conf_item(conf); |
409 |
> |
if (!IsConfDatabase(conf)) |
410 |
> |
continue; |
411 |
|
|
412 |
+ |
if (!irccmp(gecos, conf->name)) |
413 |
+ |
{ |
414 |
+ |
conf_free(conf); |
415 |
|
return 1; |
416 |
|
} |
417 |
|
} |