23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
+ |
#include "list.h" |
27 |
|
#include "ircd_defs.h" |
28 |
< |
#include "tools.h" |
28 |
> |
#include "balloc.h" |
29 |
|
#include "s_conf.h" |
30 |
|
#include "s_serv.h" |
31 |
|
#include "resv.h" |
38 |
|
#include "irc_string.h" |
39 |
|
#include "sprintf_irc.h" |
40 |
|
#include "s_bsd.h" |
40 |
– |
#include "irc_getaddrinfo.h" |
41 |
|
#include "ircd.h" |
42 |
– |
#include "list.h" |
42 |
|
#include "listener.h" |
43 |
|
#include "hostmask.h" |
44 |
|
#include "modules.h" |
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 |
< |
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 *); |
115 |
|
|
116 |
|
static void flags_to_ascii(unsigned int, const unsigned int[], char *, int); |
117 |
|
|
117 |
– |
FBFILE *conf_fbfile_in = NULL; |
118 |
– |
|
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; |
174 |
< |
struct ConfItem *conf; |
172 |
> |
struct AccessItem *aconf = vptr; |
173 |
|
|
174 |
< |
MyFree(aconf->dns_query); |
177 |
< |
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", |
183 |
< |
aconf->host); |
184 |
< |
conf = unmap_conf_item(aconf); |
185 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
186 |
< |
"Ignoring connect{} block for %s - host not found", |
187 |
< |
conf->name); |
188 |
< |
delete_conf_item(conf); |
189 |
< |
} |
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; |
205 |
< |
aconf->dns_query->callback = conf_dns_callback; |
206 |
< |
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 = MyMalloc(sizeof(struct ConfItem) + |
333 |
|
sizeof(struct ClassItem)); |
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); |
401 |
– |
MyFree(aconf->fakename); |
392 |
|
#ifdef HAVE_LIBCRYPTO |
393 |
|
if (aconf->rsa_public_key) |
394 |
|
RSA_free(aconf->rsa_public_key); |
468 |
|
dlinkDelete(&conf->node, &xconf_items); |
469 |
|
MyFree(conf); |
470 |
|
break; |
471 |
< |
|
471 |
> |
#ifdef HAVE_LIBPCRE |
472 |
|
case RKLINE_TYPE: |
473 |
|
aconf = map_to_conf(conf); |
474 |
|
MyFree(aconf->regexuser); |
491 |
|
dlinkDelete(&conf->node, &rxconf_items); |
492 |
|
MyFree(conf); |
493 |
|
break; |
494 |
< |
|
494 |
> |
#endif |
495 |
|
case NRESV_TYPE: |
496 |
|
match_item = map_to_conf(conf); |
497 |
|
MyFree(match_item->user); |
533 |
|
MyFree(conf); |
534 |
|
break; |
535 |
|
|
536 |
+ |
case SERVICE_TYPE: |
537 |
+ |
dlinkDelete(&conf->node, &service_items); |
538 |
+ |
MyFree(conf); |
539 |
+ |
break; |
540 |
+ |
|
541 |
|
default: |
542 |
|
break; |
543 |
|
} |
623 |
|
} |
624 |
|
break; |
625 |
|
|
626 |
+ |
#ifdef HAVE_LIBPCRE |
627 |
|
case RXLINE_TYPE: |
628 |
|
DLINK_FOREACH(ptr, rxconf_items.head) |
629 |
|
{ |
652 |
|
aconf->reason, aconf->oper_reason ? aconf->oper_reason : ""); |
653 |
|
} |
654 |
|
break; |
655 |
+ |
#endif |
656 |
|
|
657 |
|
case ULINE_TYPE: |
658 |
|
DLINK_FOREACH(ptr, uconf_items.head) |
729 |
|
case CLIENT_TYPE: |
730 |
|
break; |
731 |
|
|
732 |
+ |
case SERVICE_TYPE: /* XXX TBD */ |
733 |
+ |
DLINK_FOREACH(ptr, service_items.head) |
734 |
+ |
{ |
735 |
+ |
conf = ptr->data; |
736 |
+ |
} |
737 |
+ |
break; |
738 |
+ |
|
739 |
|
case SERVER_TYPE: |
740 |
|
DLINK_FOREACH(ptr, server_items.head) |
741 |
|
{ |
750 |
|
*p++ = 'A'; |
751 |
|
if (IsConfCryptLink(aconf)) |
752 |
|
*p++ = 'C'; |
749 |
– |
if (aconf->fakename) |
750 |
– |
*p++ = 'M'; |
753 |
|
if (IsConfTopicBurst(aconf)) |
754 |
|
*p++ = 'T'; |
755 |
|
if (IsConfCompressed(aconf)) |
802 |
|
case CRESV_TYPE: |
803 |
|
case NRESV_TYPE: |
804 |
|
case CLUSTER_TYPE: |
805 |
+ |
default: |
806 |
|
break; |
807 |
|
} |
808 |
|
} |
1194 |
|
{ |
1195 |
|
struct sockaddr_in *v4 = (struct sockaddr_in *)addr; |
1196 |
|
int hash; |
1197 |
< |
u_int32_t ip; |
1197 |
> |
uint32_t ip; |
1198 |
|
|
1199 |
|
ip = ntohl(v4->sin_addr.s_addr); |
1200 |
|
hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1); |
1205 |
|
{ |
1206 |
|
int hash; |
1207 |
|
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr; |
1208 |
< |
u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr; |
1208 |
> |
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
1209 |
|
|
1210 |
|
hash = ip[0] ^ ip[3]; |
1211 |
|
hash ^= hash >> 16; |
1555 |
|
case SERVER_TYPE: |
1556 |
|
return(&server_items); |
1557 |
|
break; |
1558 |
+ |
case SERVICE_TYPE: |
1559 |
+ |
return(&service_items); |
1560 |
+ |
break; |
1561 |
|
case CLUSTER_TYPE: |
1562 |
|
return(&cluster_items); |
1563 |
|
break; |
1593 |
|
|
1594 |
|
switch (type) |
1595 |
|
{ |
1596 |
< |
case RXLINE_TYPE: |
1596 |
> |
#ifdef HAVE_LIBPCRE |
1597 |
> |
case RXLINE_TYPE: |
1598 |
|
DLINK_FOREACH(ptr, list_p->head) |
1599 |
|
{ |
1600 |
|
conf = ptr->data; |
1604 |
|
return conf; |
1605 |
|
} |
1606 |
|
break; |
1607 |
+ |
#endif |
1608 |
+ |
case SERVICE_TYPE: |
1609 |
+ |
DLINK_FOREACH(ptr, list_p->head) |
1610 |
+ |
{ |
1611 |
+ |
conf = ptr->data; |
1612 |
+ |
|
1613 |
+ |
if (EmptyString(conf->name)) |
1614 |
+ |
continue; |
1615 |
+ |
if ((name != NULL) && !irccmp(name, conf->name)) |
1616 |
+ |
return conf; |
1617 |
+ |
} |
1618 |
+ |
break; |
1619 |
|
|
1620 |
|
case XLINE_TYPE: |
1621 |
|
case ULINE_TYPE: |
1780 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
1781 |
|
"Got signal SIGHUP, reloading ircd.conf file"); |
1782 |
|
|
1764 |
– |
#ifndef _WIN32 |
1783 |
|
restart_resolver(); |
1784 |
< |
#endif |
1784 |
> |
|
1785 |
|
/* don't close listeners until we know we can go ahead with the rehash */ |
1786 |
|
|
1787 |
|
/* Check to see if we magically got(or lost) IPv6 support */ |
1792 |
|
if (ServerInfo.description != NULL) |
1793 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
1794 |
|
|
1777 |
– |
#ifndef STATIC_MODULES |
1795 |
|
load_conf_modules(); |
1779 |
– |
#endif |
1796 |
|
|
1797 |
|
flush_deleted_I_P(); |
1798 |
|
|
1838 |
|
ServerInfo.specific_ipv6_vhost = 0; |
1839 |
|
|
1840 |
|
ServerInfo.max_clients = MAXCLIENTS_MAX; |
1841 |
< |
/* Don't reset hub, as that will break lazylinks */ |
1842 |
< |
/* ServerInfo.hub = NO; */ |
1841 |
> |
|
1842 |
> |
ServerInfo.hub = 0; |
1843 |
|
ServerInfo.dns_host.sin_addr.s_addr = 0; |
1844 |
|
ServerInfo.dns_host.sin_port = 0; |
1845 |
|
AdminInfo.name = NULL; |
1883 |
|
ConfigServerHide.hide_server_ips = NO; |
1884 |
|
|
1885 |
|
|
1886 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1887 |
|
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1888 |
|
ConfigFileEntry.gline_min_cidr = 16; |
1889 |
|
ConfigFileEntry.gline_min_cidr6 = 48; |
1896 |
|
ConfigFileEntry.disable_auth = NO; |
1897 |
|
ConfigFileEntry.disable_remote = NO; |
1898 |
|
ConfigFileEntry.kill_chase_time_limit = 90; |
1899 |
< |
ConfigFileEntry.default_floodcount = 8; /* XXX */ |
1899 |
> |
ConfigFileEntry.default_floodcount = 8; |
1900 |
|
ConfigFileEntry.failed_oper_notice = YES; |
1901 |
< |
ConfigFileEntry.dots_in_ident = 0; /* XXX */ |
1885 |
< |
ConfigFileEntry.dot_in_ip6_addr = YES; |
1901 |
> |
ConfigFileEntry.dots_in_ident = 0; |
1902 |
|
ConfigFileEntry.min_nonwildcard = 4; |
1903 |
|
ConfigFileEntry.min_nonwildcard_simple = 3; |
1904 |
|
ConfigFileEntry.max_accept = 20; |
1905 |
< |
ConfigFileEntry.anti_nick_flood = NO; /* XXX */ |
1905 |
> |
ConfigFileEntry.anti_nick_flood = NO; |
1906 |
|
ConfigFileEntry.max_nick_time = 20; |
1907 |
|
ConfigFileEntry.max_nick_changes = 5; |
1908 |
< |
ConfigFileEntry.anti_spam_exit_message_time = 0; /* XXX */ |
1908 |
> |
ConfigFileEntry.anti_spam_exit_message_time = 0; |
1909 |
|
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1910 |
< |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; /* XXX */ |
1910 |
> |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1911 |
|
ConfigFileEntry.kline_with_reason = YES; |
1912 |
|
ConfigFileEntry.kline_reason = NULL; |
1913 |
|
ConfigFileEntry.warn_no_nline = YES; |
1914 |
< |
ConfigFileEntry.stats_o_oper_only = NO; /* XXX */ |
1914 |
> |
ConfigFileEntry.stats_o_oper_only = NO; |
1915 |
|
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
1916 |
|
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
1917 |
|
ConfigFileEntry.stats_P_oper_only = NO; |
1921 |
|
ConfigFileEntry.pace_wait_simple = 1; |
1922 |
|
ConfigFileEntry.short_motd = NO; |
1923 |
|
ConfigFileEntry.ping_cookie = NO; |
1924 |
< |
ConfigFileEntry.no_oper_flood = NO; /* XXX */ |
1925 |
< |
ConfigFileEntry.true_no_oper_flood = NO; /* XXX */ |
1924 |
> |
ConfigFileEntry.no_oper_flood = NO; |
1925 |
> |
ConfigFileEntry.true_no_oper_flood = NO; |
1926 |
|
ConfigFileEntry.oper_pass_resv = YES; |
1927 |
< |
ConfigFileEntry.glines = NO; /* XXX */ |
1928 |
< |
ConfigFileEntry.gline_time = 12 * 3600; /* XXX */ |
1927 |
> |
ConfigFileEntry.glines = NO; |
1928 |
> |
ConfigFileEntry.gline_time = 12 * 3600; |
1929 |
|
ConfigFileEntry.idletime = 0; |
1930 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1931 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT; |
1932 |
< |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; /* XXX */ |
1932 |
> |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
1933 |
|
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1934 |
< |
UMODE_OPERWALL | UMODE_WALLOP; /* XXX */ |
1934 |
> |
UMODE_OPERWALL | UMODE_WALLOP; |
1935 |
|
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1936 |
|
#ifdef HAVE_LIBCRYPTO |
1937 |
|
/* jdc -- This is our default value for a cipher. According to the |
1964 |
|
lineno = 0; |
1965 |
|
|
1966 |
|
set_default_conf(); /* Set default values prior to conf parsing */ |
1967 |
< |
ypass = 1; |
1967 |
> |
conf_parser_ctx.pass = 1; |
1968 |
|
yyparse(); /* pick up the classes first */ |
1969 |
|
|
1970 |
|
fbrewind(file); |
1971 |
|
|
1972 |
< |
ypass = 2; |
1972 |
> |
conf_parser_ctx.pass = 2; |
1973 |
|
yyparse(); /* Load the values from the conf */ |
1974 |
|
validate_conf(); /* Check to make sure some values are still okay. */ |
1975 |
|
/* Some global values are also loaded here. */ |
1994 |
|
if (ServerInfo.network_desc == NULL) |
1995 |
|
DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT); |
1996 |
|
|
1997 |
+ |
if (ConfigFileEntry.service_name == NULL) |
1998 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1999 |
+ |
|
2000 |
|
if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) || |
2001 |
|
(ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX)) |
2002 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX; |
2040 |
|
/* Get us ready for a bind() and don't bother doing dns lookup */ |
2041 |
|
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; |
2042 |
|
|
2043 |
< |
if (irc_getaddrinfo(aconf->host, NULL, &hints, &res)) |
2043 |
> |
if (getaddrinfo(aconf->host, NULL, &hints, &res)) |
2044 |
|
{ |
2045 |
|
conf_dns_lookup(aconf); |
2046 |
|
return; |
2051 |
|
memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen); |
2052 |
|
aconf->ipnum.ss_len = res->ai_addrlen; |
2053 |
|
aconf->ipnum.ss.ss_family = res->ai_family; |
2054 |
< |
irc_freeaddrinfo(res); |
2054 |
> |
freeaddrinfo(res); |
2055 |
|
} |
2056 |
|
|
2057 |
|
/* conf_connect_allowed() |
2090 |
|
static struct AccessItem * |
2091 |
|
find_regexp_kline(const char *uhi[]) |
2092 |
|
{ |
2093 |
+ |
#ifdef HAVE_LIBPCRE |
2094 |
|
const dlink_node *ptr = NULL; |
2095 |
|
|
2096 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
2105 |
|
!ircd_pcre_exec(aptr->regexhost, uhi[2]))) |
2106 |
|
return aptr; |
2107 |
|
} |
2108 |
< |
|
2108 |
> |
#endif |
2109 |
|
return NULL; |
2110 |
|
} |
2111 |
|
|
2403 |
|
struct AccessItem *aconf; |
2404 |
|
|
2405 |
|
/* +5 for !,@,{,} and null */ |
2406 |
< |
static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5]; |
2406 |
> |
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
2407 |
|
|
2408 |
|
if (MyConnect(client_p)) |
2409 |
|
{ |
2414 |
|
|
2415 |
|
if (IsConfOperator(aconf)) |
2416 |
|
{ |
2417 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
2418 |
< |
client_p->username, client_p->host, |
2399 |
< |
conf->name); |
2417 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
2418 |
> |
client_p->username, client_p->host, conf->name); |
2419 |
|
return buffer; |
2420 |
|
} |
2421 |
|
} |
2426 |
|
assert(0); /* Oper without oper conf! */ |
2427 |
|
} |
2428 |
|
|
2429 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
2430 |
< |
client_p->username, client_p->host, client_p->servptr->name); |
2429 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
2430 |
> |
client_p->username, client_p->host, client_p->servptr->name); |
2431 |
|
return buffer; |
2432 |
|
} |
2433 |
|
|
2444 |
|
char chanmodes[32]; |
2445 |
|
char chanlimit[32]; |
2446 |
|
|
2447 |
+ |
conf_parser_ctx.boot = cold; |
2448 |
|
filename = get_conf_name(CONF_TYPE); |
2449 |
|
|
2450 |
|
/* We need to know the initial filename for the yyerror() to report |
2455 |
|
*/ |
2456 |
|
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
2457 |
|
|
2458 |
< |
if ((conf_fbfile_in = fbopen(filename, "r")) == NULL) |
2458 |
> |
if ((conf_parser_ctx.conf_file = fbopen(filename, "r")) == NULL) |
2459 |
|
{ |
2460 |
|
if (cold) |
2461 |
|
{ |
2475 |
|
if (!cold) |
2476 |
|
clear_out_old_conf(); |
2477 |
|
|
2478 |
< |
read_conf(conf_fbfile_in); |
2479 |
< |
fbclose(conf_fbfile_in); |
2478 |
> |
read_conf(conf_parser_ctx.conf_file); |
2479 |
> |
fbclose(conf_parser_ctx.conf_file); |
2480 |
|
|
2481 |
|
add_isupport("NETWORK", ServerInfo.network_name, -1); |
2482 |
< |
ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "", |
2483 |
< |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
2482 |
> |
snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d", |
2483 |
> |
ConfigChannel.use_except ? "e" : "", |
2484 |
> |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
2485 |
|
add_isupport("MAXLIST", chanmodes, -1); |
2486 |
|
add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets); |
2487 |
+ |
|
2488 |
|
if (ConfigChannel.disable_local_channels) |
2489 |
|
add_isupport("CHANTYPES", "#", -1); |
2490 |
|
else |
2491 |
|
add_isupport("CHANTYPES", "#&", -1); |
2492 |
< |
ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&", |
2493 |
< |
ConfigChannel.max_chans_per_user); |
2492 |
> |
|
2493 |
> |
snprintf(chanlimit, sizeof(chanlimit), "%s:%d", |
2494 |
> |
ConfigChannel.disable_local_channels ? "#" : "#&", |
2495 |
> |
ConfigChannel.max_chans_per_user); |
2496 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
2497 |
< |
ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "", |
2498 |
< |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst"); |
2497 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s%s%s", |
2498 |
> |
ConfigChannel.use_except ? "e" : "", |
2499 |
> |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpstOS"); |
2500 |
|
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
2501 |
+ |
|
2502 |
|
if (ConfigChannel.use_except) |
2503 |
|
add_isupport("EXCEPTS", "e", -1); |
2504 |
|
if (ConfigChannel.use_invex) |
2511 |
|
*/ |
2512 |
|
rebuild_isupport_message_line(); |
2513 |
|
|
2514 |
< |
parse_conf_file(KLINE_TYPE, cold); |
2514 |
> |
#ifdef HAVE_LIBPCRE |
2515 |
|
parse_conf_file(RKLINE_TYPE, cold); |
2516 |
+ |
parse_conf_file(RXLINE_TYPE, cold); |
2517 |
+ |
#endif |
2518 |
+ |
parse_conf_file(KLINE_TYPE, cold); |
2519 |
|
parse_conf_file(DLINE_TYPE, cold); |
2520 |
|
parse_conf_file(XLINE_TYPE, cold); |
2492 |
– |
parse_conf_file(RXLINE_TYPE, cold); |
2521 |
|
parse_conf_file(NRESV_TYPE, cold); |
2522 |
|
parse_conf_file(CRESV_TYPE, cold); |
2523 |
|
} |
2568 |
|
dlink_list *free_items [] = { |
2569 |
|
&server_items, &oconf_items, &hub_items, &leaf_items, |
2570 |
|
&uconf_items, &xconf_items, &rxconf_items, &rkconf_items, |
2571 |
< |
&nresv_items, &cluster_items, &gdeny_items, NULL |
2571 |
> |
&nresv_items, &cluster_items, &gdeny_items, &service_items, NULL |
2572 |
|
}; |
2573 |
|
|
2574 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
2669 |
|
clear_out_address_conf(); |
2670 |
|
|
2671 |
|
/* clean out module paths */ |
2644 |
– |
#ifndef STATIC_MODULES |
2672 |
|
mod_clear_paths(); |
2646 |
– |
#endif |
2673 |
|
|
2674 |
|
/* clean out ServerInfo */ |
2675 |
|
MyFree(ServerInfo.description); |
2711 |
|
*/ |
2712 |
|
|
2713 |
|
/* clean out general */ |
2714 |
+ |
MyFree(ConfigFileEntry.service_name); |
2715 |
+ |
ConfigFileEntry.service_name = NULL; |
2716 |
+ |
|
2717 |
|
MyFree(ConfigFileEntry.servlink_path); |
2718 |
|
ConfigFileEntry.servlink_path = NULL; |
2719 |
|
#ifdef HAVE_LIBCRYPTO |
3108 |
|
return 0; |
3109 |
|
} |
3110 |
|
|
3082 |
– |
/* conf_add_d_conf() |
3083 |
– |
* |
3084 |
– |
* inputs - pointer to config item |
3085 |
– |
* output - NONE |
3086 |
– |
* side effects - Add a d/D line |
3087 |
– |
*/ |
3088 |
– |
void |
3089 |
– |
conf_add_d_conf(struct AccessItem *aconf) |
3090 |
– |
{ |
3091 |
– |
if (aconf->host == NULL) |
3092 |
– |
return; |
3093 |
– |
|
3094 |
– |
aconf->user = NULL; |
3095 |
– |
|
3096 |
– |
/* XXX - Should 'd' ever be in the old conf? For new conf we don't |
3097 |
– |
* need this anyway, so I will disable it for now... -A1kmm |
3098 |
– |
*/ |
3099 |
– |
if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST) |
3100 |
– |
{ |
3101 |
– |
ilog(L_WARN, "Invalid Dline %s ignored", aconf->host); |
3102 |
– |
free_access_item(aconf); |
3103 |
– |
} |
3104 |
– |
else |
3105 |
– |
{ |
3106 |
– |
/* XXX ensure user is NULL */ |
3107 |
– |
MyFree(aconf->user); |
3108 |
– |
aconf->user = NULL; |
3109 |
– |
add_conf_by_address(CONF_DLINE, aconf); |
3110 |
– |
} |
3111 |
– |
} |
3112 |
– |
|
3111 |
|
/* yyerror() |
3112 |
|
* |
3113 |
|
* inputs - message from parser |
3119 |
|
{ |
3120 |
|
char newlinebuf[IRCD_BUFSIZE]; |
3121 |
|
|
3122 |
< |
if (ypass != 1) |
3122 |
> |
if (conf_parser_ctx.pass != 1) |
3123 |
|
return; |
3124 |
|
|
3125 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
3155 |
|
* Originally written by Dianora (Diane, db@db.net) |
3156 |
|
*/ |
3157 |
|
time_t |
3158 |
< |
valid_tkline(char *p, int minutes) |
3158 |
> |
valid_tkline(const char *p, int minutes) |
3159 |
|
{ |
3160 |
|
time_t result = 0; |
3161 |
|
|
3162 |
< |
while (*p) |
3162 |
> |
for (; *p; ++p) |
3163 |
|
{ |
3164 |
< |
if (IsDigit(*p)) |
3167 |
< |
{ |
3168 |
< |
result *= 10; |
3169 |
< |
result += ((*p) & 0xF); |
3170 |
< |
p++; |
3171 |
< |
} |
3172 |
< |
else |
3164 |
> |
if (!IsDigit(*p)) |
3165 |
|
return 0; |
3166 |
+ |
|
3167 |
+ |
result *= 10; |
3168 |
+ |
result += ((*p) & 0xF); |
3169 |
|
} |
3170 |
|
|
3171 |
< |
/* in the degenerate case where oper does a /quote kline 0 user@host :reason |
3171 |
> |
/* |
3172 |
> |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
3173 |
|
* i.e. they specifically use 0, I am going to return 1 instead |
3174 |
|
* as a return value of non-zero is used to flag it as a temporary kline |
3175 |
|
*/ |
3180 |
– |
|
3176 |
|
if (result == 0) |
3177 |
|
result = 1; |
3178 |
|
|