87 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
88 |
|
extern char yytext[]; |
89 |
|
extern int yyparse(); /* defined in y.tab.c */ |
90 |
< |
unsigned int scount = 0; /* used by yyparse(), etc */ |
91 |
< |
int ypass = 1; /* used by yyparse() */ |
90 |
> |
int ypass = 1; /* used by yyparse() */ |
91 |
|
|
92 |
|
/* internally defined functions */ |
93 |
|
static void lookup_confhost(struct ConfItem *); |
297 |
|
case GDENY_TYPE: |
298 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
299 |
|
sizeof(struct AccessItem)); |
300 |
< |
dlinkAddTail(conf, &conf->node, &gdeny_items); |
300 |
> |
dlinkAdd(conf, &conf->node, &gdeny_items); |
301 |
|
break; |
302 |
|
|
303 |
|
case XLINE_TYPE: |
337 |
|
break; |
338 |
|
|
339 |
|
case CLASS_TYPE: |
340 |
< |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
341 |
< |
sizeof(struct ClassItem)); |
340 |
> |
conf = MyMalloc(sizeof(struct ConfItem) + |
341 |
> |
sizeof(struct ClassItem)); |
342 |
|
dlinkAdd(conf, &conf->node, &class_items); |
343 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
344 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
343 |
> |
|
344 |
> |
aclass = map_to_conf(conf); |
345 |
> |
aclass->active = 1; |
346 |
> |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
347 |
|
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
348 |
|
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
349 |
|
MaxSendq(aclass) = DEFAULT_SENDQ; |
350 |
< |
CurrUserCount(aclass) = 0; |
350 |
> |
|
351 |
|
break; |
352 |
|
|
353 |
|
default: |
358 |
|
/* XXX Yes, this will core if default is hit. I want it to for now - db */ |
359 |
|
conf->type = type; |
360 |
|
|
361 |
< |
return(conf); |
361 |
> |
return conf; |
362 |
|
} |
363 |
|
|
364 |
|
void |
365 |
|
delete_conf_item(struct ConfItem *conf) |
366 |
|
{ |
367 |
+ |
dlink_node *m = NULL; |
368 |
|
struct MatchItem *match_item; |
369 |
|
struct AccessItem *aconf; |
370 |
|
ConfType type = conf->type; |
511 |
|
MyFree(match_item->reason); |
512 |
|
MyFree(match_item->oper_reason); |
513 |
|
dlinkDelete(&conf->node, &nresv_items); |
514 |
+ |
|
515 |
+ |
if (conf->flags & CONF_FLAGS_TEMPORARY) |
516 |
+ |
if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL) |
517 |
+ |
free_dlink_node(m); |
518 |
+ |
|
519 |
|
MyFree(conf); |
520 |
|
break; |
521 |
|
|
533 |
|
break; |
534 |
|
|
535 |
|
case CRESV_TYPE: |
536 |
+ |
if (conf->flags & CONF_FLAGS_TEMPORARY) |
537 |
+ |
if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL) |
538 |
+ |
free_dlink_node(m); |
539 |
+ |
|
540 |
|
MyFree(conf); |
541 |
|
break; |
542 |
|
|
587 |
|
struct ClassItem *classitem = NULL; |
588 |
|
char buf[12]; |
589 |
|
char *p = NULL; |
590 |
+ |
const char *pfx = NULL; |
591 |
|
|
592 |
|
switch (type) |
593 |
|
{ |
644 |
|
break; |
645 |
|
|
646 |
|
case RKLINE_TYPE: |
647 |
< |
p = temp ? "Rk" : "RK"; |
647 |
> |
pfx = temp ? "kR" : "KR"; |
648 |
|
|
649 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
650 |
|
{ |
654 |
|
continue; |
655 |
|
|
656 |
|
sendto_one(source_p, form_str(RPL_STATSKLINE), me.name, |
657 |
< |
source_p->name, p, aconf->host, aconf->user, |
657 |
> |
source_p->name, pfx, aconf->host, aconf->user, |
658 |
|
aconf->reason, aconf->oper_reason ? aconf->oper_reason : ""); |
659 |
|
} |
660 |
|
break; |
724 |
|
me.name, source_p->name, 'Y', |
725 |
|
conf->name, PingFreq(classitem), |
726 |
|
ConFreq(classitem), |
727 |
< |
MaxTotal(classitem), MaxSendq(classitem)); |
727 |
> |
MaxTotal(classitem), MaxSendq(classitem), |
728 |
> |
CurrUserCount(classitem), |
729 |
> |
classitem->active ? "active" : "disabled"); |
730 |
|
} |
731 |
|
break; |
732 |
|
|
761 |
|
|
762 |
|
*p = '\0'; |
763 |
|
|
764 |
< |
/* Allow admins to see actual ips |
765 |
< |
* unless hide_server_ips is enabled |
764 |
> |
/* |
765 |
> |
* Allow admins to see actual ips unless hide_server_ips is enabled |
766 |
|
*/ |
767 |
|
if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p)) |
768 |
|
sendto_one(source_p, form_str(RPL_STATSCLINE), |
830 |
|
|
831 |
|
/* I'm already in big trouble if source_p->localClient is NULL -db */ |
832 |
|
if ((i = verify_access(source_p, username))) |
819 |
– |
{ |
833 |
|
ilog(L_INFO, "Access denied: %s[%s]", |
834 |
|
source_p->name, source_p->sockhost); |
822 |
– |
} |
835 |
|
|
836 |
|
switch (i) |
837 |
|
{ |
826 |
– |
case IRCD_SOCKET_ERROR: |
827 |
– |
exit_client(source_p, &me, "Socket Error"); |
828 |
– |
break; |
829 |
– |
|
838 |
|
case TOO_MANY: |
839 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, |
840 |
|
"Too many on IP for %s (%s).", |
883 |
|
* capture reject code here or rely on the connecting too fast code. |
884 |
|
* - Dianora |
885 |
|
*/ |
886 |
< |
if(REJECT_HOLD_TIME > 0) |
886 |
> |
if (REJECT_HOLD_TIME > 0) |
887 |
|
{ |
888 |
|
sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server", |
889 |
|
me.name, source_p->name); |
1024 |
|
ip_found->count++; |
1025 |
|
SetIpHash(client_p); |
1026 |
|
|
1027 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1027 |
> |
aconf = map_to_conf(conf); |
1028 |
|
if (aconf->class_ptr == NULL) |
1029 |
|
return NOT_AUTHORIZED; /* If class is missing, this is best */ |
1030 |
|
|
1031 |
< |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
1031 |
> |
aclass = map_to_conf(aconf->class_ptr); |
1032 |
|
|
1033 |
|
count_user_host(client_p->username, client_p->host, |
1034 |
|
&global, &local, &ident); |
1039 |
|
*/ |
1040 |
|
if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass)) |
1041 |
|
a_limit_reached = 1; |
1042 |
< |
else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass)) |
1042 |
> |
else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass)) |
1043 |
|
a_limit_reached = 1; |
1044 |
|
else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass)) |
1045 |
|
a_limit_reached = 1; |
1052 |
|
if (a_limit_reached) |
1053 |
|
{ |
1054 |
|
if (!IsConfExemptLimits(aconf)) |
1055 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1055 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1056 |
|
|
1057 |
|
sendto_one(client_p, |
1058 |
|
":%s NOTICE %s :*** Your connection class is full, " |
1324 |
|
case CLIENT_TYPE: |
1325 |
|
case OPER_TYPE: |
1326 |
|
case SERVER_TYPE: |
1327 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1327 |
> |
aconf = map_to_conf(conf); |
1328 |
> |
|
1329 |
> |
assert(aconf->clients > 0); |
1330 |
> |
|
1331 |
|
if ((aclass_conf = ClassPtr(aconf)) != NULL) |
1332 |
|
{ |
1333 |
< |
aclass = (struct ClassItem *)map_to_conf(aclass_conf); |
1333 |
> |
aclass = map_to_conf(aclass_conf); |
1334 |
> |
|
1335 |
> |
assert(aclass->curr_user_count > 0); |
1336 |
|
|
1337 |
|
if (conf->type == CLIENT_TYPE) |
1338 |
|
remove_from_cidr_check(&client_p->localClient->ip, aclass); |
1339 |
< |
|
1327 |
< |
if (CurrUserCount(aclass) > 0) |
1328 |
< |
aclass->curr_user_count--; |
1329 |
< |
if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0) |
1339 |
> |
if (--aclass->curr_user_count == 0 && aclass->active == 0) |
1340 |
|
delete_conf_item(aclass_conf); |
1341 |
|
} |
1342 |
|
|
1343 |
< |
/* Please, no ioccc entries - Dianora */ |
1334 |
< |
if (aconf->clients > 0) |
1335 |
< |
--aconf->clients; |
1336 |
< |
if (aconf->clients == 0 && IsConfIllegal(aconf)) |
1343 |
> |
if (--aconf->clients == 0 && IsConfIllegal(aconf)) |
1344 |
|
delete_conf_item(conf); |
1345 |
+ |
|
1346 |
|
break; |
1347 |
+ |
|
1348 |
|
case LEAF_TYPE: |
1349 |
|
case HUB_TYPE: |
1350 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
1350 |
> |
match_item = map_to_conf(conf); |
1351 |
|
if (match_item->ref_count == 0 && match_item->illegal) |
1352 |
|
delete_conf_item(conf); |
1353 |
|
break; |
1376 |
|
int |
1377 |
|
attach_conf(struct Client *client_p, struct ConfItem *conf) |
1378 |
|
{ |
1370 |
– |
struct AccessItem *aconf; |
1371 |
– |
struct MatchItem *match_item; |
1372 |
– |
|
1379 |
|
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
1380 |
|
return 1; |
1381 |
|
|
1383 |
|
conf->type == SERVER_TYPE || |
1384 |
|
conf->type == OPER_TYPE) |
1385 |
|
{ |
1386 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1386 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
1387 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1388 |
|
|
1389 |
|
if (IsConfIllegal(aconf)) |
1390 |
|
return NOT_AUTHORIZED; |
1391 |
|
|
1392 |
|
if (conf->type == CLIENT_TYPE) |
1386 |
– |
{ |
1387 |
– |
struct ClassItem *aclass; |
1388 |
– |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
1389 |
– |
|
1393 |
|
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1394 |
|
&client_p->localClient->ip, aclass)) |
1395 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1393 |
< |
|
1394 |
< |
CurrUserCount(aclass)++; |
1395 |
< |
} |
1395 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1396 |
|
|
1397 |
+ |
CurrUserCount(aclass)++; |
1398 |
|
aconf->clients++; |
1399 |
|
} |
1400 |
|
else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE) |
1401 |
|
{ |
1402 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
1402 |
> |
struct MatchItem *match_item = map_to_conf(conf); |
1403 |
|
match_item->ref_count++; |
1404 |
|
} |
1405 |
|
|
1433 |
|
DLINK_FOREACH(ptr, server_items.head) |
1434 |
|
{ |
1435 |
|
conf = ptr->data; |
1436 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1436 |
> |
aconf = map_to_conf(conf); |
1437 |
|
|
1438 |
|
if (match(conf->name, name) == 0 || match(aconf->host, host) == 0) |
1439 |
|
continue; |
1473 |
|
|
1474 |
|
if (conf->name == NULL) |
1475 |
|
continue; |
1476 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1476 |
> |
aconf = map_to_conf(conf); |
1477 |
|
if (aconf->host == NULL) |
1478 |
|
continue; |
1479 |
|
if (irccmp(conf->name, name) != 0) |
1484 |
|
** socket host) matches *either* host or name field |
1485 |
|
** of the configuration. |
1486 |
|
*/ |
1487 |
< |
if (!match(aconf->host, host) || !match(aconf->user,user) |
1487 |
< |
|| irccmp(conf->name, name) ) |
1487 |
> |
if (!match(aconf->host, host) || !match(aconf->user, user)) |
1488 |
|
continue; |
1489 |
|
if (type == OPER_TYPE) |
1490 |
|
{ |
1491 |
< |
struct ClassItem *aclass; |
1491 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1492 |
|
|
1493 |
< |
aclass = (struct ClassItem *)aconf->class_ptr; |
1494 |
< |
if (aconf->clients < MaxTotal(aclass)) |
1495 |
< |
return conf; |
1496 |
< |
else |
1493 |
> |
if (aconf->clients >= MaxTotal(aclass)) |
1494 |
|
continue; |
1495 |
|
} |
1496 |
< |
else |
1497 |
< |
return conf; |
1496 |
> |
|
1497 |
> |
return conf; |
1498 |
|
} |
1499 |
+ |
|
1500 |
|
return NULL; |
1501 |
|
} |
1502 |
|
|
1851 |
|
ConfigLoggingEntry.ioerrlog[0] = '\0'; |
1852 |
|
ConfigLoggingEntry.failed_operlog[0] = '\0'; |
1853 |
|
|
1854 |
+ |
ConfigChannel.disable_fake_channels = NO; |
1855 |
|
ConfigChannel.restrict_channels = NO; |
1856 |
|
ConfigChannel.disable_local_channels = NO; |
1857 |
|
ConfigChannel.use_invex = YES; |
1859 |
|
ConfigChannel.use_knock = YES; |
1860 |
|
ConfigChannel.knock_delay = 300; |
1861 |
|
ConfigChannel.knock_delay_channel = 60; |
1863 |
– |
ConfigChannel.invite_ops_only = YES; |
1862 |
|
ConfigChannel.max_chans_per_user = 15; |
1863 |
|
ConfigChannel.quiet_on_ban = YES; |
1864 |
|
ConfigChannel.max_bans = 25; |
1922 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1923 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT; |
1924 |
|
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; /* XXX */ |
1925 |
< |
ConfigFileEntry.oper_umodes = UMODE_LOCOPS | UMODE_SERVNOTICE | |
1925 |
> |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1926 |
|
UMODE_OPERWALL | UMODE_WALLOP; /* XXX */ |
1927 |
|
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1928 |
|
#ifdef HAVE_LIBCRYPTO |
1953 |
|
static void |
1954 |
|
read_conf(FBFILE *file) |
1955 |
|
{ |
1956 |
< |
scount = lineno = 0; |
1956 |
> |
lineno = 0; |
1957 |
|
|
1958 |
|
set_default_conf(); /* Set default values prior to conf parsing */ |
1959 |
|
ypass = 1; |
2265 |
|
} |
2266 |
|
} |
2267 |
|
|
2268 |
+ |
dlinkDelete(ptr, tklist); |
2269 |
|
delete_one_address_conf(aconf->host, aconf); |
2271 |
– |
dlinkDelete(ptr, tklist); |
2270 |
|
} |
2271 |
|
} |
2272 |
|
else if (conf->type == XLINE_TYPE || |
2330 |
|
|
2331 |
|
/* oper_privs_as_string() |
2332 |
|
* |
2333 |
< |
* inputs - pointer to client_p or NULL |
2333 |
> |
* inputs - pointer to client_p |
2334 |
|
* output - pointer to static string showing oper privs |
2335 |
|
* side effects - return as string, the oper privs as derived from port |
2336 |
|
*/ |
2337 |
< |
|
2338 |
< |
static const unsigned int oper_flags_table[] = |
2339 |
< |
{ 'O', 'R', 'U', 'G', 'N', 'K', 'X', 'D', 'H', 'A' , 0 }; |
2337 |
> |
static const struct oper_privs |
2338 |
> |
{ |
2339 |
> |
const unsigned int oprivs; |
2340 |
> |
const unsigned int hidden; |
2341 |
> |
const unsigned char c; |
2342 |
> |
} flag_list[] = { |
2343 |
> |
{ OPER_FLAG_ADMIN, OPER_FLAG_HIDDEN_ADMIN, 'A' }, |
2344 |
> |
{ OPER_FLAG_REMOTEBAN, 0, 'B' }, |
2345 |
> |
{ OPER_FLAG_DIE, 0, 'D' }, |
2346 |
> |
{ OPER_FLAG_GLINE, 0, 'G' }, |
2347 |
> |
{ OPER_FLAG_REHASH, 0, 'H' }, |
2348 |
> |
{ OPER_FLAG_K, 0, 'K' }, |
2349 |
> |
{ OPER_FLAG_OPERWALL, 0, 'L' }, |
2350 |
> |
{ OPER_FLAG_N, 0, 'N' }, |
2351 |
> |
{ OPER_FLAG_GLOBAL_KILL, 0, 'O' }, |
2352 |
> |
{ OPER_FLAG_REMOTE, 0, 'R' }, |
2353 |
> |
{ OPER_FLAG_OPER_SPY, 0, 'S' }, |
2354 |
> |
{ OPER_FLAG_UNKLINE, 0, 'U' }, |
2355 |
> |
{ OPER_FLAG_X, 0, 'X' }, |
2356 |
> |
{ 0, 0, '\0' } |
2357 |
> |
}; |
2358 |
|
|
2359 |
|
char * |
2360 |
|
oper_privs_as_string(const unsigned int port) |
2361 |
|
{ |
2362 |
< |
static char privs_out[12]; |
2362 |
> |
static char privs_out[16]; |
2363 |
> |
char *privs_ptr = privs_out; |
2364 |
> |
unsigned int i = 0; |
2365 |
> |
|
2366 |
> |
for (; flag_list[i].oprivs; ++i) |
2367 |
> |
{ |
2368 |
> |
if ((port & flag_list[i].oprivs) && |
2369 |
> |
(port & flag_list[i].hidden) == 0) |
2370 |
> |
*privs_ptr++ = flag_list[i].c; |
2371 |
> |
else |
2372 |
> |
*privs_ptr++ = ToLowerTab[flag_list[i].c]; |
2373 |
> |
} |
2374 |
> |
|
2375 |
> |
*privs_ptr = '\0'; |
2376 |
|
|
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); |
2377 |
|
return privs_out; |
2378 |
|
} |
2379 |
|
|
2480 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
2481 |
|
ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "", |
2482 |
|
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst"); |
2483 |
< |
add_isupport("CHANNELLEN", NULL, CHANNELLEN); |
2483 |
> |
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
2484 |
|
if (ConfigChannel.use_except) |
2485 |
|
add_isupport("EXCEPTS", "e", -1); |
2486 |
|
if (ConfigChannel.use_invex) |
2565 |
|
/* XXX This is less than pretty */ |
2566 |
|
if (conf->type == SERVER_TYPE) |
2567 |
|
{ |
2568 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2568 |
> |
aconf = map_to_conf(conf); |
2569 |
> |
|
2570 |
|
if (aconf->clients != 0) |
2571 |
|
{ |
2572 |
|
SetConfIllegal(aconf); |
2579 |
|
} |
2580 |
|
else if (conf->type == OPER_TYPE) |
2581 |
|
{ |
2582 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2582 |
> |
aconf = map_to_conf(conf); |
2583 |
> |
|
2584 |
|
if (aconf->clients != 0) |
2585 |
|
{ |
2586 |
|
SetConfIllegal(aconf); |
2593 |
|
} |
2594 |
|
else if (conf->type == CLIENT_TYPE) |
2595 |
|
{ |
2596 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2596 |
> |
aconf = map_to_conf(conf); |
2597 |
> |
|
2598 |
|
if (aconf->clients != 0) |
2599 |
|
{ |
2600 |
|
SetConfIllegal(aconf); |
2619 |
|
{ |
2620 |
|
if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE)) |
2621 |
|
{ |
2622 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
2623 |
< |
if ((match_item->ref_count <= 0)) |
2622 |
> |
match_item = map_to_conf(conf); |
2623 |
> |
if (match_item->ref_count <= 0) |
2624 |
|
delete_conf_item(conf); |
2625 |
|
else |
2626 |
|
{ |
2634 |
|
} |
2635 |
|
} |
2636 |
|
|
2637 |
< |
/* don't delete the class table, rather mark all entries |
2637 |
> |
/* |
2638 |
> |
* don't delete the class table, rather mark all entries |
2639 |
|
* for deletion. The table is cleaned up by check_class. - avalon |
2640 |
|
*/ |
2641 |
|
DLINK_FOREACH(ptr, class_items.head) |
2642 |
|
{ |
2643 |
< |
conf = ptr->data; |
2644 |
< |
cltmp = (struct ClassItem *)map_to_conf(conf); |
2643 |
> |
cltmp = map_to_conf(ptr->data); |
2644 |
> |
|
2645 |
|
if (ptr != class_items.tail) /* never mark the "default" class */ |
2646 |
< |
MaxTotal(cltmp) = -1; |
2646 |
> |
cltmp->active = 0; |
2647 |
|
} |
2648 |
|
|
2649 |
|
clear_out_address_conf(); |
2716 |
|
struct ConfItem *conf; |
2717 |
|
struct AccessItem *aconf; |
2718 |
|
dlink_list * free_items [] = { |
2719 |
< |
&server_items, &oconf_items, &hub_items, &leaf_items, NULL |
2719 |
> |
&server_items, &oconf_items, NULL |
2720 |
|
}; |
2721 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
2722 |
|
|
2893 |
|
struct ConfItem *conf; |
2894 |
|
|
2895 |
|
if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL) |
2896 |
< |
return(conf); |
2896 |
> |
return conf; |
2897 |
|
|
2898 |
|
return class_default; |
2899 |
|
} |
2907 |
|
void |
2908 |
|
check_class(void) |
2909 |
|
{ |
2910 |
< |
dlink_node *ptr; |
2882 |
< |
dlink_node *next_ptr; |
2883 |
< |
struct ConfItem *conf; |
2884 |
< |
struct ClassItem *aclass; |
2910 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
2911 |
|
|
2912 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head) |
2913 |
|
{ |
2914 |
< |
conf = ptr->data; |
2889 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
2914 |
> |
struct ClassItem *aclass = map_to_conf(ptr->data); |
2915 |
|
|
2916 |
< |
if (MaxTotal(aclass) < 0) |
2916 |
> |
if (!aclass->active && !CurrUserCount(aclass)) |
2917 |
|
{ |
2918 |
|
destroy_cidr_class(aclass); |
2919 |
< |
if (CurrUserCount(aclass) > 0) |
2895 |
< |
dlinkDelete(&conf->node, &class_items); |
2896 |
< |
else |
2897 |
< |
delete_conf_item(conf); |
2919 |
> |
delete_conf_item(ptr->data); |
2920 |
|
} |
2921 |
|
} |
2922 |
|
} |
2933 |
|
struct ClassItem *aclass; |
2934 |
|
|
2935 |
|
class_default = make_conf_item(CLASS_TYPE); |
2936 |
< |
aclass = (struct ClassItem *)map_to_conf(class_default); |
2936 |
> |
|
2937 |
> |
aclass = map_to_conf(class_default); |
2938 |
> |
aclass->active = 1; |
2939 |
|
DupString(class_default->name, "default"); |
2940 |
|
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
2941 |
|
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
2994 |
|
void |
2995 |
|
conf_add_class_to_conf(struct ConfItem *conf, const char *class_name) |
2996 |
|
{ |
2997 |
< |
struct AccessItem *aconf; |
2998 |
< |
struct ClassItem *aclass; |
2975 |
< |
|
2976 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2997 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
2998 |
> |
struct ClassItem *class = NULL; |
2999 |
|
|
3000 |
|
if (class_name == NULL) |
3001 |
|
{ |
3002 |
|
aconf->class_ptr = class_default; |
3003 |
+ |
|
3004 |
|
if (conf->type == CLIENT_TYPE) |
3005 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
3006 |
|
"Warning *** Defaulting to default class for %s@%s", |
3011 |
|
conf->name); |
3012 |
|
} |
3013 |
|
else |
2991 |
– |
{ |
3014 |
|
aconf->class_ptr = find_class(class_name); |
2993 |
– |
} |
3015 |
|
|
3016 |
< |
if (aconf->class_ptr == NULL) |
3016 |
> |
if (aconf->class_ptr) |
3017 |
> |
class = map_to_conf(aconf->class_ptr); |
3018 |
> |
|
3019 |
> |
if (aconf->class_ptr == NULL || !class->active) |
3020 |
|
{ |
3021 |
|
if (conf->type == CLIENT_TYPE) |
3022 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
3028 |
|
conf->name); |
3029 |
|
aconf->class_ptr = class_default; |
3030 |
|
} |
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 |
– |
} |
3031 |
|
} |
3032 |
|
|
3017 |
– |
#define MAXCONFLINKS 150 |
3018 |
– |
|
3033 |
|
/* conf_add_server() |
3034 |
|
* |
3035 |
|
* inputs - pointer to config item |
3038 |
|
* side effects - Add a connect block |
3039 |
|
*/ |
3040 |
|
int |
3041 |
< |
conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name) |
3041 |
> |
conf_add_server(struct ConfItem *conf, const char *class_name) |
3042 |
|
{ |
3043 |
|
struct AccessItem *aconf; |
3044 |
< |
char *orig_host; |
3044 |
> |
struct split_nuh_item nuh; |
3045 |
> |
char conf_user[USERLEN + 1]; |
3046 |
> |
char conf_host[HOSTLEN + 1]; |
3047 |
|
|
3048 |
|
aconf = map_to_conf(conf); |
3049 |
|
|
3050 |
|
conf_add_class_to_conf(conf, class_name); |
3051 |
|
|
3052 |
< |
if (lcount > MAXCONFLINKS || !aconf->host || !conf->name) |
3052 |
> |
if (!aconf->host || !conf->name) |
3053 |
|
{ |
3054 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block"); |
3055 |
|
ilog(L_WARN, "Bad connect block"); |
3064 |
|
return -1; |
3065 |
|
} |
3066 |
|
|
3067 |
< |
orig_host = aconf->host; |
3068 |
< |
split_nuh(orig_host, NULL, &aconf->user, &aconf->host); |
3069 |
< |
MyFree(orig_host); |
3067 |
> |
nuh.nuhmask = aconf->host; |
3068 |
> |
nuh.nickptr = NULL; |
3069 |
> |
nuh.userptr = conf_user; |
3070 |
> |
nuh.hostptr = conf_host; |
3071 |
> |
|
3072 |
> |
nuh.nicksize = 0; |
3073 |
> |
nuh.usersize = sizeof(conf_user); |
3074 |
> |
nuh.hostsize = sizeof(conf_host); |
3075 |
> |
|
3076 |
> |
split_nuh(&nuh); |
3077 |
> |
|
3078 |
> |
MyFree(aconf->host); |
3079 |
> |
aconf->host = NULL; |
3080 |
> |
|
3081 |
> |
DupString(aconf->user, conf_user); /* somehow username checking for servers |
3082 |
> |
got lost in H6/7, will have to be re-added */ |
3083 |
> |
DupString(aconf->host, conf_host); |
3084 |
> |
|
3085 |
|
lookup_confhost(conf); |
3086 |
|
|
3087 |
|
return 0; |
3441 |
|
{ |
3442 |
|
/* Explicit user@host mask given */ |
3443 |
|
|
3444 |
< |
if(hostp != NULL) /* I'm a little user@host */ |
3444 |
> |
if (hostp != NULL) /* I'm a little user@host */ |
3445 |
|
{ |
3446 |
|
*(hostp++) = '\0'; /* short and squat */ |
3447 |
|
if (*user_host_or_nick) |
3572 |
|
*/ |
3573 |
|
void |
3574 |
|
cluster_a_line(struct Client *source_p, const char *command, |
3575 |
< |
int capab, int cluster_type, const char *pattern, ...) |
3575 |
> |
int capab, int cluster_type, const char *pattern, ...) |
3576 |
|
{ |
3577 |
|
va_list args; |
3578 |
|
char buffer[IRCD_BUFSIZE]; |
3579 |
< |
struct ConfItem *conf; |
3549 |
< |
dlink_node *ptr; |
3579 |
> |
const dlink_node *ptr = NULL; |
3580 |
|
|
3581 |
|
va_start(args, pattern); |
3582 |
|
vsnprintf(buffer, sizeof(buffer), pattern, args); |
3584 |
|
|
3585 |
|
DLINK_FOREACH(ptr, cluster_items.head) |
3586 |
|
{ |
3587 |
< |
conf = ptr->data; |
3587 |
> |
const struct ConfItem *conf = ptr->data; |
3588 |
|
|
3589 |
|
if (conf->flags & cluster_type) |
3560 |
– |
{ |
3590 |
|
sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab, |
3591 |
|
"%s %s %s", command, conf->name, buffer); |
3563 |
– |
} |
3592 |
|
} |
3593 |
|
} |
3594 |
|
|
3620 |
|
* @ * * * |
3621 |
|
* ! * * * |
3622 |
|
*/ |
3595 |
– |
|
3623 |
|
void |
3624 |
< |
split_nuh(char *mask, char **nick, char **user, char **host) |
3624 |
> |
split_nuh(struct split_nuh_item *const iptr) |
3625 |
|
{ |
3626 |
|
char *p = NULL, *q = NULL; |
3627 |
|
|
3628 |
< |
if ((p = strchr(mask, '!')) != NULL) |
3628 |
> |
if (iptr->nickptr) |
3629 |
> |
strlcpy(iptr->nickptr, "*", iptr->nicksize); |
3630 |
> |
if (iptr->userptr) |
3631 |
> |
strlcpy(iptr->userptr, "*", iptr->usersize); |
3632 |
> |
if (iptr->hostptr) |
3633 |
> |
strlcpy(iptr->hostptr, "*", iptr->hostsize); |
3634 |
> |
|
3635 |
> |
if ((p = strchr(iptr->nuhmask, '!'))) |
3636 |
|
{ |
3637 |
|
*p = '\0'; |
3604 |
– |
if (nick != NULL) |
3605 |
– |
{ |
3606 |
– |
if (*mask != '\0') |
3607 |
– |
*nick = xstrldup(mask, NICKLEN); |
3608 |
– |
else |
3609 |
– |
DupString(*nick, "*"); |
3610 |
– |
} |
3638 |
|
|
3639 |
< |
if ((q = strchr(++p, '@')) != NULL) |
3640 |
< |
{ |
3641 |
< |
*q = '\0'; |
3639 |
> |
if (iptr->nickptr && *iptr->nuhmask != '\0') |
3640 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
3641 |
> |
|
3642 |
> |
if ((q = strchr(++p, '@'))) { |
3643 |
> |
*q++ = '\0'; |
3644 |
|
|
3645 |
|
if (*p != '\0') |
3646 |
< |
*user = xstrldup(p, USERLEN+1); |
3618 |
< |
else |
3619 |
< |
DupString(*user, "*"); |
3646 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
3647 |
|
|
3648 |
< |
if (*++q != '\0') |
3649 |
< |
*host = xstrldup(q, HOSTLEN+1); |
3623 |
< |
else |
3624 |
< |
DupString(*host, "*"); |
3648 |
> |
if (*q != '\0') |
3649 |
> |
strlcpy(iptr->hostptr, q, iptr->hostsize); |
3650 |
|
} |
3651 |
|
else |
3652 |
|
{ |
3653 |
|
if (*p != '\0') |
3654 |
< |
*user = xstrldup(p, USERLEN+1); |
3630 |
< |
else |
3631 |
< |
DupString(*user, "*"); |
3632 |
< |
|
3633 |
< |
DupString(*host, "*"); |
3654 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
3655 |
|
} |
3656 |
|
} |
3657 |
< |
else /* No ! found so lets look for a user@host */ |
3657 |
> |
else |
3658 |
|
{ |
3659 |
< |
if ((p = strchr(mask, '@')) != NULL) /* if found a @ */ |
3659 |
> |
/* No ! found so lets look for a user@host */ |
3660 |
> |
if ((p = strchr(iptr->nuhmask, '@'))) |
3661 |
|
{ |
3662 |
< |
if (nick != NULL) |
3663 |
< |
DupString(*nick, "*"); |
3642 |
< |
*p = '\0'; |
3662 |
> |
/* if found a @ */ |
3663 |
> |
*p++ = '\0'; |
3664 |
|
|
3665 |
< |
if (*mask != '\0') |
3666 |
< |
*user = xstrldup(mask, USERLEN+1); |
3646 |
< |
else |
3647 |
< |
DupString(*user, "*"); |
3665 |
> |
if (*iptr->nuhmask != '\0') |
3666 |
> |
strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize); |
3667 |
|
|
3668 |
< |
if (*++p != '\0') |
3669 |
< |
*host = xstrldup(p, HOSTLEN+1); |
3651 |
< |
else |
3652 |
< |
DupString(*host, "*"); |
3668 |
> |
if (*p != '\0') |
3669 |
> |
strlcpy(iptr->hostptr, p, iptr->hostsize); |
3670 |
|
} |
3671 |
< |
else /* no @ found */ |
3671 |
> |
else |
3672 |
|
{ |
3673 |
< |
if (nick != NULL) |
3674 |
< |
{ |
3675 |
< |
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 |
< |
} |
3673 |
> |
/* no @ found */ |
3674 |
> |
if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:")) |
3675 |
> |
strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize); |
3676 |
|
else |
3677 |
< |
{ |
3673 |
< |
DupString(*user, "*"); |
3674 |
< |
*host = xstrldup(mask, HOSTLEN+1); |
3675 |
< |
} |
3677 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
3678 |
|
} |
3679 |
|
} |
3680 |
|
} |
3701 |
|
{ |
3702 |
|
if (flags & mask) |
3703 |
|
*p++ = bit_table[i]; |
3704 |
< |
else if(lowerit) |
3704 |
> |
else if (lowerit) |
3705 |
|
*p++ = ToLower(bit_table[i]); |
3706 |
|
} |
3707 |
|
*p = '\0'; |
3908 |
|
static void |
3909 |
|
destroy_cidr_list(dlink_list *list) |
3910 |
|
{ |
3911 |
< |
dlink_node *ptr = NULL; |
3910 |
< |
dlink_node *next_ptr = NULL; |
3911 |
< |
struct CidrItem *cidr; |
3911 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
3912 |
|
|
3913 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) |
3914 |
|
{ |
3915 |
– |
cidr = ptr->data; |
3915 |
|
dlinkDelete(ptr, list); |
3916 |
< |
MyFree(cidr); |
3916 |
> |
MyFree(ptr->data); |
3917 |
|
} |
3918 |
|
} |
3919 |
|
|