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 |
|
* |
23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
+ |
#include "list.h" |
27 |
|
#include "ircd_defs.h" |
28 |
< |
#include "tools.h" |
29 |
< |
#include "s_conf.h" |
28 |
> |
#include "balloc.h" |
29 |
> |
#include "conf.h" |
30 |
|
#include "s_serv.h" |
31 |
|
#include "resv.h" |
31 |
– |
#include "s_stats.h" |
32 |
|
#include "channel.h" |
33 |
|
#include "client.h" |
34 |
– |
#include "common.h" |
34 |
|
#include "event.h" |
35 |
|
#include "hash.h" |
36 |
|
#include "hook.h" |
37 |
|
#include "irc_string.h" |
38 |
|
#include "sprintf_irc.h" |
39 |
|
#include "s_bsd.h" |
41 |
– |
#include "irc_getnameinfo.h" |
42 |
– |
#include "irc_getaddrinfo.h" |
40 |
|
#include "ircd.h" |
44 |
– |
#include "list.h" |
41 |
|
#include "listener.h" |
42 |
|
#include "hostmask.h" |
43 |
|
#include "modules.h" |
44 |
|
#include "numeric.h" |
45 |
|
#include "fdlist.h" |
46 |
< |
#include "s_log.h" |
46 |
> |
#include "log.h" |
47 |
|
#include "send.h" |
48 |
|
#include "s_gline.h" |
53 |
– |
#include "fileio.h" |
49 |
|
#include "memory.h" |
50 |
|
#include "irc_res.h" |
51 |
|
#include "userhost.h" |
52 |
|
#include "s_user.h" |
53 |
|
#include "channel_mode.h" |
54 |
+ |
#include "parse.h" |
55 |
+ |
#include "s_misc.h" |
56 |
|
|
57 |
|
struct Callback *client_check_cb = NULL; |
58 |
|
struct config_server_hide ConfigServerHide; |
59 |
|
|
60 |
|
/* general conf items link list root, other than k lines etc. */ |
61 |
+ |
dlink_list service_items = { NULL, NULL, 0 }; |
62 |
|
dlink_list server_items = { NULL, NULL, 0 }; |
63 |
|
dlink_list cluster_items = { NULL, NULL, 0 }; |
64 |
|
dlink_list hub_items = { NULL, NULL, 0 }; |
85 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
86 |
|
extern char yytext[]; |
87 |
|
extern int yyparse(); /* defined in y.tab.c */ |
88 |
< |
unsigned int scount = 0; /* used by yyparse(), etc */ |
89 |
< |
int ypass = 1; /* used by yyparse() */ |
88 |
> |
|
89 |
> |
struct conf_parser_context conf_parser_ctx = { 0, 0, NULL }; |
90 |
|
|
91 |
|
/* internally defined functions */ |
92 |
|
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 *); |
95 |
> |
static void read_conf(FILE *); |
96 |
|
static void clear_out_old_conf(void); |
97 |
|
static void flush_deleted_I_P(void); |
98 |
|
static void expire_tklines(dlink_list *); |
115 |
|
|
116 |
|
static void flags_to_ascii(unsigned int, const unsigned int[], char *, int); |
117 |
|
|
120 |
– |
FBFILE *conf_fbfile_in = NULL; |
121 |
– |
|
118 |
|
/* address of default class conf */ |
119 |
|
static struct ConfItem *class_default; |
120 |
|
|
137 |
|
static int ip_entries_count = 0; |
138 |
|
|
139 |
|
|
140 |
< |
inline void * |
140 |
> |
void * |
141 |
|
map_to_conf(struct ConfItem *aconf) |
142 |
|
{ |
143 |
|
void *conf; |
144 |
< |
conf = (void *)((unsigned long)aconf + |
145 |
< |
(unsigned long)sizeof(struct ConfItem)); |
144 |
> |
conf = (void *)((uintptr_t)aconf + |
145 |
> |
(uintptr_t)sizeof(struct ConfItem)); |
146 |
|
return(conf); |
147 |
|
} |
148 |
|
|
149 |
< |
inline struct ConfItem * |
149 |
> |
struct ConfItem * |
150 |
|
unmap_conf_item(void *aconf) |
151 |
|
{ |
152 |
|
struct ConfItem *conf; |
153 |
|
|
154 |
< |
conf = (struct ConfItem *)((unsigned long)aconf - |
155 |
< |
(unsigned long)sizeof(struct ConfItem)); |
154 |
> |
conf = (struct ConfItem *)((uintptr_t)aconf - |
155 |
> |
(uintptr_t)sizeof(struct ConfItem)); |
156 |
|
return(conf); |
157 |
|
} |
158 |
|
|
167 |
|
* if successful save hp in the conf item it was called with |
168 |
|
*/ |
169 |
|
static void |
170 |
< |
conf_dns_callback(void *vptr, struct DNSReply *reply) |
170 |
> |
conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name) |
171 |
|
{ |
172 |
< |
struct AccessItem *aconf = (struct AccessItem *)vptr; |
177 |
< |
struct ConfItem *conf; |
172 |
> |
struct AccessItem *aconf = vptr; |
173 |
|
|
174 |
< |
MyFree(aconf->dns_query); |
180 |
< |
aconf->dns_query = NULL; |
174 |
> |
aconf->dns_pending = 0; |
175 |
|
|
176 |
< |
if (reply != NULL) |
177 |
< |
memcpy(&aconf->ipnum, &reply->addr, sizeof(reply->addr)); |
178 |
< |
else { |
179 |
< |
ilog(L_NOTICE, "Host not found: %s, ignoring connect{} block", |
186 |
< |
aconf->host); |
187 |
< |
conf = unmap_conf_item(aconf); |
188 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
189 |
< |
"Ignoring connect{} block for %s - host not found", |
190 |
< |
conf->name); |
191 |
< |
delete_conf_item(conf); |
192 |
< |
} |
176 |
> |
if (addr != NULL) |
177 |
> |
memcpy(&aconf->ipnum, addr, sizeof(aconf->ipnum)); |
178 |
> |
else |
179 |
> |
aconf->dns_failed = 1; |
180 |
|
} |
181 |
|
|
182 |
|
/* conf_dns_lookup() |
188 |
|
static void |
189 |
|
conf_dns_lookup(struct AccessItem *aconf) |
190 |
|
{ |
191 |
< |
if (aconf->dns_query == NULL) |
191 |
> |
if (!aconf->dns_pending) |
192 |
|
{ |
193 |
< |
aconf->dns_query = MyMalloc(sizeof(struct DNSQuery)); |
194 |
< |
aconf->dns_query->ptr = aconf; |
208 |
< |
aconf->dns_query->callback = conf_dns_callback; |
209 |
< |
gethost_byname(aconf->host, aconf->dns_query); |
193 |
> |
aconf->dns_pending = 1; |
194 |
> |
gethost_byname(conf_dns_callback, aconf, aconf->host); |
195 |
|
} |
196 |
|
} |
197 |
|
|
291 |
|
sizeof(struct MatchItem)); |
292 |
|
dlinkAdd(conf, &conf->node, &xconf_items); |
293 |
|
break; |
294 |
< |
|
294 |
> |
#ifdef HAVE_LIBPCRE |
295 |
|
case RXLINE_TYPE: |
296 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
297 |
|
sizeof(struct MatchItem)); |
305 |
|
aconf->status = CONF_KLINE; |
306 |
|
dlinkAdd(conf, &conf->node, &rkconf_items); |
307 |
|
break; |
308 |
< |
|
308 |
> |
#endif |
309 |
|
case CLUSTER_TYPE: |
310 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem)); |
311 |
|
dlinkAdd(conf, &conf->node, &cluster_items); |
322 |
|
dlinkAdd(conf, &conf->node, &nresv_items); |
323 |
|
break; |
324 |
|
|
325 |
+ |
case SERVICE_TYPE: |
326 |
+ |
status = CONF_SERVICE; |
327 |
+ |
conf = MyMalloc(sizeof(struct ConfItem)); |
328 |
+ |
dlinkAdd(conf, &conf->node, &service_items); |
329 |
+ |
break; |
330 |
+ |
|
331 |
|
case CLASS_TYPE: |
332 |
< |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
333 |
< |
sizeof(struct ClassItem)); |
332 |
> |
conf = MyMalloc(sizeof(struct ConfItem) + |
333 |
> |
sizeof(struct ClassItem)); |
334 |
|
dlinkAdd(conf, &conf->node, &class_items); |
335 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
336 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
335 |
> |
|
336 |
> |
aclass = map_to_conf(conf); |
337 |
> |
aclass->active = 1; |
338 |
> |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
339 |
|
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
340 |
|
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
341 |
|
MaxSendq(aclass) = DEFAULT_SENDQ; |
342 |
< |
CurrUserCount(aclass) = 0; |
342 |
> |
|
343 |
|
break; |
344 |
|
|
345 |
|
default: |
350 |
|
/* XXX Yes, this will core if default is hit. I want it to for now - db */ |
351 |
|
conf->type = type; |
352 |
|
|
353 |
< |
return(conf); |
353 |
> |
return conf; |
354 |
|
} |
355 |
|
|
356 |
|
void |
357 |
|
delete_conf_item(struct ConfItem *conf) |
358 |
|
{ |
359 |
+ |
dlink_node *m = NULL; |
360 |
|
struct MatchItem *match_item; |
361 |
|
struct AccessItem *aconf; |
362 |
|
ConfType type = conf->type; |
375 |
|
case SERVER_TYPE: |
376 |
|
aconf = map_to_conf(conf); |
377 |
|
|
378 |
< |
if (aconf->dns_query != NULL) |
379 |
< |
{ |
386 |
< |
delete_resolver_queries(aconf->dns_query); |
387 |
< |
MyFree(aconf->dns_query); |
388 |
< |
} |
378 |
> |
if (aconf->dns_pending) |
379 |
> |
delete_resolver_queries(aconf); |
380 |
|
if (aconf->passwd != NULL) |
381 |
|
memset(aconf->passwd, 0, strlen(aconf->passwd)); |
382 |
|
if (aconf->spasswd != NULL) |
389 |
|
MyFree(aconf->oper_reason); |
390 |
|
MyFree(aconf->user); |
391 |
|
MyFree(aconf->host); |
392 |
< |
MyFree(aconf->fakename); |
392 |
> |
MyFree(aconf->cipher_list); |
393 |
|
#ifdef HAVE_LIBCRYPTO |
394 |
|
if (aconf->rsa_public_key) |
395 |
|
RSA_free(aconf->rsa_public_key); |
469 |
|
dlinkDelete(&conf->node, &xconf_items); |
470 |
|
MyFree(conf); |
471 |
|
break; |
472 |
< |
|
472 |
> |
#ifdef HAVE_LIBPCRE |
473 |
|
case RKLINE_TYPE: |
474 |
|
aconf = map_to_conf(conf); |
475 |
|
MyFree(aconf->regexuser); |
492 |
|
dlinkDelete(&conf->node, &rxconf_items); |
493 |
|
MyFree(conf); |
494 |
|
break; |
495 |
< |
|
495 |
> |
#endif |
496 |
|
case NRESV_TYPE: |
497 |
|
match_item = map_to_conf(conf); |
498 |
|
MyFree(match_item->user); |
500 |
|
MyFree(match_item->reason); |
501 |
|
MyFree(match_item->oper_reason); |
502 |
|
dlinkDelete(&conf->node, &nresv_items); |
503 |
+ |
|
504 |
+ |
if (conf->flags & CONF_FLAGS_TEMPORARY) |
505 |
+ |
if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL) |
506 |
+ |
free_dlink_node(m); |
507 |
+ |
|
508 |
|
MyFree(conf); |
509 |
|
break; |
510 |
|
|
522 |
|
break; |
523 |
|
|
524 |
|
case CRESV_TYPE: |
525 |
+ |
if (conf->flags & CONF_FLAGS_TEMPORARY) |
526 |
+ |
if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL) |
527 |
+ |
free_dlink_node(m); |
528 |
+ |
|
529 |
|
MyFree(conf); |
530 |
|
break; |
531 |
|
|
534 |
|
MyFree(conf); |
535 |
|
break; |
536 |
|
|
537 |
+ |
case SERVICE_TYPE: |
538 |
+ |
dlinkDelete(&conf->node, &service_items); |
539 |
+ |
MyFree(conf); |
540 |
+ |
break; |
541 |
+ |
|
542 |
|
default: |
543 |
|
break; |
544 |
|
} |
581 |
|
struct ClassItem *classitem = NULL; |
582 |
|
char buf[12]; |
583 |
|
char *p = NULL; |
584 |
+ |
const char *pfx = NULL; |
585 |
|
|
586 |
|
switch (type) |
587 |
|
{ |
624 |
|
} |
625 |
|
break; |
626 |
|
|
627 |
+ |
#ifdef HAVE_LIBPCRE |
628 |
|
case RXLINE_TYPE: |
629 |
|
DLINK_FOREACH(ptr, rxconf_items.head) |
630 |
|
{ |
639 |
|
break; |
640 |
|
|
641 |
|
case RKLINE_TYPE: |
642 |
< |
p = temp ? "Rk" : "RK"; |
642 |
> |
pfx = temp ? "kR" : "KR"; |
643 |
|
|
644 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
645 |
|
{ |
649 |
|
continue; |
650 |
|
|
651 |
|
sendto_one(source_p, form_str(RPL_STATSKLINE), me.name, |
652 |
< |
source_p->name, p, aconf->host, aconf->user, |
652 |
> |
source_p->name, pfx, aconf->host, aconf->user, |
653 |
|
aconf->reason, aconf->oper_reason ? aconf->oper_reason : ""); |
654 |
|
} |
655 |
|
break; |
656 |
+ |
#endif |
657 |
|
|
658 |
|
case ULINE_TYPE: |
659 |
|
DLINK_FOREACH(ptr, uconf_items.head) |
698 |
|
aconf = map_to_conf(conf); |
699 |
|
|
700 |
|
/* Don't allow non opers to see oper privs */ |
701 |
< |
if (IsOper(source_p)) |
701 |
> |
if (HasUMode(source_p, UMODE_OPER)) |
702 |
|
sendto_one(source_p, form_str(RPL_STATSOLINE), |
703 |
|
me.name, source_p->name, 'O', aconf->user, aconf->host, |
704 |
|
conf->name, oper_privs_as_string(aconf->port), |
720 |
|
me.name, source_p->name, 'Y', |
721 |
|
conf->name, PingFreq(classitem), |
722 |
|
ConFreq(classitem), |
723 |
< |
MaxTotal(classitem), MaxSendq(classitem)); |
723 |
> |
MaxTotal(classitem), MaxSendq(classitem), |
724 |
> |
CurrUserCount(classitem), |
725 |
> |
classitem->active ? "active" : "disabled"); |
726 |
|
} |
727 |
|
break; |
728 |
|
|
730 |
|
case CLIENT_TYPE: |
731 |
|
break; |
732 |
|
|
733 |
+ |
case SERVICE_TYPE: |
734 |
+ |
DLINK_FOREACH(ptr, service_items.head) |
735 |
+ |
{ |
736 |
+ |
conf = ptr->data; |
737 |
+ |
sendto_one(source_p, form_str(RPL_STATSSERVICE), |
738 |
+ |
me.name, source_p->name, 'S', "*", conf->name, 0, 0); |
739 |
+ |
} |
740 |
+ |
break; |
741 |
+ |
|
742 |
|
case SERVER_TYPE: |
743 |
|
DLINK_FOREACH(ptr, server_items.head) |
744 |
|
{ |
751 |
|
|
752 |
|
if (IsConfAllowAutoConn(aconf)) |
753 |
|
*p++ = 'A'; |
754 |
< |
if (IsConfCryptLink(aconf)) |
755 |
< |
*p++ = 'C'; |
737 |
< |
if (IsConfLazyLink(aconf)) |
738 |
< |
*p++ = 'L'; |
739 |
< |
if (aconf->fakename) |
740 |
< |
*p++ = 'M'; |
754 |
> |
if (IsConfSSL(aconf)) |
755 |
> |
*p++ = 'S'; |
756 |
|
if (IsConfTopicBurst(aconf)) |
757 |
|
*p++ = 'T'; |
743 |
– |
if (IsConfCompressed(aconf)) |
744 |
– |
*p++ = 'Z'; |
758 |
|
if (buf[0] == '\0') |
759 |
|
*p++ = '*'; |
760 |
|
|
761 |
|
*p = '\0'; |
762 |
|
|
763 |
< |
/* Allow admins to see actual ips |
764 |
< |
* unless hide_server_ips is enabled |
763 |
> |
/* |
764 |
> |
* Allow admins to see actual ips unless hide_server_ips is enabled |
765 |
|
*/ |
766 |
< |
if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p)) |
766 |
> |
if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN)) |
767 |
|
sendto_one(source_p, form_str(RPL_STATSCLINE), |
768 |
|
me.name, source_p->name, 'C', aconf->host, |
769 |
|
buf, conf->name, aconf->port, |
803 |
|
case CRESV_TYPE: |
804 |
|
case NRESV_TYPE: |
805 |
|
case CLUSTER_TYPE: |
806 |
+ |
default: |
807 |
|
break; |
808 |
|
} |
809 |
|
} |
830 |
|
|
831 |
|
/* I'm already in big trouble if source_p->localClient is NULL -db */ |
832 |
|
if ((i = verify_access(source_p, username))) |
833 |
< |
{ |
820 |
< |
ilog(L_INFO, "Access denied: %s[%s]", |
833 |
> |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
834 |
|
source_p->name, source_p->sockhost); |
822 |
– |
} |
835 |
|
|
836 |
|
switch (i) |
837 |
|
{ |
826 |
– |
case IRCD_SOCKET_ERROR: |
827 |
– |
exit_client(source_p, &me, "Socket Error"); |
828 |
– |
break; |
829 |
– |
|
838 |
|
case TOO_MANY: |
839 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, |
840 |
|
"Too many on IP for %s (%s).", |
841 |
|
get_client_name(source_p, SHOW_IP), |
842 |
|
source_p->sockhost); |
843 |
< |
ilog(L_INFO,"Too many connections on IP from %s.", |
843 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
844 |
|
get_client_name(source_p, SHOW_IP)); |
845 |
< |
ServerStats->is_ref++; |
845 |
> |
++ServerStats.is_ref; |
846 |
|
exit_client(source_p, &me, "No more connections allowed on that IP"); |
847 |
|
break; |
848 |
|
|
851 |
|
"I-line is full for %s (%s).", |
852 |
|
get_client_name(source_p, SHOW_IP), |
853 |
|
source_p->sockhost); |
854 |
< |
ilog(L_INFO,"Too many connections from %s.", |
854 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
855 |
|
get_client_name(source_p, SHOW_IP)); |
856 |
< |
ServerStats->is_ref++; |
856 |
> |
++ServerStats.is_ref; |
857 |
|
exit_client(source_p, &me, |
858 |
|
"No more connections allowed in your connection class"); |
859 |
|
break; |
860 |
|
|
861 |
|
case NOT_AUTHORIZED: |
862 |
< |
{ |
855 |
< |
static char ipaddr[HOSTIPLEN]; |
856 |
< |
ServerStats->is_ref++; |
862 |
> |
++ServerStats.is_ref; |
863 |
|
/* jdc - lists server name & port connections are on */ |
864 |
|
/* a purely cosmetical change */ |
859 |
– |
irc_getnameinfo((struct sockaddr*)&source_p->localClient->ip, |
860 |
– |
source_p->localClient->ip.ss_len, ipaddr, HOSTIPLEN, NULL, 0, |
861 |
– |
NI_NUMERICHOST); |
865 |
|
sendto_realops_flags(UMODE_UNAUTH, L_ALL, |
866 |
|
"Unauthorized client connection from %s [%s] on [%s/%u].", |
867 |
|
get_client_name(source_p, SHOW_IP), |
868 |
< |
ipaddr, |
868 |
> |
source_p->sockhost, |
869 |
|
source_p->localClient->listener->name, |
870 |
|
source_p->localClient->listener->port); |
871 |
< |
ilog(L_INFO, |
871 |
> |
ilog(LOG_TYPE_IRCD, |
872 |
|
"Unauthorized client connection from %s on [%s/%u].", |
873 |
|
get_client_name(source_p, SHOW_IP), |
874 |
|
source_p->localClient->listener->name, |
878 |
|
* capture reject code here or rely on the connecting too fast code. |
879 |
|
* - Dianora |
880 |
|
*/ |
881 |
< |
if(REJECT_HOLD_TIME > 0) |
881 |
> |
if (REJECT_HOLD_TIME > 0) |
882 |
|
{ |
883 |
|
sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server", |
884 |
|
me.name, source_p->name); |
888 |
|
else |
889 |
|
exit_client(source_p, &me, "You are not authorized to use this server"); |
890 |
|
break; |
891 |
< |
} |
889 |
< |
|
891 |
> |
|
892 |
|
case BANNED_CLIENT: |
893 |
|
/* |
894 |
|
* Don't exit them immediately, play with them a bit. |
901 |
|
} |
902 |
|
else |
903 |
|
exit_client(source_p, &me, "Banned"); |
904 |
< |
ServerStats->is_ref++; |
904 |
> |
++ServerStats.is_ref; |
905 |
|
break; |
906 |
|
|
907 |
|
case 0: |
1018 |
|
ip_found->count++; |
1019 |
|
SetIpHash(client_p); |
1020 |
|
|
1021 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1021 |
> |
aconf = map_to_conf(conf); |
1022 |
|
if (aconf->class_ptr == NULL) |
1023 |
|
return NOT_AUTHORIZED; /* If class is missing, this is best */ |
1024 |
|
|
1025 |
< |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
1025 |
> |
aclass = map_to_conf(aconf->class_ptr); |
1026 |
|
|
1027 |
|
count_user_host(client_p->username, client_p->host, |
1028 |
|
&global, &local, &ident); |
1033 |
|
*/ |
1034 |
|
if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass)) |
1035 |
|
a_limit_reached = 1; |
1036 |
< |
else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass)) |
1036 |
> |
else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass)) |
1037 |
|
a_limit_reached = 1; |
1038 |
|
else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass)) |
1039 |
|
a_limit_reached = 1; |
1046 |
|
if (a_limit_reached) |
1047 |
|
{ |
1048 |
|
if (!IsConfExemptLimits(aconf)) |
1049 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1049 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1050 |
|
|
1051 |
|
sendto_one(client_p, |
1052 |
|
":%s NOTICE %s :*** Your connection class is full, " |
1195 |
|
{ |
1196 |
|
struct sockaddr_in *v4 = (struct sockaddr_in *)addr; |
1197 |
|
int hash; |
1198 |
< |
u_int32_t ip; |
1198 |
> |
uint32_t ip; |
1199 |
|
|
1200 |
|
ip = ntohl(v4->sin_addr.s_addr); |
1201 |
|
hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1); |
1206 |
|
{ |
1207 |
|
int hash; |
1208 |
|
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr; |
1209 |
< |
u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr; |
1209 |
> |
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
1210 |
|
|
1211 |
|
hash = ip[0] ^ ip[3]; |
1212 |
|
hash ^= hash >> 16; |
1230 |
|
* used in the hash. |
1231 |
|
*/ |
1232 |
|
void |
1233 |
< |
count_ip_hash(int *number_ips_stored, unsigned long *mem_ips_stored) |
1233 |
> |
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
1234 |
|
{ |
1235 |
|
struct ip_entry *ptr; |
1236 |
|
int i; |
1318 |
|
case CLIENT_TYPE: |
1319 |
|
case OPER_TYPE: |
1320 |
|
case SERVER_TYPE: |
1321 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1321 |
> |
aconf = map_to_conf(conf); |
1322 |
> |
|
1323 |
> |
assert(aconf->clients > 0); |
1324 |
> |
|
1325 |
|
if ((aclass_conf = ClassPtr(aconf)) != NULL) |
1326 |
|
{ |
1327 |
< |
aclass = (struct ClassItem *)map_to_conf(aclass_conf); |
1327 |
> |
aclass = map_to_conf(aclass_conf); |
1328 |
> |
|
1329 |
> |
assert(aclass->curr_user_count > 0); |
1330 |
|
|
1331 |
|
if (conf->type == CLIENT_TYPE) |
1332 |
|
remove_from_cidr_check(&client_p->localClient->ip, aclass); |
1333 |
< |
|
1327 |
< |
if (CurrUserCount(aclass) > 0) |
1328 |
< |
aclass->curr_user_count--; |
1329 |
< |
if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0) |
1333 |
> |
if (--aclass->curr_user_count == 0 && aclass->active == 0) |
1334 |
|
delete_conf_item(aclass_conf); |
1335 |
|
} |
1336 |
|
|
1337 |
< |
/* Please, no ioccc entries - Dianora */ |
1334 |
< |
if (aconf->clients > 0) |
1335 |
< |
--aconf->clients; |
1336 |
< |
if (aconf->clients == 0 && IsConfIllegal(aconf)) |
1337 |
> |
if (--aconf->clients == 0 && IsConfIllegal(aconf)) |
1338 |
|
delete_conf_item(conf); |
1339 |
+ |
|
1340 |
|
break; |
1341 |
+ |
|
1342 |
|
case LEAF_TYPE: |
1343 |
|
case HUB_TYPE: |
1344 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
1344 |
> |
match_item = map_to_conf(conf); |
1345 |
|
if (match_item->ref_count == 0 && match_item->illegal) |
1346 |
|
delete_conf_item(conf); |
1347 |
|
break; |
1370 |
|
int |
1371 |
|
attach_conf(struct Client *client_p, struct ConfItem *conf) |
1372 |
|
{ |
1370 |
– |
struct AccessItem *aconf; |
1371 |
– |
struct MatchItem *match_item; |
1372 |
– |
|
1373 |
|
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
1374 |
|
return 1; |
1375 |
|
|
1377 |
|
conf->type == SERVER_TYPE || |
1378 |
|
conf->type == OPER_TYPE) |
1379 |
|
{ |
1380 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1380 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
1381 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1382 |
|
|
1383 |
|
if (IsConfIllegal(aconf)) |
1384 |
|
return NOT_AUTHORIZED; |
1385 |
|
|
1386 |
|
if (conf->type == CLIENT_TYPE) |
1386 |
– |
{ |
1387 |
– |
struct ClassItem *aclass; |
1388 |
– |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
1389 |
– |
|
1387 |
|
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1388 |
|
&client_p->localClient->ip, aclass)) |
1389 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1393 |
< |
|
1394 |
< |
CurrUserCount(aclass)++; |
1395 |
< |
} |
1389 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1390 |
|
|
1391 |
+ |
CurrUserCount(aclass)++; |
1392 |
|
aconf->clients++; |
1393 |
|
} |
1394 |
|
else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE) |
1395 |
|
{ |
1396 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
1396 |
> |
struct MatchItem *match_item = map_to_conf(conf); |
1397 |
|
match_item->ref_count++; |
1398 |
|
} |
1399 |
|
|
1427 |
|
DLINK_FOREACH(ptr, server_items.head) |
1428 |
|
{ |
1429 |
|
conf = ptr->data; |
1430 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1430 |
> |
aconf = map_to_conf(conf); |
1431 |
|
|
1432 |
|
if (match(conf->name, name) == 0 || match(aconf->host, host) == 0) |
1433 |
|
continue; |
1467 |
|
|
1468 |
|
if (conf->name == NULL) |
1469 |
|
continue; |
1470 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1470 |
> |
aconf = map_to_conf(conf); |
1471 |
|
if (aconf->host == NULL) |
1472 |
|
continue; |
1473 |
|
if (irccmp(conf->name, name) != 0) |
1478 |
|
** socket host) matches *either* host or name field |
1479 |
|
** of the configuration. |
1480 |
|
*/ |
1481 |
< |
if (!match(aconf->host, host) || !match(aconf->user,user) |
1487 |
< |
|| irccmp(conf->name, name) ) |
1481 |
> |
if (!match(aconf->host, host) || !match(aconf->user, user)) |
1482 |
|
continue; |
1483 |
|
if (type == OPER_TYPE) |
1484 |
|
{ |
1485 |
< |
struct ClassItem *aclass; |
1485 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1486 |
|
|
1487 |
< |
aclass = (struct ClassItem *)aconf->class_ptr; |
1494 |
< |
if (aconf->clients < MaxTotal(aclass)) |
1495 |
< |
return conf; |
1496 |
< |
else |
1487 |
> |
if (aconf->clients >= MaxTotal(aclass)) |
1488 |
|
continue; |
1489 |
|
} |
1490 |
< |
else |
1491 |
< |
return conf; |
1490 |
> |
|
1491 |
> |
return conf; |
1492 |
|
} |
1493 |
+ |
|
1494 |
|
return NULL; |
1495 |
|
} |
1496 |
|
|
1556 |
|
case SERVER_TYPE: |
1557 |
|
return(&server_items); |
1558 |
|
break; |
1559 |
+ |
case SERVICE_TYPE: |
1560 |
+ |
return(&service_items); |
1561 |
+ |
break; |
1562 |
|
case CLUSTER_TYPE: |
1563 |
|
return(&cluster_items); |
1564 |
|
break; |
1594 |
|
|
1595 |
|
switch (type) |
1596 |
|
{ |
1597 |
< |
case RXLINE_TYPE: |
1597 |
> |
#ifdef HAVE_LIBPCRE |
1598 |
> |
case RXLINE_TYPE: |
1599 |
|
DLINK_FOREACH(ptr, list_p->head) |
1600 |
|
{ |
1601 |
|
conf = ptr->data; |
1605 |
|
return conf; |
1606 |
|
} |
1607 |
|
break; |
1608 |
+ |
#endif |
1609 |
+ |
case SERVICE_TYPE: |
1610 |
+ |
DLINK_FOREACH(ptr, list_p->head) |
1611 |
+ |
{ |
1612 |
+ |
conf = ptr->data; |
1613 |
+ |
|
1614 |
+ |
if (EmptyString(conf->name)) |
1615 |
+ |
continue; |
1616 |
+ |
if ((name != NULL) && !irccmp(name, conf->name)) |
1617 |
+ |
return conf; |
1618 |
+ |
} |
1619 |
+ |
break; |
1620 |
|
|
1621 |
|
case XLINE_TYPE: |
1622 |
|
case ULINE_TYPE: |
1671 |
|
* side effects - looks for an exact match on name field |
1672 |
|
*/ |
1673 |
|
struct ConfItem * |
1674 |
< |
find_exact_name_conf(ConfType type, const char *name, |
1674 |
> |
find_exact_name_conf(ConfType type, const struct Client *who, const char *name, |
1675 |
|
const char *user, const char *host) |
1676 |
|
{ |
1677 |
|
dlink_node *ptr = NULL; |
1712 |
|
DLINK_FOREACH(ptr, list_p->head) |
1713 |
|
{ |
1714 |
|
conf = ptr->data; |
1715 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1715 |
> |
aconf = map_to_conf(conf); |
1716 |
> |
|
1717 |
|
if (EmptyString(conf->name)) |
1718 |
< |
continue; |
1719 |
< |
|
1720 |
< |
if (irccmp(conf->name, name) == 0) |
1718 |
> |
continue; |
1719 |
> |
|
1720 |
> |
if (!irccmp(conf->name, name)) |
1721 |
|
{ |
1722 |
< |
if ((user == NULL && (host == NULL))) |
1723 |
< |
return (conf); |
1724 |
< |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
1725 |
< |
return (conf); |
1726 |
< |
if (match(aconf->user, user) && match(aconf->host, host)) |
1727 |
< |
return (conf); |
1722 |
> |
if (!who) |
1723 |
> |
return conf; |
1724 |
> |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
1725 |
> |
return conf; |
1726 |
> |
if (match(aconf->user, who->username)) |
1727 |
> |
{ |
1728 |
> |
switch (aconf->type) |
1729 |
> |
{ |
1730 |
> |
case HM_HOST: |
1731 |
> |
if (match(aconf->host, who->host) || match(aconf->host, who->sockhost)) |
1732 |
> |
return conf; |
1733 |
> |
break; |
1734 |
> |
case HM_IPV4: |
1735 |
> |
if (who->localClient->aftype == AF_INET) |
1736 |
> |
if (match_ipv4(&who->localClient->ip, &aconf->ipnum, aconf->bits)) |
1737 |
> |
return conf; |
1738 |
> |
break; |
1739 |
> |
#ifdef IPV6 |
1740 |
> |
case HM_IPV6: |
1741 |
> |
if (who->localClient->aftype == AF_INET6) |
1742 |
> |
if (match_ipv6(&who->localClient->ip, &aconf->ipnum, aconf->bits)) |
1743 |
> |
return conf; |
1744 |
> |
break; |
1745 |
> |
#endif |
1746 |
> |
default: |
1747 |
> |
assert(0); |
1748 |
> |
} |
1749 |
> |
} |
1750 |
|
} |
1751 |
|
} |
1752 |
+ |
|
1753 |
|
break; |
1754 |
|
|
1755 |
|
case SERVER_TYPE: |
1805 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
1806 |
|
"Got signal SIGHUP, reloading ircd.conf file"); |
1807 |
|
|
1776 |
– |
#ifndef _WIN32 |
1808 |
|
restart_resolver(); |
1809 |
< |
#endif |
1809 |
> |
|
1810 |
|
/* don't close listeners until we know we can go ahead with the rehash */ |
1811 |
|
|
1812 |
|
/* Check to see if we magically got(or lost) IPv6 support */ |
1817 |
|
if (ServerInfo.description != NULL) |
1818 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
1819 |
|
|
1789 |
– |
#ifndef STATIC_MODULES |
1820 |
|
load_conf_modules(); |
1791 |
– |
#endif |
1821 |
|
|
1822 |
|
flush_deleted_I_P(); |
1823 |
|
|
1824 |
|
rehashed_klines = 1; |
1825 |
< |
|
1825 |
> |
/* XXX */ |
1826 |
|
if (ConfigLoggingEntry.use_logging) |
1827 |
< |
reopen_log(logFileName); |
1827 |
> |
log_close_all(); |
1828 |
|
|
1829 |
|
return(0); |
1830 |
|
} |
1863 |
|
ServerInfo.specific_ipv6_vhost = 0; |
1864 |
|
|
1865 |
|
ServerInfo.max_clients = MAXCLIENTS_MAX; |
1866 |
< |
/* Don't reset hub, as that will break lazylinks */ |
1867 |
< |
/* ServerInfo.hub = NO; */ |
1866 |
> |
|
1867 |
> |
ServerInfo.hub = 0; |
1868 |
|
ServerInfo.dns_host.sin_addr.s_addr = 0; |
1869 |
|
ServerInfo.dns_host.sin_port = 0; |
1870 |
|
AdminInfo.name = NULL; |
1871 |
|
AdminInfo.email = NULL; |
1872 |
|
AdminInfo.description = NULL; |
1873 |
|
|
1874 |
< |
set_log_level(L_NOTICE); |
1874 |
> |
log_close_all(); |
1875 |
> |
|
1876 |
|
ConfigLoggingEntry.use_logging = 1; |
1877 |
< |
ConfigLoggingEntry.operlog[0] = '\0'; |
1878 |
< |
ConfigLoggingEntry.userlog[0] = '\0'; |
1879 |
< |
ConfigLoggingEntry.klinelog[0] = '\0'; |
1880 |
< |
ConfigLoggingEntry.glinelog[0] = '\0'; |
1881 |
< |
ConfigLoggingEntry.killlog[0] = '\0'; |
1882 |
< |
ConfigLoggingEntry.operspylog[0] = '\0'; |
1883 |
< |
ConfigLoggingEntry.ioerrlog[0] = '\0'; |
1854 |
< |
ConfigLoggingEntry.failed_operlog[0] = '\0'; |
1855 |
< |
|
1856 |
< |
ConfigChannel.restrict_channels = NO; |
1857 |
< |
ConfigChannel.disable_local_channels = NO; |
1858 |
< |
ConfigChannel.use_invex = YES; |
1859 |
< |
ConfigChannel.use_except = YES; |
1860 |
< |
ConfigChannel.use_knock = YES; |
1877 |
> |
|
1878 |
> |
ConfigChannel.disable_fake_channels = 0; |
1879 |
> |
ConfigChannel.restrict_channels = 0; |
1880 |
> |
ConfigChannel.disable_local_channels = 0; |
1881 |
> |
ConfigChannel.use_invex = 1; |
1882 |
> |
ConfigChannel.use_except = 1; |
1883 |
> |
ConfigChannel.use_knock = 1; |
1884 |
|
ConfigChannel.knock_delay = 300; |
1885 |
|
ConfigChannel.knock_delay_channel = 60; |
1886 |
|
ConfigChannel.max_chans_per_user = 15; |
1887 |
< |
ConfigChannel.quiet_on_ban = YES; |
1887 |
> |
ConfigChannel.quiet_on_ban = 1; |
1888 |
|
ConfigChannel.max_bans = 25; |
1889 |
|
ConfigChannel.default_split_user_count = 0; |
1890 |
|
ConfigChannel.default_split_server_count = 0; |
1891 |
< |
ConfigChannel.no_join_on_split = NO; |
1892 |
< |
ConfigChannel.no_create_on_split = NO; |
1893 |
< |
ConfigChannel.burst_topicwho = YES; |
1891 |
> |
ConfigChannel.no_join_on_split = 0; |
1892 |
> |
ConfigChannel.no_create_on_split = 0; |
1893 |
> |
ConfigChannel.burst_topicwho = 1; |
1894 |
|
|
1895 |
< |
ConfigServerHide.flatten_links = NO; |
1895 |
> |
ConfigServerHide.flatten_links = 0; |
1896 |
|
ConfigServerHide.links_delay = 300; |
1897 |
< |
ConfigServerHide.hidden = NO; |
1898 |
< |
ConfigServerHide.disable_hidden = NO; |
1899 |
< |
ConfigServerHide.hide_servers = NO; |
1897 |
> |
ConfigServerHide.hidden = 0; |
1898 |
> |
ConfigServerHide.disable_hidden = 0; |
1899 |
> |
ConfigServerHide.hide_servers = 0; |
1900 |
|
DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT); |
1901 |
< |
ConfigServerHide.hide_server_ips = NO; |
1901 |
> |
ConfigServerHide.hide_server_ips = 0; |
1902 |
|
|
1903 |
+ |
|
1904 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1905 |
+ |
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1906 |
|
ConfigFileEntry.gline_min_cidr = 16; |
1907 |
|
ConfigFileEntry.gline_min_cidr6 = 48; |
1908 |
< |
ConfigFileEntry.invisible_on_connect = YES; |
1909 |
< |
ConfigFileEntry.burst_away = NO; |
1910 |
< |
ConfigFileEntry.use_whois_actually = YES; |
1911 |
< |
ConfigFileEntry.tkline_expire_notices = YES; |
1912 |
< |
ConfigFileEntry.hide_spoof_ips = YES; |
1913 |
< |
ConfigFileEntry.ignore_bogus_ts = NO; |
1914 |
< |
ConfigFileEntry.disable_auth = NO; |
1915 |
< |
ConfigFileEntry.disable_remote = NO; |
1908 |
> |
ConfigFileEntry.invisible_on_connect = 1; |
1909 |
> |
ConfigFileEntry.burst_away = 0; |
1910 |
> |
ConfigFileEntry.use_whois_actually = 1; |
1911 |
> |
ConfigFileEntry.tkline_expire_notices = 1; |
1912 |
> |
ConfigFileEntry.hide_spoof_ips = 1; |
1913 |
> |
ConfigFileEntry.ignore_bogus_ts = 0; |
1914 |
> |
ConfigFileEntry.disable_auth = 0; |
1915 |
> |
ConfigFileEntry.disable_remote = 0; |
1916 |
|
ConfigFileEntry.kill_chase_time_limit = 90; |
1917 |
< |
ConfigFileEntry.default_floodcount = 8; /* XXX */ |
1918 |
< |
ConfigFileEntry.failed_oper_notice = YES; |
1919 |
< |
ConfigFileEntry.dots_in_ident = 0; /* XXX */ |
1894 |
< |
ConfigFileEntry.dot_in_ip6_addr = YES; |
1917 |
> |
ConfigFileEntry.default_floodcount = 8; |
1918 |
> |
ConfigFileEntry.failed_oper_notice = 1; |
1919 |
> |
ConfigFileEntry.dots_in_ident = 0; |
1920 |
|
ConfigFileEntry.min_nonwildcard = 4; |
1921 |
|
ConfigFileEntry.min_nonwildcard_simple = 3; |
1922 |
|
ConfigFileEntry.max_accept = 20; |
1923 |
< |
ConfigFileEntry.anti_nick_flood = NO; /* XXX */ |
1923 |
> |
ConfigFileEntry.anti_nick_flood = 0; |
1924 |
|
ConfigFileEntry.max_nick_time = 20; |
1925 |
|
ConfigFileEntry.max_nick_changes = 5; |
1926 |
< |
ConfigFileEntry.anti_spam_exit_message_time = 0; /* XXX */ |
1926 |
> |
ConfigFileEntry.anti_spam_exit_message_time = 0; |
1927 |
|
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1928 |
< |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; /* XXX */ |
1929 |
< |
ConfigFileEntry.kline_with_reason = YES; |
1928 |
> |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1929 |
> |
ConfigFileEntry.kline_with_reason = 1; |
1930 |
|
ConfigFileEntry.kline_reason = NULL; |
1931 |
< |
ConfigFileEntry.warn_no_nline = YES; |
1932 |
< |
ConfigFileEntry.stats_o_oper_only = NO; /* XXX */ |
1931 |
> |
ConfigFileEntry.warn_no_nline = 1; |
1932 |
> |
ConfigFileEntry.stats_o_oper_only = 0; |
1933 |
|
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
1934 |
|
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
1935 |
< |
ConfigFileEntry.stats_P_oper_only = NO; |
1935 |
> |
ConfigFileEntry.stats_P_oper_only = 0; |
1936 |
|
ConfigFileEntry.caller_id_wait = 60; |
1937 |
< |
ConfigFileEntry.opers_bypass_callerid = NO; |
1937 |
> |
ConfigFileEntry.opers_bypass_callerid = 0; |
1938 |
|
ConfigFileEntry.pace_wait = 10; |
1939 |
|
ConfigFileEntry.pace_wait_simple = 1; |
1940 |
< |
ConfigFileEntry.short_motd = NO; |
1941 |
< |
ConfigFileEntry.ping_cookie = NO; |
1942 |
< |
ConfigFileEntry.no_oper_flood = NO; /* XXX */ |
1943 |
< |
ConfigFileEntry.true_no_oper_flood = NO; /* XXX */ |
1944 |
< |
ConfigFileEntry.oper_pass_resv = YES; |
1945 |
< |
ConfigFileEntry.glines = NO; /* XXX */ |
1946 |
< |
ConfigFileEntry.gline_time = 12 * 3600; /* XXX */ |
1922 |
< |
ConfigFileEntry.idletime = 0; |
1940 |
> |
ConfigFileEntry.short_motd = 0; |
1941 |
> |
ConfigFileEntry.ping_cookie = 0; |
1942 |
> |
ConfigFileEntry.no_oper_flood = 0; |
1943 |
> |
ConfigFileEntry.true_no_oper_flood = 0; |
1944 |
> |
ConfigFileEntry.oper_pass_resv = 1; |
1945 |
> |
ConfigFileEntry.glines = 0; |
1946 |
> |
ConfigFileEntry.gline_time = 12 * 3600; |
1947 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1948 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT; |
1949 |
< |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; /* XXX */ |
1949 |
> |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
1950 |
|
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1951 |
< |
UMODE_OPERWALL | UMODE_WALLOP; /* XXX */ |
1952 |
< |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1929 |
< |
#ifdef HAVE_LIBCRYPTO |
1930 |
< |
/* jdc -- This is our default value for a cipher. According to the |
1931 |
< |
* CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported |
1932 |
< |
* under all circumstances if cryptlinks are enabled. So, |
1933 |
< |
* this will be our default. |
1934 |
< |
* |
1935 |
< |
* NOTE: I apologise for the hard-coded value of "1" (BF/128). |
1936 |
< |
* This should be moved into a find_cipher() routine. |
1937 |
< |
*/ |
1938 |
< |
ConfigFileEntry.default_cipher_preference = &CipherTable[1]; |
1939 |
< |
#endif |
1940 |
< |
ConfigFileEntry.use_egd = NO; |
1951 |
> |
UMODE_OPERWALL | UMODE_WALLOP; |
1952 |
> |
ConfigFileEntry.use_egd = 0; |
1953 |
|
ConfigFileEntry.egdpool_path = NULL; |
1942 |
– |
#ifdef HAVE_LIBZ |
1943 |
– |
ConfigFileEntry.compression_level = 0; |
1944 |
– |
#endif |
1954 |
|
ConfigFileEntry.throttle_time = 10; |
1955 |
|
} |
1956 |
|
|
1961 |
|
* side effects - Read configuration file. |
1962 |
|
*/ |
1963 |
|
static void |
1964 |
< |
read_conf(FBFILE *file) |
1964 |
> |
read_conf(FILE *file) |
1965 |
|
{ |
1966 |
< |
scount = lineno = 0; |
1966 |
> |
lineno = 0; |
1967 |
|
|
1968 |
|
set_default_conf(); /* Set default values prior to conf parsing */ |
1969 |
< |
ypass = 1; |
1969 |
> |
conf_parser_ctx.pass = 1; |
1970 |
|
yyparse(); /* pick up the classes first */ |
1971 |
|
|
1972 |
< |
fbrewind(file); |
1972 |
> |
rewind(file); |
1973 |
|
|
1974 |
< |
ypass = 2; |
1974 |
> |
conf_parser_ctx.pass = 2; |
1975 |
|
yyparse(); /* Load the values from the conf */ |
1976 |
|
validate_conf(); /* Check to make sure some values are still okay. */ |
1977 |
|
/* Some global values are also loaded here. */ |
1987 |
|
if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN) |
1988 |
|
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1989 |
|
|
1981 |
– |
if (ConfigFileEntry.servlink_path == NULL) |
1982 |
– |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1983 |
– |
|
1990 |
|
if (ServerInfo.network_name == NULL) |
1991 |
|
DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT); |
1992 |
|
|
1993 |
|
if (ServerInfo.network_desc == NULL) |
1994 |
|
DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT); |
1995 |
|
|
1996 |
+ |
if (ConfigFileEntry.service_name == NULL) |
1997 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1998 |
+ |
|
1999 |
|
if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) || |
2000 |
|
(ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX)) |
2001 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX; |
2002 |
+ |
|
2003 |
+ |
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
2004 |
|
} |
2005 |
|
|
2006 |
|
/* lookup_confhost() |
2019 |
|
if (EmptyString(aconf->host) || |
2020 |
|
EmptyString(aconf->user)) |
2021 |
|
{ |
2022 |
< |
ilog(L_ERROR, "Host/server name error: (%s) (%s)", |
2022 |
> |
ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)", |
2023 |
|
aconf->host, conf->name); |
2024 |
|
return; |
2025 |
|
} |
2039 |
|
/* Get us ready for a bind() and don't bother doing dns lookup */ |
2040 |
|
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; |
2041 |
|
|
2042 |
< |
if (irc_getaddrinfo(aconf->host, NULL, &hints, &res)) |
2042 |
> |
if (getaddrinfo(aconf->host, NULL, &hints, &res)) |
2043 |
|
{ |
2044 |
|
conf_dns_lookup(aconf); |
2045 |
|
return; |
2050 |
|
memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen); |
2051 |
|
aconf->ipnum.ss_len = res->ai_addrlen; |
2052 |
|
aconf->ipnum.ss.ss_family = res->ai_family; |
2053 |
< |
irc_freeaddrinfo(res); |
2053 |
> |
freeaddrinfo(res); |
2054 |
|
} |
2055 |
|
|
2056 |
|
/* conf_connect_allowed() |
2089 |
|
static struct AccessItem * |
2090 |
|
find_regexp_kline(const char *uhi[]) |
2091 |
|
{ |
2092 |
+ |
#ifdef HAVE_LIBPCRE |
2093 |
|
const dlink_node *ptr = NULL; |
2094 |
|
|
2095 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
2104 |
|
!ircd_pcre_exec(aptr->regexhost, uhi[2]))) |
2105 |
|
return aptr; |
2106 |
|
} |
2107 |
< |
|
2107 |
> |
#endif |
2108 |
|
return NULL; |
2109 |
|
} |
2110 |
|
|
2278 |
|
} |
2279 |
|
} |
2280 |
|
|
2281 |
+ |
dlinkDelete(ptr, tklist); |
2282 |
|
delete_one_address_conf(aconf->host, aconf); |
2270 |
– |
dlinkDelete(ptr, tklist); |
2283 |
|
} |
2284 |
|
} |
2285 |
|
else if (conf->type == XLINE_TYPE || |
2333 |
|
if (ConfigFileEntry.tkline_expire_notices) |
2334 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2335 |
|
"Temporary RESV for [%s] expired", cconf->name); |
2336 |
< |
dlinkDelete(ptr, tklist); |
2325 |
< |
free_dlink_node(ptr); |
2326 |
< |
delete_conf_item(conf); |
2336 |
> |
delete_channel_resv(cconf); |
2337 |
|
} |
2338 |
|
} |
2339 |
|
} |
2348 |
|
static const struct oper_privs |
2349 |
|
{ |
2350 |
|
const unsigned int oprivs; |
2341 |
– |
const unsigned int hidden; |
2351 |
|
const unsigned char c; |
2352 |
|
} flag_list[] = { |
2353 |
< |
{ OPER_FLAG_ADMIN, OPER_FLAG_HIDDEN_ADMIN, 'A' }, |
2354 |
< |
{ OPER_FLAG_REMOTEBAN, 0, 'B' }, |
2355 |
< |
{ OPER_FLAG_DIE, 0, 'D' }, |
2356 |
< |
{ OPER_FLAG_GLINE, 0, 'G' }, |
2357 |
< |
{ OPER_FLAG_REHASH, 0, 'H' }, |
2358 |
< |
{ OPER_FLAG_K, 0, 'K' }, |
2359 |
< |
{ OPER_FLAG_OPERWALL, 0, 'L' }, |
2360 |
< |
{ OPER_FLAG_N, 0, 'N' }, |
2361 |
< |
{ OPER_FLAG_GLOBAL_KILL, 0, 'O' }, |
2362 |
< |
{ OPER_FLAG_REMOTE, 0, 'R' }, |
2363 |
< |
{ OPER_FLAG_OPER_SPY, 0, 'S' }, |
2364 |
< |
{ OPER_FLAG_UNKLINE, 0, 'U' }, |
2365 |
< |
{ OPER_FLAG_X, 0, 'X' }, |
2366 |
< |
{ 0, 0, '\0' } |
2353 |
> |
{ OPER_FLAG_ADMIN, 'A' }, |
2354 |
> |
{ OPER_FLAG_REMOTEBAN, 'B' }, |
2355 |
> |
{ OPER_FLAG_DIE, 'D' }, |
2356 |
> |
{ OPER_FLAG_GLINE, 'G' }, |
2357 |
> |
{ OPER_FLAG_REHASH, 'H' }, |
2358 |
> |
{ OPER_FLAG_K, 'K' }, |
2359 |
> |
{ OPER_FLAG_OPERWALL, 'L' }, |
2360 |
> |
{ OPER_FLAG_N, 'N' }, |
2361 |
> |
{ OPER_FLAG_GLOBAL_KILL, 'O' }, |
2362 |
> |
{ OPER_FLAG_REMOTE, 'R' }, |
2363 |
> |
{ OPER_FLAG_OPER_SPY, 'S' }, |
2364 |
> |
{ OPER_FLAG_UNKLINE, 'U' }, |
2365 |
> |
{ OPER_FLAG_X, 'X' }, |
2366 |
> |
{ 0, '\0' } |
2367 |
|
}; |
2368 |
|
|
2369 |
|
char * |
2375 |
|
|
2376 |
|
for (; flag_list[i].oprivs; ++i) |
2377 |
|
{ |
2378 |
< |
if ((port & flag_list[i].oprivs) && |
2370 |
< |
(port & flag_list[i].hidden) == 0) |
2378 |
> |
if (port & flag_list[i].oprivs) |
2379 |
|
*privs_ptr++ = flag_list[i].c; |
2380 |
|
else |
2381 |
|
*privs_ptr++ = ToLowerTab[flag_list[i].c]; |
2400 |
|
struct AccessItem *aconf; |
2401 |
|
|
2402 |
|
/* +5 for !,@,{,} and null */ |
2403 |
< |
static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5]; |
2403 |
> |
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
2404 |
|
|
2405 |
|
if (MyConnect(client_p)) |
2406 |
|
{ |
2411 |
|
|
2412 |
|
if (IsConfOperator(aconf)) |
2413 |
|
{ |
2414 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
2415 |
< |
client_p->username, client_p->host, |
2408 |
< |
conf->name); |
2414 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
2415 |
> |
client_p->username, client_p->host, conf->name); |
2416 |
|
return buffer; |
2417 |
|
} |
2418 |
|
} |
2423 |
|
assert(0); /* Oper without oper conf! */ |
2424 |
|
} |
2425 |
|
|
2426 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
2427 |
< |
client_p->username, client_p->host, client_p->servptr->name); |
2426 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
2427 |
> |
client_p->username, client_p->host, client_p->servptr->name); |
2428 |
|
return buffer; |
2429 |
|
} |
2430 |
|
|
2441 |
|
char chanmodes[32]; |
2442 |
|
char chanlimit[32]; |
2443 |
|
|
2444 |
+ |
conf_parser_ctx.boot = cold; |
2445 |
|
filename = get_conf_name(CONF_TYPE); |
2446 |
|
|
2447 |
|
/* We need to know the initial filename for the yyerror() to report |
2452 |
|
*/ |
2453 |
|
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
2454 |
|
|
2455 |
< |
if ((conf_fbfile_in = fbopen(filename, "r")) == NULL) |
2455 |
> |
if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL) |
2456 |
|
{ |
2457 |
|
if (cold) |
2458 |
|
{ |
2459 |
< |
ilog(L_CRIT, "Unable to read configuration file '%s': %s", |
2459 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
2460 |
|
filename, strerror(errno)); |
2461 |
|
exit(-1); |
2462 |
|
} |
2472 |
|
if (!cold) |
2473 |
|
clear_out_old_conf(); |
2474 |
|
|
2475 |
< |
read_conf(conf_fbfile_in); |
2476 |
< |
fbclose(conf_fbfile_in); |
2475 |
> |
read_conf(conf_parser_ctx.conf_file); |
2476 |
> |
fclose(conf_parser_ctx.conf_file); |
2477 |
|
|
2478 |
|
add_isupport("NETWORK", ServerInfo.network_name, -1); |
2479 |
< |
ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "", |
2480 |
< |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
2479 |
> |
snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d", |
2480 |
> |
ConfigChannel.use_except ? "e" : "", |
2481 |
> |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
2482 |
|
add_isupport("MAXLIST", chanmodes, -1); |
2483 |
|
add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets); |
2484 |
+ |
|
2485 |
|
if (ConfigChannel.disable_local_channels) |
2486 |
|
add_isupport("CHANTYPES", "#", -1); |
2487 |
|
else |
2488 |
|
add_isupport("CHANTYPES", "#&", -1); |
2489 |
< |
ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&", |
2490 |
< |
ConfigChannel.max_chans_per_user); |
2489 |
> |
|
2490 |
> |
snprintf(chanlimit, sizeof(chanlimit), "%s:%d", |
2491 |
> |
ConfigChannel.disable_local_channels ? "#" : "#&", |
2492 |
> |
ConfigChannel.max_chans_per_user); |
2493 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
2494 |
< |
ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "", |
2495 |
< |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst"); |
2494 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s%s%s", |
2495 |
> |
ConfigChannel.use_except ? "e" : "", |
2496 |
> |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS"); |
2497 |
|
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
2498 |
+ |
|
2499 |
|
if (ConfigChannel.use_except) |
2500 |
|
add_isupport("EXCEPTS", "e", -1); |
2501 |
|
if (ConfigChannel.use_invex) |
2508 |
|
*/ |
2509 |
|
rebuild_isupport_message_line(); |
2510 |
|
|
2511 |
< |
parse_conf_file(KLINE_TYPE, cold); |
2511 |
> |
#ifdef HAVE_LIBPCRE |
2512 |
|
parse_conf_file(RKLINE_TYPE, cold); |
2513 |
+ |
parse_conf_file(RXLINE_TYPE, cold); |
2514 |
+ |
#endif |
2515 |
+ |
parse_conf_file(KLINE_TYPE, cold); |
2516 |
|
parse_conf_file(DLINE_TYPE, cold); |
2517 |
|
parse_conf_file(XLINE_TYPE, cold); |
2501 |
– |
parse_conf_file(RXLINE_TYPE, cold); |
2518 |
|
parse_conf_file(NRESV_TYPE, cold); |
2519 |
|
parse_conf_file(CRESV_TYPE, cold); |
2520 |
|
} |
2528 |
|
static void |
2529 |
|
parse_conf_file(int type, int cold) |
2530 |
|
{ |
2531 |
< |
FBFILE *file = NULL; |
2531 |
> |
FILE *file = NULL; |
2532 |
|
const char *filename = get_conf_name(type); |
2533 |
|
|
2534 |
< |
if ((file = fbopen(filename, "r")) == NULL) |
2534 |
> |
if ((file = fopen(filename, "r")) == NULL) |
2535 |
|
{ |
2536 |
|
if (cold) |
2537 |
< |
ilog(L_ERROR, "Unable to read configuration file '%s': %s", |
2537 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
2538 |
|
filename, strerror(errno)); |
2539 |
|
else |
2540 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2544 |
|
else |
2545 |
|
{ |
2546 |
|
parse_csv_file(file, type); |
2547 |
< |
fbclose(file); |
2547 |
> |
fclose(file); |
2548 |
|
} |
2549 |
|
} |
2550 |
|
|
2565 |
|
dlink_list *free_items [] = { |
2566 |
|
&server_items, &oconf_items, &hub_items, &leaf_items, |
2567 |
|
&uconf_items, &xconf_items, &rxconf_items, &rkconf_items, |
2568 |
< |
&nresv_items, &cluster_items, &gdeny_items, NULL |
2568 |
> |
&nresv_items, &cluster_items, &gdeny_items, &service_items, NULL |
2569 |
|
}; |
2570 |
|
|
2571 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
2582 |
|
/* XXX This is less than pretty */ |
2583 |
|
if (conf->type == SERVER_TYPE) |
2584 |
|
{ |
2585 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2585 |
> |
aconf = map_to_conf(conf); |
2586 |
> |
|
2587 |
|
if (aconf->clients != 0) |
2588 |
|
{ |
2589 |
|
SetConfIllegal(aconf); |
2596 |
|
} |
2597 |
|
else if (conf->type == OPER_TYPE) |
2598 |
|
{ |
2599 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2599 |
> |
aconf = map_to_conf(conf); |
2600 |
> |
|
2601 |
|
if (aconf->clients != 0) |
2602 |
|
{ |
2603 |
|
SetConfIllegal(aconf); |
2610 |
|
} |
2611 |
|
else if (conf->type == CLIENT_TYPE) |
2612 |
|
{ |
2613 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2613 |
> |
aconf = map_to_conf(conf); |
2614 |
> |
|
2615 |
|
if (aconf->clients != 0) |
2616 |
|
{ |
2617 |
|
SetConfIllegal(aconf); |
2636 |
|
{ |
2637 |
|
if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE)) |
2638 |
|
{ |
2639 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
2640 |
< |
if ((match_item->ref_count <= 0)) |
2639 |
> |
match_item = map_to_conf(conf); |
2640 |
> |
if (match_item->ref_count <= 0) |
2641 |
|
delete_conf_item(conf); |
2642 |
|
else |
2643 |
|
{ |
2651 |
|
} |
2652 |
|
} |
2653 |
|
|
2654 |
< |
/* don't delete the class table, rather mark all entries |
2654 |
> |
/* |
2655 |
> |
* don't delete the class table, rather mark all entries |
2656 |
|
* for deletion. The table is cleaned up by check_class. - avalon |
2657 |
|
*/ |
2658 |
|
DLINK_FOREACH(ptr, class_items.head) |
2659 |
|
{ |
2660 |
< |
conf = ptr->data; |
2661 |
< |
cltmp = (struct ClassItem *)map_to_conf(conf); |
2660 |
> |
cltmp = map_to_conf(ptr->data); |
2661 |
> |
|
2662 |
|
if (ptr != class_items.tail) /* never mark the "default" class */ |
2663 |
< |
MaxTotal(cltmp) = -1; |
2663 |
> |
cltmp->active = 0; |
2664 |
|
} |
2665 |
|
|
2666 |
|
clear_out_address_conf(); |
2667 |
|
|
2668 |
|
/* clean out module paths */ |
2649 |
– |
#ifndef STATIC_MODULES |
2669 |
|
mod_clear_paths(); |
2651 |
– |
#endif |
2670 |
|
|
2671 |
|
/* clean out ServerInfo */ |
2672 |
|
MyFree(ServerInfo.description); |
2686 |
|
|
2687 |
|
MyFree(ServerInfo.rsa_private_key_file); |
2688 |
|
ServerInfo.rsa_private_key_file = NULL; |
2689 |
+ |
|
2690 |
+ |
if (ServerInfo.server_ctx) |
2691 |
+ |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2| |
2692 |
+ |
SSL_OP_NO_SSLv3| |
2693 |
+ |
SSL_OP_NO_TLSv1); |
2694 |
+ |
if (ServerInfo.client_ctx) |
2695 |
+ |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2| |
2696 |
+ |
SSL_OP_NO_SSLv3| |
2697 |
+ |
SSL_OP_NO_TLSv1); |
2698 |
|
#endif |
2699 |
|
|
2700 |
|
/* clean out old resvs from the conf */ |
2717 |
|
*/ |
2718 |
|
|
2719 |
|
/* clean out general */ |
2720 |
< |
MyFree(ConfigFileEntry.servlink_path); |
2721 |
< |
ConfigFileEntry.servlink_path = NULL; |
2722 |
< |
#ifdef HAVE_LIBCRYPTO |
2696 |
< |
ConfigFileEntry.default_cipher_preference = NULL; |
2697 |
< |
#endif /* HAVE_LIBCRYPTO */ |
2720 |
> |
MyFree(ConfigFileEntry.service_name); |
2721 |
> |
ConfigFileEntry.service_name = NULL; |
2722 |
> |
|
2723 |
|
delete_isupport("INVEX"); |
2724 |
|
delete_isupport("EXCEPTS"); |
2725 |
|
} |
2914 |
|
{ |
2915 |
|
struct ConfItem *conf; |
2916 |
|
|
2917 |
< |
if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL) |
2918 |
< |
return(conf); |
2917 |
> |
if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL) |
2918 |
> |
return conf; |
2919 |
|
|
2920 |
|
return class_default; |
2921 |
|
} |
2929 |
|
void |
2930 |
|
check_class(void) |
2931 |
|
{ |
2932 |
< |
dlink_node *ptr; |
2908 |
< |
dlink_node *next_ptr; |
2909 |
< |
struct ConfItem *conf; |
2910 |
< |
struct ClassItem *aclass; |
2932 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
2933 |
|
|
2934 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head) |
2935 |
|
{ |
2936 |
< |
conf = ptr->data; |
2915 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
2936 |
> |
struct ClassItem *aclass = map_to_conf(ptr->data); |
2937 |
|
|
2938 |
< |
if (MaxTotal(aclass) < 0) |
2938 |
> |
if (!aclass->active && !CurrUserCount(aclass)) |
2939 |
|
{ |
2940 |
|
destroy_cidr_class(aclass); |
2941 |
< |
if (CurrUserCount(aclass) > 0) |
2921 |
< |
dlinkDelete(&conf->node, &class_items); |
2922 |
< |
else |
2923 |
< |
delete_conf_item(conf); |
2941 |
> |
delete_conf_item(ptr->data); |
2942 |
|
} |
2943 |
|
} |
2944 |
|
} |
2955 |
|
struct ClassItem *aclass; |
2956 |
|
|
2957 |
|
class_default = make_conf_item(CLASS_TYPE); |
2958 |
< |
aclass = (struct ClassItem *)map_to_conf(class_default); |
2958 |
> |
|
2959 |
> |
aclass = map_to_conf(class_default); |
2960 |
> |
aclass->active = 1; |
2961 |
|
DupString(class_default->name, "default"); |
2962 |
|
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
2963 |
|
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
2973 |
|
* output - sendq for this client as found from its class |
2974 |
|
* side effects - NONE |
2975 |
|
*/ |
2976 |
< |
unsigned long |
2976 |
> |
unsigned int |
2977 |
|
get_sendq(struct Client *client_p) |
2978 |
|
{ |
2979 |
< |
unsigned long sendq = DEFAULT_SENDQ; |
2979 |
> |
unsigned int sendq = DEFAULT_SENDQ; |
2980 |
|
dlink_node *ptr; |
2981 |
|
struct ConfItem *conf; |
2982 |
|
struct ConfItem *class_conf; |
3016 |
|
void |
3017 |
|
conf_add_class_to_conf(struct ConfItem *conf, const char *class_name) |
3018 |
|
{ |
3019 |
< |
struct AccessItem *aconf; |
3020 |
< |
struct ClassItem *aclass; |
3001 |
< |
|
3002 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
3019 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
3020 |
> |
struct ClassItem *class = NULL; |
3021 |
|
|
3022 |
|
if (class_name == NULL) |
3023 |
|
{ |
3024 |
|
aconf->class_ptr = class_default; |
3025 |
+ |
|
3026 |
|
if (conf->type == CLIENT_TYPE) |
3027 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
3028 |
|
"Warning *** Defaulting to default class for %s@%s", |
3033 |
|
conf->name); |
3034 |
|
} |
3035 |
|
else |
3017 |
– |
{ |
3036 |
|
aconf->class_ptr = find_class(class_name); |
3019 |
– |
} |
3037 |
|
|
3038 |
< |
if (aconf->class_ptr == NULL) |
3038 |
> |
if (aconf->class_ptr) |
3039 |
> |
class = map_to_conf(aconf->class_ptr); |
3040 |
> |
|
3041 |
> |
if (aconf->class_ptr == NULL || !class->active) |
3042 |
|
{ |
3043 |
|
if (conf->type == CLIENT_TYPE) |
3044 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
3050 |
|
conf->name); |
3051 |
|
aconf->class_ptr = class_default; |
3052 |
|
} |
3033 |
– |
else |
3034 |
– |
{ |
3035 |
– |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
3036 |
– |
if (MaxTotal(aclass) < 0) |
3037 |
– |
{ |
3038 |
– |
aconf->class_ptr = class_default; |
3039 |
– |
} |
3040 |
– |
} |
3053 |
|
} |
3054 |
|
|
3043 |
– |
#define MAXCONFLINKS 150 |
3044 |
– |
|
3055 |
|
/* conf_add_server() |
3056 |
|
* |
3057 |
|
* inputs - pointer to config item |
3060 |
|
* side effects - Add a connect block |
3061 |
|
*/ |
3062 |
|
int |
3063 |
< |
conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name) |
3063 |
> |
conf_add_server(struct ConfItem *conf, const char *class_name) |
3064 |
|
{ |
3065 |
|
struct AccessItem *aconf; |
3066 |
< |
char *orig_host; |
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); |
3071 |
|
|
3072 |
|
conf_add_class_to_conf(conf, class_name); |
3073 |
|
|
3074 |
< |
if (lcount > MAXCONFLINKS || !aconf->host || !conf->name) |
3074 |
> |
if (!aconf->host || !conf->name) |
3075 |
|
{ |
3076 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block"); |
3077 |
< |
ilog(L_WARN, "Bad connect block"); |
3077 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block"); |
3078 |
|
return -1; |
3079 |
|
} |
3080 |
|
|
3081 |
< |
if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf)) |
3081 |
> |
if (EmptyString(aconf->passwd)) |
3082 |
|
{ |
3083 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s", |
3084 |
|
conf->name); |
3085 |
< |
ilog(L_WARN, "Bad connect block, host %s", conf->name); |
3085 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name); |
3086 |
|
return -1; |
3087 |
|
} |
3088 |
|
|
3089 |
< |
orig_host = aconf->host; |
3090 |
< |
split_nuh(orig_host, NULL, &aconf->user, &aconf->host); |
3091 |
< |
MyFree(orig_host); |
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 |
> |
|
3107 |
|
lookup_confhost(conf); |
3108 |
|
|
3109 |
|
return 0; |
3110 |
|
} |
3111 |
|
|
3085 |
– |
/* conf_add_d_conf() |
3086 |
– |
* |
3087 |
– |
* inputs - pointer to config item |
3088 |
– |
* output - NONE |
3089 |
– |
* side effects - Add a d/D line |
3090 |
– |
*/ |
3091 |
– |
void |
3092 |
– |
conf_add_d_conf(struct AccessItem *aconf) |
3093 |
– |
{ |
3094 |
– |
if (aconf->host == NULL) |
3095 |
– |
return; |
3096 |
– |
|
3097 |
– |
aconf->user = NULL; |
3098 |
– |
|
3099 |
– |
/* XXX - Should 'd' ever be in the old conf? For new conf we don't |
3100 |
– |
* need this anyway, so I will disable it for now... -A1kmm |
3101 |
– |
*/ |
3102 |
– |
if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST) |
3103 |
– |
{ |
3104 |
– |
ilog(L_WARN, "Invalid Dline %s ignored", aconf->host); |
3105 |
– |
free_access_item(aconf); |
3106 |
– |
} |
3107 |
– |
else |
3108 |
– |
{ |
3109 |
– |
/* XXX ensure user is NULL */ |
3110 |
– |
MyFree(aconf->user); |
3111 |
– |
aconf->user = NULL; |
3112 |
– |
add_conf_by_address(CONF_DLINE, aconf); |
3113 |
– |
} |
3114 |
– |
} |
3115 |
– |
|
3112 |
|
/* yyerror() |
3113 |
|
* |
3114 |
|
* inputs - message from parser |
3120 |
|
{ |
3121 |
|
char newlinebuf[IRCD_BUFSIZE]; |
3122 |
|
|
3123 |
< |
if (ypass != 1) |
3123 |
> |
if (conf_parser_ctx.pass != 1) |
3124 |
|
return; |
3125 |
|
|
3126 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
3127 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s", |
3128 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
3129 |
< |
ilog(L_WARN, "\"%s\", line %u: %s: %s", |
3129 |
> |
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
3130 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
3131 |
|
} |
3132 |
|
|
3137 |
– |
int |
3138 |
– |
conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb) |
3139 |
– |
{ |
3140 |
– |
if (fbgets(lbuf, max_size, fb) == NULL) |
3141 |
– |
return 0; |
3142 |
– |
|
3143 |
– |
return strlen(lbuf); |
3144 |
– |
} |
3145 |
– |
|
3146 |
– |
int |
3147 |
– |
conf_yy_fatal_error(const char *msg) |
3148 |
– |
{ |
3149 |
– |
return 0; |
3150 |
– |
} |
3151 |
– |
|
3133 |
|
/* |
3134 |
|
* valid_tkline() |
3135 |
|
* |
3141 |
|
* Originally written by Dianora (Diane, db@db.net) |
3142 |
|
*/ |
3143 |
|
time_t |
3144 |
< |
valid_tkline(char *p, int minutes) |
3144 |
> |
valid_tkline(const char *p, int minutes) |
3145 |
|
{ |
3146 |
|
time_t result = 0; |
3147 |
|
|
3148 |
< |
while (*p) |
3148 |
> |
for (; *p; ++p) |
3149 |
|
{ |
3150 |
< |
if (IsDigit(*p)) |
3170 |
< |
{ |
3171 |
< |
result *= 10; |
3172 |
< |
result += ((*p) & 0xF); |
3173 |
< |
p++; |
3174 |
< |
} |
3175 |
< |
else |
3150 |
> |
if (!IsDigit(*p)) |
3151 |
|
return 0; |
3152 |
+ |
|
3153 |
+ |
result *= 10; |
3154 |
+ |
result += ((*p) & 0xF); |
3155 |
|
} |
3156 |
|
|
3157 |
< |
/* in the degenerate case where oper does a /quote kline 0 user@host :reason |
3157 |
> |
/* |
3158 |
> |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
3159 |
|
* i.e. they specifically use 0, I am going to return 1 instead |
3160 |
|
* as a return value of non-zero is used to flag it as a temporary kline |
3161 |
|
*/ |
3183 |
– |
|
3162 |
|
if (result == 0) |
3163 |
|
result = 1; |
3164 |
|
|
3259 |
|
* if target_server is NULL and an "ON" is found error |
3260 |
|
* is reported. |
3261 |
|
* if reason pointer is NULL ignore pointer, |
3262 |
< |
* this allows usee of parse_a_line in unkline etc. |
3262 |
> |
* this allows use of parse_a_line in unkline etc. |
3263 |
|
* |
3264 |
|
* - Dianora |
3265 |
|
*/ |
3329 |
|
return -1; |
3330 |
|
} |
3331 |
|
|
3332 |
< |
if (!IsOperRemoteBan(source_p)) |
3332 |
> |
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
3333 |
|
{ |
3334 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
3335 |
|
me.name, source_p->name, "remoteban"); |
3366 |
|
return -1; |
3367 |
|
} |
3368 |
|
|
3369 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p)) |
3369 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p)) |
3370 |
|
return -1; |
3371 |
|
} |
3372 |
|
else |
3373 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p)) |
3373 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p)) |
3374 |
|
return -1; |
3375 |
|
|
3376 |
|
if (reason != NULL) |
3377 |
|
{ |
3378 |
< |
if (parc != 0) |
3378 |
> |
if (parc != 0 && !EmptyString(*parv)) |
3379 |
|
{ |
3380 |
|
*reason = *parv; |
3381 |
< |
if (!valid_comment(source_p, *reason, YES)) |
3381 |
> |
if (!valid_comment(source_p, *reason, 1)) |
3382 |
|
return -1; |
3383 |
|
} |
3384 |
|
else |
3414 |
|
{ |
3415 |
|
/* Explicit user@host mask given */ |
3416 |
|
|
3417 |
< |
if(hostp != NULL) /* I'm a little user@host */ |
3417 |
> |
if (hostp != NULL) /* I'm a little user@host */ |
3418 |
|
{ |
3419 |
|
*(hostp++) = '\0'; /* short and squat */ |
3420 |
|
if (*user_host_or_nick) |
3537 |
|
* inputs - client sending the cluster |
3538 |
|
* - command name "KLINE" "XLINE" etc. |
3539 |
|
* - capab -- CAP_KLN etc. from s_serv.h |
3540 |
< |
* - cluster type -- CLUSTER_KLINE etc. from s_conf.h |
3540 |
> |
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
3541 |
|
* - pattern and args to send along |
3542 |
|
* output - none |
3543 |
|
* side effects - Take source_p send the pattern with args given |
3545 |
|
*/ |
3546 |
|
void |
3547 |
|
cluster_a_line(struct Client *source_p, const char *command, |
3548 |
< |
int capab, int cluster_type, const char *pattern, ...) |
3548 |
> |
int capab, int cluster_type, const char *pattern, ...) |
3549 |
|
{ |
3550 |
|
va_list args; |
3551 |
|
char buffer[IRCD_BUFSIZE]; |
3552 |
< |
struct ConfItem *conf; |
3575 |
< |
dlink_node *ptr; |
3552 |
> |
const dlink_node *ptr = NULL; |
3553 |
|
|
3554 |
|
va_start(args, pattern); |
3555 |
|
vsnprintf(buffer, sizeof(buffer), pattern, args); |
3557 |
|
|
3558 |
|
DLINK_FOREACH(ptr, cluster_items.head) |
3559 |
|
{ |
3560 |
< |
conf = ptr->data; |
3560 |
> |
const struct ConfItem *conf = ptr->data; |
3561 |
|
|
3562 |
|
if (conf->flags & cluster_type) |
3586 |
– |
{ |
3563 |
|
sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab, |
3564 |
|
"%s %s %s", command, conf->name, buffer); |
3589 |
– |
} |
3565 |
|
} |
3566 |
|
} |
3567 |
|
|
3593 |
|
* @ * * * |
3594 |
|
* ! * * * |
3595 |
|
*/ |
3621 |
– |
|
3596 |
|
void |
3597 |
< |
split_nuh(char *mask, char **nick, char **user, char **host) |
3597 |
> |
split_nuh(struct split_nuh_item *const iptr) |
3598 |
|
{ |
3599 |
|
char *p = NULL, *q = NULL; |
3600 |
|
|
3601 |
< |
if ((p = strchr(mask, '!')) != NULL) |
3601 |
> |
if (iptr->nickptr) |
3602 |
> |
strlcpy(iptr->nickptr, "*", iptr->nicksize); |
3603 |
> |
if (iptr->userptr) |
3604 |
> |
strlcpy(iptr->userptr, "*", iptr->usersize); |
3605 |
> |
if (iptr->hostptr) |
3606 |
> |
strlcpy(iptr->hostptr, "*", iptr->hostsize); |
3607 |
> |
|
3608 |
> |
if ((p = strchr(iptr->nuhmask, '!'))) |
3609 |
|
{ |
3610 |
|
*p = '\0'; |
3630 |
– |
if (nick != NULL) |
3631 |
– |
{ |
3632 |
– |
if (*mask != '\0') |
3633 |
– |
*nick = xstrldup(mask, NICKLEN); |
3634 |
– |
else |
3635 |
– |
DupString(*nick, "*"); |
3636 |
– |
} |
3611 |
|
|
3612 |
< |
if ((q = strchr(++p, '@')) != NULL) |
3613 |
< |
{ |
3614 |
< |
*q = '\0'; |
3612 |
> |
if (iptr->nickptr && *iptr->nuhmask != '\0') |
3613 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
3614 |
> |
|
3615 |
> |
if ((q = strchr(++p, '@'))) { |
3616 |
> |
*q++ = '\0'; |
3617 |
|
|
3618 |
|
if (*p != '\0') |
3619 |
< |
*user = xstrldup(p, USERLEN+1); |
3644 |
< |
else |
3645 |
< |
DupString(*user, "*"); |
3619 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
3620 |
|
|
3621 |
< |
if (*++q != '\0') |
3622 |
< |
*host = xstrldup(q, HOSTLEN+1); |
3649 |
< |
else |
3650 |
< |
DupString(*host, "*"); |
3621 |
> |
if (*q != '\0') |
3622 |
> |
strlcpy(iptr->hostptr, q, iptr->hostsize); |
3623 |
|
} |
3624 |
|
else |
3625 |
|
{ |
3626 |
|
if (*p != '\0') |
3627 |
< |
*user = xstrldup(p, USERLEN+1); |
3656 |
< |
else |
3657 |
< |
DupString(*user, "*"); |
3658 |
< |
|
3659 |
< |
DupString(*host, "*"); |
3627 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
3628 |
|
} |
3629 |
|
} |
3630 |
< |
else /* No ! found so lets look for a user@host */ |
3630 |
> |
else |
3631 |
|
{ |
3632 |
< |
if ((p = strchr(mask, '@')) != NULL) /* if found a @ */ |
3632 |
> |
/* No ! found so lets look for a user@host */ |
3633 |
> |
if ((p = strchr(iptr->nuhmask, '@'))) |
3634 |
|
{ |
3635 |
< |
if (nick != NULL) |
3636 |
< |
DupString(*nick, "*"); |
3668 |
< |
*p = '\0'; |
3635 |
> |
/* if found a @ */ |
3636 |
> |
*p++ = '\0'; |
3637 |
|
|
3638 |
< |
if (*mask != '\0') |
3639 |
< |
*user = xstrldup(mask, USERLEN+1); |
3672 |
< |
else |
3673 |
< |
DupString(*user, "*"); |
3638 |
> |
if (*iptr->nuhmask != '\0') |
3639 |
> |
strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize); |
3640 |
|
|
3641 |
< |
if (*++p != '\0') |
3642 |
< |
*host = xstrldup(p, HOSTLEN+1); |
3677 |
< |
else |
3678 |
< |
DupString(*host, "*"); |
3641 |
> |
if (*p != '\0') |
3642 |
> |
strlcpy(iptr->hostptr, p, iptr->hostsize); |
3643 |
|
} |
3644 |
< |
else /* no @ found */ |
3644 |
> |
else |
3645 |
|
{ |
3646 |
< |
if (nick != NULL) |
3647 |
< |
{ |
3648 |
< |
if (strpbrk(mask, ".:")) |
3685 |
< |
{ |
3686 |
< |
DupString(*nick, "*"); |
3687 |
< |
*host = xstrldup(mask, HOSTLEN+1); |
3688 |
< |
} |
3689 |
< |
else |
3690 |
< |
{ |
3691 |
< |
*nick = xstrldup(mask, NICKLEN); |
3692 |
< |
DupString(*host, "*"); |
3693 |
< |
} |
3694 |
< |
|
3695 |
< |
DupString(*user, "*"); |
3696 |
< |
} |
3646 |
> |
/* no @ found */ |
3647 |
> |
if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:")) |
3648 |
> |
strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize); |
3649 |
|
else |
3650 |
< |
{ |
3699 |
< |
DupString(*user, "*"); |
3700 |
< |
*host = xstrldup(mask, HOSTLEN+1); |
3701 |
< |
} |
3650 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
3651 |
|
} |
3652 |
|
} |
3653 |
|
} |
3674 |
|
{ |
3675 |
|
if (flags & mask) |
3676 |
|
*p++ = bit_table[i]; |
3677 |
< |
else if(lowerit) |
3677 |
> |
else if (lowerit) |
3678 |
|
*p++ = ToLower(bit_table[i]); |
3679 |
|
} |
3680 |
|
*p = '\0'; |
3881 |
|
static void |
3882 |
|
destroy_cidr_list(dlink_list *list) |
3883 |
|
{ |
3884 |
< |
dlink_node *ptr = NULL; |
3936 |
< |
dlink_node *next_ptr = NULL; |
3937 |
< |
struct CidrItem *cidr; |
3884 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
3885 |
|
|
3886 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) |
3887 |
|
{ |
3941 |
– |
cidr = ptr->data; |
3888 |
|
dlinkDelete(ptr, list); |
3889 |
< |
MyFree(cidr); |
3889 |
> |
MyFree(ptr->data); |
3890 |
|
} |
3891 |
|
} |
3892 |
|
|