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 |
|
|
47 |
|
|
48 |
|
static int valid_xline(struct Client *, char *, char *, int); |
49 |
|
static void write_xline(struct Client *, char *, char *, time_t); |
50 |
|
static void remove_xline(struct Client *, char *); |
51 |
< |
static int remove_txline_match(const char *); |
51 |
> |
static int remove_xline_match(const char *); |
52 |
|
|
53 |
|
static void relay_xline(struct Client *, char *[]); |
54 |
|
|
68 |
|
{ |
69 |
|
char *reason = NULL; |
70 |
|
char *gecos = NULL; |
71 |
< |
struct ConfItem *conf = NULL; |
71 |
< |
struct MatchItem *match_item = NULL; |
71 |
> |
struct MaskItem *conf = NULL; |
72 |
|
char *target_server = NULL; |
73 |
|
time_t tkline_time = 0; |
74 |
|
|
116 |
|
if (!valid_xline(source_p, gecos, reason, 0)) |
117 |
|
return; |
118 |
|
|
119 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, gecos, |
119 |
> |
if ((conf = find_matching_name_conf(CONF_XLINE, gecos, |
120 |
|
NULL, NULL, 0)) != NULL) |
121 |
|
{ |
122 |
– |
match_item = map_to_conf(conf); |
123 |
– |
|
122 |
|
sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s", |
123 |
|
me.name, source_p->name, gecos, |
124 |
< |
conf->name, match_item->reason); |
124 |
> |
conf->name, conf->reason); |
125 |
|
return; |
126 |
|
} |
127 |
|
|
181 |
|
static void |
182 |
|
relay_xline(struct Client *source_p, char *parv[]) |
183 |
|
{ |
184 |
< |
struct ConfItem *conf; |
187 |
< |
struct MatchItem *match_item; |
184 |
> |
struct MaskItem *conf = NULL; |
185 |
|
int t_sec; |
186 |
|
|
187 |
|
t_sec = atoi(parv[3]); |
196 |
|
if (!match(parv[1], me.name)) |
197 |
|
return; |
198 |
|
|
199 |
< |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, source_p->servptr->name, |
199 |
> |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name, |
200 |
|
source_p->username, source_p->host, |
201 |
|
SHARED_XLINE)) |
202 |
|
{ |
203 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, parv[2], |
203 |
> |
if ((conf = find_matching_name_conf(CONF_XLINE, parv[2], |
204 |
|
NULL, NULL, 0)) != NULL) |
205 |
|
{ |
209 |
– |
match_item = map_to_conf(conf); |
206 |
|
sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s", |
207 |
|
ID_or_name(&me, source_p->from), |
208 |
|
ID_or_name(source_p, source_p->from), |
209 |
< |
parv[2], conf->name, match_item->reason); |
209 |
> |
parv[2], conf->name, conf->reason); |
210 |
|
return; |
211 |
|
} |
212 |
|
|
280 |
|
if (!match(parv[1], me.name)) |
281 |
|
return; |
282 |
|
|
283 |
< |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, source_p->servptr->name, |
283 |
> |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name, |
284 |
|
source_p->username, source_p->host, |
285 |
|
SHARED_UNXLINE)) |
286 |
|
remove_xline(source_p, parv[2]); |
303 |
|
return 0; |
304 |
|
} |
305 |
|
|
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 |
– |
|
306 |
|
if (!valid_wild_card_simple(gecos)) |
307 |
|
{ |
308 |
|
if (warn) |
325 |
|
write_xline(struct Client *source_p, char *gecos, char *reason, |
326 |
|
time_t tkline_time) |
327 |
|
{ |
328 |
< |
struct ConfItem *conf; |
340 |
< |
struct MatchItem *match_item; |
328 |
> |
struct MaskItem *conf; |
329 |
|
const char *current_date; |
330 |
|
time_t cur_time; |
331 |
|
|
332 |
< |
conf = make_conf_item(XLINE_TYPE); |
345 |
< |
match_item = map_to_conf(conf); |
332 |
> |
conf = conf_make(CONF_XLINE); |
333 |
|
|
334 |
|
collapse(gecos); |
335 |
|
DupString(conf->name, gecos); |
336 |
< |
DupString(match_item->reason, reason); |
350 |
< |
DupString(match_item->oper_reason, ""); /* XXX */ |
336 |
> |
DupString(conf->reason, reason); |
337 |
|
cur_time = CurrentTime; |
338 |
|
current_date = smalldate(cur_time); |
339 |
+ |
conf->setat = CurrentTime; |
340 |
+ |
|
341 |
+ |
SetConfDatabase(conf); |
342 |
|
|
343 |
|
if (tkline_time != 0) |
344 |
|
{ |
345 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
345 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
346 |
|
"%s added temporary %d min. X-Line for [%s] [%s]", |
347 |
|
get_oper_name(source_p), (int)tkline_time/60, |
348 |
< |
conf->name, match_item->reason); |
348 |
> |
conf->name, conf->reason); |
349 |
|
sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. X-Line [%s]", |
350 |
|
MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), |
351 |
|
source_p->name, (int)tkline_time/60, conf->name); |
352 |
|
ilog(LOG_TYPE_KLINE, "%s added temporary %d min. X-Line for [%s] [%s]", |
353 |
|
source_p->name, (int)tkline_time/60, |
354 |
< |
conf->name, match_item->reason); |
355 |
< |
match_item->hold = CurrentTime + tkline_time; |
367 |
< |
add_temp_line(conf); |
354 |
> |
conf->name, conf->reason); |
355 |
> |
conf->hold = CurrentTime + tkline_time; |
356 |
|
} |
357 |
|
else |
358 |
< |
write_conf_line(source_p, conf, current_date, cur_time); |
358 |
> |
{ |
359 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
360 |
> |
"%s added X-Line for [%s] [%s]", |
361 |
> |
get_oper_name(source_p), conf->name, |
362 |
> |
conf->reason); |
363 |
> |
sendto_one(source_p, |
364 |
> |
":%s NOTICE %s :Added X-Line [%s] [%s]", |
365 |
> |
MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), |
366 |
> |
source_p->name, conf->name, conf->reason); |
367 |
> |
ilog(LOG_TYPE_IRCD, "%s added X-Line for [%s] [%s]", |
368 |
> |
get_oper_name(source_p), conf->name, conf->reason); |
369 |
> |
} |
370 |
> |
|
371 |
|
rehashed_klines = 1; |
372 |
|
} |
373 |
|
|
374 |
|
static void |
375 |
|
remove_xline(struct Client *source_p, char *gecos) |
376 |
|
{ |
377 |
< |
/* XXX use common temporary un function later */ |
378 |
< |
if (remove_txline_match(gecos)) |
377 |
> |
if (remove_xline_match(gecos)) |
378 |
|
{ |
379 |
|
sendto_one(source_p, |
380 |
< |
":%s NOTICE %s :Un-xlined [%s] from temporary X-Lines", |
380 |
> |
":%s NOTICE %s :X-Line for [%s] is removed", |
381 |
|
me.name, source_p->name, gecos); |
382 |
< |
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, |
382 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
383 |
|
"%s has removed the X-Line for: [%s]", |
384 |
|
get_oper_name(source_p), gecos); |
385 |
|
ilog(LOG_TYPE_KLINE, "%s removed X-Line for [%s]", |
386 |
< |
get_oper_name(source_p), gecos); |
386 |
> |
source_p->name, gecos); |
387 |
|
} |
388 |
|
else |
389 |
|
sendto_one(source_p, ":%s NOTICE %s :No X-Line for %s", |
397 |
|
* Side effects: Any matching tklines are removed. |
398 |
|
*/ |
399 |
|
static int |
400 |
< |
remove_txline_match(const char *gecos) |
400 |
> |
remove_xline_match(const char *gecos) |
401 |
|
{ |
402 |
|
dlink_node *ptr = NULL, *next_ptr = NULL; |
416 |
– |
struct ConfItem *conf = NULL; |
403 |
|
|
404 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, temporary_xlines.head) |
404 |
> |
DLINK_FOREACH_SAFE(ptr, next_ptr, xconf_items.head) |
405 |
|
{ |
406 |
< |
conf = ptr->data; |
406 |
> |
struct MaskItem *conf = ptr->data; |
407 |
|
|
408 |
< |
if (irccmp(gecos, conf->name) == 0) |
409 |
< |
{ |
424 |
< |
dlinkDelete(ptr, &temporary_xlines); |
425 |
< |
free_dlink_node(ptr); |
426 |
< |
delete_conf_item(conf); |
408 |
> |
if (!IsConfDatabase(conf)) |
409 |
> |
continue; |
410 |
|
|
411 |
+ |
if (!irccmp(gecos, conf->name)) |
412 |
+ |
{ |
413 |
+ |
conf_free(conf); |
414 |
|
return 1; |
415 |
|
} |
416 |
|
} |