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" |
36 |
– |
#include "hash.h" |
35 |
|
#include "hook.h" |
36 |
|
#include "irc_string.h" |
39 |
– |
#include "sprintf_irc.h" |
37 |
|
#include "s_bsd.h" |
41 |
– |
#include "irc_getnameinfo.h" |
42 |
– |
#include "irc_getaddrinfo.h" |
38 |
|
#include "ircd.h" |
44 |
– |
#include "list.h" |
39 |
|
#include "listener.h" |
40 |
|
#include "hostmask.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" |
53 |
– |
#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; |
57 |
|
|
58 |
|
/* general conf items link list root, other than k lines etc. */ |
59 |
+ |
dlink_list service_items = { NULL, NULL, 0 }; |
60 |
|
dlink_list server_items = { NULL, NULL, 0 }; |
61 |
|
dlink_list cluster_items = { NULL, NULL, 0 }; |
62 |
|
dlink_list hub_items = { NULL, NULL, 0 }; |
81 |
|
extern unsigned int lineno; |
82 |
|
extern char linebuf[]; |
83 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
88 |
– |
extern char yytext[]; |
84 |
|
extern int yyparse(); /* defined in y.tab.c */ |
85 |
< |
unsigned int scount = 0; /* used by yyparse(), etc */ |
86 |
< |
int ypass = 1; /* used by yyparse() */ |
85 |
> |
|
86 |
> |
struct conf_parser_context conf_parser_ctx = { 0, 0, NULL }; |
87 |
|
|
88 |
|
/* internally defined functions */ |
89 |
< |
static void lookup_confhost(struct ConfItem *); |
95 |
< |
static void set_default_conf(void); |
96 |
< |
static void validate_conf(void); |
97 |
< |
static void read_conf(FBFILE *); |
89 |
> |
static void read_conf(FILE *); |
90 |
|
static void clear_out_old_conf(void); |
91 |
|
static void flush_deleted_I_P(void); |
92 |
|
static void expire_tklines(dlink_list *); |
109 |
|
|
110 |
|
static void flags_to_ascii(unsigned int, const unsigned int[], char *, int); |
111 |
|
|
120 |
– |
FBFILE *conf_fbfile_in = NULL; |
121 |
– |
|
112 |
|
/* address of default class conf */ |
113 |
|
static struct ConfItem *class_default; |
114 |
|
|
131 |
|
static int ip_entries_count = 0; |
132 |
|
|
133 |
|
|
134 |
< |
inline void * |
134 |
> |
void * |
135 |
|
map_to_conf(struct ConfItem *aconf) |
136 |
|
{ |
137 |
|
void *conf; |
138 |
< |
conf = (void *)((unsigned long)aconf + |
139 |
< |
(unsigned long)sizeof(struct ConfItem)); |
138 |
> |
conf = (void *)((uintptr_t)aconf + |
139 |
> |
(uintptr_t)sizeof(struct ConfItem)); |
140 |
|
return(conf); |
141 |
|
} |
142 |
|
|
143 |
< |
inline struct ConfItem * |
143 |
> |
struct ConfItem * |
144 |
|
unmap_conf_item(void *aconf) |
145 |
|
{ |
146 |
|
struct ConfItem *conf; |
147 |
|
|
148 |
< |
conf = (struct ConfItem *)((unsigned long)aconf - |
149 |
< |
(unsigned long)sizeof(struct ConfItem)); |
148 |
> |
conf = (struct ConfItem *)((uintptr_t)aconf - |
149 |
> |
(uintptr_t)sizeof(struct ConfItem)); |
150 |
|
return(conf); |
151 |
|
} |
152 |
|
|
161 |
|
* if successful save hp in the conf item it was called with |
162 |
|
*/ |
163 |
|
static void |
164 |
< |
conf_dns_callback(void *vptr, struct DNSReply *reply) |
164 |
> |
conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name) |
165 |
|
{ |
166 |
< |
struct AccessItem *aconf = (struct AccessItem *)vptr; |
177 |
< |
struct ConfItem *conf; |
166 |
> |
struct AccessItem *aconf = vptr; |
167 |
|
|
168 |
< |
MyFree(aconf->dns_query); |
180 |
< |
aconf->dns_query = NULL; |
168 |
> |
aconf->dns_pending = 0; |
169 |
|
|
170 |
< |
if (reply != NULL) |
171 |
< |
memcpy(&aconf->ipnum, &reply->addr, sizeof(reply->addr)); |
172 |
< |
else { |
173 |
< |
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 |
< |
} |
170 |
> |
if (addr != NULL) |
171 |
> |
memcpy(&aconf->ipnum, addr, sizeof(aconf->ipnum)); |
172 |
> |
else |
173 |
> |
aconf->dns_failed = 1; |
174 |
|
} |
175 |
|
|
176 |
|
/* conf_dns_lookup() |
182 |
|
static void |
183 |
|
conf_dns_lookup(struct AccessItem *aconf) |
184 |
|
{ |
185 |
< |
if (aconf->dns_query == NULL) |
185 |
> |
if (!aconf->dns_pending) |
186 |
|
{ |
187 |
< |
aconf->dns_query = MyMalloc(sizeof(struct DNSQuery)); |
188 |
< |
aconf->dns_query->ptr = aconf; |
208 |
< |
aconf->dns_query->callback = conf_dns_callback; |
209 |
< |
gethost_byname(aconf->host, aconf->dns_query); |
187 |
> |
aconf->dns_pending = 1; |
188 |
> |
gethost_byname(conf_dns_callback, aconf, aconf->host); |
189 |
|
} |
190 |
|
} |
191 |
|
|
285 |
|
sizeof(struct MatchItem)); |
286 |
|
dlinkAdd(conf, &conf->node, &xconf_items); |
287 |
|
break; |
288 |
< |
|
288 |
> |
#ifdef HAVE_LIBPCRE |
289 |
|
case RXLINE_TYPE: |
290 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
291 |
|
sizeof(struct MatchItem)); |
299 |
|
aconf->status = CONF_KLINE; |
300 |
|
dlinkAdd(conf, &conf->node, &rkconf_items); |
301 |
|
break; |
302 |
< |
|
302 |
> |
#endif |
303 |
|
case CLUSTER_TYPE: |
304 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem)); |
305 |
|
dlinkAdd(conf, &conf->node, &cluster_items); |
316 |
|
dlinkAdd(conf, &conf->node, &nresv_items); |
317 |
|
break; |
318 |
|
|
319 |
+ |
case SERVICE_TYPE: |
320 |
+ |
status = CONF_SERVICE; |
321 |
+ |
conf = MyMalloc(sizeof(struct ConfItem)); |
322 |
+ |
dlinkAdd(conf, &conf->node, &service_items); |
323 |
+ |
break; |
324 |
+ |
|
325 |
|
case CLASS_TYPE: |
326 |
< |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
327 |
< |
sizeof(struct ClassItem)); |
326 |
> |
conf = MyMalloc(sizeof(struct ConfItem) + |
327 |
> |
sizeof(struct ClassItem)); |
328 |
|
dlinkAdd(conf, &conf->node, &class_items); |
329 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
330 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
329 |
> |
|
330 |
> |
aclass = map_to_conf(conf); |
331 |
> |
aclass->active = 1; |
332 |
> |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
333 |
|
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
334 |
|
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
335 |
|
MaxSendq(aclass) = DEFAULT_SENDQ; |
336 |
< |
CurrUserCount(aclass) = 0; |
336 |
> |
|
337 |
|
break; |
338 |
|
|
339 |
|
default: |
344 |
|
/* XXX Yes, this will core if default is hit. I want it to for now - db */ |
345 |
|
conf->type = type; |
346 |
|
|
347 |
< |
return(conf); |
347 |
> |
return conf; |
348 |
|
} |
349 |
|
|
350 |
|
void |
369 |
|
case SERVER_TYPE: |
370 |
|
aconf = map_to_conf(conf); |
371 |
|
|
372 |
< |
if (aconf->dns_query != NULL) |
373 |
< |
{ |
387 |
< |
delete_resolver_queries(aconf->dns_query); |
388 |
< |
MyFree(aconf->dns_query); |
389 |
< |
} |
372 |
> |
if (aconf->dns_pending) |
373 |
> |
delete_resolver_queries(aconf); |
374 |
|
if (aconf->passwd != NULL) |
375 |
|
memset(aconf->passwd, 0, strlen(aconf->passwd)); |
376 |
|
if (aconf->spasswd != NULL) |
383 |
|
MyFree(aconf->oper_reason); |
384 |
|
MyFree(aconf->user); |
385 |
|
MyFree(aconf->host); |
386 |
< |
MyFree(aconf->fakename); |
386 |
> |
MyFree(aconf->cipher_list); |
387 |
|
#ifdef HAVE_LIBCRYPTO |
388 |
|
if (aconf->rsa_public_key) |
389 |
|
RSA_free(aconf->rsa_public_key); |
463 |
|
dlinkDelete(&conf->node, &xconf_items); |
464 |
|
MyFree(conf); |
465 |
|
break; |
466 |
< |
|
466 |
> |
#ifdef HAVE_LIBPCRE |
467 |
|
case RKLINE_TYPE: |
468 |
|
aconf = map_to_conf(conf); |
469 |
|
MyFree(aconf->regexuser); |
486 |
|
dlinkDelete(&conf->node, &rxconf_items); |
487 |
|
MyFree(conf); |
488 |
|
break; |
489 |
< |
|
489 |
> |
#endif |
490 |
|
case NRESV_TYPE: |
491 |
|
match_item = map_to_conf(conf); |
492 |
|
MyFree(match_item->user); |
528 |
|
MyFree(conf); |
529 |
|
break; |
530 |
|
|
531 |
+ |
case SERVICE_TYPE: |
532 |
+ |
dlinkDelete(&conf->node, &service_items); |
533 |
+ |
MyFree(conf); |
534 |
+ |
break; |
535 |
+ |
|
536 |
|
default: |
537 |
|
break; |
538 |
|
} |
575 |
|
struct ClassItem *classitem = NULL; |
576 |
|
char buf[12]; |
577 |
|
char *p = NULL; |
578 |
+ |
const char *pfx = NULL; |
579 |
|
|
580 |
|
switch (type) |
581 |
|
{ |
618 |
|
} |
619 |
|
break; |
620 |
|
|
621 |
+ |
#ifdef HAVE_LIBPCRE |
622 |
|
case RXLINE_TYPE: |
623 |
|
DLINK_FOREACH(ptr, rxconf_items.head) |
624 |
|
{ |
633 |
|
break; |
634 |
|
|
635 |
|
case RKLINE_TYPE: |
636 |
< |
p = temp ? "Rk" : "RK"; |
636 |
> |
pfx = temp ? "kR" : "KR"; |
637 |
|
|
638 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
639 |
|
{ |
643 |
|
continue; |
644 |
|
|
645 |
|
sendto_one(source_p, form_str(RPL_STATSKLINE), me.name, |
646 |
< |
source_p->name, p, aconf->host, aconf->user, |
646 |
> |
source_p->name, pfx, aconf->host, aconf->user, |
647 |
|
aconf->reason, aconf->oper_reason ? aconf->oper_reason : ""); |
648 |
|
} |
649 |
|
break; |
650 |
+ |
#endif |
651 |
|
|
652 |
|
case ULINE_TYPE: |
653 |
|
DLINK_FOREACH(ptr, uconf_items.head) |
692 |
|
aconf = map_to_conf(conf); |
693 |
|
|
694 |
|
/* Don't allow non opers to see oper privs */ |
695 |
< |
if (IsOper(source_p)) |
695 |
> |
if (HasUMode(source_p, UMODE_OPER)) |
696 |
|
sendto_one(source_p, form_str(RPL_STATSOLINE), |
697 |
|
me.name, source_p->name, 'O', aconf->user, aconf->host, |
698 |
|
conf->name, oper_privs_as_string(aconf->port), |
714 |
|
me.name, source_p->name, 'Y', |
715 |
|
conf->name, PingFreq(classitem), |
716 |
|
ConFreq(classitem), |
717 |
< |
MaxTotal(classitem), MaxSendq(classitem)); |
717 |
> |
MaxTotal(classitem), MaxSendq(classitem), |
718 |
> |
CurrUserCount(classitem), |
719 |
> |
classitem->active ? "active" : "disabled"); |
720 |
|
} |
721 |
|
break; |
722 |
|
|
724 |
|
case CLIENT_TYPE: |
725 |
|
break; |
726 |
|
|
727 |
+ |
case SERVICE_TYPE: |
728 |
+ |
DLINK_FOREACH(ptr, service_items.head) |
729 |
+ |
{ |
730 |
+ |
conf = ptr->data; |
731 |
+ |
sendto_one(source_p, form_str(RPL_STATSSERVICE), |
732 |
+ |
me.name, source_p->name, 'S', "*", conf->name, 0, 0); |
733 |
+ |
} |
734 |
+ |
break; |
735 |
+ |
|
736 |
|
case SERVER_TYPE: |
737 |
|
DLINK_FOREACH(ptr, server_items.head) |
738 |
|
{ |
745 |
|
|
746 |
|
if (IsConfAllowAutoConn(aconf)) |
747 |
|
*p++ = 'A'; |
748 |
< |
if (IsConfCryptLink(aconf)) |
749 |
< |
*p++ = 'C'; |
747 |
< |
if (IsConfLazyLink(aconf)) |
748 |
< |
*p++ = 'L'; |
749 |
< |
if (aconf->fakename) |
750 |
< |
*p++ = 'M'; |
748 |
> |
if (IsConfSSL(aconf)) |
749 |
> |
*p++ = 'S'; |
750 |
|
if (IsConfTopicBurst(aconf)) |
751 |
|
*p++ = 'T'; |
753 |
– |
if (IsConfCompressed(aconf)) |
754 |
– |
*p++ = 'Z'; |
752 |
|
if (buf[0] == '\0') |
753 |
|
*p++ = '*'; |
754 |
|
|
755 |
|
*p = '\0'; |
756 |
|
|
757 |
< |
/* Allow admins to see actual ips |
758 |
< |
* unless hide_server_ips is enabled |
757 |
> |
/* |
758 |
> |
* Allow admins to see actual ips unless hide_server_ips is enabled |
759 |
|
*/ |
760 |
< |
if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p)) |
760 |
> |
if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN)) |
761 |
|
sendto_one(source_p, form_str(RPL_STATSCLINE), |
762 |
|
me.name, source_p->name, 'C', aconf->host, |
763 |
|
buf, conf->name, aconf->port, |
797 |
|
case CRESV_TYPE: |
798 |
|
case NRESV_TYPE: |
799 |
|
case CLUSTER_TYPE: |
800 |
+ |
default: |
801 |
|
break; |
802 |
|
} |
803 |
|
} |
824 |
|
|
825 |
|
/* I'm already in big trouble if source_p->localClient is NULL -db */ |
826 |
|
if ((i = verify_access(source_p, username))) |
827 |
< |
{ |
830 |
< |
ilog(L_INFO, "Access denied: %s[%s]", |
827 |
> |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
828 |
|
source_p->name, source_p->sockhost); |
832 |
– |
} |
829 |
|
|
830 |
|
switch (i) |
831 |
|
{ |
836 |
– |
case IRCD_SOCKET_ERROR: |
837 |
– |
exit_client(source_p, &me, "Socket Error"); |
838 |
– |
break; |
839 |
– |
|
832 |
|
case TOO_MANY: |
833 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, |
834 |
|
"Too many on IP for %s (%s).", |
835 |
|
get_client_name(source_p, SHOW_IP), |
836 |
|
source_p->sockhost); |
837 |
< |
ilog(L_INFO,"Too many connections on IP from %s.", |
837 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
838 |
|
get_client_name(source_p, SHOW_IP)); |
839 |
< |
ServerStats->is_ref++; |
839 |
> |
++ServerStats.is_ref; |
840 |
|
exit_client(source_p, &me, "No more connections allowed on that IP"); |
841 |
|
break; |
842 |
|
|
845 |
|
"I-line is full for %s (%s).", |
846 |
|
get_client_name(source_p, SHOW_IP), |
847 |
|
source_p->sockhost); |
848 |
< |
ilog(L_INFO,"Too many connections from %s.", |
848 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
849 |
|
get_client_name(source_p, SHOW_IP)); |
850 |
< |
ServerStats->is_ref++; |
850 |
> |
++ServerStats.is_ref; |
851 |
|
exit_client(source_p, &me, |
852 |
|
"No more connections allowed in your connection class"); |
853 |
|
break; |
854 |
|
|
855 |
|
case NOT_AUTHORIZED: |
856 |
< |
{ |
865 |
< |
static char ipaddr[HOSTIPLEN]; |
866 |
< |
ServerStats->is_ref++; |
856 |
> |
++ServerStats.is_ref; |
857 |
|
/* jdc - lists server name & port connections are on */ |
858 |
|
/* a purely cosmetical change */ |
869 |
– |
irc_getnameinfo((struct sockaddr*)&source_p->localClient->ip, |
870 |
– |
source_p->localClient->ip.ss_len, ipaddr, HOSTIPLEN, NULL, 0, |
871 |
– |
NI_NUMERICHOST); |
859 |
|
sendto_realops_flags(UMODE_UNAUTH, L_ALL, |
860 |
|
"Unauthorized client connection from %s [%s] on [%s/%u].", |
861 |
|
get_client_name(source_p, SHOW_IP), |
862 |
< |
ipaddr, |
862 |
> |
source_p->sockhost, |
863 |
|
source_p->localClient->listener->name, |
864 |
|
source_p->localClient->listener->port); |
865 |
< |
ilog(L_INFO, |
865 |
> |
ilog(LOG_TYPE_IRCD, |
866 |
|
"Unauthorized client connection from %s on [%s/%u].", |
867 |
|
get_client_name(source_p, SHOW_IP), |
868 |
|
source_p->localClient->listener->name, |
872 |
|
* capture reject code here or rely on the connecting too fast code. |
873 |
|
* - Dianora |
874 |
|
*/ |
875 |
< |
if(REJECT_HOLD_TIME > 0) |
875 |
> |
if (REJECT_HOLD_TIME > 0) |
876 |
|
{ |
877 |
|
sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server", |
878 |
|
me.name, source_p->name); |
882 |
|
else |
883 |
|
exit_client(source_p, &me, "You are not authorized to use this server"); |
884 |
|
break; |
885 |
< |
} |
899 |
< |
|
885 |
> |
|
886 |
|
case BANNED_CLIENT: |
887 |
|
/* |
888 |
|
* Don't exit them immediately, play with them a bit. |
895 |
|
} |
896 |
|
else |
897 |
|
exit_client(source_p, &me, "Banned"); |
898 |
< |
ServerStats->is_ref++; |
898 |
> |
++ServerStats.is_ref; |
899 |
|
break; |
900 |
|
|
901 |
|
case 0: |
1012 |
|
ip_found->count++; |
1013 |
|
SetIpHash(client_p); |
1014 |
|
|
1015 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1015 |
> |
aconf = map_to_conf(conf); |
1016 |
|
if (aconf->class_ptr == NULL) |
1017 |
|
return NOT_AUTHORIZED; /* If class is missing, this is best */ |
1018 |
|
|
1019 |
< |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
1019 |
> |
aclass = map_to_conf(aconf->class_ptr); |
1020 |
|
|
1021 |
|
count_user_host(client_p->username, client_p->host, |
1022 |
|
&global, &local, &ident); |
1027 |
|
*/ |
1028 |
|
if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass)) |
1029 |
|
a_limit_reached = 1; |
1030 |
< |
else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass)) |
1030 |
> |
else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass)) |
1031 |
|
a_limit_reached = 1; |
1032 |
|
else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass)) |
1033 |
|
a_limit_reached = 1; |
1040 |
|
if (a_limit_reached) |
1041 |
|
{ |
1042 |
|
if (!IsConfExemptLimits(aconf)) |
1043 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1043 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1044 |
|
|
1045 |
|
sendto_one(client_p, |
1046 |
|
":%s NOTICE %s :*** Your connection class is full, " |
1189 |
|
{ |
1190 |
|
struct sockaddr_in *v4 = (struct sockaddr_in *)addr; |
1191 |
|
int hash; |
1192 |
< |
u_int32_t ip; |
1192 |
> |
uint32_t ip; |
1193 |
|
|
1194 |
|
ip = ntohl(v4->sin_addr.s_addr); |
1195 |
|
hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1); |
1200 |
|
{ |
1201 |
|
int hash; |
1202 |
|
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr; |
1203 |
< |
u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr; |
1203 |
> |
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
1204 |
|
|
1205 |
|
hash = ip[0] ^ ip[3]; |
1206 |
|
hash ^= hash >> 16; |
1224 |
|
* used in the hash. |
1225 |
|
*/ |
1226 |
|
void |
1227 |
< |
count_ip_hash(int *number_ips_stored, unsigned long *mem_ips_stored) |
1227 |
> |
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
1228 |
|
{ |
1229 |
|
struct ip_entry *ptr; |
1230 |
|
int i; |
1312 |
|
case CLIENT_TYPE: |
1313 |
|
case OPER_TYPE: |
1314 |
|
case SERVER_TYPE: |
1315 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1315 |
> |
aconf = map_to_conf(conf); |
1316 |
> |
|
1317 |
> |
assert(aconf->clients > 0); |
1318 |
> |
|
1319 |
|
if ((aclass_conf = ClassPtr(aconf)) != NULL) |
1320 |
|
{ |
1321 |
< |
aclass = (struct ClassItem *)map_to_conf(aclass_conf); |
1321 |
> |
aclass = map_to_conf(aclass_conf); |
1322 |
> |
|
1323 |
> |
assert(aclass->curr_user_count > 0); |
1324 |
|
|
1325 |
|
if (conf->type == CLIENT_TYPE) |
1326 |
|
remove_from_cidr_check(&client_p->localClient->ip, aclass); |
1327 |
< |
|
1337 |
< |
if (CurrUserCount(aclass) > 0) |
1338 |
< |
aclass->curr_user_count--; |
1339 |
< |
if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0) |
1327 |
> |
if (--aclass->curr_user_count == 0 && aclass->active == 0) |
1328 |
|
delete_conf_item(aclass_conf); |
1329 |
|
} |
1330 |
|
|
1331 |
< |
/* Please, no ioccc entries - Dianora */ |
1344 |
< |
if (aconf->clients > 0) |
1345 |
< |
--aconf->clients; |
1346 |
< |
if (aconf->clients == 0 && IsConfIllegal(aconf)) |
1331 |
> |
if (--aconf->clients == 0 && IsConfIllegal(aconf)) |
1332 |
|
delete_conf_item(conf); |
1333 |
+ |
|
1334 |
|
break; |
1335 |
+ |
|
1336 |
|
case LEAF_TYPE: |
1337 |
|
case HUB_TYPE: |
1338 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
1338 |
> |
match_item = map_to_conf(conf); |
1339 |
|
if (match_item->ref_count == 0 && match_item->illegal) |
1340 |
|
delete_conf_item(conf); |
1341 |
|
break; |
1364 |
|
int |
1365 |
|
attach_conf(struct Client *client_p, struct ConfItem *conf) |
1366 |
|
{ |
1380 |
– |
struct AccessItem *aconf; |
1381 |
– |
struct MatchItem *match_item; |
1382 |
– |
|
1367 |
|
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
1368 |
|
return 1; |
1369 |
|
|
1371 |
|
conf->type == SERVER_TYPE || |
1372 |
|
conf->type == OPER_TYPE) |
1373 |
|
{ |
1374 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1374 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
1375 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1376 |
|
|
1377 |
|
if (IsConfIllegal(aconf)) |
1378 |
|
return NOT_AUTHORIZED; |
1379 |
|
|
1380 |
|
if (conf->type == CLIENT_TYPE) |
1396 |
– |
{ |
1397 |
– |
struct ClassItem *aclass; |
1398 |
– |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
1399 |
– |
|
1381 |
|
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1382 |
|
&client_p->localClient->ip, aclass)) |
1383 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1403 |
< |
|
1404 |
< |
CurrUserCount(aclass)++; |
1405 |
< |
} |
1383 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1384 |
|
|
1385 |
+ |
CurrUserCount(aclass)++; |
1386 |
|
aconf->clients++; |
1387 |
|
} |
1388 |
|
else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE) |
1389 |
|
{ |
1390 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
1390 |
> |
struct MatchItem *match_item = map_to_conf(conf); |
1391 |
|
match_item->ref_count++; |
1392 |
|
} |
1393 |
|
|
1421 |
|
DLINK_FOREACH(ptr, server_items.head) |
1422 |
|
{ |
1423 |
|
conf = ptr->data; |
1424 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1424 |
> |
aconf = map_to_conf(conf); |
1425 |
|
|
1426 |
|
if (match(conf->name, name) == 0 || match(aconf->host, host) == 0) |
1427 |
|
continue; |
1461 |
|
|
1462 |
|
if (conf->name == NULL) |
1463 |
|
continue; |
1464 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1464 |
> |
aconf = map_to_conf(conf); |
1465 |
|
if (aconf->host == NULL) |
1466 |
|
continue; |
1467 |
|
if (irccmp(conf->name, name) != 0) |
1472 |
|
** socket host) matches *either* host or name field |
1473 |
|
** of the configuration. |
1474 |
|
*/ |
1475 |
< |
if (!match(aconf->host, host) || !match(aconf->user,user) |
1497 |
< |
|| irccmp(conf->name, name) ) |
1475 |
> |
if (!match(aconf->host, host) || !match(aconf->user, user)) |
1476 |
|
continue; |
1477 |
|
if (type == OPER_TYPE) |
1478 |
|
{ |
1479 |
< |
struct ClassItem *aclass; |
1479 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1480 |
|
|
1481 |
< |
aclass = (struct ClassItem *)aconf->class_ptr; |
1504 |
< |
if (aconf->clients < MaxTotal(aclass)) |
1505 |
< |
return conf; |
1506 |
< |
else |
1481 |
> |
if (aconf->clients >= MaxTotal(aclass)) |
1482 |
|
continue; |
1483 |
|
} |
1484 |
< |
else |
1485 |
< |
return conf; |
1484 |
> |
|
1485 |
> |
return conf; |
1486 |
|
} |
1487 |
+ |
|
1488 |
|
return NULL; |
1489 |
|
} |
1490 |
|
|
1550 |
|
case SERVER_TYPE: |
1551 |
|
return(&server_items); |
1552 |
|
break; |
1553 |
+ |
case SERVICE_TYPE: |
1554 |
+ |
return(&service_items); |
1555 |
+ |
break; |
1556 |
|
case CLUSTER_TYPE: |
1557 |
|
return(&cluster_items); |
1558 |
|
break; |
1588 |
|
|
1589 |
|
switch (type) |
1590 |
|
{ |
1591 |
< |
case RXLINE_TYPE: |
1591 |
> |
#ifdef HAVE_LIBPCRE |
1592 |
> |
case RXLINE_TYPE: |
1593 |
|
DLINK_FOREACH(ptr, list_p->head) |
1594 |
|
{ |
1595 |
|
conf = ptr->data; |
1599 |
|
return conf; |
1600 |
|
} |
1601 |
|
break; |
1602 |
+ |
#endif |
1603 |
+ |
case SERVICE_TYPE: |
1604 |
+ |
DLINK_FOREACH(ptr, list_p->head) |
1605 |
+ |
{ |
1606 |
+ |
conf = ptr->data; |
1607 |
+ |
|
1608 |
+ |
if (EmptyString(conf->name)) |
1609 |
+ |
continue; |
1610 |
+ |
if ((name != NULL) && !irccmp(name, conf->name)) |
1611 |
+ |
return conf; |
1612 |
+ |
} |
1613 |
+ |
break; |
1614 |
|
|
1615 |
|
case XLINE_TYPE: |
1616 |
|
case ULINE_TYPE: |
1665 |
|
* side effects - looks for an exact match on name field |
1666 |
|
*/ |
1667 |
|
struct ConfItem * |
1668 |
< |
find_exact_name_conf(ConfType type, const char *name, |
1668 |
> |
find_exact_name_conf(ConfType type, const struct Client *who, const char *name, |
1669 |
|
const char *user, const char *host) |
1670 |
|
{ |
1671 |
|
dlink_node *ptr = NULL; |
1706 |
|
DLINK_FOREACH(ptr, list_p->head) |
1707 |
|
{ |
1708 |
|
conf = ptr->data; |
1709 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1709 |
> |
aconf = map_to_conf(conf); |
1710 |
> |
|
1711 |
|
if (EmptyString(conf->name)) |
1712 |
< |
continue; |
1713 |
< |
|
1714 |
< |
if (irccmp(conf->name, name) == 0) |
1712 |
> |
continue; |
1713 |
> |
|
1714 |
> |
if (!irccmp(conf->name, name)) |
1715 |
|
{ |
1716 |
< |
if ((user == NULL && (host == NULL))) |
1717 |
< |
return (conf); |
1718 |
< |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
1719 |
< |
return (conf); |
1720 |
< |
if (match(aconf->user, user) && match(aconf->host, host)) |
1721 |
< |
return (conf); |
1716 |
> |
if (!who) |
1717 |
> |
return conf; |
1718 |
> |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
1719 |
> |
return conf; |
1720 |
> |
if (match(aconf->user, who->username)) |
1721 |
> |
{ |
1722 |
> |
switch (aconf->type) |
1723 |
> |
{ |
1724 |
> |
case HM_HOST: |
1725 |
> |
if (match(aconf->host, who->host) || match(aconf->host, who->sockhost)) |
1726 |
> |
return conf; |
1727 |
> |
break; |
1728 |
> |
case HM_IPV4: |
1729 |
> |
if (who->localClient->aftype == AF_INET) |
1730 |
> |
if (match_ipv4(&who->localClient->ip, &aconf->ipnum, aconf->bits)) |
1731 |
> |
return conf; |
1732 |
> |
break; |
1733 |
> |
#ifdef IPV6 |
1734 |
> |
case HM_IPV6: |
1735 |
> |
if (who->localClient->aftype == AF_INET6) |
1736 |
> |
if (match_ipv6(&who->localClient->ip, &aconf->ipnum, aconf->bits)) |
1737 |
> |
return conf; |
1738 |
> |
break; |
1739 |
> |
#endif |
1740 |
> |
default: |
1741 |
> |
assert(0); |
1742 |
> |
} |
1743 |
> |
} |
1744 |
|
} |
1745 |
|
} |
1746 |
+ |
|
1747 |
|
break; |
1748 |
|
|
1749 |
|
case SERVER_TYPE: |
1799 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
1800 |
|
"Got signal SIGHUP, reloading ircd.conf file"); |
1801 |
|
|
1786 |
– |
#ifndef _WIN32 |
1802 |
|
restart_resolver(); |
1803 |
< |
#endif |
1803 |
> |
|
1804 |
|
/* don't close listeners until we know we can go ahead with the rehash */ |
1805 |
|
|
1806 |
|
/* Check to see if we magically got(or lost) IPv6 support */ |
1811 |
|
if (ServerInfo.description != NULL) |
1812 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
1813 |
|
|
1799 |
– |
#ifndef STATIC_MODULES |
1814 |
|
load_conf_modules(); |
1801 |
– |
#endif |
1815 |
|
|
1816 |
|
flush_deleted_I_P(); |
1817 |
|
|
1818 |
|
rehashed_klines = 1; |
1819 |
< |
|
1819 |
> |
/* XXX */ |
1820 |
|
if (ConfigLoggingEntry.use_logging) |
1821 |
< |
reopen_log(logFileName); |
1821 |
> |
log_close_all(); |
1822 |
|
|
1823 |
|
return(0); |
1824 |
|
} |
1857 |
|
ServerInfo.specific_ipv6_vhost = 0; |
1858 |
|
|
1859 |
|
ServerInfo.max_clients = MAXCLIENTS_MAX; |
1860 |
< |
/* Don't reset hub, as that will break lazylinks */ |
1861 |
< |
/* ServerInfo.hub = NO; */ |
1860 |
> |
|
1861 |
> |
ServerInfo.hub = 0; |
1862 |
|
ServerInfo.dns_host.sin_addr.s_addr = 0; |
1863 |
|
ServerInfo.dns_host.sin_port = 0; |
1864 |
|
AdminInfo.name = NULL; |
1865 |
|
AdminInfo.email = NULL; |
1866 |
|
AdminInfo.description = NULL; |
1867 |
|
|
1868 |
< |
set_log_level(L_NOTICE); |
1868 |
> |
log_close_all(); |
1869 |
> |
|
1870 |
|
ConfigLoggingEntry.use_logging = 1; |
1871 |
< |
ConfigLoggingEntry.operlog[0] = '\0'; |
1872 |
< |
ConfigLoggingEntry.userlog[0] = '\0'; |
1873 |
< |
ConfigLoggingEntry.klinelog[0] = '\0'; |
1874 |
< |
ConfigLoggingEntry.glinelog[0] = '\0'; |
1875 |
< |
ConfigLoggingEntry.killlog[0] = '\0'; |
1876 |
< |
ConfigLoggingEntry.operspylog[0] = '\0'; |
1877 |
< |
ConfigLoggingEntry.ioerrlog[0] = '\0'; |
1864 |
< |
ConfigLoggingEntry.failed_operlog[0] = '\0'; |
1865 |
< |
|
1866 |
< |
ConfigChannel.restrict_channels = NO; |
1867 |
< |
ConfigChannel.disable_local_channels = NO; |
1868 |
< |
ConfigChannel.use_invex = YES; |
1869 |
< |
ConfigChannel.use_except = YES; |
1870 |
< |
ConfigChannel.use_knock = YES; |
1871 |
> |
|
1872 |
> |
ConfigChannel.disable_fake_channels = 0; |
1873 |
> |
ConfigChannel.restrict_channels = 0; |
1874 |
> |
ConfigChannel.disable_local_channels = 0; |
1875 |
> |
ConfigChannel.use_invex = 1; |
1876 |
> |
ConfigChannel.use_except = 1; |
1877 |
> |
ConfigChannel.use_knock = 1; |
1878 |
|
ConfigChannel.knock_delay = 300; |
1879 |
|
ConfigChannel.knock_delay_channel = 60; |
1880 |
|
ConfigChannel.max_chans_per_user = 15; |
1881 |
< |
ConfigChannel.quiet_on_ban = YES; |
1881 |
> |
ConfigChannel.quiet_on_ban = 1; |
1882 |
|
ConfigChannel.max_bans = 25; |
1883 |
|
ConfigChannel.default_split_user_count = 0; |
1884 |
|
ConfigChannel.default_split_server_count = 0; |
1885 |
< |
ConfigChannel.no_join_on_split = NO; |
1886 |
< |
ConfigChannel.no_create_on_split = NO; |
1887 |
< |
ConfigChannel.burst_topicwho = YES; |
1885 |
> |
ConfigChannel.no_join_on_split = 0; |
1886 |
> |
ConfigChannel.no_create_on_split = 0; |
1887 |
> |
ConfigChannel.burst_topicwho = 1; |
1888 |
|
|
1889 |
< |
ConfigServerHide.flatten_links = NO; |
1889 |
> |
ConfigServerHide.flatten_links = 0; |
1890 |
|
ConfigServerHide.links_delay = 300; |
1891 |
< |
ConfigServerHide.hidden = NO; |
1892 |
< |
ConfigServerHide.disable_hidden = NO; |
1893 |
< |
ConfigServerHide.hide_servers = NO; |
1891 |
> |
ConfigServerHide.hidden = 0; |
1892 |
> |
ConfigServerHide.disable_hidden = 0; |
1893 |
> |
ConfigServerHide.hide_servers = 0; |
1894 |
|
DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT); |
1895 |
< |
ConfigServerHide.hide_server_ips = NO; |
1895 |
> |
ConfigServerHide.hide_server_ips = 0; |
1896 |
|
|
1897 |
+ |
|
1898 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1899 |
+ |
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1900 |
|
ConfigFileEntry.gline_min_cidr = 16; |
1901 |
|
ConfigFileEntry.gline_min_cidr6 = 48; |
1902 |
< |
ConfigFileEntry.invisible_on_connect = YES; |
1903 |
< |
ConfigFileEntry.burst_away = NO; |
1904 |
< |
ConfigFileEntry.use_whois_actually = YES; |
1905 |
< |
ConfigFileEntry.tkline_expire_notices = YES; |
1906 |
< |
ConfigFileEntry.hide_spoof_ips = YES; |
1907 |
< |
ConfigFileEntry.ignore_bogus_ts = NO; |
1908 |
< |
ConfigFileEntry.disable_auth = NO; |
1909 |
< |
ConfigFileEntry.disable_remote = NO; |
1902 |
> |
ConfigFileEntry.invisible_on_connect = 1; |
1903 |
> |
ConfigFileEntry.burst_away = 0; |
1904 |
> |
ConfigFileEntry.use_whois_actually = 1; |
1905 |
> |
ConfigFileEntry.tkline_expire_notices = 1; |
1906 |
> |
ConfigFileEntry.hide_spoof_ips = 1; |
1907 |
> |
ConfigFileEntry.ignore_bogus_ts = 0; |
1908 |
> |
ConfigFileEntry.disable_auth = 0; |
1909 |
> |
ConfigFileEntry.disable_remote = 0; |
1910 |
|
ConfigFileEntry.kill_chase_time_limit = 90; |
1911 |
< |
ConfigFileEntry.default_floodcount = 8; /* XXX */ |
1912 |
< |
ConfigFileEntry.failed_oper_notice = YES; |
1913 |
< |
ConfigFileEntry.dots_in_ident = 0; /* XXX */ |
1904 |
< |
ConfigFileEntry.dot_in_ip6_addr = YES; |
1911 |
> |
ConfigFileEntry.default_floodcount = 8; |
1912 |
> |
ConfigFileEntry.failed_oper_notice = 1; |
1913 |
> |
ConfigFileEntry.dots_in_ident = 0; |
1914 |
|
ConfigFileEntry.min_nonwildcard = 4; |
1915 |
|
ConfigFileEntry.min_nonwildcard_simple = 3; |
1916 |
|
ConfigFileEntry.max_accept = 20; |
1917 |
< |
ConfigFileEntry.anti_nick_flood = NO; /* XXX */ |
1917 |
> |
ConfigFileEntry.anti_nick_flood = 0; |
1918 |
|
ConfigFileEntry.max_nick_time = 20; |
1919 |
|
ConfigFileEntry.max_nick_changes = 5; |
1920 |
< |
ConfigFileEntry.anti_spam_exit_message_time = 0; /* XXX */ |
1920 |
> |
ConfigFileEntry.anti_spam_exit_message_time = 0; |
1921 |
|
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1922 |
< |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; /* XXX */ |
1923 |
< |
ConfigFileEntry.kline_with_reason = YES; |
1922 |
> |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1923 |
> |
ConfigFileEntry.kline_with_reason = 1; |
1924 |
|
ConfigFileEntry.kline_reason = NULL; |
1925 |
< |
ConfigFileEntry.warn_no_nline = YES; |
1926 |
< |
ConfigFileEntry.stats_o_oper_only = NO; /* XXX */ |
1925 |
> |
ConfigFileEntry.warn_no_nline = 1; |
1926 |
> |
ConfigFileEntry.stats_o_oper_only = 0; |
1927 |
|
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
1928 |
|
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
1929 |
< |
ConfigFileEntry.stats_P_oper_only = NO; |
1929 |
> |
ConfigFileEntry.stats_P_oper_only = 0; |
1930 |
|
ConfigFileEntry.caller_id_wait = 60; |
1931 |
< |
ConfigFileEntry.opers_bypass_callerid = NO; |
1931 |
> |
ConfigFileEntry.opers_bypass_callerid = 0; |
1932 |
|
ConfigFileEntry.pace_wait = 10; |
1933 |
|
ConfigFileEntry.pace_wait_simple = 1; |
1934 |
< |
ConfigFileEntry.short_motd = NO; |
1935 |
< |
ConfigFileEntry.ping_cookie = NO; |
1936 |
< |
ConfigFileEntry.no_oper_flood = NO; /* XXX */ |
1937 |
< |
ConfigFileEntry.true_no_oper_flood = NO; /* XXX */ |
1938 |
< |
ConfigFileEntry.oper_pass_resv = YES; |
1939 |
< |
ConfigFileEntry.glines = NO; /* XXX */ |
1940 |
< |
ConfigFileEntry.gline_time = 12 * 3600; /* XXX */ |
1932 |
< |
ConfigFileEntry.idletime = 0; |
1934 |
> |
ConfigFileEntry.short_motd = 0; |
1935 |
> |
ConfigFileEntry.ping_cookie = 0; |
1936 |
> |
ConfigFileEntry.no_oper_flood = 0; |
1937 |
> |
ConfigFileEntry.true_no_oper_flood = 0; |
1938 |
> |
ConfigFileEntry.oper_pass_resv = 1; |
1939 |
> |
ConfigFileEntry.glines = 0; |
1940 |
> |
ConfigFileEntry.gline_time = 12 * 3600; |
1941 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1942 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT; |
1943 |
< |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; /* XXX */ |
1943 |
> |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
1944 |
|
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1945 |
< |
UMODE_OPERWALL | UMODE_WALLOP; /* XXX */ |
1946 |
< |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1939 |
< |
#ifdef HAVE_LIBCRYPTO |
1940 |
< |
/* jdc -- This is our default value for a cipher. According to the |
1941 |
< |
* CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported |
1942 |
< |
* under all circumstances if cryptlinks are enabled. So, |
1943 |
< |
* this will be our default. |
1944 |
< |
* |
1945 |
< |
* NOTE: I apologise for the hard-coded value of "1" (BF/128). |
1946 |
< |
* This should be moved into a find_cipher() routine. |
1947 |
< |
*/ |
1948 |
< |
ConfigFileEntry.default_cipher_preference = &CipherTable[1]; |
1949 |
< |
#endif |
1950 |
< |
ConfigFileEntry.use_egd = NO; |
1945 |
> |
UMODE_OPERWALL | UMODE_WALLOP; |
1946 |
> |
ConfigFileEntry.use_egd = 0; |
1947 |
|
ConfigFileEntry.egdpool_path = NULL; |
1952 |
– |
#ifdef HAVE_LIBZ |
1953 |
– |
ConfigFileEntry.compression_level = 0; |
1954 |
– |
#endif |
1948 |
|
ConfigFileEntry.throttle_time = 10; |
1949 |
|
} |
1950 |
|
|
1958 |
– |
/* read_conf() |
1959 |
– |
* |
1960 |
– |
* inputs - file descriptor pointing to config file to use |
1961 |
– |
* output - None |
1962 |
– |
* side effects - Read configuration file. |
1963 |
– |
*/ |
1964 |
– |
static void |
1965 |
– |
read_conf(FBFILE *file) |
1966 |
– |
{ |
1967 |
– |
scount = lineno = 0; |
1968 |
– |
|
1969 |
– |
set_default_conf(); /* Set default values prior to conf parsing */ |
1970 |
– |
ypass = 1; |
1971 |
– |
yyparse(); /* pick up the classes first */ |
1972 |
– |
|
1973 |
– |
fbrewind(file); |
1974 |
– |
|
1975 |
– |
ypass = 2; |
1976 |
– |
yyparse(); /* Load the values from the conf */ |
1977 |
– |
validate_conf(); /* Check to make sure some values are still okay. */ |
1978 |
– |
/* Some global values are also loaded here. */ |
1979 |
– |
check_class(); /* Make sure classes are valid */ |
1980 |
– |
} |
1981 |
– |
|
1951 |
|
static void |
1952 |
|
validate_conf(void) |
1953 |
|
{ |
1957 |
|
if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN) |
1958 |
|
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1959 |
|
|
1991 |
– |
if (ConfigFileEntry.servlink_path == NULL) |
1992 |
– |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1993 |
– |
|
1960 |
|
if (ServerInfo.network_name == NULL) |
1961 |
|
DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT); |
1962 |
|
|
1963 |
|
if (ServerInfo.network_desc == NULL) |
1964 |
|
DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT); |
1965 |
|
|
1966 |
+ |
if (ConfigFileEntry.service_name == NULL) |
1967 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1968 |
+ |
|
1969 |
|
if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) || |
1970 |
|
(ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX)) |
1971 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX; |
1972 |
+ |
|
1973 |
+ |
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
1974 |
+ |
} |
1975 |
+ |
|
1976 |
+ |
/* read_conf() |
1977 |
+ |
* |
1978 |
+ |
* inputs - file descriptor pointing to config file to use |
1979 |
+ |
* output - None |
1980 |
+ |
* side effects - Read configuration file. |
1981 |
+ |
*/ |
1982 |
+ |
static void |
1983 |
+ |
read_conf(FILE *file) |
1984 |
+ |
{ |
1985 |
+ |
lineno = 0; |
1986 |
+ |
|
1987 |
+ |
set_default_conf(); /* Set default values prior to conf parsing */ |
1988 |
+ |
conf_parser_ctx.pass = 1; |
1989 |
+ |
yyparse(); /* pick up the classes first */ |
1990 |
+ |
|
1991 |
+ |
rewind(file); |
1992 |
+ |
|
1993 |
+ |
conf_parser_ctx.pass = 2; |
1994 |
+ |
yyparse(); /* Load the values from the conf */ |
1995 |
+ |
validate_conf(); /* Check to make sure some values are still okay. */ |
1996 |
+ |
/* Some global values are also loaded here. */ |
1997 |
+ |
check_class(); /* Make sure classes are valid */ |
1998 |
|
} |
1999 |
|
|
2000 |
|
/* lookup_confhost() |
2013 |
|
if (EmptyString(aconf->host) || |
2014 |
|
EmptyString(aconf->user)) |
2015 |
|
{ |
2016 |
< |
ilog(L_ERROR, "Host/server name error: (%s) (%s)", |
2016 |
> |
ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)", |
2017 |
|
aconf->host, conf->name); |
2018 |
|
return; |
2019 |
|
} |
2033 |
|
/* Get us ready for a bind() and don't bother doing dns lookup */ |
2034 |
|
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; |
2035 |
|
|
2036 |
< |
if (irc_getaddrinfo(aconf->host, NULL, &hints, &res)) |
2036 |
> |
if (getaddrinfo(aconf->host, NULL, &hints, &res)) |
2037 |
|
{ |
2038 |
|
conf_dns_lookup(aconf); |
2039 |
|
return; |
2044 |
|
memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen); |
2045 |
|
aconf->ipnum.ss_len = res->ai_addrlen; |
2046 |
|
aconf->ipnum.ss.ss_family = res->ai_family; |
2047 |
< |
irc_freeaddrinfo(res); |
2047 |
> |
freeaddrinfo(res); |
2048 |
|
} |
2049 |
|
|
2050 |
|
/* conf_connect_allowed() |
2083 |
|
static struct AccessItem * |
2084 |
|
find_regexp_kline(const char *uhi[]) |
2085 |
|
{ |
2086 |
+ |
#ifdef HAVE_LIBPCRE |
2087 |
|
const dlink_node *ptr = NULL; |
2088 |
|
|
2089 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
2098 |
|
!ircd_pcre_exec(aptr->regexhost, uhi[2]))) |
2099 |
|
return aptr; |
2100 |
|
} |
2101 |
< |
|
2101 |
> |
#endif |
2102 |
|
return NULL; |
2103 |
|
} |
2104 |
|
|
2327 |
|
if (ConfigFileEntry.tkline_expire_notices) |
2328 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2329 |
|
"Temporary RESV for [%s] expired", cconf->name); |
2330 |
< |
dlinkDelete(ptr, tklist); |
2335 |
< |
free_dlink_node(ptr); |
2336 |
< |
delete_conf_item(conf); |
2330 |
> |
delete_channel_resv(cconf); |
2331 |
|
} |
2332 |
|
} |
2333 |
|
} |
2342 |
|
static const struct oper_privs |
2343 |
|
{ |
2344 |
|
const unsigned int oprivs; |
2351 |
– |
const unsigned int hidden; |
2345 |
|
const unsigned char c; |
2346 |
|
} flag_list[] = { |
2347 |
< |
{ OPER_FLAG_ADMIN, OPER_FLAG_HIDDEN_ADMIN, 'A' }, |
2348 |
< |
{ OPER_FLAG_REMOTEBAN, 0, 'B' }, |
2349 |
< |
{ OPER_FLAG_DIE, 0, 'D' }, |
2350 |
< |
{ OPER_FLAG_GLINE, 0, 'G' }, |
2351 |
< |
{ OPER_FLAG_REHASH, 0, 'H' }, |
2352 |
< |
{ OPER_FLAG_K, 0, 'K' }, |
2353 |
< |
{ OPER_FLAG_OPERWALL, 0, 'L' }, |
2354 |
< |
{ OPER_FLAG_N, 0, 'N' }, |
2355 |
< |
{ OPER_FLAG_GLOBAL_KILL, 0, 'O' }, |
2356 |
< |
{ OPER_FLAG_REMOTE, 0, 'R' }, |
2357 |
< |
{ OPER_FLAG_OPER_SPY, 0, 'S' }, |
2358 |
< |
{ OPER_FLAG_UNKLINE, 0, 'U' }, |
2359 |
< |
{ OPER_FLAG_X, 0, 'X' }, |
2360 |
< |
{ 0, 0, '\0' } |
2347 |
> |
{ OPER_FLAG_ADMIN, 'A' }, |
2348 |
> |
{ OPER_FLAG_REMOTEBAN, 'B' }, |
2349 |
> |
{ OPER_FLAG_DIE, 'D' }, |
2350 |
> |
{ OPER_FLAG_GLINE, 'G' }, |
2351 |
> |
{ OPER_FLAG_REHASH, 'H' }, |
2352 |
> |
{ OPER_FLAG_K, 'K' }, |
2353 |
> |
{ OPER_FLAG_OPERWALL, 'L' }, |
2354 |
> |
{ OPER_FLAG_N, 'N' }, |
2355 |
> |
{ OPER_FLAG_GLOBAL_KILL, 'O' }, |
2356 |
> |
{ OPER_FLAG_REMOTE, 'R' }, |
2357 |
> |
{ OPER_FLAG_OPER_SPY, 'S' }, |
2358 |
> |
{ OPER_FLAG_UNKLINE, 'U' }, |
2359 |
> |
{ OPER_FLAG_X, 'X' }, |
2360 |
> |
{ 0, '\0' } |
2361 |
|
}; |
2362 |
|
|
2363 |
|
char * |
2369 |
|
|
2370 |
|
for (; flag_list[i].oprivs; ++i) |
2371 |
|
{ |
2372 |
< |
if ((port & flag_list[i].oprivs) && |
2380 |
< |
(port & flag_list[i].hidden) == 0) |
2372 |
> |
if (port & flag_list[i].oprivs) |
2373 |
|
*privs_ptr++ = flag_list[i].c; |
2374 |
|
else |
2375 |
|
*privs_ptr++ = ToLowerTab[flag_list[i].c]; |
2386 |
|
* "oper" is server name for remote opers |
2387 |
|
* Side effects: None. |
2388 |
|
*/ |
2389 |
< |
char * |
2389 |
> |
const char * |
2390 |
|
get_oper_name(const struct Client *client_p) |
2391 |
|
{ |
2392 |
< |
dlink_node *cnode; |
2401 |
< |
struct ConfItem *conf; |
2402 |
< |
struct AccessItem *aconf; |
2403 |
< |
|
2392 |
> |
dlink_node *cnode = NULL; |
2393 |
|
/* +5 for !,@,{,} and null */ |
2394 |
< |
static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5]; |
2394 |
> |
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
2395 |
|
|
2396 |
|
if (MyConnect(client_p)) |
2397 |
|
{ |
2398 |
< |
DLINK_FOREACH(cnode, client_p->localClient->confs.head) |
2398 |
> |
if ((cnode = client_p->localClient->confs.head)) |
2399 |
|
{ |
2400 |
< |
conf = cnode->data; |
2401 |
< |
aconf = map_to_conf(conf); |
2400 |
> |
struct ConfItem *conf = cnode->data; |
2401 |
> |
const struct AccessItem *aconf = map_to_conf(conf); |
2402 |
|
|
2403 |
|
if (IsConfOperator(aconf)) |
2404 |
|
{ |
2405 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
2406 |
< |
client_p->username, client_p->host, |
2418 |
< |
conf->name); |
2405 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
2406 |
> |
client_p->username, client_p->host, conf->name); |
2407 |
|
return buffer; |
2408 |
|
} |
2409 |
|
} |
2414 |
|
assert(0); /* Oper without oper conf! */ |
2415 |
|
} |
2416 |
|
|
2417 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
2418 |
< |
client_p->username, client_p->host, client_p->servptr->name); |
2417 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
2418 |
> |
client_p->username, client_p->host, client_p->servptr->name); |
2419 |
|
return buffer; |
2420 |
|
} |
2421 |
|
|
2432 |
|
char chanmodes[32]; |
2433 |
|
char chanlimit[32]; |
2434 |
|
|
2435 |
+ |
conf_parser_ctx.boot = cold; |
2436 |
|
filename = get_conf_name(CONF_TYPE); |
2437 |
|
|
2438 |
|
/* We need to know the initial filename for the yyerror() to report |
2443 |
|
*/ |
2444 |
|
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
2445 |
|
|
2446 |
< |
if ((conf_fbfile_in = fbopen(filename, "r")) == NULL) |
2446 |
> |
if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL) |
2447 |
|
{ |
2448 |
|
if (cold) |
2449 |
|
{ |
2450 |
< |
ilog(L_CRIT, "Unable to read configuration file '%s': %s", |
2450 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
2451 |
|
filename, strerror(errno)); |
2452 |
|
exit(-1); |
2453 |
|
} |
2463 |
|
if (!cold) |
2464 |
|
clear_out_old_conf(); |
2465 |
|
|
2466 |
< |
read_conf(conf_fbfile_in); |
2467 |
< |
fbclose(conf_fbfile_in); |
2466 |
> |
read_conf(conf_parser_ctx.conf_file); |
2467 |
> |
fclose(conf_parser_ctx.conf_file); |
2468 |
|
|
2469 |
|
add_isupport("NETWORK", ServerInfo.network_name, -1); |
2470 |
< |
ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "", |
2471 |
< |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
2470 |
> |
snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d", |
2471 |
> |
ConfigChannel.use_except ? "e" : "", |
2472 |
> |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
2473 |
|
add_isupport("MAXLIST", chanmodes, -1); |
2474 |
|
add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets); |
2475 |
+ |
|
2476 |
|
if (ConfigChannel.disable_local_channels) |
2477 |
|
add_isupport("CHANTYPES", "#", -1); |
2478 |
|
else |
2479 |
|
add_isupport("CHANTYPES", "#&", -1); |
2480 |
< |
ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&", |
2481 |
< |
ConfigChannel.max_chans_per_user); |
2480 |
> |
|
2481 |
> |
snprintf(chanlimit, sizeof(chanlimit), "%s:%d", |
2482 |
> |
ConfigChannel.disable_local_channels ? "#" : "#&", |
2483 |
> |
ConfigChannel.max_chans_per_user); |
2484 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
2485 |
< |
ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "", |
2486 |
< |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst"); |
2485 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s%s%s", |
2486 |
> |
ConfigChannel.use_except ? "e" : "", |
2487 |
> |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS"); |
2488 |
|
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
2489 |
+ |
|
2490 |
|
if (ConfigChannel.use_except) |
2491 |
|
add_isupport("EXCEPTS", "e", -1); |
2492 |
|
if (ConfigChannel.use_invex) |
2499 |
|
*/ |
2500 |
|
rebuild_isupport_message_line(); |
2501 |
|
|
2502 |
< |
parse_conf_file(KLINE_TYPE, cold); |
2502 |
> |
#ifdef HAVE_LIBPCRE |
2503 |
|
parse_conf_file(RKLINE_TYPE, cold); |
2504 |
+ |
parse_conf_file(RXLINE_TYPE, cold); |
2505 |
+ |
#endif |
2506 |
+ |
parse_conf_file(KLINE_TYPE, cold); |
2507 |
|
parse_conf_file(DLINE_TYPE, cold); |
2508 |
|
parse_conf_file(XLINE_TYPE, cold); |
2511 |
– |
parse_conf_file(RXLINE_TYPE, cold); |
2509 |
|
parse_conf_file(NRESV_TYPE, cold); |
2510 |
|
parse_conf_file(CRESV_TYPE, cold); |
2511 |
|
} |
2519 |
|
static void |
2520 |
|
parse_conf_file(int type, int cold) |
2521 |
|
{ |
2522 |
< |
FBFILE *file = NULL; |
2522 |
> |
FILE *file = NULL; |
2523 |
|
const char *filename = get_conf_name(type); |
2524 |
|
|
2525 |
< |
if ((file = fbopen(filename, "r")) == NULL) |
2525 |
> |
if ((file = fopen(filename, "r")) == NULL) |
2526 |
|
{ |
2527 |
|
if (cold) |
2528 |
< |
ilog(L_ERROR, "Unable to read configuration file '%s': %s", |
2528 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
2529 |
|
filename, strerror(errno)); |
2530 |
|
else |
2531 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2535 |
|
else |
2536 |
|
{ |
2537 |
|
parse_csv_file(file, type); |
2538 |
< |
fbclose(file); |
2538 |
> |
fclose(file); |
2539 |
|
} |
2540 |
|
} |
2541 |
|
|
2556 |
|
dlink_list *free_items [] = { |
2557 |
|
&server_items, &oconf_items, &hub_items, &leaf_items, |
2558 |
|
&uconf_items, &xconf_items, &rxconf_items, &rkconf_items, |
2559 |
< |
&nresv_items, &cluster_items, &gdeny_items, NULL |
2559 |
> |
&nresv_items, &cluster_items, &gdeny_items, &service_items, NULL |
2560 |
|
}; |
2561 |
|
|
2562 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
2573 |
|
/* XXX This is less than pretty */ |
2574 |
|
if (conf->type == SERVER_TYPE) |
2575 |
|
{ |
2576 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2576 |
> |
aconf = map_to_conf(conf); |
2577 |
> |
|
2578 |
|
if (aconf->clients != 0) |
2579 |
|
{ |
2580 |
|
SetConfIllegal(aconf); |
2587 |
|
} |
2588 |
|
else if (conf->type == OPER_TYPE) |
2589 |
|
{ |
2590 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2590 |
> |
aconf = map_to_conf(conf); |
2591 |
> |
|
2592 |
|
if (aconf->clients != 0) |
2593 |
|
{ |
2594 |
|
SetConfIllegal(aconf); |
2601 |
|
} |
2602 |
|
else if (conf->type == CLIENT_TYPE) |
2603 |
|
{ |
2604 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2604 |
> |
aconf = map_to_conf(conf); |
2605 |
> |
|
2606 |
|
if (aconf->clients != 0) |
2607 |
|
{ |
2608 |
|
SetConfIllegal(aconf); |
2627 |
|
{ |
2628 |
|
if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE)) |
2629 |
|
{ |
2630 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
2631 |
< |
if ((match_item->ref_count <= 0)) |
2630 |
> |
match_item = map_to_conf(conf); |
2631 |
> |
if (match_item->ref_count <= 0) |
2632 |
|
delete_conf_item(conf); |
2633 |
|
else |
2634 |
|
{ |
2642 |
|
} |
2643 |
|
} |
2644 |
|
|
2645 |
< |
/* don't delete the class table, rather mark all entries |
2645 |
> |
/* |
2646 |
> |
* don't delete the class table, rather mark all entries |
2647 |
|
* for deletion. The table is cleaned up by check_class. - avalon |
2648 |
|
*/ |
2649 |
|
DLINK_FOREACH(ptr, class_items.head) |
2650 |
|
{ |
2651 |
< |
conf = ptr->data; |
2652 |
< |
cltmp = (struct ClassItem *)map_to_conf(conf); |
2651 |
> |
cltmp = map_to_conf(ptr->data); |
2652 |
> |
|
2653 |
|
if (ptr != class_items.tail) /* never mark the "default" class */ |
2654 |
< |
MaxTotal(cltmp) = -1; |
2654 |
> |
cltmp->active = 0; |
2655 |
|
} |
2656 |
|
|
2657 |
|
clear_out_address_conf(); |
2658 |
|
|
2659 |
|
/* clean out module paths */ |
2659 |
– |
#ifndef STATIC_MODULES |
2660 |
|
mod_clear_paths(); |
2661 |
– |
#endif |
2661 |
|
|
2662 |
|
/* clean out ServerInfo */ |
2663 |
|
MyFree(ServerInfo.description); |
2677 |
|
|
2678 |
|
MyFree(ServerInfo.rsa_private_key_file); |
2679 |
|
ServerInfo.rsa_private_key_file = NULL; |
2680 |
+ |
|
2681 |
+ |
if (ServerInfo.server_ctx) |
2682 |
+ |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2| |
2683 |
+ |
SSL_OP_NO_SSLv3| |
2684 |
+ |
SSL_OP_NO_TLSv1); |
2685 |
+ |
if (ServerInfo.client_ctx) |
2686 |
+ |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2| |
2687 |
+ |
SSL_OP_NO_SSLv3| |
2688 |
+ |
SSL_OP_NO_TLSv1); |
2689 |
|
#endif |
2690 |
|
|
2691 |
|
/* clean out old resvs from the conf */ |
2708 |
|
*/ |
2709 |
|
|
2710 |
|
/* clean out general */ |
2711 |
< |
MyFree(ConfigFileEntry.servlink_path); |
2712 |
< |
ConfigFileEntry.servlink_path = NULL; |
2713 |
< |
#ifdef HAVE_LIBCRYPTO |
2706 |
< |
ConfigFileEntry.default_cipher_preference = NULL; |
2707 |
< |
#endif /* HAVE_LIBCRYPTO */ |
2711 |
> |
MyFree(ConfigFileEntry.service_name); |
2712 |
> |
ConfigFileEntry.service_name = NULL; |
2713 |
> |
|
2714 |
|
delete_isupport("INVEX"); |
2715 |
|
delete_isupport("EXCEPTS"); |
2716 |
|
} |
2905 |
|
{ |
2906 |
|
struct ConfItem *conf; |
2907 |
|
|
2908 |
< |
if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL) |
2909 |
< |
return(conf); |
2908 |
> |
if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL) |
2909 |
> |
return conf; |
2910 |
|
|
2911 |
|
return class_default; |
2912 |
|
} |
2920 |
|
void |
2921 |
|
check_class(void) |
2922 |
|
{ |
2923 |
< |
dlink_node *ptr; |
2918 |
< |
dlink_node *next_ptr; |
2919 |
< |
struct ConfItem *conf; |
2920 |
< |
struct ClassItem *aclass; |
2923 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
2924 |
|
|
2925 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head) |
2926 |
|
{ |
2927 |
< |
conf = ptr->data; |
2925 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
2927 |
> |
struct ClassItem *aclass = map_to_conf(ptr->data); |
2928 |
|
|
2929 |
< |
if (MaxTotal(aclass) < 0) |
2929 |
> |
if (!aclass->active && !CurrUserCount(aclass)) |
2930 |
|
{ |
2931 |
|
destroy_cidr_class(aclass); |
2932 |
< |
if (CurrUserCount(aclass) > 0) |
2931 |
< |
dlinkDelete(&conf->node, &class_items); |
2932 |
< |
else |
2933 |
< |
delete_conf_item(conf); |
2932 |
> |
delete_conf_item(ptr->data); |
2933 |
|
} |
2934 |
|
} |
2935 |
|
} |
2946 |
|
struct ClassItem *aclass; |
2947 |
|
|
2948 |
|
class_default = make_conf_item(CLASS_TYPE); |
2949 |
< |
aclass = (struct ClassItem *)map_to_conf(class_default); |
2949 |
> |
|
2950 |
> |
aclass = map_to_conf(class_default); |
2951 |
> |
aclass->active = 1; |
2952 |
|
DupString(class_default->name, "default"); |
2953 |
|
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
2954 |
|
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
2964 |
|
* output - sendq for this client as found from its class |
2965 |
|
* side effects - NONE |
2966 |
|
*/ |
2967 |
< |
unsigned long |
2967 |
> |
unsigned int |
2968 |
|
get_sendq(struct Client *client_p) |
2969 |
|
{ |
2970 |
< |
unsigned long sendq = DEFAULT_SENDQ; |
2970 |
> |
unsigned int sendq = DEFAULT_SENDQ; |
2971 |
|
dlink_node *ptr; |
2972 |
|
struct ConfItem *conf; |
2973 |
|
struct ConfItem *class_conf; |
3007 |
|
void |
3008 |
|
conf_add_class_to_conf(struct ConfItem *conf, const char *class_name) |
3009 |
|
{ |
3010 |
< |
struct AccessItem *aconf; |
3011 |
< |
struct ClassItem *aclass; |
3011 |
< |
|
3012 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
3010 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
3011 |
> |
struct ClassItem *class = NULL; |
3012 |
|
|
3013 |
|
if (class_name == NULL) |
3014 |
|
{ |
3015 |
|
aconf->class_ptr = class_default; |
3016 |
+ |
|
3017 |
|
if (conf->type == CLIENT_TYPE) |
3018 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
3019 |
|
"Warning *** Defaulting to default class for %s@%s", |
3024 |
|
conf->name); |
3025 |
|
} |
3026 |
|
else |
3027 |
– |
{ |
3027 |
|
aconf->class_ptr = find_class(class_name); |
3029 |
– |
} |
3028 |
|
|
3029 |
< |
if (aconf->class_ptr == NULL) |
3029 |
> |
if (aconf->class_ptr) |
3030 |
> |
class = map_to_conf(aconf->class_ptr); |
3031 |
> |
|
3032 |
> |
if (aconf->class_ptr == NULL || !class->active) |
3033 |
|
{ |
3034 |
|
if (conf->type == CLIENT_TYPE) |
3035 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
3041 |
|
conf->name); |
3042 |
|
aconf->class_ptr = class_default; |
3043 |
|
} |
3043 |
– |
else |
3044 |
– |
{ |
3045 |
– |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
3046 |
– |
if (MaxTotal(aclass) < 0) |
3047 |
– |
{ |
3048 |
– |
aconf->class_ptr = class_default; |
3049 |
– |
} |
3050 |
– |
} |
3044 |
|
} |
3045 |
|
|
3053 |
– |
#define MAXCONFLINKS 150 |
3054 |
– |
|
3046 |
|
/* conf_add_server() |
3047 |
|
* |
3048 |
|
* inputs - pointer to config item |
3051 |
|
* side effects - Add a connect block |
3052 |
|
*/ |
3053 |
|
int |
3054 |
< |
conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name) |
3054 |
> |
conf_add_server(struct ConfItem *conf, const char *class_name) |
3055 |
|
{ |
3056 |
|
struct AccessItem *aconf; |
3057 |
< |
char *orig_host; |
3057 |
> |
struct split_nuh_item nuh; |
3058 |
> |
char conf_user[USERLEN + 1]; |
3059 |
> |
char conf_host[HOSTLEN + 1]; |
3060 |
|
|
3061 |
|
aconf = map_to_conf(conf); |
3062 |
|
|
3063 |
|
conf_add_class_to_conf(conf, class_name); |
3064 |
|
|
3065 |
< |
if (lcount > MAXCONFLINKS || !aconf->host || !conf->name) |
3065 |
> |
if (!aconf->host || !conf->name) |
3066 |
|
{ |
3067 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block"); |
3068 |
< |
ilog(L_WARN, "Bad connect block"); |
3068 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block"); |
3069 |
|
return -1; |
3070 |
|
} |
3071 |
|
|
3072 |
< |
if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf)) |
3072 |
> |
if (EmptyString(aconf->passwd)) |
3073 |
|
{ |
3074 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s", |
3075 |
|
conf->name); |
3076 |
< |
ilog(L_WARN, "Bad connect block, host %s", conf->name); |
3076 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name); |
3077 |
|
return -1; |
3078 |
|
} |
3079 |
|
|
3080 |
< |
orig_host = aconf->host; |
3081 |
< |
split_nuh(orig_host, NULL, &aconf->user, &aconf->host); |
3082 |
< |
MyFree(orig_host); |
3080 |
> |
nuh.nuhmask = aconf->host; |
3081 |
> |
nuh.nickptr = NULL; |
3082 |
> |
nuh.userptr = conf_user; |
3083 |
> |
nuh.hostptr = conf_host; |
3084 |
> |
|
3085 |
> |
nuh.nicksize = 0; |
3086 |
> |
nuh.usersize = sizeof(conf_user); |
3087 |
> |
nuh.hostsize = sizeof(conf_host); |
3088 |
> |
|
3089 |
> |
split_nuh(&nuh); |
3090 |
> |
|
3091 |
> |
MyFree(aconf->host); |
3092 |
> |
aconf->host = NULL; |
3093 |
> |
|
3094 |
> |
DupString(aconf->user, conf_user); /* somehow username checking for servers |
3095 |
> |
got lost in H6/7, will have to be re-added */ |
3096 |
> |
DupString(aconf->host, conf_host); |
3097 |
> |
|
3098 |
|
lookup_confhost(conf); |
3099 |
|
|
3100 |
|
return 0; |
3101 |
|
} |
3102 |
|
|
3095 |
– |
/* conf_add_d_conf() |
3096 |
– |
* |
3097 |
– |
* inputs - pointer to config item |
3098 |
– |
* output - NONE |
3099 |
– |
* side effects - Add a d/D line |
3100 |
– |
*/ |
3101 |
– |
void |
3102 |
– |
conf_add_d_conf(struct AccessItem *aconf) |
3103 |
– |
{ |
3104 |
– |
if (aconf->host == NULL) |
3105 |
– |
return; |
3106 |
– |
|
3107 |
– |
aconf->user = NULL; |
3108 |
– |
|
3109 |
– |
/* XXX - Should 'd' ever be in the old conf? For new conf we don't |
3110 |
– |
* need this anyway, so I will disable it for now... -A1kmm |
3111 |
– |
*/ |
3112 |
– |
if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST) |
3113 |
– |
{ |
3114 |
– |
ilog(L_WARN, "Invalid Dline %s ignored", aconf->host); |
3115 |
– |
free_access_item(aconf); |
3116 |
– |
} |
3117 |
– |
else |
3118 |
– |
{ |
3119 |
– |
/* XXX ensure user is NULL */ |
3120 |
– |
MyFree(aconf->user); |
3121 |
– |
aconf->user = NULL; |
3122 |
– |
add_conf_by_address(CONF_DLINE, aconf); |
3123 |
– |
} |
3124 |
– |
} |
3125 |
– |
|
3103 |
|
/* yyerror() |
3104 |
|
* |
3105 |
|
* inputs - message from parser |
3111 |
|
{ |
3112 |
|
char newlinebuf[IRCD_BUFSIZE]; |
3113 |
|
|
3114 |
< |
if (ypass != 1) |
3114 |
> |
if (conf_parser_ctx.pass != 1) |
3115 |
|
return; |
3116 |
|
|
3117 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
3118 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s", |
3119 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
3120 |
< |
ilog(L_WARN, "\"%s\", line %u: %s: %s", |
3120 |
> |
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
3121 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
3122 |
|
} |
3123 |
|
|
3147 |
– |
int |
3148 |
– |
conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb) |
3149 |
– |
{ |
3150 |
– |
if (fbgets(lbuf, max_size, fb) == NULL) |
3151 |
– |
return 0; |
3152 |
– |
|
3153 |
– |
return strlen(lbuf); |
3154 |
– |
} |
3155 |
– |
|
3156 |
– |
int |
3157 |
– |
conf_yy_fatal_error(const char *msg) |
3158 |
– |
{ |
3159 |
– |
return 0; |
3160 |
– |
} |
3161 |
– |
|
3124 |
|
/* |
3125 |
|
* valid_tkline() |
3126 |
|
* |
3132 |
|
* Originally written by Dianora (Diane, db@db.net) |
3133 |
|
*/ |
3134 |
|
time_t |
3135 |
< |
valid_tkline(char *p, int minutes) |
3135 |
> |
valid_tkline(const char *p, int minutes) |
3136 |
|
{ |
3137 |
|
time_t result = 0; |
3138 |
|
|
3139 |
< |
while (*p) |
3139 |
> |
for (; *p; ++p) |
3140 |
|
{ |
3141 |
< |
if (IsDigit(*p)) |
3180 |
< |
{ |
3181 |
< |
result *= 10; |
3182 |
< |
result += ((*p) & 0xF); |
3183 |
< |
p++; |
3184 |
< |
} |
3185 |
< |
else |
3141 |
> |
if (!IsDigit(*p)) |
3142 |
|
return 0; |
3143 |
+ |
|
3144 |
+ |
result *= 10; |
3145 |
+ |
result += ((*p) & 0xF); |
3146 |
|
} |
3147 |
|
|
3148 |
< |
/* in the degenerate case where oper does a /quote kline 0 user@host :reason |
3148 |
> |
/* |
3149 |
> |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
3150 |
|
* i.e. they specifically use 0, I am going to return 1 instead |
3151 |
|
* as a return value of non-zero is used to flag it as a temporary kline |
3152 |
|
*/ |
3193 |
– |
|
3153 |
|
if (result == 0) |
3154 |
|
result = 1; |
3155 |
|
|
3250 |
|
* if target_server is NULL and an "ON" is found error |
3251 |
|
* is reported. |
3252 |
|
* if reason pointer is NULL ignore pointer, |
3253 |
< |
* this allows usee of parse_a_line in unkline etc. |
3253 |
> |
* this allows use of parse_a_line in unkline etc. |
3254 |
|
* |
3255 |
|
* - Dianora |
3256 |
|
*/ |
3320 |
|
return -1; |
3321 |
|
} |
3322 |
|
|
3323 |
< |
if (!IsOperRemoteBan(source_p)) |
3323 |
> |
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
3324 |
|
{ |
3325 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
3326 |
|
me.name, source_p->name, "remoteban"); |
3357 |
|
return -1; |
3358 |
|
} |
3359 |
|
|
3360 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p)) |
3360 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p)) |
3361 |
|
return -1; |
3362 |
|
} |
3363 |
|
else |
3364 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p)) |
3364 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p)) |
3365 |
|
return -1; |
3366 |
|
|
3367 |
|
if (reason != NULL) |
3368 |
|
{ |
3369 |
< |
if (parc != 0) |
3369 |
> |
if (parc != 0 && !EmptyString(*parv)) |
3370 |
|
{ |
3371 |
|
*reason = *parv; |
3372 |
< |
if (!valid_comment(source_p, *reason, YES)) |
3372 |
> |
if (!valid_comment(source_p, *reason, 1)) |
3373 |
|
return -1; |
3374 |
|
} |
3375 |
|
else |
3405 |
|
{ |
3406 |
|
/* Explicit user@host mask given */ |
3407 |
|
|
3408 |
< |
if(hostp != NULL) /* I'm a little user@host */ |
3408 |
> |
if (hostp != NULL) /* I'm a little user@host */ |
3409 |
|
{ |
3410 |
|
*(hostp++) = '\0'; /* short and squat */ |
3411 |
|
if (*user_host_or_nick) |
3528 |
|
* inputs - client sending the cluster |
3529 |
|
* - command name "KLINE" "XLINE" etc. |
3530 |
|
* - capab -- CAP_KLN etc. from s_serv.h |
3531 |
< |
* - cluster type -- CLUSTER_KLINE etc. from s_conf.h |
3531 |
> |
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
3532 |
|
* - pattern and args to send along |
3533 |
|
* output - none |
3534 |
|
* side effects - Take source_p send the pattern with args given |
3536 |
|
*/ |
3537 |
|
void |
3538 |
|
cluster_a_line(struct Client *source_p, const char *command, |
3539 |
< |
int capab, int cluster_type, const char *pattern, ...) |
3539 |
> |
int capab, int cluster_type, const char *pattern, ...) |
3540 |
|
{ |
3541 |
|
va_list args; |
3542 |
|
char buffer[IRCD_BUFSIZE]; |
3543 |
< |
struct ConfItem *conf; |
3585 |
< |
dlink_node *ptr; |
3543 |
> |
const dlink_node *ptr = NULL; |
3544 |
|
|
3545 |
|
va_start(args, pattern); |
3546 |
|
vsnprintf(buffer, sizeof(buffer), pattern, args); |
3548 |
|
|
3549 |
|
DLINK_FOREACH(ptr, cluster_items.head) |
3550 |
|
{ |
3551 |
< |
conf = ptr->data; |
3551 |
> |
const struct ConfItem *conf = ptr->data; |
3552 |
|
|
3553 |
|
if (conf->flags & cluster_type) |
3596 |
– |
{ |
3554 |
|
sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab, |
3555 |
|
"%s %s %s", command, conf->name, buffer); |
3599 |
– |
} |
3556 |
|
} |
3557 |
|
} |
3558 |
|
|
3584 |
|
* @ * * * |
3585 |
|
* ! * * * |
3586 |
|
*/ |
3631 |
– |
|
3587 |
|
void |
3588 |
< |
split_nuh(char *mask, char **nick, char **user, char **host) |
3588 |
> |
split_nuh(struct split_nuh_item *const iptr) |
3589 |
|
{ |
3590 |
|
char *p = NULL, *q = NULL; |
3591 |
|
|
3592 |
< |
if ((p = strchr(mask, '!')) != NULL) |
3592 |
> |
if (iptr->nickptr) |
3593 |
> |
strlcpy(iptr->nickptr, "*", iptr->nicksize); |
3594 |
> |
if (iptr->userptr) |
3595 |
> |
strlcpy(iptr->userptr, "*", iptr->usersize); |
3596 |
> |
if (iptr->hostptr) |
3597 |
> |
strlcpy(iptr->hostptr, "*", iptr->hostsize); |
3598 |
> |
|
3599 |
> |
if ((p = strchr(iptr->nuhmask, '!'))) |
3600 |
|
{ |
3601 |
|
*p = '\0'; |
3640 |
– |
if (nick != NULL) |
3641 |
– |
{ |
3642 |
– |
if (*mask != '\0') |
3643 |
– |
*nick = xstrldup(mask, NICKLEN); |
3644 |
– |
else |
3645 |
– |
DupString(*nick, "*"); |
3646 |
– |
} |
3602 |
|
|
3603 |
< |
if ((q = strchr(++p, '@')) != NULL) |
3604 |
< |
{ |
3605 |
< |
*q = '\0'; |
3603 |
> |
if (iptr->nickptr && *iptr->nuhmask != '\0') |
3604 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
3605 |
> |
|
3606 |
> |
if ((q = strchr(++p, '@'))) { |
3607 |
> |
*q++ = '\0'; |
3608 |
|
|
3609 |
|
if (*p != '\0') |
3610 |
< |
*user = xstrldup(p, USERLEN+1); |
3654 |
< |
else |
3655 |
< |
DupString(*user, "*"); |
3610 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
3611 |
|
|
3612 |
< |
if (*++q != '\0') |
3613 |
< |
*host = xstrldup(q, HOSTLEN+1); |
3659 |
< |
else |
3660 |
< |
DupString(*host, "*"); |
3612 |
> |
if (*q != '\0') |
3613 |
> |
strlcpy(iptr->hostptr, q, iptr->hostsize); |
3614 |
|
} |
3615 |
|
else |
3616 |
|
{ |
3617 |
|
if (*p != '\0') |
3618 |
< |
*user = xstrldup(p, USERLEN+1); |
3666 |
< |
else |
3667 |
< |
DupString(*user, "*"); |
3668 |
< |
|
3669 |
< |
DupString(*host, "*"); |
3618 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
3619 |
|
} |
3620 |
|
} |
3621 |
< |
else /* No ! found so lets look for a user@host */ |
3621 |
> |
else |
3622 |
|
{ |
3623 |
< |
if ((p = strchr(mask, '@')) != NULL) /* if found a @ */ |
3623 |
> |
/* No ! found so lets look for a user@host */ |
3624 |
> |
if ((p = strchr(iptr->nuhmask, '@'))) |
3625 |
|
{ |
3626 |
< |
if (nick != NULL) |
3627 |
< |
DupString(*nick, "*"); |
3678 |
< |
*p = '\0'; |
3626 |
> |
/* if found a @ */ |
3627 |
> |
*p++ = '\0'; |
3628 |
|
|
3629 |
< |
if (*mask != '\0') |
3630 |
< |
*user = xstrldup(mask, USERLEN+1); |
3682 |
< |
else |
3683 |
< |
DupString(*user, "*"); |
3629 |
> |
if (*iptr->nuhmask != '\0') |
3630 |
> |
strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize); |
3631 |
|
|
3632 |
< |
if (*++p != '\0') |
3633 |
< |
*host = xstrldup(p, HOSTLEN+1); |
3687 |
< |
else |
3688 |
< |
DupString(*host, "*"); |
3632 |
> |
if (*p != '\0') |
3633 |
> |
strlcpy(iptr->hostptr, p, iptr->hostsize); |
3634 |
|
} |
3635 |
< |
else /* no @ found */ |
3635 |
> |
else |
3636 |
|
{ |
3637 |
< |
if (nick != NULL) |
3638 |
< |
{ |
3639 |
< |
if (strpbrk(mask, ".:")) |
3695 |
< |
{ |
3696 |
< |
DupString(*nick, "*"); |
3697 |
< |
*host = xstrldup(mask, HOSTLEN+1); |
3698 |
< |
} |
3699 |
< |
else |
3700 |
< |
{ |
3701 |
< |
*nick = xstrldup(mask, NICKLEN); |
3702 |
< |
DupString(*host, "*"); |
3703 |
< |
} |
3704 |
< |
|
3705 |
< |
DupString(*user, "*"); |
3706 |
< |
} |
3637 |
> |
/* no @ found */ |
3638 |
> |
if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:")) |
3639 |
> |
strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize); |
3640 |
|
else |
3641 |
< |
{ |
3709 |
< |
DupString(*user, "*"); |
3710 |
< |
*host = xstrldup(mask, HOSTLEN+1); |
3711 |
< |
} |
3641 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
3642 |
|
} |
3643 |
|
} |
3644 |
|
} |
3665 |
|
{ |
3666 |
|
if (flags & mask) |
3667 |
|
*p++ = bit_table[i]; |
3668 |
< |
else if(lowerit) |
3668 |
> |
else if (lowerit) |
3669 |
|
*p++ = ToLower(bit_table[i]); |
3670 |
|
} |
3671 |
|
*p = '\0'; |
3872 |
|
static void |
3873 |
|
destroy_cidr_list(dlink_list *list) |
3874 |
|
{ |
3875 |
< |
dlink_node *ptr = NULL; |
3946 |
< |
dlink_node *next_ptr = NULL; |
3947 |
< |
struct CidrItem *cidr; |
3875 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
3876 |
|
|
3877 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) |
3878 |
|
{ |
3951 |
– |
cidr = ptr->data; |
3879 |
|
dlinkDelete(ptr, list); |
3880 |
< |
MyFree(cidr); |
3880 |
> |
MyFree(ptr->data); |
3881 |
|
} |
3882 |
|
} |
3883 |
|
|