28 |
|
#include "s_conf.h" |
29 |
|
#include "s_serv.h" |
30 |
|
#include "resv.h" |
31 |
– |
#include "s_stats.h" |
31 |
|
#include "channel.h" |
32 |
|
#include "client.h" |
33 |
|
#include "common.h" |
37 |
|
#include "irc_string.h" |
38 |
|
#include "sprintf_irc.h" |
39 |
|
#include "s_bsd.h" |
41 |
– |
#include "irc_getnameinfo.h" |
40 |
|
#include "irc_getaddrinfo.h" |
41 |
|
#include "ircd.h" |
42 |
|
#include "list.h" |
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 */ |
91 |
< |
int ypass = 1; /* used by yyparse() */ |
88 |
> |
int ypass = 1; /* used by yyparse() */ |
89 |
|
|
90 |
|
/* internally defined functions */ |
91 |
|
static void lookup_confhost(struct ConfItem *); |
295 |
|
case GDENY_TYPE: |
296 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
297 |
|
sizeof(struct AccessItem)); |
298 |
< |
dlinkAddTail(conf, &conf->node, &gdeny_items); |
298 |
> |
dlinkAdd(conf, &conf->node, &gdeny_items); |
299 |
|
break; |
300 |
|
|
301 |
|
case XLINE_TYPE: |
335 |
|
break; |
336 |
|
|
337 |
|
case CLASS_TYPE: |
338 |
< |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
339 |
< |
sizeof(struct ClassItem)); |
338 |
> |
conf = MyMalloc(sizeof(struct ConfItem) + |
339 |
> |
sizeof(struct ClassItem)); |
340 |
|
dlinkAdd(conf, &conf->node, &class_items); |
341 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
342 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
341 |
> |
|
342 |
> |
aclass = map_to_conf(conf); |
343 |
> |
aclass->active = 1; |
344 |
> |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
345 |
|
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
346 |
|
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
347 |
|
MaxSendq(aclass) = DEFAULT_SENDQ; |
348 |
< |
CurrUserCount(aclass) = 0; |
348 |
> |
|
349 |
|
break; |
350 |
|
|
351 |
|
default: |
356 |
|
/* XXX Yes, this will core if default is hit. I want it to for now - db */ |
357 |
|
conf->type = type; |
358 |
|
|
359 |
< |
return(conf); |
359 |
> |
return conf; |
360 |
|
} |
361 |
|
|
362 |
|
void |
363 |
|
delete_conf_item(struct ConfItem *conf) |
364 |
|
{ |
365 |
+ |
dlink_node *m = NULL; |
366 |
|
struct MatchItem *match_item; |
367 |
|
struct AccessItem *aconf; |
368 |
|
ConfType type = conf->type; |
509 |
|
MyFree(match_item->reason); |
510 |
|
MyFree(match_item->oper_reason); |
511 |
|
dlinkDelete(&conf->node, &nresv_items); |
512 |
+ |
|
513 |
+ |
if (conf->flags & CONF_FLAGS_TEMPORARY) |
514 |
+ |
if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL) |
515 |
+ |
free_dlink_node(m); |
516 |
+ |
|
517 |
|
MyFree(conf); |
518 |
|
break; |
519 |
|
|
531 |
|
break; |
532 |
|
|
533 |
|
case CRESV_TYPE: |
534 |
+ |
if (conf->flags & CONF_FLAGS_TEMPORARY) |
535 |
+ |
if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL) |
536 |
+ |
free_dlink_node(m); |
537 |
+ |
|
538 |
|
MyFree(conf); |
539 |
|
break; |
540 |
|
|
585 |
|
struct ClassItem *classitem = NULL; |
586 |
|
char buf[12]; |
587 |
|
char *p = NULL; |
588 |
+ |
const char *pfx = NULL; |
589 |
|
|
590 |
|
switch (type) |
591 |
|
{ |
642 |
|
break; |
643 |
|
|
644 |
|
case RKLINE_TYPE: |
645 |
< |
p = temp ? "Rk" : "RK"; |
645 |
> |
pfx = temp ? "kR" : "KR"; |
646 |
|
|
647 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
648 |
|
{ |
652 |
|
continue; |
653 |
|
|
654 |
|
sendto_one(source_p, form_str(RPL_STATSKLINE), me.name, |
655 |
< |
source_p->name, p, aconf->host, aconf->user, |
655 |
> |
source_p->name, pfx, aconf->host, aconf->user, |
656 |
|
aconf->reason, aconf->oper_reason ? aconf->oper_reason : ""); |
657 |
|
} |
658 |
|
break; |
722 |
|
me.name, source_p->name, 'Y', |
723 |
|
conf->name, PingFreq(classitem), |
724 |
|
ConFreq(classitem), |
725 |
< |
MaxTotal(classitem), MaxSendq(classitem)); |
725 |
> |
MaxTotal(classitem), MaxSendq(classitem), |
726 |
> |
CurrUserCount(classitem), |
727 |
> |
classitem->active ? "active" : "disabled"); |
728 |
|
} |
729 |
|
break; |
730 |
|
|
746 |
|
*p++ = 'A'; |
747 |
|
if (IsConfCryptLink(aconf)) |
748 |
|
*p++ = 'C'; |
737 |
– |
if (IsConfLazyLink(aconf)) |
738 |
– |
*p++ = 'L'; |
749 |
|
if (aconf->fakename) |
750 |
|
*p++ = 'M'; |
751 |
|
if (IsConfTopicBurst(aconf)) |
757 |
|
|
758 |
|
*p = '\0'; |
759 |
|
|
760 |
< |
/* Allow admins to see actual ips |
761 |
< |
* unless hide_server_ips is enabled |
760 |
> |
/* |
761 |
> |
* Allow admins to see actual ips unless hide_server_ips is enabled |
762 |
|
*/ |
763 |
|
if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p)) |
764 |
|
sendto_one(source_p, form_str(RPL_STATSCLINE), |
826 |
|
|
827 |
|
/* I'm already in big trouble if source_p->localClient is NULL -db */ |
828 |
|
if ((i = verify_access(source_p, username))) |
819 |
– |
{ |
829 |
|
ilog(L_INFO, "Access denied: %s[%s]", |
830 |
|
source_p->name, source_p->sockhost); |
822 |
– |
} |
831 |
|
|
832 |
|
switch (i) |
833 |
|
{ |
826 |
– |
case IRCD_SOCKET_ERROR: |
827 |
– |
exit_client(source_p, &me, "Socket Error"); |
828 |
– |
break; |
829 |
– |
|
834 |
|
case TOO_MANY: |
835 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, |
836 |
|
"Too many on IP for %s (%s).", |
838 |
|
source_p->sockhost); |
839 |
|
ilog(L_INFO,"Too many connections on IP from %s.", |
840 |
|
get_client_name(source_p, SHOW_IP)); |
841 |
< |
ServerStats->is_ref++; |
841 |
> |
++ServerStats.is_ref; |
842 |
|
exit_client(source_p, &me, "No more connections allowed on that IP"); |
843 |
|
break; |
844 |
|
|
849 |
|
source_p->sockhost); |
850 |
|
ilog(L_INFO,"Too many connections from %s.", |
851 |
|
get_client_name(source_p, SHOW_IP)); |
852 |
< |
ServerStats->is_ref++; |
852 |
> |
++ServerStats.is_ref; |
853 |
|
exit_client(source_p, &me, |
854 |
|
"No more connections allowed in your connection class"); |
855 |
|
break; |
856 |
|
|
857 |
|
case NOT_AUTHORIZED: |
858 |
< |
{ |
855 |
< |
static char ipaddr[HOSTIPLEN]; |
856 |
< |
ServerStats->is_ref++; |
858 |
> |
++ServerStats.is_ref; |
859 |
|
/* jdc - lists server name & port connections are on */ |
860 |
|
/* 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); |
861 |
|
sendto_realops_flags(UMODE_UNAUTH, L_ALL, |
862 |
|
"Unauthorized client connection from %s [%s] on [%s/%u].", |
863 |
|
get_client_name(source_p, SHOW_IP), |
864 |
< |
ipaddr, |
864 |
> |
source_p->sockhost, |
865 |
|
source_p->localClient->listener->name, |
866 |
|
source_p->localClient->listener->port); |
867 |
|
ilog(L_INFO, |
874 |
|
* capture reject code here or rely on the connecting too fast code. |
875 |
|
* - Dianora |
876 |
|
*/ |
877 |
< |
if(REJECT_HOLD_TIME > 0) |
877 |
> |
if (REJECT_HOLD_TIME > 0) |
878 |
|
{ |
879 |
|
sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server", |
880 |
|
me.name, source_p->name); |
884 |
|
else |
885 |
|
exit_client(source_p, &me, "You are not authorized to use this server"); |
886 |
|
break; |
887 |
< |
} |
889 |
< |
|
887 |
> |
|
888 |
|
case BANNED_CLIENT: |
889 |
|
/* |
890 |
|
* Don't exit them immediately, play with them a bit. |
897 |
|
} |
898 |
|
else |
899 |
|
exit_client(source_p, &me, "Banned"); |
900 |
< |
ServerStats->is_ref++; |
900 |
> |
++ServerStats.is_ref; |
901 |
|
break; |
902 |
|
|
903 |
|
case 0: |
1014 |
|
ip_found->count++; |
1015 |
|
SetIpHash(client_p); |
1016 |
|
|
1017 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1017 |
> |
aconf = map_to_conf(conf); |
1018 |
|
if (aconf->class_ptr == NULL) |
1019 |
|
return NOT_AUTHORIZED; /* If class is missing, this is best */ |
1020 |
|
|
1021 |
< |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
1021 |
> |
aclass = map_to_conf(aconf->class_ptr); |
1022 |
|
|
1023 |
|
count_user_host(client_p->username, client_p->host, |
1024 |
|
&global, &local, &ident); |
1029 |
|
*/ |
1030 |
|
if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass)) |
1031 |
|
a_limit_reached = 1; |
1032 |
< |
else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass)) |
1032 |
> |
else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass)) |
1033 |
|
a_limit_reached = 1; |
1034 |
|
else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass)) |
1035 |
|
a_limit_reached = 1; |
1042 |
|
if (a_limit_reached) |
1043 |
|
{ |
1044 |
|
if (!IsConfExemptLimits(aconf)) |
1045 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1045 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1046 |
|
|
1047 |
|
sendto_one(client_p, |
1048 |
|
":%s NOTICE %s :*** Your connection class is full, " |
1226 |
|
* used in the hash. |
1227 |
|
*/ |
1228 |
|
void |
1229 |
< |
count_ip_hash(int *number_ips_stored, unsigned long *mem_ips_stored) |
1229 |
> |
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
1230 |
|
{ |
1231 |
|
struct ip_entry *ptr; |
1232 |
|
int i; |
1314 |
|
case CLIENT_TYPE: |
1315 |
|
case OPER_TYPE: |
1316 |
|
case SERVER_TYPE: |
1317 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1317 |
> |
aconf = map_to_conf(conf); |
1318 |
> |
|
1319 |
> |
assert(aconf->clients > 0); |
1320 |
> |
|
1321 |
|
if ((aclass_conf = ClassPtr(aconf)) != NULL) |
1322 |
|
{ |
1323 |
< |
aclass = (struct ClassItem *)map_to_conf(aclass_conf); |
1323 |
> |
aclass = map_to_conf(aclass_conf); |
1324 |
> |
|
1325 |
> |
assert(aclass->curr_user_count > 0); |
1326 |
|
|
1327 |
|
if (conf->type == CLIENT_TYPE) |
1328 |
|
remove_from_cidr_check(&client_p->localClient->ip, aclass); |
1329 |
< |
|
1327 |
< |
if (CurrUserCount(aclass) > 0) |
1328 |
< |
aclass->curr_user_count--; |
1329 |
< |
if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0) |
1329 |
> |
if (--aclass->curr_user_count == 0 && aclass->active == 0) |
1330 |
|
delete_conf_item(aclass_conf); |
1331 |
|
} |
1332 |
|
|
1333 |
< |
/* Please, no ioccc entries - Dianora */ |
1334 |
< |
if (aconf->clients > 0) |
1335 |
< |
--aconf->clients; |
1336 |
< |
if (aconf->clients == 0 && IsConfIllegal(aconf)) |
1333 |
> |
if (--aconf->clients == 0 && IsConfIllegal(aconf)) |
1334 |
|
delete_conf_item(conf); |
1335 |
+ |
|
1336 |
|
break; |
1337 |
+ |
|
1338 |
|
case LEAF_TYPE: |
1339 |
|
case HUB_TYPE: |
1340 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
1340 |
> |
match_item = map_to_conf(conf); |
1341 |
|
if (match_item->ref_count == 0 && match_item->illegal) |
1342 |
|
delete_conf_item(conf); |
1343 |
|
break; |
1366 |
|
int |
1367 |
|
attach_conf(struct Client *client_p, struct ConfItem *conf) |
1368 |
|
{ |
1370 |
– |
struct AccessItem *aconf; |
1371 |
– |
struct MatchItem *match_item; |
1372 |
– |
|
1369 |
|
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
1370 |
|
return 1; |
1371 |
|
|
1373 |
|
conf->type == SERVER_TYPE || |
1374 |
|
conf->type == OPER_TYPE) |
1375 |
|
{ |
1376 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1376 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
1377 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1378 |
|
|
1379 |
|
if (IsConfIllegal(aconf)) |
1380 |
|
return NOT_AUTHORIZED; |
1381 |
|
|
1382 |
|
if (conf->type == CLIENT_TYPE) |
1386 |
– |
{ |
1387 |
– |
struct ClassItem *aclass; |
1388 |
– |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
1389 |
– |
|
1383 |
|
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1384 |
|
&client_p->localClient->ip, aclass)) |
1385 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1393 |
< |
|
1394 |
< |
CurrUserCount(aclass)++; |
1395 |
< |
} |
1385 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1386 |
|
|
1387 |
+ |
CurrUserCount(aclass)++; |
1388 |
|
aconf->clients++; |
1389 |
|
} |
1390 |
|
else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE) |
1391 |
|
{ |
1392 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
1392 |
> |
struct MatchItem *match_item = map_to_conf(conf); |
1393 |
|
match_item->ref_count++; |
1394 |
|
} |
1395 |
|
|
1423 |
|
DLINK_FOREACH(ptr, server_items.head) |
1424 |
|
{ |
1425 |
|
conf = ptr->data; |
1426 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1426 |
> |
aconf = map_to_conf(conf); |
1427 |
|
|
1428 |
|
if (match(conf->name, name) == 0 || match(aconf->host, host) == 0) |
1429 |
|
continue; |
1463 |
|
|
1464 |
|
if (conf->name == NULL) |
1465 |
|
continue; |
1466 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1466 |
> |
aconf = map_to_conf(conf); |
1467 |
|
if (aconf->host == NULL) |
1468 |
|
continue; |
1469 |
|
if (irccmp(conf->name, name) != 0) |
1474 |
|
** socket host) matches *either* host or name field |
1475 |
|
** of the configuration. |
1476 |
|
*/ |
1477 |
< |
if (!match(aconf->host, host) || !match(aconf->user,user) |
1487 |
< |
|| irccmp(conf->name, name) ) |
1477 |
> |
if (!match(aconf->host, host) || !match(aconf->user, user)) |
1478 |
|
continue; |
1479 |
|
if (type == OPER_TYPE) |
1480 |
|
{ |
1481 |
< |
struct ClassItem *aclass; |
1481 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1482 |
|
|
1483 |
< |
aclass = (struct ClassItem *)aconf->class_ptr; |
1494 |
< |
if (aconf->clients < MaxTotal(aclass)) |
1495 |
< |
return conf; |
1496 |
< |
else |
1483 |
> |
if (aconf->clients >= MaxTotal(aclass)) |
1484 |
|
continue; |
1485 |
|
} |
1486 |
< |
else |
1487 |
< |
return conf; |
1486 |
> |
|
1487 |
> |
return conf; |
1488 |
|
} |
1489 |
+ |
|
1490 |
|
return NULL; |
1491 |
|
} |
1492 |
|
|
1822 |
|
ServerInfo.specific_ipv6_vhost = 0; |
1823 |
|
|
1824 |
|
ServerInfo.max_clients = MAXCLIENTS_MAX; |
1825 |
< |
/* Don't reset hub, as that will break lazylinks */ |
1826 |
< |
/* ServerInfo.hub = NO; */ |
1825 |
> |
|
1826 |
> |
ServerInfo.hub = 0; |
1827 |
> |
delete_capability("HUB"); |
1828 |
|
ServerInfo.dns_host.sin_addr.s_addr = 0; |
1829 |
|
ServerInfo.dns_host.sin_port = 0; |
1830 |
|
AdminInfo.name = NULL; |
1842 |
|
ConfigLoggingEntry.ioerrlog[0] = '\0'; |
1843 |
|
ConfigLoggingEntry.failed_operlog[0] = '\0'; |
1844 |
|
|
1845 |
+ |
ConfigChannel.disable_fake_channels = NO; |
1846 |
|
ConfigChannel.restrict_channels = NO; |
1847 |
|
ConfigChannel.disable_local_channels = NO; |
1848 |
|
ConfigChannel.use_invex = YES; |
1850 |
|
ConfigChannel.use_knock = YES; |
1851 |
|
ConfigChannel.knock_delay = 300; |
1852 |
|
ConfigChannel.knock_delay_channel = 60; |
1863 |
– |
ConfigChannel.invite_ops_only = YES; |
1853 |
|
ConfigChannel.max_chans_per_user = 15; |
1854 |
|
ConfigChannel.quiet_on_ban = YES; |
1855 |
|
ConfigChannel.max_bans = 25; |
1867 |
|
DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT); |
1868 |
|
ConfigServerHide.hide_server_ips = NO; |
1869 |
|
|
1870 |
+ |
|
1871 |
+ |
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1872 |
|
ConfigFileEntry.gline_min_cidr = 16; |
1873 |
|
ConfigFileEntry.gline_min_cidr6 = 48; |
1874 |
|
ConfigFileEntry.invisible_on_connect = YES; |
1915 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1916 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT; |
1917 |
|
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; /* XXX */ |
1918 |
< |
ConfigFileEntry.oper_umodes = UMODE_LOCOPS | UMODE_SERVNOTICE | |
1918 |
> |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1919 |
|
UMODE_OPERWALL | UMODE_WALLOP; /* XXX */ |
1920 |
|
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1921 |
|
#ifdef HAVE_LIBCRYPTO |
1946 |
|
static void |
1947 |
|
read_conf(FBFILE *file) |
1948 |
|
{ |
1949 |
< |
scount = lineno = 0; |
1949 |
> |
lineno = 0; |
1950 |
|
|
1951 |
|
set_default_conf(); /* Set default values prior to conf parsing */ |
1952 |
|
ypass = 1; |
1982 |
|
if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) || |
1983 |
|
(ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX)) |
1984 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX; |
1985 |
+ |
|
1986 |
+ |
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
1987 |
|
} |
1988 |
|
|
1989 |
|
/* lookup_confhost() |
2260 |
|
} |
2261 |
|
} |
2262 |
|
|
2263 |
+ |
dlinkDelete(ptr, tklist); |
2264 |
|
delete_one_address_conf(aconf->host, aconf); |
2271 |
– |
dlinkDelete(ptr, tklist); |
2265 |
|
} |
2266 |
|
} |
2267 |
|
else if (conf->type == XLINE_TYPE || |
2315 |
|
if (ConfigFileEntry.tkline_expire_notices) |
2316 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2317 |
|
"Temporary RESV for [%s] expired", cconf->name); |
2318 |
< |
dlinkDelete(ptr, tklist); |
2326 |
< |
free_dlink_node(ptr); |
2327 |
< |
delete_conf_item(conf); |
2318 |
> |
delete_channel_resv(cconf); |
2319 |
|
} |
2320 |
|
} |
2321 |
|
} |
2323 |
|
|
2324 |
|
/* oper_privs_as_string() |
2325 |
|
* |
2326 |
< |
* inputs - pointer to client_p or NULL |
2326 |
> |
* inputs - pointer to client_p |
2327 |
|
* output - pointer to static string showing oper privs |
2328 |
|
* side effects - return as string, the oper privs as derived from port |
2329 |
|
*/ |
2330 |
< |
|
2331 |
< |
static const unsigned int oper_flags_table[] = |
2332 |
< |
{ 'O', 'R', 'U', 'G', 'N', 'K', 'X', 'D', 'H', 'A' , 0 }; |
2330 |
> |
static const struct oper_privs |
2331 |
> |
{ |
2332 |
> |
const unsigned int oprivs; |
2333 |
> |
const unsigned int hidden; |
2334 |
> |
const unsigned char c; |
2335 |
> |
} flag_list[] = { |
2336 |
> |
{ OPER_FLAG_ADMIN, OPER_FLAG_HIDDEN_ADMIN, 'A' }, |
2337 |
> |
{ OPER_FLAG_REMOTEBAN, 0, 'B' }, |
2338 |
> |
{ OPER_FLAG_DIE, 0, 'D' }, |
2339 |
> |
{ OPER_FLAG_GLINE, 0, 'G' }, |
2340 |
> |
{ OPER_FLAG_REHASH, 0, 'H' }, |
2341 |
> |
{ OPER_FLAG_K, 0, 'K' }, |
2342 |
> |
{ OPER_FLAG_OPERWALL, 0, 'L' }, |
2343 |
> |
{ OPER_FLAG_N, 0, 'N' }, |
2344 |
> |
{ OPER_FLAG_GLOBAL_KILL, 0, 'O' }, |
2345 |
> |
{ OPER_FLAG_REMOTE, 0, 'R' }, |
2346 |
> |
{ OPER_FLAG_OPER_SPY, 0, 'S' }, |
2347 |
> |
{ OPER_FLAG_UNKLINE, 0, 'U' }, |
2348 |
> |
{ OPER_FLAG_X, 0, 'X' }, |
2349 |
> |
{ 0, 0, '\0' } |
2350 |
> |
}; |
2351 |
|
|
2352 |
|
char * |
2353 |
|
oper_privs_as_string(const unsigned int port) |
2354 |
|
{ |
2355 |
< |
static char privs_out[12]; |
2355 |
> |
static char privs_out[16]; |
2356 |
> |
char *privs_ptr = privs_out; |
2357 |
> |
unsigned int i = 0; |
2358 |
> |
|
2359 |
> |
for (; flag_list[i].oprivs; ++i) |
2360 |
> |
{ |
2361 |
> |
if ((port & flag_list[i].oprivs) && |
2362 |
> |
(port & flag_list[i].hidden) == 0) |
2363 |
> |
*privs_ptr++ = flag_list[i].c; |
2364 |
> |
else |
2365 |
> |
*privs_ptr++ = ToLowerTab[flag_list[i].c]; |
2366 |
> |
} |
2367 |
> |
|
2368 |
> |
*privs_ptr = '\0'; |
2369 |
|
|
2348 |
– |
if (port & OPER_FLAG_HIDDEN_ADMIN) |
2349 |
– |
flags_to_ascii(port & ~OPER_FLAG_ADMIN, oper_flags_table, privs_out, 1); |
2350 |
– |
else |
2351 |
– |
flags_to_ascii(port, oper_flags_table, privs_out, 1); |
2370 |
|
return privs_out; |
2371 |
|
} |
2372 |
|
|
2473 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
2474 |
|
ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "", |
2475 |
|
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst"); |
2476 |
< |
add_isupport("CHANNELLEN", NULL, CHANNELLEN); |
2476 |
> |
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
2477 |
|
if (ConfigChannel.use_except) |
2478 |
|
add_isupport("EXCEPTS", "e", -1); |
2479 |
|
if (ConfigChannel.use_invex) |
2558 |
|
/* XXX This is less than pretty */ |
2559 |
|
if (conf->type == SERVER_TYPE) |
2560 |
|
{ |
2561 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2561 |
> |
aconf = map_to_conf(conf); |
2562 |
> |
|
2563 |
|
if (aconf->clients != 0) |
2564 |
|
{ |
2565 |
|
SetConfIllegal(aconf); |
2572 |
|
} |
2573 |
|
else if (conf->type == OPER_TYPE) |
2574 |
|
{ |
2575 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2575 |
> |
aconf = map_to_conf(conf); |
2576 |
> |
|
2577 |
|
if (aconf->clients != 0) |
2578 |
|
{ |
2579 |
|
SetConfIllegal(aconf); |
2586 |
|
} |
2587 |
|
else if (conf->type == CLIENT_TYPE) |
2588 |
|
{ |
2589 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2589 |
> |
aconf = map_to_conf(conf); |
2590 |
> |
|
2591 |
|
if (aconf->clients != 0) |
2592 |
|
{ |
2593 |
|
SetConfIllegal(aconf); |
2612 |
|
{ |
2613 |
|
if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE)) |
2614 |
|
{ |
2615 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
2616 |
< |
if ((match_item->ref_count <= 0)) |
2615 |
> |
match_item = map_to_conf(conf); |
2616 |
> |
if (match_item->ref_count <= 0) |
2617 |
|
delete_conf_item(conf); |
2618 |
|
else |
2619 |
|
{ |
2627 |
|
} |
2628 |
|
} |
2629 |
|
|
2630 |
< |
/* don't delete the class table, rather mark all entries |
2630 |
> |
/* |
2631 |
> |
* don't delete the class table, rather mark all entries |
2632 |
|
* for deletion. The table is cleaned up by check_class. - avalon |
2633 |
|
*/ |
2634 |
|
DLINK_FOREACH(ptr, class_items.head) |
2635 |
|
{ |
2636 |
< |
conf = ptr->data; |
2637 |
< |
cltmp = (struct ClassItem *)map_to_conf(conf); |
2636 |
> |
cltmp = map_to_conf(ptr->data); |
2637 |
> |
|
2638 |
|
if (ptr != class_items.tail) /* never mark the "default" class */ |
2639 |
< |
MaxTotal(cltmp) = -1; |
2639 |
> |
cltmp->active = 0; |
2640 |
|
} |
2641 |
|
|
2642 |
|
clear_out_address_conf(); |
2709 |
|
struct ConfItem *conf; |
2710 |
|
struct AccessItem *aconf; |
2711 |
|
dlink_list * free_items [] = { |
2712 |
< |
&server_items, &oconf_items, &hub_items, &leaf_items, NULL |
2712 |
> |
&server_items, &oconf_items, NULL |
2713 |
|
}; |
2714 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
2715 |
|
|
2886 |
|
struct ConfItem *conf; |
2887 |
|
|
2888 |
|
if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL) |
2889 |
< |
return(conf); |
2889 |
> |
return conf; |
2890 |
|
|
2891 |
|
return class_default; |
2892 |
|
} |
2900 |
|
void |
2901 |
|
check_class(void) |
2902 |
|
{ |
2903 |
< |
dlink_node *ptr; |
2882 |
< |
dlink_node *next_ptr; |
2883 |
< |
struct ConfItem *conf; |
2884 |
< |
struct ClassItem *aclass; |
2903 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
2904 |
|
|
2905 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head) |
2906 |
|
{ |
2907 |
< |
conf = ptr->data; |
2889 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
2907 |
> |
struct ClassItem *aclass = map_to_conf(ptr->data); |
2908 |
|
|
2909 |
< |
if (MaxTotal(aclass) < 0) |
2909 |
> |
if (!aclass->active && !CurrUserCount(aclass)) |
2910 |
|
{ |
2911 |
|
destroy_cidr_class(aclass); |
2912 |
< |
if (CurrUserCount(aclass) > 0) |
2895 |
< |
dlinkDelete(&conf->node, &class_items); |
2896 |
< |
else |
2897 |
< |
delete_conf_item(conf); |
2912 |
> |
delete_conf_item(ptr->data); |
2913 |
|
} |
2914 |
|
} |
2915 |
|
} |
2926 |
|
struct ClassItem *aclass; |
2927 |
|
|
2928 |
|
class_default = make_conf_item(CLASS_TYPE); |
2929 |
< |
aclass = (struct ClassItem *)map_to_conf(class_default); |
2929 |
> |
|
2930 |
> |
aclass = map_to_conf(class_default); |
2931 |
> |
aclass->active = 1; |
2932 |
|
DupString(class_default->name, "default"); |
2933 |
|
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
2934 |
|
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
2944 |
|
* output - sendq for this client as found from its class |
2945 |
|
* side effects - NONE |
2946 |
|
*/ |
2947 |
< |
unsigned long |
2947 |
> |
unsigned int |
2948 |
|
get_sendq(struct Client *client_p) |
2949 |
|
{ |
2950 |
< |
unsigned long sendq = DEFAULT_SENDQ; |
2950 |
> |
unsigned int sendq = DEFAULT_SENDQ; |
2951 |
|
dlink_node *ptr; |
2952 |
|
struct ConfItem *conf; |
2953 |
|
struct ConfItem *class_conf; |
2987 |
|
void |
2988 |
|
conf_add_class_to_conf(struct ConfItem *conf, const char *class_name) |
2989 |
|
{ |
2990 |
< |
struct AccessItem *aconf; |
2991 |
< |
struct ClassItem *aclass; |
2975 |
< |
|
2976 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2990 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
2991 |
> |
struct ClassItem *class = NULL; |
2992 |
|
|
2993 |
|
if (class_name == NULL) |
2994 |
|
{ |
2995 |
|
aconf->class_ptr = class_default; |
2996 |
+ |
|
2997 |
|
if (conf->type == CLIENT_TYPE) |
2998 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2999 |
|
"Warning *** Defaulting to default class for %s@%s", |
3004 |
|
conf->name); |
3005 |
|
} |
3006 |
|
else |
2991 |
– |
{ |
3007 |
|
aconf->class_ptr = find_class(class_name); |
2993 |
– |
} |
3008 |
|
|
3009 |
< |
if (aconf->class_ptr == NULL) |
3009 |
> |
if (aconf->class_ptr) |
3010 |
> |
class = map_to_conf(aconf->class_ptr); |
3011 |
> |
|
3012 |
> |
if (aconf->class_ptr == NULL || !class->active) |
3013 |
|
{ |
3014 |
|
if (conf->type == CLIENT_TYPE) |
3015 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
3021 |
|
conf->name); |
3022 |
|
aconf->class_ptr = class_default; |
3023 |
|
} |
3007 |
– |
else |
3008 |
– |
{ |
3009 |
– |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
3010 |
– |
if (MaxTotal(aclass) < 0) |
3011 |
– |
{ |
3012 |
– |
aconf->class_ptr = class_default; |
3013 |
– |
} |
3014 |
– |
} |
3024 |
|
} |
3025 |
|
|
3017 |
– |
#define MAXCONFLINKS 150 |
3018 |
– |
|
3026 |
|
/* conf_add_server() |
3027 |
|
* |
3028 |
|
* inputs - pointer to config item |
3031 |
|
* side effects - Add a connect block |
3032 |
|
*/ |
3033 |
|
int |
3034 |
< |
conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name) |
3034 |
> |
conf_add_server(struct ConfItem *conf, const char *class_name) |
3035 |
|
{ |
3036 |
|
struct AccessItem *aconf; |
3037 |
< |
char *orig_host; |
3037 |
> |
struct split_nuh_item nuh; |
3038 |
> |
char conf_user[USERLEN + 1]; |
3039 |
> |
char conf_host[HOSTLEN + 1]; |
3040 |
|
|
3041 |
|
aconf = map_to_conf(conf); |
3042 |
|
|
3043 |
|
conf_add_class_to_conf(conf, class_name); |
3044 |
|
|
3045 |
< |
if (lcount > MAXCONFLINKS || !aconf->host || !conf->name) |
3045 |
> |
if (!aconf->host || !conf->name) |
3046 |
|
{ |
3047 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block"); |
3048 |
|
ilog(L_WARN, "Bad connect block"); |
3057 |
|
return -1; |
3058 |
|
} |
3059 |
|
|
3060 |
< |
orig_host = aconf->host; |
3061 |
< |
split_nuh(orig_host, NULL, &aconf->user, &aconf->host); |
3062 |
< |
MyFree(orig_host); |
3060 |
> |
nuh.nuhmask = aconf->host; |
3061 |
> |
nuh.nickptr = NULL; |
3062 |
> |
nuh.userptr = conf_user; |
3063 |
> |
nuh.hostptr = conf_host; |
3064 |
> |
|
3065 |
> |
nuh.nicksize = 0; |
3066 |
> |
nuh.usersize = sizeof(conf_user); |
3067 |
> |
nuh.hostsize = sizeof(conf_host); |
3068 |
> |
|
3069 |
> |
split_nuh(&nuh); |
3070 |
> |
|
3071 |
> |
MyFree(aconf->host); |
3072 |
> |
aconf->host = NULL; |
3073 |
> |
|
3074 |
> |
DupString(aconf->user, conf_user); /* somehow username checking for servers |
3075 |
> |
got lost in H6/7, will have to be re-added */ |
3076 |
> |
DupString(aconf->host, conf_host); |
3077 |
> |
|
3078 |
|
lookup_confhost(conf); |
3079 |
|
|
3080 |
|
return 0; |
3279 |
|
* if target_server is NULL and an "ON" is found error |
3280 |
|
* is reported. |
3281 |
|
* if reason pointer is NULL ignore pointer, |
3282 |
< |
* this allows usee of parse_a_line in unkline etc. |
3282 |
> |
* this allows use of parse_a_line in unkline etc. |
3283 |
|
* |
3284 |
|
* - Dianora |
3285 |
|
*/ |
3395 |
|
|
3396 |
|
if (reason != NULL) |
3397 |
|
{ |
3398 |
< |
if (parc != 0) |
3398 |
> |
if (parc != 0 && !EmptyString(*parv)) |
3399 |
|
{ |
3400 |
|
*reason = *parv; |
3401 |
|
if (!valid_comment(source_p, *reason, YES)) |
3434 |
|
{ |
3435 |
|
/* Explicit user@host mask given */ |
3436 |
|
|
3437 |
< |
if(hostp != NULL) /* I'm a little user@host */ |
3437 |
> |
if (hostp != NULL) /* I'm a little user@host */ |
3438 |
|
{ |
3439 |
|
*(hostp++) = '\0'; /* short and squat */ |
3440 |
|
if (*user_host_or_nick) |
3565 |
|
*/ |
3566 |
|
void |
3567 |
|
cluster_a_line(struct Client *source_p, const char *command, |
3568 |
< |
int capab, int cluster_type, const char *pattern, ...) |
3568 |
> |
int capab, int cluster_type, const char *pattern, ...) |
3569 |
|
{ |
3570 |
|
va_list args; |
3571 |
|
char buffer[IRCD_BUFSIZE]; |
3572 |
< |
struct ConfItem *conf; |
3549 |
< |
dlink_node *ptr; |
3572 |
> |
const dlink_node *ptr = NULL; |
3573 |
|
|
3574 |
|
va_start(args, pattern); |
3575 |
|
vsnprintf(buffer, sizeof(buffer), pattern, args); |
3577 |
|
|
3578 |
|
DLINK_FOREACH(ptr, cluster_items.head) |
3579 |
|
{ |
3580 |
< |
conf = ptr->data; |
3580 |
> |
const struct ConfItem *conf = ptr->data; |
3581 |
|
|
3582 |
|
if (conf->flags & cluster_type) |
3560 |
– |
{ |
3583 |
|
sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab, |
3584 |
|
"%s %s %s", command, conf->name, buffer); |
3563 |
– |
} |
3585 |
|
} |
3586 |
|
} |
3587 |
|
|
3613 |
|
* @ * * * |
3614 |
|
* ! * * * |
3615 |
|
*/ |
3595 |
– |
|
3616 |
|
void |
3617 |
< |
split_nuh(char *mask, char **nick, char **user, char **host) |
3617 |
> |
split_nuh(struct split_nuh_item *const iptr) |
3618 |
|
{ |
3619 |
|
char *p = NULL, *q = NULL; |
3620 |
|
|
3621 |
< |
if ((p = strchr(mask, '!')) != NULL) |
3621 |
> |
if (iptr->nickptr) |
3622 |
> |
strlcpy(iptr->nickptr, "*", iptr->nicksize); |
3623 |
> |
if (iptr->userptr) |
3624 |
> |
strlcpy(iptr->userptr, "*", iptr->usersize); |
3625 |
> |
if (iptr->hostptr) |
3626 |
> |
strlcpy(iptr->hostptr, "*", iptr->hostsize); |
3627 |
> |
|
3628 |
> |
if ((p = strchr(iptr->nuhmask, '!'))) |
3629 |
|
{ |
3630 |
|
*p = '\0'; |
3604 |
– |
if (nick != NULL) |
3605 |
– |
{ |
3606 |
– |
if (*mask != '\0') |
3607 |
– |
*nick = xstrldup(mask, NICKLEN); |
3608 |
– |
else |
3609 |
– |
DupString(*nick, "*"); |
3610 |
– |
} |
3631 |
|
|
3632 |
< |
if ((q = strchr(++p, '@')) != NULL) |
3633 |
< |
{ |
3634 |
< |
*q = '\0'; |
3632 |
> |
if (iptr->nickptr && *iptr->nuhmask != '\0') |
3633 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
3634 |
> |
|
3635 |
> |
if ((q = strchr(++p, '@'))) { |
3636 |
> |
*q++ = '\0'; |
3637 |
|
|
3638 |
|
if (*p != '\0') |
3639 |
< |
*user = xstrldup(p, USERLEN+1); |
3618 |
< |
else |
3619 |
< |
DupString(*user, "*"); |
3639 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
3640 |
|
|
3641 |
< |
if (*++q != '\0') |
3642 |
< |
*host = xstrldup(q, HOSTLEN+1); |
3623 |
< |
else |
3624 |
< |
DupString(*host, "*"); |
3641 |
> |
if (*q != '\0') |
3642 |
> |
strlcpy(iptr->hostptr, q, iptr->hostsize); |
3643 |
|
} |
3644 |
|
else |
3645 |
|
{ |
3646 |
|
if (*p != '\0') |
3647 |
< |
*user = xstrldup(p, USERLEN+1); |
3630 |
< |
else |
3631 |
< |
DupString(*user, "*"); |
3632 |
< |
|
3633 |
< |
DupString(*host, "*"); |
3647 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
3648 |
|
} |
3649 |
|
} |
3650 |
< |
else /* No ! found so lets look for a user@host */ |
3650 |
> |
else |
3651 |
|
{ |
3652 |
< |
if ((p = strchr(mask, '@')) != NULL) /* if found a @ */ |
3652 |
> |
/* No ! found so lets look for a user@host */ |
3653 |
> |
if ((p = strchr(iptr->nuhmask, '@'))) |
3654 |
|
{ |
3655 |
< |
if (nick != NULL) |
3656 |
< |
DupString(*nick, "*"); |
3642 |
< |
*p = '\0'; |
3655 |
> |
/* if found a @ */ |
3656 |
> |
*p++ = '\0'; |
3657 |
|
|
3658 |
< |
if (*mask != '\0') |
3659 |
< |
*user = xstrldup(mask, USERLEN+1); |
3646 |
< |
else |
3647 |
< |
DupString(*user, "*"); |
3658 |
> |
if (*iptr->nuhmask != '\0') |
3659 |
> |
strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize); |
3660 |
|
|
3661 |
< |
if (*++p != '\0') |
3662 |
< |
*host = xstrldup(p, HOSTLEN+1); |
3651 |
< |
else |
3652 |
< |
DupString(*host, "*"); |
3661 |
> |
if (*p != '\0') |
3662 |
> |
strlcpy(iptr->hostptr, p, iptr->hostsize); |
3663 |
|
} |
3664 |
< |
else /* no @ found */ |
3664 |
> |
else |
3665 |
|
{ |
3666 |
< |
if (nick != NULL) |
3667 |
< |
{ |
3668 |
< |
if (strpbrk(mask, ".:")) |
3659 |
< |
{ |
3660 |
< |
DupString(*nick, "*"); |
3661 |
< |
*host = xstrldup(mask, HOSTLEN+1); |
3662 |
< |
} |
3663 |
< |
else |
3664 |
< |
{ |
3665 |
< |
*nick = xstrldup(mask, NICKLEN); |
3666 |
< |
DupString(*host, "*"); |
3667 |
< |
} |
3668 |
< |
|
3669 |
< |
DupString(*user, "*"); |
3670 |
< |
} |
3666 |
> |
/* no @ found */ |
3667 |
> |
if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:")) |
3668 |
> |
strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize); |
3669 |
|
else |
3670 |
< |
{ |
3673 |
< |
DupString(*user, "*"); |
3674 |
< |
*host = xstrldup(mask, HOSTLEN+1); |
3675 |
< |
} |
3670 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
3671 |
|
} |
3672 |
|
} |
3673 |
|
} |
3694 |
|
{ |
3695 |
|
if (flags & mask) |
3696 |
|
*p++ = bit_table[i]; |
3697 |
< |
else if(lowerit) |
3697 |
> |
else if (lowerit) |
3698 |
|
*p++ = ToLower(bit_table[i]); |
3699 |
|
} |
3700 |
|
*p = '\0'; |
3901 |
|
static void |
3902 |
|
destroy_cidr_list(dlink_list *list) |
3903 |
|
{ |
3904 |
< |
dlink_node *ptr = NULL; |
3910 |
< |
dlink_node *next_ptr = NULL; |
3911 |
< |
struct CidrItem *cidr; |
3904 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
3905 |
|
|
3906 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) |
3907 |
|
{ |
3915 |
– |
cidr = ptr->data; |
3908 |
|
dlinkDelete(ptr, list); |
3909 |
< |
MyFree(cidr); |
3909 |
> |
MyFree(ptr->data); |
3910 |
|
} |
3911 |
|
} |
3912 |
|
|