1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* s_conf.c: Configuration file functions. |
3 |
> |
* conf.c: Configuration file functions. |
4 |
|
* |
5 |
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
|
* |
26 |
|
#include "list.h" |
27 |
|
#include "ircd_defs.h" |
28 |
|
#include "balloc.h" |
29 |
< |
#include "s_conf.h" |
29 |
> |
#include "conf.h" |
30 |
|
#include "s_serv.h" |
31 |
|
#include "resv.h" |
32 |
|
#include "channel.h" |
33 |
|
#include "client.h" |
34 |
– |
#include "common.h" |
34 |
|
#include "event.h" |
36 |
– |
#include "hash.h" |
35 |
|
#include "hook.h" |
36 |
|
#include "irc_string.h" |
39 |
– |
#include "sprintf_irc.h" |
37 |
|
#include "s_bsd.h" |
38 |
|
#include "ircd.h" |
39 |
|
#include "listener.h" |
41 |
|
#include "modules.h" |
42 |
|
#include "numeric.h" |
43 |
|
#include "fdlist.h" |
44 |
< |
#include "s_log.h" |
44 |
> |
#include "log.h" |
45 |
|
#include "send.h" |
46 |
|
#include "s_gline.h" |
50 |
– |
#include "fileio.h" |
47 |
|
#include "memory.h" |
48 |
|
#include "irc_res.h" |
49 |
|
#include "userhost.h" |
50 |
|
#include "s_user.h" |
51 |
|
#include "channel_mode.h" |
52 |
+ |
#include "parse.h" |
53 |
+ |
#include "s_misc.h" |
54 |
|
|
55 |
|
struct Callback *client_check_cb = NULL; |
56 |
|
struct config_server_hide ConfigServerHide; |
59 |
|
dlink_list service_items = { NULL, NULL, 0 }; |
60 |
|
dlink_list server_items = { NULL, NULL, 0 }; |
61 |
|
dlink_list cluster_items = { NULL, NULL, 0 }; |
64 |
– |
dlink_list hub_items = { NULL, NULL, 0 }; |
65 |
– |
dlink_list leaf_items = { NULL, NULL, 0 }; |
62 |
|
dlink_list oconf_items = { NULL, NULL, 0 }; |
63 |
|
dlink_list uconf_items = { NULL, NULL, 0 }; |
64 |
|
dlink_list xconf_items = { NULL, NULL, 0 }; |
68 |
|
dlink_list class_items = { NULL, NULL, 0 }; |
69 |
|
dlink_list gdeny_items = { NULL, NULL, 0 }; |
70 |
|
|
75 |
– |
dlink_list temporary_klines = { NULL, NULL, 0 }; |
76 |
– |
dlink_list temporary_dlines = { NULL, NULL, 0 }; |
71 |
|
dlink_list temporary_xlines = { NULL, NULL, 0 }; |
78 |
– |
dlink_list temporary_rklines = { NULL, NULL, 0 }; |
79 |
– |
dlink_list temporary_glines = { NULL, NULL, 0 }; |
80 |
– |
dlink_list temporary_rxlines = { NULL, NULL, 0 }; |
72 |
|
dlink_list temporary_resv = { NULL, NULL, 0 }; |
73 |
|
|
74 |
|
extern unsigned int lineno; |
75 |
|
extern char linebuf[]; |
76 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
86 |
– |
extern char yytext[]; |
77 |
|
extern int yyparse(); /* defined in y.tab.c */ |
78 |
|
|
79 |
|
struct conf_parser_context conf_parser_ctx = { 0, 0, NULL }; |
80 |
|
|
81 |
|
/* internally defined functions */ |
82 |
< |
static void lookup_confhost(struct ConfItem *); |
93 |
< |
static void set_default_conf(void); |
94 |
< |
static void validate_conf(void); |
95 |
< |
static void read_conf(FBFILE *); |
82 |
> |
static void read_conf(FILE *); |
83 |
|
static void clear_out_old_conf(void); |
84 |
|
static void flush_deleted_I_P(void); |
85 |
|
static void expire_tklines(dlink_list *); |
161 |
|
aconf->dns_pending = 0; |
162 |
|
|
163 |
|
if (addr != NULL) |
164 |
< |
memcpy(&aconf->ipnum, addr, sizeof(aconf->ipnum)); |
164 |
> |
memcpy(&aconf->addr, addr, sizeof(aconf->addr)); |
165 |
|
else |
166 |
|
aconf->dns_failed = 1; |
167 |
|
} |
249 |
|
aconf->status = status; |
250 |
|
break; |
251 |
|
|
265 |
– |
case LEAF_TYPE: |
266 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
267 |
– |
sizeof(struct MatchItem)); |
268 |
– |
dlinkAdd(conf, &conf->node, &leaf_items); |
269 |
– |
break; |
270 |
– |
|
271 |
– |
case HUB_TYPE: |
272 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
273 |
– |
sizeof(struct MatchItem)); |
274 |
– |
dlinkAdd(conf, &conf->node, &hub_items); |
275 |
– |
break; |
276 |
– |
|
252 |
|
case ULINE_TYPE: |
253 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
254 |
|
sizeof(struct MatchItem)); |
310 |
|
|
311 |
|
aclass = map_to_conf(conf); |
312 |
|
aclass->active = 1; |
313 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
314 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
315 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
316 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
313 |
> |
aclass->con_freq = DEFAULT_CONNECTFREQUENCY; |
314 |
> |
aclass->ping_freq = DEFAULT_PINGFREQUENCY; |
315 |
> |
aclass->max_total = MAXIMUM_LINKS_DEFAULT; |
316 |
> |
aclass->max_sendq = DEFAULT_SENDQ; |
317 |
|
|
318 |
|
break; |
319 |
|
|
331 |
|
void |
332 |
|
delete_conf_item(struct ConfItem *conf) |
333 |
|
{ |
334 |
< |
dlink_node *m = NULL; |
334 |
> |
dlink_node *m = NULL, *m_next = NULL; |
335 |
|
struct MatchItem *match_item; |
336 |
|
struct AccessItem *aconf; |
337 |
|
ConfType type = conf->type; |
365 |
|
MyFree(aconf->user); |
366 |
|
MyFree(aconf->host); |
367 |
|
#ifdef HAVE_LIBCRYPTO |
368 |
+ |
MyFree(aconf->cipher_list); |
369 |
+ |
|
370 |
|
if (aconf->rsa_public_key) |
371 |
|
RSA_free(aconf->rsa_public_key); |
372 |
|
MyFree(aconf->rsa_public_key_file); |
392 |
|
|
393 |
|
case SERVER_TYPE: |
394 |
|
aconf = map_to_conf(conf); |
395 |
+ |
|
396 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head) |
397 |
+ |
{ |
398 |
+ |
MyFree(m->data); |
399 |
+ |
free_dlink_node(m); |
400 |
+ |
} |
401 |
+ |
|
402 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head) |
403 |
+ |
{ |
404 |
+ |
MyFree(m->data); |
405 |
+ |
free_dlink_node(m); |
406 |
+ |
} |
407 |
+ |
|
408 |
|
if (!IsConfIllegal(aconf)) |
409 |
|
dlinkDelete(&conf->node, &server_items); |
410 |
|
MyFree(conf); |
415 |
|
} |
416 |
|
break; |
417 |
|
|
428 |
– |
case HUB_TYPE: |
429 |
– |
match_item = map_to_conf(conf); |
430 |
– |
MyFree(match_item->user); |
431 |
– |
MyFree(match_item->host); |
432 |
– |
MyFree(match_item->reason); |
433 |
– |
MyFree(match_item->oper_reason); |
434 |
– |
/* If marked illegal, its already been pulled off of the hub_items list */ |
435 |
– |
if (!match_item->illegal) |
436 |
– |
dlinkDelete(&conf->node, &hub_items); |
437 |
– |
MyFree(conf); |
438 |
– |
break; |
439 |
– |
|
440 |
– |
case LEAF_TYPE: |
441 |
– |
match_item = map_to_conf(conf); |
442 |
– |
MyFree(match_item->user); |
443 |
– |
MyFree(match_item->host); |
444 |
– |
MyFree(match_item->reason); |
445 |
– |
MyFree(match_item->oper_reason); |
446 |
– |
/* If marked illegal, its already been pulled off of the leaf_items list */ |
447 |
– |
if (!match_item->illegal) |
448 |
– |
dlinkDelete(&conf->node, &leaf_items); |
449 |
– |
MyFree(conf); |
450 |
– |
break; |
451 |
– |
|
418 |
|
case ULINE_TYPE: |
419 |
|
match_item = map_to_conf(conf); |
420 |
|
MyFree(match_item->user); |
537 |
|
* side effects - |
538 |
|
*/ |
539 |
|
void |
540 |
< |
report_confitem_types(struct Client *source_p, ConfType type, int temp) |
540 |
> |
report_confitem_types(struct Client *source_p, ConfType type) |
541 |
|
{ |
542 |
< |
dlink_node *ptr = NULL; |
542 |
> |
dlink_node *ptr = NULL, *dptr = NULL; |
543 |
|
struct ConfItem *conf = NULL; |
544 |
|
struct AccessItem *aconf = NULL; |
545 |
|
struct MatchItem *matchitem = NULL; |
546 |
|
struct ClassItem *classitem = NULL; |
547 |
|
char buf[12]; |
548 |
|
char *p = NULL; |
583 |
– |
const char *pfx = NULL; |
549 |
|
|
550 |
|
switch (type) |
551 |
|
{ |
597 |
|
|
598 |
|
sendto_one(source_p, form_str(RPL_STATSXLINE), |
599 |
|
me.name, source_p->name, |
600 |
< |
matchitem->hold ? "xR": "XR", matchitem->count, |
600 |
> |
"XR", matchitem->count, |
601 |
|
conf->name, matchitem->reason); |
602 |
|
} |
603 |
|
break; |
604 |
|
|
605 |
|
case RKLINE_TYPE: |
641 |
– |
pfx = temp ? "kR" : "KR"; |
642 |
– |
|
606 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
607 |
|
{ |
608 |
|
aconf = map_to_conf((conf = ptr->data)); |
609 |
|
|
647 |
– |
if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY)) |
648 |
– |
continue; |
649 |
– |
|
610 |
|
sendto_one(source_p, form_str(RPL_STATSKLINE), me.name, |
611 |
< |
source_p->name, pfx, aconf->host, aconf->user, |
611 |
> |
source_p->name, "KR", aconf->host, aconf->user, |
612 |
|
aconf->reason, aconf->oper_reason ? aconf->oper_reason : ""); |
613 |
|
} |
614 |
|
break; |
657 |
|
aconf = map_to_conf(conf); |
658 |
|
|
659 |
|
/* Don't allow non opers to see oper privs */ |
660 |
< |
if (IsOper(source_p)) |
660 |
> |
if (HasUMode(source_p, UMODE_OPER)) |
661 |
|
sendto_one(source_p, form_str(RPL_STATSOLINE), |
662 |
|
me.name, source_p->name, 'O', aconf->user, aconf->host, |
663 |
|
conf->name, oper_privs_as_string(aconf->port), |
677 |
|
classitem = map_to_conf(conf); |
678 |
|
sendto_one(source_p, form_str(RPL_STATSYLINE), |
679 |
|
me.name, source_p->name, 'Y', |
680 |
< |
conf->name, PingFreq(classitem), |
681 |
< |
ConFreq(classitem), |
682 |
< |
MaxTotal(classitem), MaxSendq(classitem), |
683 |
< |
CurrUserCount(classitem), |
680 |
> |
conf->name, classitem->ping_freq, |
681 |
> |
classitem->con_freq, |
682 |
> |
classitem->max_total, classitem->max_sendq, |
683 |
> |
classitem->curr_user_count, |
684 |
> |
classitem->number_per_cidr, classitem->cidr_bitlen_ipv4, |
685 |
> |
classitem->number_per_cidr, classitem->cidr_bitlen_ipv6, |
686 |
|
classitem->active ? "active" : "disabled"); |
687 |
|
} |
688 |
|
break; |
712 |
|
|
713 |
|
if (IsConfAllowAutoConn(aconf)) |
714 |
|
*p++ = 'A'; |
715 |
< |
if (IsConfCryptLink(aconf)) |
716 |
< |
*p++ = 'C'; |
715 |
> |
if (IsConfSSL(aconf)) |
716 |
> |
*p++ = 'S'; |
717 |
|
if (IsConfTopicBurst(aconf)) |
718 |
|
*p++ = 'T'; |
757 |
– |
if (IsConfCompressed(aconf)) |
758 |
– |
*p++ = 'Z'; |
719 |
|
if (buf[0] == '\0') |
720 |
|
*p++ = '*'; |
721 |
|
|
724 |
|
/* |
725 |
|
* Allow admins to see actual ips unless hide_server_ips is enabled |
726 |
|
*/ |
727 |
< |
if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p)) |
727 |
> |
if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN)) |
728 |
|
sendto_one(source_p, form_str(RPL_STATSCLINE), |
729 |
|
me.name, source_p->name, 'C', aconf->host, |
730 |
|
buf, conf->name, aconf->port, |
738 |
|
break; |
739 |
|
|
740 |
|
case HUB_TYPE: |
741 |
< |
DLINK_FOREACH(ptr, hub_items.head) |
741 |
> |
DLINK_FOREACH(ptr, server_items.head) |
742 |
|
{ |
743 |
|
conf = ptr->data; |
744 |
< |
matchitem = map_to_conf(conf); |
745 |
< |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
746 |
< |
source_p->name, 'H', matchitem->host, conf->name, 0, "*"); |
744 |
> |
aconf = map_to_conf(conf); |
745 |
> |
|
746 |
> |
DLINK_FOREACH(dptr, aconf->hub_list.head) |
747 |
> |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
748 |
> |
source_p->name, 'H', dptr->data, conf->name, 0, "*"); |
749 |
|
} |
750 |
|
break; |
751 |
|
|
752 |
|
case LEAF_TYPE: |
753 |
< |
DLINK_FOREACH(ptr, leaf_items.head) |
753 |
> |
DLINK_FOREACH(ptr, server_items.head) |
754 |
|
{ |
755 |
|
conf = ptr->data; |
756 |
< |
matchitem = map_to_conf(conf); |
757 |
< |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
758 |
< |
source_p->name, 'L', matchitem->host, conf->name, 0, "*"); |
756 |
> |
aconf = map_to_conf(conf); |
757 |
> |
|
758 |
> |
DLINK_FOREACH(dptr, aconf->leaf_list.head) |
759 |
> |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
760 |
> |
source_p->name, 'L', dptr->data, conf->name, 0, "*"); |
761 |
|
} |
762 |
|
break; |
763 |
|
|
795 |
|
|
796 |
|
/* I'm already in big trouble if source_p->localClient is NULL -db */ |
797 |
|
if ((i = verify_access(source_p, username))) |
798 |
< |
ilog(L_INFO, "Access denied: %s[%s]", |
798 |
> |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
799 |
|
source_p->name, source_p->sockhost); |
800 |
|
|
801 |
|
switch (i) |
805 |
|
"Too many on IP for %s (%s).", |
806 |
|
get_client_name(source_p, SHOW_IP), |
807 |
|
source_p->sockhost); |
808 |
< |
ilog(L_INFO,"Too many connections on IP from %s.", |
808 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
809 |
|
get_client_name(source_p, SHOW_IP)); |
810 |
|
++ServerStats.is_ref; |
811 |
|
exit_client(source_p, &me, "No more connections allowed on that IP"); |
816 |
|
"I-line is full for %s (%s).", |
817 |
|
get_client_name(source_p, SHOW_IP), |
818 |
|
source_p->sockhost); |
819 |
< |
ilog(L_INFO,"Too many connections from %s.", |
819 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
820 |
|
get_client_name(source_p, SHOW_IP)); |
821 |
|
++ServerStats.is_ref; |
822 |
|
exit_client(source_p, &me, |
833 |
|
source_p->sockhost, |
834 |
|
source_p->localClient->listener->name, |
835 |
|
source_p->localClient->listener->port); |
836 |
< |
ilog(L_INFO, |
836 |
> |
ilog(LOG_TYPE_IRCD, |
837 |
|
"Unauthorized client connection from %s on [%s/%u].", |
838 |
|
get_client_name(source_p, SHOW_IP), |
839 |
|
source_p->localClient->listener->name, |
996 |
|
* setting a_limit_reached if any limit is reached. |
997 |
|
* - Dianora |
998 |
|
*/ |
999 |
< |
if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass)) |
999 |
> |
if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total) |
1000 |
|
a_limit_reached = 1; |
1001 |
< |
else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass)) |
1001 |
> |
else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip) |
1002 |
|
a_limit_reached = 1; |
1003 |
< |
else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass)) |
1003 |
> |
else if (aclass->max_local != 0 && local >= aclass->max_local) |
1004 |
|
a_limit_reached = 1; |
1005 |
< |
else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass)) |
1005 |
> |
else if (aclass->max_global != 0 && global >= aclass->max_global) |
1006 |
|
a_limit_reached = 1; |
1007 |
< |
else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) && |
1007 |
> |
else if (aclass->max_ident != 0 && ident >= aclass->max_ident && |
1008 |
|
client_p->username[0] != '~') |
1009 |
|
a_limit_reached = 1; |
1010 |
|
|
1287 |
|
|
1288 |
|
assert(aconf->clients > 0); |
1289 |
|
|
1290 |
< |
if ((aclass_conf = ClassPtr(aconf)) != NULL) |
1290 |
> |
if ((aclass_conf = aconf->class_ptr) != NULL) |
1291 |
|
{ |
1292 |
|
aclass = map_to_conf(aclass_conf); |
1293 |
|
|
1303 |
|
delete_conf_item(conf); |
1304 |
|
|
1305 |
|
break; |
1342 |
– |
|
1343 |
– |
case LEAF_TYPE: |
1344 |
– |
case HUB_TYPE: |
1345 |
– |
match_item = map_to_conf(conf); |
1346 |
– |
if (match_item->ref_count == 0 && match_item->illegal) |
1347 |
– |
delete_conf_item(conf); |
1348 |
– |
break; |
1306 |
|
default: |
1307 |
|
break; |
1308 |
|
} |
1328 |
|
int |
1329 |
|
attach_conf(struct Client *client_p, struct ConfItem *conf) |
1330 |
|
{ |
1331 |
+ |
struct AccessItem *aconf = map_to_conf(conf); |
1332 |
+ |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1333 |
+ |
|
1334 |
|
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
1335 |
|
return 1; |
1336 |
|
|
1337 |
< |
if (conf->type == CLIENT_TYPE || |
1338 |
< |
conf->type == SERVER_TYPE || |
1379 |
< |
conf->type == OPER_TYPE) |
1380 |
< |
{ |
1381 |
< |
struct AccessItem *aconf = map_to_conf(conf); |
1382 |
< |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1383 |
< |
|
1384 |
< |
if (IsConfIllegal(aconf)) |
1385 |
< |
return NOT_AUTHORIZED; |
1337 |
> |
if (IsConfIllegal(aconf)) /* TBV: can't happen */ |
1338 |
> |
return NOT_AUTHORIZED; |
1339 |
|
|
1340 |
< |
if (conf->type == CLIENT_TYPE) |
1341 |
< |
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1342 |
< |
&client_p->localClient->ip, aclass)) |
1343 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1340 |
> |
if (conf->type == CLIENT_TYPE) |
1341 |
> |
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1342 |
> |
&client_p->localClient->ip, aclass)) |
1343 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1344 |
|
|
1345 |
< |
CurrUserCount(aclass)++; |
1346 |
< |
aconf->clients++; |
1394 |
< |
} |
1395 |
< |
else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE) |
1396 |
< |
{ |
1397 |
< |
struct MatchItem *match_item = map_to_conf(conf); |
1398 |
< |
match_item->ref_count++; |
1399 |
< |
} |
1345 |
> |
aclass->curr_user_count++; |
1346 |
> |
aconf->clients++; |
1347 |
|
|
1348 |
|
dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs); |
1349 |
|
|
1432 |
|
{ |
1433 |
|
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1434 |
|
|
1435 |
< |
if (aconf->clients >= MaxTotal(aclass)) |
1435 |
> |
if (aconf->clients >= aclass->max_total) |
1436 |
|
continue; |
1437 |
|
} |
1438 |
|
|
1619 |
|
* side effects - looks for an exact match on name field |
1620 |
|
*/ |
1621 |
|
struct ConfItem * |
1622 |
< |
find_exact_name_conf(ConfType type, const char *name, |
1622 |
> |
find_exact_name_conf(ConfType type, const struct Client *who, const char *name, |
1623 |
|
const char *user, const char *host) |
1624 |
|
{ |
1625 |
|
dlink_node *ptr = NULL; |
1660 |
|
DLINK_FOREACH(ptr, list_p->head) |
1661 |
|
{ |
1662 |
|
conf = ptr->data; |
1663 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1663 |
> |
aconf = map_to_conf(conf); |
1664 |
> |
|
1665 |
|
if (EmptyString(conf->name)) |
1666 |
< |
continue; |
1667 |
< |
|
1668 |
< |
if (irccmp(conf->name, name) == 0) |
1666 |
> |
continue; |
1667 |
> |
|
1668 |
> |
if (!irccmp(conf->name, name)) |
1669 |
|
{ |
1670 |
< |
if ((user == NULL && (host == NULL))) |
1671 |
< |
return (conf); |
1672 |
< |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
1673 |
< |
return (conf); |
1674 |
< |
if (match(aconf->user, user) && match(aconf->host, host)) |
1675 |
< |
return (conf); |
1670 |
> |
if (!who) |
1671 |
> |
return conf; |
1672 |
> |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
1673 |
> |
return conf; |
1674 |
> |
if (match(aconf->user, who->username)) |
1675 |
> |
{ |
1676 |
> |
switch (aconf->type) |
1677 |
> |
{ |
1678 |
> |
case HM_HOST: |
1679 |
> |
if (match(aconf->host, who->host) || match(aconf->host, who->sockhost)) |
1680 |
> |
return conf; |
1681 |
> |
break; |
1682 |
> |
case HM_IPV4: |
1683 |
> |
if (who->localClient->aftype == AF_INET) |
1684 |
> |
if (match_ipv4(&who->localClient->ip, &aconf->addr, aconf->bits)) |
1685 |
> |
return conf; |
1686 |
> |
break; |
1687 |
> |
#ifdef IPV6 |
1688 |
> |
case HM_IPV6: |
1689 |
> |
if (who->localClient->aftype == AF_INET6) |
1690 |
> |
if (match_ipv6(&who->localClient->ip, &aconf->addr, aconf->bits)) |
1691 |
> |
return conf; |
1692 |
> |
break; |
1693 |
> |
#endif |
1694 |
> |
default: |
1695 |
> |
assert(0); |
1696 |
> |
} |
1697 |
> |
} |
1698 |
|
} |
1699 |
|
} |
1700 |
+ |
|
1701 |
|
break; |
1702 |
|
|
1703 |
|
case SERVER_TYPE: |
1770 |
|
flush_deleted_I_P(); |
1771 |
|
|
1772 |
|
rehashed_klines = 1; |
1773 |
< |
|
1773 |
> |
/* XXX */ |
1774 |
|
if (ConfigLoggingEntry.use_logging) |
1775 |
< |
reopen_log(logFileName); |
1775 |
> |
log_close_all(); |
1776 |
|
|
1777 |
|
return(0); |
1778 |
|
} |
1819 |
|
AdminInfo.email = NULL; |
1820 |
|
AdminInfo.description = NULL; |
1821 |
|
|
1822 |
< |
set_log_level(L_NOTICE); |
1822 |
> |
log_close_all(); |
1823 |
> |
|
1824 |
|
ConfigLoggingEntry.use_logging = 1; |
1825 |
< |
ConfigLoggingEntry.operlog[0] = '\0'; |
1826 |
< |
ConfigLoggingEntry.userlog[0] = '\0'; |
1827 |
< |
ConfigLoggingEntry.klinelog[0] = '\0'; |
1828 |
< |
ConfigLoggingEntry.glinelog[0] = '\0'; |
1829 |
< |
ConfigLoggingEntry.killlog[0] = '\0'; |
1830 |
< |
ConfigLoggingEntry.operspylog[0] = '\0'; |
1831 |
< |
ConfigLoggingEntry.ioerrlog[0] = '\0'; |
1860 |
< |
ConfigLoggingEntry.failed_operlog[0] = '\0'; |
1861 |
< |
|
1862 |
< |
ConfigChannel.disable_fake_channels = NO; |
1863 |
< |
ConfigChannel.restrict_channels = NO; |
1864 |
< |
ConfigChannel.disable_local_channels = NO; |
1865 |
< |
ConfigChannel.use_invex = YES; |
1866 |
< |
ConfigChannel.use_except = YES; |
1867 |
< |
ConfigChannel.use_knock = YES; |
1825 |
> |
|
1826 |
> |
ConfigChannel.disable_fake_channels = 0; |
1827 |
> |
ConfigChannel.restrict_channels = 0; |
1828 |
> |
ConfigChannel.disable_local_channels = 0; |
1829 |
> |
ConfigChannel.use_invex = 1; |
1830 |
> |
ConfigChannel.use_except = 1; |
1831 |
> |
ConfigChannel.use_knock = 1; |
1832 |
|
ConfigChannel.knock_delay = 300; |
1833 |
|
ConfigChannel.knock_delay_channel = 60; |
1834 |
|
ConfigChannel.max_chans_per_user = 15; |
1835 |
< |
ConfigChannel.quiet_on_ban = YES; |
1835 |
> |
ConfigChannel.quiet_on_ban = 1; |
1836 |
|
ConfigChannel.max_bans = 25; |
1837 |
|
ConfigChannel.default_split_user_count = 0; |
1838 |
|
ConfigChannel.default_split_server_count = 0; |
1839 |
< |
ConfigChannel.no_join_on_split = NO; |
1840 |
< |
ConfigChannel.no_create_on_split = NO; |
1877 |
< |
ConfigChannel.burst_topicwho = YES; |
1839 |
> |
ConfigChannel.no_join_on_split = 0; |
1840 |
> |
ConfigChannel.no_create_on_split = 0; |
1841 |
|
|
1842 |
< |
ConfigServerHide.flatten_links = NO; |
1842 |
> |
ConfigServerHide.flatten_links = 0; |
1843 |
|
ConfigServerHide.links_delay = 300; |
1844 |
< |
ConfigServerHide.hidden = NO; |
1845 |
< |
ConfigServerHide.disable_hidden = NO; |
1846 |
< |
ConfigServerHide.hide_servers = NO; |
1844 |
> |
ConfigServerHide.hidden = 0; |
1845 |
> |
ConfigServerHide.disable_hidden = 0; |
1846 |
> |
ConfigServerHide.hide_servers = 0; |
1847 |
|
DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT); |
1848 |
< |
ConfigServerHide.hide_server_ips = NO; |
1848 |
> |
ConfigServerHide.hide_server_ips = 0; |
1849 |
|
|
1850 |
|
|
1851 |
|
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1852 |
|
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1853 |
|
ConfigFileEntry.gline_min_cidr = 16; |
1854 |
|
ConfigFileEntry.gline_min_cidr6 = 48; |
1855 |
< |
ConfigFileEntry.invisible_on_connect = YES; |
1856 |
< |
ConfigFileEntry.burst_away = NO; |
1857 |
< |
ConfigFileEntry.use_whois_actually = YES; |
1858 |
< |
ConfigFileEntry.tkline_expire_notices = YES; |
1859 |
< |
ConfigFileEntry.hide_spoof_ips = YES; |
1860 |
< |
ConfigFileEntry.ignore_bogus_ts = NO; |
1861 |
< |
ConfigFileEntry.disable_auth = NO; |
1862 |
< |
ConfigFileEntry.disable_remote = NO; |
1855 |
> |
ConfigFileEntry.invisible_on_connect = 1; |
1856 |
> |
ConfigFileEntry.burst_away = 0; |
1857 |
> |
ConfigFileEntry.use_whois_actually = 1; |
1858 |
> |
ConfigFileEntry.tkline_expire_notices = 1; |
1859 |
> |
ConfigFileEntry.hide_spoof_ips = 1; |
1860 |
> |
ConfigFileEntry.ignore_bogus_ts = 0; |
1861 |
> |
ConfigFileEntry.disable_auth = 0; |
1862 |
> |
ConfigFileEntry.disable_remote = 0; |
1863 |
|
ConfigFileEntry.kill_chase_time_limit = 90; |
1864 |
|
ConfigFileEntry.default_floodcount = 8; |
1865 |
< |
ConfigFileEntry.failed_oper_notice = YES; |
1865 |
> |
ConfigFileEntry.failed_oper_notice = 1; |
1866 |
|
ConfigFileEntry.dots_in_ident = 0; |
1867 |
|
ConfigFileEntry.min_nonwildcard = 4; |
1868 |
|
ConfigFileEntry.min_nonwildcard_simple = 3; |
1869 |
|
ConfigFileEntry.max_accept = 20; |
1870 |
< |
ConfigFileEntry.anti_nick_flood = NO; |
1870 |
> |
ConfigFileEntry.anti_nick_flood = 0; |
1871 |
|
ConfigFileEntry.max_nick_time = 20; |
1872 |
|
ConfigFileEntry.max_nick_changes = 5; |
1873 |
|
ConfigFileEntry.anti_spam_exit_message_time = 0; |
1874 |
|
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1875 |
|
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1876 |
< |
ConfigFileEntry.kline_with_reason = YES; |
1876 |
> |
ConfigFileEntry.kline_with_reason = 1; |
1877 |
|
ConfigFileEntry.kline_reason = NULL; |
1878 |
< |
ConfigFileEntry.warn_no_nline = YES; |
1879 |
< |
ConfigFileEntry.stats_o_oper_only = NO; |
1878 |
> |
ConfigFileEntry.warn_no_nline = 1; |
1879 |
> |
ConfigFileEntry.stats_o_oper_only = 0; |
1880 |
|
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
1881 |
|
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
1882 |
< |
ConfigFileEntry.stats_P_oper_only = NO; |
1882 |
> |
ConfigFileEntry.stats_P_oper_only = 0; |
1883 |
|
ConfigFileEntry.caller_id_wait = 60; |
1884 |
< |
ConfigFileEntry.opers_bypass_callerid = NO; |
1884 |
> |
ConfigFileEntry.opers_bypass_callerid = 0; |
1885 |
|
ConfigFileEntry.pace_wait = 10; |
1886 |
|
ConfigFileEntry.pace_wait_simple = 1; |
1887 |
< |
ConfigFileEntry.short_motd = NO; |
1888 |
< |
ConfigFileEntry.ping_cookie = NO; |
1889 |
< |
ConfigFileEntry.no_oper_flood = NO; |
1890 |
< |
ConfigFileEntry.true_no_oper_flood = NO; |
1891 |
< |
ConfigFileEntry.oper_pass_resv = YES; |
1892 |
< |
ConfigFileEntry.glines = NO; |
1887 |
> |
ConfigFileEntry.short_motd = 0; |
1888 |
> |
ConfigFileEntry.ping_cookie = 0; |
1889 |
> |
ConfigFileEntry.no_oper_flood = 0; |
1890 |
> |
ConfigFileEntry.true_no_oper_flood = 0; |
1891 |
> |
ConfigFileEntry.oper_pass_resv = 1; |
1892 |
> |
ConfigFileEntry.glines = 0; |
1893 |
|
ConfigFileEntry.gline_time = 12 * 3600; |
1894 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1895 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT; |
1896 |
|
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
1897 |
|
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1898 |
|
UMODE_OPERWALL | UMODE_WALLOP; |
1899 |
< |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1937 |
< |
#ifdef HAVE_LIBCRYPTO |
1938 |
< |
/* jdc -- This is our default value for a cipher. According to the |
1939 |
< |
* CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported |
1940 |
< |
* under all circumstances if cryptlinks are enabled. So, |
1941 |
< |
* this will be our default. |
1942 |
< |
* |
1943 |
< |
* NOTE: I apologise for the hard-coded value of "1" (BF/128). |
1944 |
< |
* This should be moved into a find_cipher() routine. |
1945 |
< |
*/ |
1946 |
< |
ConfigFileEntry.default_cipher_preference = &CipherTable[1]; |
1947 |
< |
#endif |
1948 |
< |
ConfigFileEntry.use_egd = NO; |
1899 |
> |
ConfigFileEntry.use_egd = 0; |
1900 |
|
ConfigFileEntry.egdpool_path = NULL; |
1950 |
– |
#ifdef HAVE_LIBZ |
1951 |
– |
ConfigFileEntry.compression_level = 0; |
1952 |
– |
#endif |
1901 |
|
ConfigFileEntry.throttle_time = 10; |
1902 |
|
} |
1903 |
|
|
1956 |
– |
/* read_conf() |
1957 |
– |
* |
1958 |
– |
* inputs - file descriptor pointing to config file to use |
1959 |
– |
* output - None |
1960 |
– |
* side effects - Read configuration file. |
1961 |
– |
*/ |
1962 |
– |
static void |
1963 |
– |
read_conf(FBFILE *file) |
1964 |
– |
{ |
1965 |
– |
lineno = 0; |
1966 |
– |
|
1967 |
– |
set_default_conf(); /* Set default values prior to conf parsing */ |
1968 |
– |
conf_parser_ctx.pass = 1; |
1969 |
– |
yyparse(); /* pick up the classes first */ |
1970 |
– |
|
1971 |
– |
fbrewind(file); |
1972 |
– |
|
1973 |
– |
conf_parser_ctx.pass = 2; |
1974 |
– |
yyparse(); /* Load the values from the conf */ |
1975 |
– |
validate_conf(); /* Check to make sure some values are still okay. */ |
1976 |
– |
/* Some global values are also loaded here. */ |
1977 |
– |
check_class(); /* Make sure classes are valid */ |
1978 |
– |
} |
1979 |
– |
|
1904 |
|
static void |
1905 |
|
validate_conf(void) |
1906 |
|
{ |
1910 |
|
if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN) |
1911 |
|
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1912 |
|
|
1989 |
– |
if (ConfigFileEntry.servlink_path == NULL) |
1990 |
– |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1991 |
– |
|
1913 |
|
if (ServerInfo.network_name == NULL) |
1914 |
|
DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT); |
1915 |
|
|
1926 |
|
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
1927 |
|
} |
1928 |
|
|
1929 |
+ |
/* read_conf() |
1930 |
+ |
* |
1931 |
+ |
* inputs - file descriptor pointing to config file to use |
1932 |
+ |
* output - None |
1933 |
+ |
* side effects - Read configuration file. |
1934 |
+ |
*/ |
1935 |
+ |
static void |
1936 |
+ |
read_conf(FILE *file) |
1937 |
+ |
{ |
1938 |
+ |
lineno = 0; |
1939 |
+ |
|
1940 |
+ |
set_default_conf(); /* Set default values prior to conf parsing */ |
1941 |
+ |
conf_parser_ctx.pass = 1; |
1942 |
+ |
yyparse(); /* pick up the classes first */ |
1943 |
+ |
|
1944 |
+ |
rewind(file); |
1945 |
+ |
|
1946 |
+ |
conf_parser_ctx.pass = 2; |
1947 |
+ |
yyparse(); /* Load the values from the conf */ |
1948 |
+ |
validate_conf(); /* Check to make sure some values are still okay. */ |
1949 |
+ |
/* Some global values are also loaded here. */ |
1950 |
+ |
check_class(); /* Make sure classes are valid */ |
1951 |
+ |
} |
1952 |
+ |
|
1953 |
|
/* lookup_confhost() |
1954 |
|
* |
1955 |
|
* start DNS lookups of all hostnames in the conf |
1963 |
|
|
1964 |
|
aconf = map_to_conf(conf); |
1965 |
|
|
1966 |
< |
if (EmptyString(aconf->host) || |
2022 |
< |
EmptyString(aconf->user)) |
1966 |
> |
if (has_wildcards(aconf->host)) |
1967 |
|
{ |
1968 |
< |
ilog(L_ERROR, "Host/server name error: (%s) (%s)", |
1968 |
> |
ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)", |
1969 |
|
aconf->host, conf->name); |
1970 |
|
return; |
1971 |
|
} |
1972 |
|
|
2029 |
– |
if (strchr(aconf->host, '*') || |
2030 |
– |
strchr(aconf->host, '?')) |
2031 |
– |
return; |
2032 |
– |
|
1973 |
|
/* Do name lookup now on hostnames given and store the |
1974 |
|
* ip numbers in conf structure. |
1975 |
|
*/ |
1989 |
|
|
1990 |
|
assert(res != NULL); |
1991 |
|
|
1992 |
< |
memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen); |
1993 |
< |
aconf->ipnum.ss_len = res->ai_addrlen; |
1994 |
< |
aconf->ipnum.ss.ss_family = res->ai_family; |
1992 |
> |
memcpy(&aconf->addr, res->ai_addr, res->ai_addrlen); |
1993 |
> |
aconf->addr.ss_len = res->ai_addrlen; |
1994 |
> |
aconf->addr.ss.ss_family = res->ai_family; |
1995 |
|
freeaddrinfo(res); |
1996 |
|
} |
1997 |
|
|
2069 |
|
|
2070 |
|
assert(client_p != NULL); |
2071 |
|
|
2072 |
< |
aconf = find_kline_conf(client_p->host, client_p->username, |
2073 |
< |
&client_p->localClient->ip, |
2074 |
< |
client_p->localClient->aftype); |
2072 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
2073 |
> |
CONF_KLINE, client_p->localClient->aftype, |
2074 |
> |
client_p->username, NULL, 1); |
2075 |
|
if (aconf == NULL) |
2076 |
|
aconf = find_regexp_kline(uhi); |
2077 |
|
|
2078 |
< |
if (aconf && (aconf->status & CONF_KLINE)) |
2139 |
< |
return aconf; |
2140 |
< |
|
2141 |
< |
return NULL; |
2078 |
> |
return aconf; |
2079 |
|
} |
2080 |
|
|
2081 |
|
struct AccessItem * |
2085 |
|
|
2086 |
|
assert(client_p != NULL); |
2087 |
|
|
2088 |
< |
aconf = find_gline_conf(client_p->host, client_p->username, |
2089 |
< |
&client_p->localClient->ip, |
2090 |
< |
client_p->localClient->aftype); |
2091 |
< |
|
2155 |
< |
if (aconf && (aconf->status & CONF_GLINE)) |
2156 |
< |
return aconf; |
2157 |
< |
|
2158 |
< |
return NULL; |
2088 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
2089 |
> |
CONF_GLINE, client_p->localClient->aftype, |
2090 |
> |
client_p->username, NULL, 1); |
2091 |
> |
return aconf; |
2092 |
|
} |
2093 |
|
|
2094 |
|
/* add_temp_line() |
2101 |
|
void |
2102 |
|
add_temp_line(struct ConfItem *conf) |
2103 |
|
{ |
2104 |
< |
struct AccessItem *aconf; |
2172 |
< |
|
2173 |
< |
if (conf->type == DLINE_TYPE) |
2174 |
< |
{ |
2175 |
< |
aconf = map_to_conf(conf); |
2176 |
< |
SetConfTemporary(aconf); |
2177 |
< |
dlinkAdd(conf, &conf->node, &temporary_dlines); |
2178 |
< |
MyFree(aconf->user); |
2179 |
< |
aconf->user = NULL; |
2180 |
< |
add_conf_by_address(CONF_DLINE, aconf); |
2181 |
< |
} |
2182 |
< |
else if (conf->type == KLINE_TYPE) |
2183 |
< |
{ |
2184 |
< |
aconf = map_to_conf(conf); |
2185 |
< |
SetConfTemporary(aconf); |
2186 |
< |
dlinkAdd(conf, &conf->node, &temporary_klines); |
2187 |
< |
add_conf_by_address(CONF_KILL, aconf); |
2188 |
< |
} |
2189 |
< |
else if (conf->type == GLINE_TYPE) |
2190 |
< |
{ |
2191 |
< |
aconf = map_to_conf(conf); |
2192 |
< |
SetConfTemporary(aconf); |
2193 |
< |
dlinkAdd(conf, &conf->node, &temporary_glines); |
2194 |
< |
add_conf_by_address(CONF_GLINE, aconf); |
2195 |
< |
} |
2196 |
< |
else if (conf->type == XLINE_TYPE) |
2104 |
> |
if (conf->type == XLINE_TYPE) |
2105 |
|
{ |
2106 |
|
conf->flags |= CONF_FLAGS_TEMPORARY; |
2107 |
|
dlinkAdd(conf, make_dlink_node(), &temporary_xlines); |
2108 |
|
} |
2201 |
– |
else if (conf->type == RXLINE_TYPE) |
2202 |
– |
{ |
2203 |
– |
conf->flags |= CONF_FLAGS_TEMPORARY; |
2204 |
– |
dlinkAdd(conf, make_dlink_node(), &temporary_rxlines); |
2205 |
– |
} |
2206 |
– |
else if (conf->type == RKLINE_TYPE) |
2207 |
– |
{ |
2208 |
– |
conf->flags |= CONF_FLAGS_TEMPORARY; |
2209 |
– |
dlinkAdd(conf, make_dlink_node(), &temporary_rklines); |
2210 |
– |
} |
2109 |
|
else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE)) |
2110 |
|
{ |
2111 |
|
conf->flags |= CONF_FLAGS_TEMPORARY; |
2123 |
|
void |
2124 |
|
cleanup_tklines(void *notused) |
2125 |
|
{ |
2126 |
< |
expire_tklines(&temporary_glines); |
2229 |
< |
expire_tklines(&temporary_klines); |
2230 |
< |
expire_tklines(&temporary_dlines); |
2126 |
> |
hostmask_expire_temporary(); |
2127 |
|
expire_tklines(&temporary_xlines); |
2232 |
– |
expire_tklines(&temporary_rxlines); |
2233 |
– |
expire_tklines(&temporary_rklines); |
2128 |
|
expire_tklines(&temporary_resv); |
2129 |
|
} |
2130 |
|
|
2142 |
|
struct ConfItem *conf; |
2143 |
|
struct MatchItem *xconf; |
2144 |
|
struct MatchItem *nconf; |
2251 |
– |
struct AccessItem *aconf; |
2145 |
|
struct ResvChannel *cconf; |
2146 |
|
|
2147 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head) |
2148 |
|
{ |
2149 |
|
conf = ptr->data; |
2257 |
– |
if (conf->type == GLINE_TYPE || |
2258 |
– |
conf->type == KLINE_TYPE || |
2259 |
– |
conf->type == DLINE_TYPE) |
2260 |
– |
{ |
2261 |
– |
aconf = (struct AccessItem *)map_to_conf(conf); |
2262 |
– |
if (aconf->hold <= CurrentTime) |
2263 |
– |
{ |
2264 |
– |
/* XXX - Do we want GLINE expiry notices?? */ |
2265 |
– |
/* Alert opers that a TKline expired - Hwy */ |
2266 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
2267 |
– |
{ |
2268 |
– |
if (aconf->status & CONF_KILL) |
2269 |
– |
{ |
2270 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
2271 |
– |
"Temporary K-line for [%s@%s] expired", |
2272 |
– |
(aconf->user) ? aconf->user : "*", |
2273 |
– |
(aconf->host) ? aconf->host : "*"); |
2274 |
– |
} |
2275 |
– |
else if (conf->type == DLINE_TYPE) |
2276 |
– |
{ |
2277 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
2278 |
– |
"Temporary D-line for [%s] expired", |
2279 |
– |
(aconf->host) ? aconf->host : "*"); |
2280 |
– |
} |
2281 |
– |
} |
2150 |
|
|
2151 |
< |
dlinkDelete(ptr, tklist); |
2284 |
< |
delete_one_address_conf(aconf->host, aconf); |
2285 |
< |
} |
2286 |
< |
} |
2287 |
< |
else if (conf->type == XLINE_TYPE || |
2288 |
< |
conf->type == RXLINE_TYPE) |
2151 |
> |
if (conf->type == XLINE_TYPE) |
2152 |
|
{ |
2153 |
|
xconf = (struct MatchItem *)map_to_conf(conf); |
2154 |
|
if (xconf->hold <= CurrentTime) |
2155 |
|
{ |
2156 |
|
if (ConfigFileEntry.tkline_expire_notices) |
2157 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2158 |
< |
"Temporary X-line for [%s] %sexpired", conf->name, |
2296 |
< |
conf->type == RXLINE_TYPE ? "(REGEX) " : ""); |
2158 |
> |
"Temporary X-line for [%s] sexpired", conf->name); |
2159 |
|
dlinkDelete(ptr, tklist); |
2160 |
|
free_dlink_node(ptr); |
2161 |
|
delete_conf_item(conf); |
2162 |
|
} |
2163 |
|
} |
2302 |
– |
else if (conf->type == RKLINE_TYPE) |
2303 |
– |
{ |
2304 |
– |
aconf = map_to_conf(conf); |
2305 |
– |
if (aconf->hold <= CurrentTime) |
2306 |
– |
{ |
2307 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
2308 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
2309 |
– |
"Temporary K-line for [%s@%s] (REGEX) expired", |
2310 |
– |
(aconf->user) ? aconf->user : "*", |
2311 |
– |
(aconf->host) ? aconf->host : "*"); |
2312 |
– |
dlinkDelete(ptr, tklist); |
2313 |
– |
free_dlink_node(ptr); |
2314 |
– |
delete_conf_item(conf); |
2315 |
– |
} |
2316 |
– |
} |
2164 |
|
else if (conf->type == NRESV_TYPE) |
2165 |
|
{ |
2166 |
|
nconf = (struct MatchItem *)map_to_conf(conf); |
2197 |
|
static const struct oper_privs |
2198 |
|
{ |
2199 |
|
const unsigned int oprivs; |
2353 |
– |
const unsigned int hidden; |
2200 |
|
const unsigned char c; |
2201 |
|
} flag_list[] = { |
2202 |
< |
{ OPER_FLAG_ADMIN, OPER_FLAG_HIDDEN_ADMIN, 'A' }, |
2203 |
< |
{ OPER_FLAG_REMOTEBAN, 0, 'B' }, |
2204 |
< |
{ OPER_FLAG_DIE, 0, 'D' }, |
2205 |
< |
{ OPER_FLAG_GLINE, 0, 'G' }, |
2206 |
< |
{ OPER_FLAG_REHASH, 0, 'H' }, |
2207 |
< |
{ OPER_FLAG_K, 0, 'K' }, |
2208 |
< |
{ OPER_FLAG_OPERWALL, 0, 'L' }, |
2209 |
< |
{ OPER_FLAG_N, 0, 'N' }, |
2210 |
< |
{ OPER_FLAG_GLOBAL_KILL, 0, 'O' }, |
2211 |
< |
{ OPER_FLAG_REMOTE, 0, 'R' }, |
2212 |
< |
{ OPER_FLAG_OPER_SPY, 0, 'S' }, |
2213 |
< |
{ OPER_FLAG_UNKLINE, 0, 'U' }, |
2214 |
< |
{ OPER_FLAG_X, 0, 'X' }, |
2215 |
< |
{ 0, 0, '\0' } |
2202 |
> |
{ OPER_FLAG_ADMIN, 'A' }, |
2203 |
> |
{ OPER_FLAG_REMOTEBAN, 'B' }, |
2204 |
> |
{ OPER_FLAG_DIE, 'D' }, |
2205 |
> |
{ OPER_FLAG_GLINE, 'G' }, |
2206 |
> |
{ OPER_FLAG_REHASH, 'H' }, |
2207 |
> |
{ OPER_FLAG_K, 'K' }, |
2208 |
> |
{ OPER_FLAG_OPERWALL, 'L' }, |
2209 |
> |
{ OPER_FLAG_N, 'N' }, |
2210 |
> |
{ OPER_FLAG_GLOBAL_KILL, 'O' }, |
2211 |
> |
{ OPER_FLAG_REMOTE, 'R' }, |
2212 |
> |
{ OPER_FLAG_OPER_SPY, 'S' }, |
2213 |
> |
{ OPER_FLAG_UNKLINE, 'U' }, |
2214 |
> |
{ OPER_FLAG_X, 'X' }, |
2215 |
> |
{ 0, '\0' } |
2216 |
|
}; |
2217 |
|
|
2218 |
|
char * |
2224 |
|
|
2225 |
|
for (; flag_list[i].oprivs; ++i) |
2226 |
|
{ |
2227 |
< |
if ((port & flag_list[i].oprivs) && |
2382 |
< |
(port & flag_list[i].hidden) == 0) |
2227 |
> |
if (port & flag_list[i].oprivs) |
2228 |
|
*privs_ptr++ = flag_list[i].c; |
2229 |
|
else |
2230 |
|
*privs_ptr++ = ToLowerTab[flag_list[i].c]; |
2241 |
|
* "oper" is server name for remote opers |
2242 |
|
* Side effects: None. |
2243 |
|
*/ |
2244 |
< |
char * |
2244 |
> |
const char * |
2245 |
|
get_oper_name(const struct Client *client_p) |
2246 |
|
{ |
2247 |
< |
dlink_node *cnode; |
2403 |
< |
struct ConfItem *conf; |
2404 |
< |
struct AccessItem *aconf; |
2405 |
< |
|
2247 |
> |
dlink_node *cnode = NULL; |
2248 |
|
/* +5 for !,@,{,} and null */ |
2249 |
|
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
2250 |
|
|
2251 |
|
if (MyConnect(client_p)) |
2252 |
|
{ |
2253 |
< |
DLINK_FOREACH(cnode, client_p->localClient->confs.head) |
2253 |
> |
if ((cnode = client_p->localClient->confs.head)) |
2254 |
|
{ |
2255 |
< |
conf = cnode->data; |
2256 |
< |
aconf = map_to_conf(conf); |
2255 |
> |
struct ConfItem *conf = cnode->data; |
2256 |
> |
const struct AccessItem *aconf = map_to_conf(conf); |
2257 |
|
|
2258 |
|
if (IsConfOperator(aconf)) |
2259 |
|
{ |
2298 |
|
*/ |
2299 |
|
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
2300 |
|
|
2301 |
< |
if ((conf_parser_ctx.conf_file = fbopen(filename, "r")) == NULL) |
2301 |
> |
if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL) |
2302 |
|
{ |
2303 |
|
if (cold) |
2304 |
|
{ |
2305 |
< |
ilog(L_CRIT, "Unable to read configuration file '%s': %s", |
2305 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
2306 |
|
filename, strerror(errno)); |
2307 |
|
exit(-1); |
2308 |
|
} |
2319 |
|
clear_out_old_conf(); |
2320 |
|
|
2321 |
|
read_conf(conf_parser_ctx.conf_file); |
2322 |
< |
fbclose(conf_parser_ctx.conf_file); |
2322 |
> |
fclose(conf_parser_ctx.conf_file); |
2323 |
|
|
2324 |
|
add_isupport("NETWORK", ServerInfo.network_name, -1); |
2325 |
|
snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d", |
2374 |
|
static void |
2375 |
|
parse_conf_file(int type, int cold) |
2376 |
|
{ |
2377 |
< |
FBFILE *file = NULL; |
2377 |
> |
FILE *file = NULL; |
2378 |
|
const char *filename = get_conf_name(type); |
2379 |
|
|
2380 |
< |
if ((file = fbopen(filename, "r")) == NULL) |
2380 |
> |
if ((file = fopen(filename, "r")) == NULL) |
2381 |
|
{ |
2382 |
|
if (cold) |
2383 |
< |
ilog(L_ERROR, "Unable to read configuration file '%s': %s", |
2383 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
2384 |
|
filename, strerror(errno)); |
2385 |
|
else |
2386 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2390 |
|
else |
2391 |
|
{ |
2392 |
|
parse_csv_file(file, type); |
2393 |
< |
fbclose(file); |
2393 |
> |
fclose(file); |
2394 |
|
} |
2395 |
|
} |
2396 |
|
|
2409 |
|
struct ClassItem *cltmp; |
2410 |
|
struct MatchItem *match_item; |
2411 |
|
dlink_list *free_items [] = { |
2412 |
< |
&server_items, &oconf_items, &hub_items, &leaf_items, |
2412 |
> |
&server_items, &oconf_items, |
2413 |
|
&uconf_items, &xconf_items, &rxconf_items, &rkconf_items, |
2414 |
|
&nresv_items, &cluster_items, &gdeny_items, &service_items, NULL |
2415 |
|
}; |
2454 |
|
delete_conf_item(conf); |
2455 |
|
} |
2456 |
|
} |
2615 |
– |
else if (conf->type == CLIENT_TYPE) |
2616 |
– |
{ |
2617 |
– |
aconf = map_to_conf(conf); |
2618 |
– |
|
2619 |
– |
if (aconf->clients != 0) |
2620 |
– |
{ |
2621 |
– |
SetConfIllegal(aconf); |
2622 |
– |
} |
2623 |
– |
else |
2624 |
– |
{ |
2625 |
– |
delete_conf_item(conf); |
2626 |
– |
} |
2627 |
– |
} |
2457 |
|
else if (conf->type == XLINE_TYPE || |
2458 |
|
conf->type == RXLINE_TYPE || |
2459 |
|
conf->type == RKLINE_TYPE) |
2467 |
|
} |
2468 |
|
else |
2469 |
|
{ |
2641 |
– |
if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE)) |
2642 |
– |
{ |
2643 |
– |
match_item = map_to_conf(conf); |
2644 |
– |
if (match_item->ref_count <= 0) |
2645 |
– |
delete_conf_item(conf); |
2646 |
– |
else |
2647 |
– |
{ |
2648 |
– |
match_item->illegal = 1; |
2649 |
– |
dlinkDelete(&conf->node, *iterator); |
2650 |
– |
} |
2651 |
– |
} |
2652 |
– |
else |
2470 |
|
delete_conf_item(conf); |
2471 |
|
} |
2472 |
|
} |
2507 |
|
|
2508 |
|
MyFree(ServerInfo.rsa_private_key_file); |
2509 |
|
ServerInfo.rsa_private_key_file = NULL; |
2510 |
+ |
|
2511 |
+ |
if (ServerInfo.server_ctx) |
2512 |
+ |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2| |
2513 |
+ |
SSL_OP_NO_SSLv3| |
2514 |
+ |
SSL_OP_NO_TLSv1); |
2515 |
+ |
if (ServerInfo.client_ctx) |
2516 |
+ |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2| |
2517 |
+ |
SSL_OP_NO_SSLv3| |
2518 |
+ |
SSL_OP_NO_TLSv1); |
2519 |
|
#endif |
2520 |
|
|
2521 |
|
/* clean out old resvs from the conf */ |
2541 |
|
MyFree(ConfigFileEntry.service_name); |
2542 |
|
ConfigFileEntry.service_name = NULL; |
2543 |
|
|
2718 |
– |
MyFree(ConfigFileEntry.servlink_path); |
2719 |
– |
ConfigFileEntry.servlink_path = NULL; |
2720 |
– |
#ifdef HAVE_LIBCRYPTO |
2721 |
– |
ConfigFileEntry.default_cipher_preference = NULL; |
2722 |
– |
#endif /* HAVE_LIBCRYPTO */ |
2544 |
|
delete_isupport("INVEX"); |
2545 |
|
delete_isupport("EXCEPTS"); |
2546 |
|
} |
2651 |
|
if (aconf->class_ptr != NULL) |
2652 |
|
{ |
2653 |
|
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
2654 |
< |
*pingwarn = PingWarning(aclass); |
2655 |
< |
return PingFreq(aclass); |
2654 |
> |
*pingwarn = aclass->ping_warning; |
2655 |
> |
return aclass->ping_freq; |
2656 |
|
} |
2657 |
|
} |
2658 |
|
|
2668 |
|
const char * |
2669 |
|
get_client_class(struct Client *target_p) |
2670 |
|
{ |
2671 |
< |
dlink_node *ptr; |
2672 |
< |
struct ConfItem *conf; |
2852 |
< |
struct AccessItem *aconf; |
2671 |
> |
dlink_node *cnode = NULL; |
2672 |
> |
struct AccessItem *aconf = NULL; |
2673 |
|
|
2674 |
< |
if (target_p != NULL && !IsMe(target_p) && |
2675 |
< |
target_p->localClient->confs.head != NULL) |
2674 |
> |
assert(!IsMe(target_p)); |
2675 |
> |
|
2676 |
> |
if ((cnode = target_p->localClient->confs.head)) |
2677 |
|
{ |
2678 |
< |
DLINK_FOREACH(ptr, target_p->localClient->confs.head) |
2858 |
< |
{ |
2859 |
< |
conf = ptr->data; |
2678 |
> |
struct ConfItem *conf = cnode->data; |
2679 |
|
|
2680 |
< |
if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE || |
2681 |
< |
conf->type == OPER_TYPE) |
2682 |
< |
{ |
2683 |
< |
aconf = (struct AccessItem *) map_to_conf(conf); |
2684 |
< |
if (aconf->class_ptr != NULL) |
2685 |
< |
return aconf->class_ptr->name; |
2867 |
< |
} |
2868 |
< |
} |
2680 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2681 |
> |
(conf->type == OPER_TYPE)); |
2682 |
> |
|
2683 |
> |
aconf = map_to_conf(conf); |
2684 |
> |
if (aconf->class_ptr != NULL) |
2685 |
> |
return aconf->class_ptr->name; |
2686 |
|
} |
2687 |
|
|
2688 |
|
return "default"; |
2698 |
|
int |
2699 |
|
get_client_ping(struct Client *target_p, int *pingwarn) |
2700 |
|
{ |
2701 |
< |
int ping; |
2702 |
< |
struct ConfItem *conf; |
2886 |
< |
dlink_node *nlink; |
2701 |
> |
int ping = 0; |
2702 |
> |
dlink_node *cnode = NULL; |
2703 |
|
|
2704 |
< |
if (target_p->localClient->confs.head != NULL) |
2705 |
< |
DLINK_FOREACH(nlink, target_p->localClient->confs.head) |
2706 |
< |
{ |
2891 |
< |
conf = nlink->data; |
2704 |
> |
if ((cnode = target_p->localClient->confs.head)) |
2705 |
> |
{ |
2706 |
> |
struct ConfItem *conf = cnode->data; |
2707 |
|
|
2708 |
< |
if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2709 |
< |
(conf->type == OPER_TYPE)) |
2710 |
< |
{ |
2711 |
< |
ping = get_conf_ping(conf, pingwarn); |
2712 |
< |
if (ping > 0) |
2713 |
< |
return ping; |
2714 |
< |
} |
2900 |
< |
} |
2708 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2709 |
> |
(conf->type == OPER_TYPE)); |
2710 |
> |
|
2711 |
> |
ping = get_conf_ping(conf, pingwarn); |
2712 |
> |
if (ping > 0) |
2713 |
> |
return ping; |
2714 |
> |
} |
2715 |
|
|
2716 |
|
*pingwarn = 0; |
2717 |
|
return DEFAULT_PINGFREQUENCY; |
2728 |
|
{ |
2729 |
|
struct ConfItem *conf; |
2730 |
|
|
2731 |
< |
if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL) |
2731 |
> |
if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL) |
2732 |
|
return conf; |
2733 |
|
|
2734 |
|
return class_default; |
2749 |
|
{ |
2750 |
|
struct ClassItem *aclass = map_to_conf(ptr->data); |
2751 |
|
|
2752 |
< |
if (!aclass->active && !CurrUserCount(aclass)) |
2752 |
> |
if (!aclass->active && !aclass->curr_user_count) |
2753 |
|
{ |
2754 |
|
destroy_cidr_class(aclass); |
2755 |
|
delete_conf_item(ptr->data); |
2773 |
|
aclass = map_to_conf(class_default); |
2774 |
|
aclass->active = 1; |
2775 |
|
DupString(class_default->name, "default"); |
2776 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
2777 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
2778 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
2779 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
2776 |
> |
aclass->con_freq = DEFAULT_CONNECTFREQUENCY; |
2777 |
> |
aclass->ping_freq = DEFAULT_PINGFREQUENCY; |
2778 |
> |
aclass->max_total = MAXIMUM_LINKS_DEFAULT; |
2779 |
> |
aclass->max_sendq = DEFAULT_SENDQ; |
2780 |
|
|
2781 |
|
client_check_cb = register_callback("check_client", check_client); |
2782 |
|
} |
2791 |
|
get_sendq(struct Client *client_p) |
2792 |
|
{ |
2793 |
|
unsigned int sendq = DEFAULT_SENDQ; |
2794 |
< |
dlink_node *ptr; |
2981 |
< |
struct ConfItem *conf; |
2794 |
> |
dlink_node *cnode; |
2795 |
|
struct ConfItem *class_conf; |
2796 |
|
struct ClassItem *aclass; |
2797 |
|
struct AccessItem *aconf; |
2798 |
|
|
2799 |
< |
if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head)) |
2799 |
> |
assert(!IsMe(client_p)); |
2800 |
> |
|
2801 |
> |
if ((cnode = client_p->localClient->confs.head)) |
2802 |
|
{ |
2803 |
< |
DLINK_FOREACH(ptr, client_p->localClient->confs.head) |
2804 |
< |
{ |
2805 |
< |
conf = ptr->data; |
2806 |
< |
if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE) |
2807 |
< |
|| (conf->type == CLIENT_TYPE)) |
2808 |
< |
{ |
2809 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2810 |
< |
if ((class_conf = aconf->class_ptr) == NULL) |
2811 |
< |
continue; |
2812 |
< |
aclass = (struct ClassItem *)map_to_conf(class_conf); |
2813 |
< |
sendq = MaxSendq(aclass); |
2814 |
< |
return sendq; |
2815 |
< |
} |
3001 |
< |
} |
2803 |
> |
struct ConfItem *conf = cnode->data; |
2804 |
> |
|
2805 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2806 |
> |
(conf->type == OPER_TYPE)); |
2807 |
> |
|
2808 |
> |
aconf = map_to_conf(conf); |
2809 |
> |
|
2810 |
> |
if ((class_conf = aconf->class_ptr) == NULL) |
2811 |
> |
return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */ |
2812 |
> |
|
2813 |
> |
aclass = map_to_conf(class_conf); |
2814 |
> |
sendq = aclass->max_sendq; |
2815 |
> |
return sendq; |
2816 |
|
} |
2817 |
+ |
|
2818 |
|
/* XXX return a default? |
2819 |
|
* if here, then there wasn't an attached conf with a sendq |
2820 |
|
* that is very bad -Dianora |
2877 |
|
int |
2878 |
|
conf_add_server(struct ConfItem *conf, const char *class_name) |
2879 |
|
{ |
2880 |
< |
struct AccessItem *aconf; |
3066 |
< |
struct split_nuh_item nuh; |
3067 |
< |
char conf_user[USERLEN + 1]; |
3068 |
< |
char conf_host[HOSTLEN + 1]; |
3069 |
< |
|
3070 |
< |
aconf = map_to_conf(conf); |
2880 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
2881 |
|
|
2882 |
|
conf_add_class_to_conf(conf, class_name); |
2883 |
|
|
2884 |
|
if (!aconf->host || !conf->name) |
2885 |
|
{ |
2886 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block"); |
2887 |
< |
ilog(L_WARN, "Bad connect block"); |
2887 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block"); |
2888 |
|
return -1; |
2889 |
|
} |
2890 |
|
|
2891 |
< |
if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf)) |
2891 |
> |
if (EmptyString(aconf->passwd)) |
2892 |
|
{ |
2893 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s", |
2894 |
|
conf->name); |
2895 |
< |
ilog(L_WARN, "Bad connect block, host %s", conf->name); |
2895 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name); |
2896 |
|
return -1; |
2897 |
|
} |
2898 |
|
|
3089 |
– |
nuh.nuhmask = aconf->host; |
3090 |
– |
nuh.nickptr = NULL; |
3091 |
– |
nuh.userptr = conf_user; |
3092 |
– |
nuh.hostptr = conf_host; |
3093 |
– |
|
3094 |
– |
nuh.nicksize = 0; |
3095 |
– |
nuh.usersize = sizeof(conf_user); |
3096 |
– |
nuh.hostsize = sizeof(conf_host); |
3097 |
– |
|
3098 |
– |
split_nuh(&nuh); |
3099 |
– |
|
3100 |
– |
MyFree(aconf->host); |
3101 |
– |
aconf->host = NULL; |
3102 |
– |
|
3103 |
– |
DupString(aconf->user, conf_user); /* somehow username checking for servers |
3104 |
– |
got lost in H6/7, will have to be re-added */ |
3105 |
– |
DupString(aconf->host, conf_host); |
3106 |
– |
|
2899 |
|
lookup_confhost(conf); |
2900 |
|
|
2901 |
|
return 0; |
2918 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
2919 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s", |
2920 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
2921 |
< |
ilog(L_WARN, "\"%s\", line %u: %s: %s", |
2921 |
> |
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
2922 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
2923 |
|
} |
2924 |
|
|
3133 |
– |
int |
3134 |
– |
conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb) |
3135 |
– |
{ |
3136 |
– |
if (fbgets(lbuf, max_size, fb) == NULL) |
3137 |
– |
return 0; |
3138 |
– |
|
3139 |
– |
return strlen(lbuf); |
3140 |
– |
} |
3141 |
– |
|
3142 |
– |
int |
3143 |
– |
conf_yy_fatal_error(const char *msg) |
3144 |
– |
{ |
3145 |
– |
return 0; |
3146 |
– |
} |
3147 |
– |
|
2925 |
|
/* |
2926 |
|
* valid_tkline() |
2927 |
|
* |
3121 |
|
return -1; |
3122 |
|
} |
3123 |
|
|
3124 |
< |
if (!IsOperRemoteBan(source_p)) |
3124 |
> |
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
3125 |
|
{ |
3126 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
3127 |
|
me.name, source_p->name, "remoteban"); |
3158 |
|
return -1; |
3159 |
|
} |
3160 |
|
|
3161 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p)) |
3161 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p)) |
3162 |
|
return -1; |
3163 |
|
} |
3164 |
|
else |
3165 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p)) |
3165 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p)) |
3166 |
|
return -1; |
3167 |
|
|
3168 |
|
if (reason != NULL) |
3170 |
|
if (parc != 0 && !EmptyString(*parv)) |
3171 |
|
{ |
3172 |
|
*reason = *parv; |
3173 |
< |
if (!valid_comment(source_p, *reason, YES)) |
3173 |
> |
if (!valid_comment(source_p, *reason, 1)) |
3174 |
|
return -1; |
3175 |
|
} |
3176 |
|
else |
3301 |
|
{ |
3302 |
|
const char *encr = NULL; |
3303 |
|
|
3304 |
< |
if (password == NULL || aconf->passwd == NULL) |
3304 |
> |
if (EmptyString(password) || EmptyString(aconf->passwd)) |
3305 |
|
return 0; |
3306 |
|
|
3307 |
|
if (aconf->flags & CONF_FLAGS_ENCRYPTED) |
3308 |
< |
{ |
3532 |
< |
/* use first two chars of the password they send in as salt */ |
3533 |
< |
/* If the password in the conf is MD5, and ircd is linked |
3534 |
< |
* to scrypt on FreeBSD, or the standard crypt library on |
3535 |
< |
* glibc Linux, then this code will work fine on generating |
3536 |
< |
* the proper encrypted hash for comparison. |
3537 |
< |
*/ |
3538 |
< |
if (*aconf->passwd) |
3539 |
< |
encr = crypt(password, aconf->passwd); |
3540 |
< |
else |
3541 |
< |
encr = ""; |
3542 |
< |
} |
3308 |
> |
encr = crypt(password, aconf->passwd); |
3309 |
|
else |
3310 |
|
encr = password; |
3311 |
|
|
3318 |
|
* inputs - client sending the cluster |
3319 |
|
* - command name "KLINE" "XLINE" etc. |
3320 |
|
* - capab -- CAP_KLN etc. from s_serv.h |
3321 |
< |
* - cluster type -- CLUSTER_KLINE etc. from s_conf.h |
3321 |
> |
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
3322 |
|
* - pattern and args to send along |
3323 |
|
* output - none |
3324 |
|
* side effects - Take source_p send the pattern with args given |
3478 |
|
dlink_node *ptr = NULL; |
3479 |
|
struct CidrItem *cidr; |
3480 |
|
|
3481 |
< |
if (NumberPerCidr(aclass) <= 0) |
3481 |
> |
if (aclass->number_per_cidr <= 0) |
3482 |
|
return 0; |
3483 |
|
|
3484 |
|
if (ip->ss.ss_family == AF_INET) |
3485 |
|
{ |
3486 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
3486 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
3487 |
|
return 0; |
3488 |
|
|
3489 |
|
DLINK_FOREACH(ptr, aclass->list_ipv4.head) |
3490 |
|
{ |
3491 |
|
cidr = ptr->data; |
3492 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
3492 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
3493 |
|
{ |
3494 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
3494 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
3495 |
|
return -1; |
3496 |
|
cidr->number_on_this_cidr++; |
3497 |
|
return 0; |
3500 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
3501 |
|
cidr->number_on_this_cidr = 1; |
3502 |
|
cidr->mask = *ip; |
3503 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV4(aclass)); |
3503 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4); |
3504 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4); |
3505 |
|
} |
3506 |
|
#ifdef IPV6 |
3507 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
3507 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
3508 |
|
{ |
3509 |
|
DLINK_FOREACH(ptr, aclass->list_ipv6.head) |
3510 |
|
{ |
3511 |
|
cidr = ptr->data; |
3512 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
3512 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
3513 |
|
{ |
3514 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
3514 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
3515 |
|
return -1; |
3516 |
|
cidr->number_on_this_cidr++; |
3517 |
|
return 0; |
3520 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
3521 |
|
cidr->number_on_this_cidr = 1; |
3522 |
|
cidr->mask = *ip; |
3523 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV6(aclass)); |
3523 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6); |
3524 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6); |
3525 |
|
} |
3526 |
|
#endif |
3542 |
|
dlink_node *next_ptr = NULL; |
3543 |
|
struct CidrItem *cidr; |
3544 |
|
|
3545 |
< |
if (NumberPerCidr(aclass) == 0) |
3545 |
> |
if (aclass->number_per_cidr == 0) |
3546 |
|
return; |
3547 |
|
|
3548 |
|
if (ip->ss.ss_family == AF_INET) |
3549 |
|
{ |
3550 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
3550 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
3551 |
|
return; |
3552 |
|
|
3553 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head) |
3554 |
|
{ |
3555 |
|
cidr = ptr->data; |
3556 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
3556 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
3557 |
|
{ |
3558 |
|
cidr->number_on_this_cidr--; |
3559 |
|
if (cidr->number_on_this_cidr == 0) |
3566 |
|
} |
3567 |
|
} |
3568 |
|
#ifdef IPV6 |
3569 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
3569 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
3570 |
|
{ |
3571 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head) |
3572 |
|
{ |
3573 |
|
cidr = ptr->data; |
3574 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
3574 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
3575 |
|
{ |
3576 |
|
cidr->number_on_this_cidr--; |
3577 |
|
if (cidr->number_on_this_cidr == 0) |
3634 |
|
{ |
3635 |
|
struct ClassItem *old_class = map_to_conf(conf); |
3636 |
|
|
3637 |
< |
if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0) |
3637 |
> |
if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0) |
3638 |
|
{ |
3639 |
< |
if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0) |
3639 |
> |
if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0) |
3640 |
|
rebuild_cidr_list(AF_INET, conf, new_class, |
3641 |
|
&old_class->list_ipv4, &new_class->list_ipv4, |
3642 |
< |
CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class)); |
3642 |
> |
old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4); |
3643 |
|
|
3644 |
|
#ifdef IPV6 |
3645 |
< |
if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0) |
3645 |
> |
if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0) |
3646 |
|
rebuild_cidr_list(AF_INET6, conf, new_class, |
3647 |
|
&old_class->list_ipv6, &new_class->list_ipv6, |
3648 |
< |
CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class)); |
3648 |
> |
old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6); |
3649 |
|
#endif |
3650 |
|
} |
3651 |
|
|