1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (c) 1997-2016 ircd-hybrid development team |
4 |
> |
* Copyright (c) 1997-2018 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
28 |
|
#include "list.h" |
29 |
|
#include "ircd_defs.h" |
30 |
|
#include "conf.h" |
31 |
+ |
#include "conf_cluster.h" |
32 |
+ |
#include "conf_gecos.h" |
33 |
|
#include "conf_pseudo.h" |
34 |
+ |
#include "conf_resv.h" |
35 |
+ |
#include "conf_service.h" |
36 |
+ |
#include "conf_shared.h" |
37 |
|
#include "server.h" |
33 |
– |
#include "resv.h" |
38 |
|
#include "channel.h" |
39 |
|
#include "client.h" |
40 |
|
#include "event.h" |
60 |
|
#include "motd.h" |
61 |
|
#include "ipcache.h" |
62 |
|
#include "isupport.h" |
63 |
+ |
#include "whowas.h" |
64 |
|
|
65 |
|
|
66 |
|
struct config_channel_entry ConfigChannel; |
72 |
|
struct conf_parser_context conf_parser_ctx; |
73 |
|
|
74 |
|
/* general conf items link list root, other than k lines etc. */ |
75 |
< |
dlink_list service_items; |
71 |
< |
dlink_list server_items; |
72 |
< |
dlink_list cluster_items; |
75 |
> |
dlink_list connect_items; |
76 |
|
dlink_list operator_items; |
74 |
– |
dlink_list shared_items; |
75 |
– |
dlink_list gecos_items; |
76 |
– |
dlink_list nresv_items; |
77 |
– |
dlink_list cresv_items; |
77 |
|
|
78 |
|
extern unsigned int lineno; |
79 |
|
extern char linebuf[]; |
135 |
|
{ |
136 |
|
switch (type) |
137 |
|
{ |
139 |
– |
case CONF_XLINE: |
140 |
– |
return &gecos_items; |
141 |
– |
break; |
142 |
– |
case CONF_SHARED: |
143 |
– |
return &shared_items; |
144 |
– |
break; |
145 |
– |
case CONF_NRESV: |
146 |
– |
return &nresv_items; |
147 |
– |
break; |
148 |
– |
case CONF_CRESV: |
149 |
– |
return &cresv_items; |
150 |
– |
break; |
138 |
|
case CONF_OPER: |
139 |
|
return &operator_items; |
140 |
|
break; |
141 |
|
case CONF_SERVER: |
142 |
< |
return &server_items; |
156 |
< |
break; |
157 |
< |
case CONF_SERVICE: |
158 |
< |
return &service_items; |
159 |
< |
break; |
160 |
< |
case CONF_CLUSTER: |
161 |
< |
return &cluster_items; |
142 |
> |
return &connect_items; |
143 |
|
break; |
144 |
|
default: |
145 |
|
return NULL; |
204 |
|
free_dlink_node(node); |
205 |
|
} |
206 |
|
|
226 |
– |
DLINK_FOREACH_SAFE(node, node_next, conf->exempt_list.head) |
227 |
– |
{ |
228 |
– |
struct exempt *exptr = node->data; |
229 |
– |
|
230 |
– |
dlinkDelete(node, &conf->exempt_list); |
231 |
– |
xfree(exptr->name); |
232 |
– |
xfree(exptr->user); |
233 |
– |
xfree(exptr->host); |
234 |
– |
xfree(exptr); |
235 |
– |
} |
236 |
– |
|
207 |
|
xfree(conf); |
208 |
|
} |
209 |
|
|
220 |
|
const struct ClassItem *const class = conf->class; |
221 |
|
struct ip_entry *ip_found; |
222 |
|
int a_limit_reached = 0; |
223 |
< |
unsigned int local = 0, global = 0, ident = 0; |
223 |
> |
unsigned int local = 0, global = 0; |
224 |
|
|
225 |
|
ip_found = ipcache_find_or_add_address(&client_p->connection->ip); |
226 |
|
ip_found->count++; |
227 |
|
AddFlag(client_p, FLAGS_IPHASH); |
228 |
|
|
229 |
< |
userhost_count(client_p->username, client_p->host, |
260 |
< |
&global, &local, &ident); |
229 |
> |
userhost_count(client_p->sockhost, &global, &local); |
230 |
|
|
231 |
|
/* XXX blah. go down checking the various silly limits |
232 |
|
* setting a_limit_reached if any limit is reached. |
236 |
|
a_limit_reached = 1; |
237 |
|
else if (class->max_perip && ip_found->count > class->max_perip) |
238 |
|
a_limit_reached = 1; |
239 |
< |
else if (class->max_local && local >= class->max_local) |
239 |
> |
else if (class->max_local && local >= class->max_local) /* XXX: redundant */ |
240 |
|
a_limit_reached = 1; |
241 |
|
else if (class->max_global && global >= class->max_global) |
242 |
|
a_limit_reached = 1; |
274 |
– |
else if (class->max_ident && ident >= class->max_ident && |
275 |
– |
client_p->username[0] != '~') |
276 |
– |
a_limit_reached = 1; |
243 |
|
|
244 |
|
if (a_limit_reached) |
245 |
|
{ |
250 |
|
"but you have exceed_limit = yes;"); |
251 |
|
} |
252 |
|
|
253 |
< |
return attach_conf(client_p, conf); |
253 |
> |
return conf_attach(client_p, conf); |
254 |
|
} |
255 |
|
|
256 |
|
/* verify_access() |
340 |
|
case TOO_MANY: |
341 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
342 |
|
"Too many on IP for %s (%s).", |
343 |
< |
get_client_name(source_p, SHOW_IP), |
343 |
> |
client_get_name(source_p, SHOW_IP), |
344 |
|
source_p->sockhost); |
345 |
|
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
346 |
< |
get_client_name(source_p, SHOW_IP)); |
346 |
> |
client_get_name(source_p, SHOW_IP)); |
347 |
|
++ServerStats.is_ref; |
348 |
|
exit_client(source_p, "No more connections allowed on that IP"); |
349 |
|
break; |
351 |
|
case I_LINE_FULL: |
352 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
353 |
|
"auth {} block is full for %s (%s).", |
354 |
< |
get_client_name(source_p, SHOW_IP), |
354 |
> |
client_get_name(source_p, SHOW_IP), |
355 |
|
source_p->sockhost); |
356 |
|
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
357 |
< |
get_client_name(source_p, SHOW_IP)); |
357 |
> |
client_get_name(source_p, SHOW_IP)); |
358 |
|
++ServerStats.is_ref; |
359 |
|
exit_client(source_p, "No more connections allowed in your connection class"); |
360 |
|
break; |
363 |
|
/* jdc - lists server name & port connections are on */ |
364 |
|
/* a purely cosmetical change */ |
365 |
|
sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE, |
366 |
< |
"Unauthorized client connection from %s [%s] on [%s/%u].", |
367 |
< |
get_client_name(source_p, SHOW_IP), |
402 |
< |
source_p->sockhost, |
366 |
> |
"Unauthorized client connection from %s on [%s/%u].", |
367 |
> |
client_get_name(source_p, SHOW_IP), |
368 |
|
source_p->connection->listener->name, |
369 |
|
source_p->connection->listener->port); |
370 |
|
ilog(LOG_TYPE_IRCD, "Unauthorized client connection from %s on [%s/%u].", |
371 |
< |
get_client_name(source_p, SHOW_IP), |
371 |
> |
client_get_name(source_p, SHOW_IP), |
372 |
|
source_p->connection->listener->name, |
373 |
|
source_p->connection->listener->port); |
374 |
|
|
389 |
|
return !(i < 0); |
390 |
|
} |
391 |
|
|
392 |
< |
/* detach_conf() |
393 |
< |
* |
394 |
< |
* inputs - pointer to client to detach |
395 |
< |
* - type of conf to detach |
431 |
< |
* output - 0 for success, -1 for failure |
432 |
< |
* side effects - Disassociate configuration from the client. |
433 |
< |
* Also removes a class from the list if marked for deleting. |
392 |
> |
/*! \brief Disassociate configuration from the client. Also removes a class |
393 |
> |
* from the list if marked for deleting. |
394 |
> |
* \param client_p Client to operate on |
395 |
> |
* \param type Type of conf to detach |
396 |
|
*/ |
397 |
|
void |
398 |
< |
detach_conf(struct Client *client_p, enum maskitem_type type) |
398 |
> |
conf_detach(struct Client *client_p, enum maskitem_type type) |
399 |
|
{ |
400 |
< |
dlink_node *node = NULL, *node_next = NULL; |
400 |
> |
dlink_node *node, *node_next; |
401 |
|
|
402 |
|
DLINK_FOREACH_SAFE(node, node_next, client_p->connection->confs.head) |
403 |
|
{ |
427 |
|
} |
428 |
|
} |
429 |
|
|
430 |
< |
/* attach_conf() |
431 |
< |
* |
432 |
< |
* inputs - client pointer |
433 |
< |
* - conf pointer |
434 |
< |
* output - |
473 |
< |
* side effects - Associate a specific configuration entry to a *local* |
474 |
< |
* client (this is the one which used in accepting the |
475 |
< |
* connection). Note, that this automatically changes the |
476 |
< |
* attachment if there was an old one... |
430 |
> |
/*! \brief Associate a specific configuration entry to a *local* client (this |
431 |
> |
* is the one which used in accepting the connection). Note, that this |
432 |
> |
* automatically changes the attachment if there was an old one. |
433 |
> |
* \param client_p Client to attach the conf to |
434 |
> |
* \param conf Configuration record to attach |
435 |
|
*/ |
436 |
|
int |
437 |
< |
attach_conf(struct Client *client_p, struct MaskItem *conf) |
437 |
> |
conf_attach(struct Client *client_p, struct MaskItem *conf) |
438 |
|
{ |
439 |
|
if (dlinkFind(&client_p->connection->confs, conf)) |
440 |
|
return 1; |
452 |
|
return 0; |
453 |
|
} |
454 |
|
|
497 |
– |
/* attach_connect_block() |
498 |
– |
* |
499 |
– |
* inputs - pointer to server to attach |
500 |
– |
* - name of server |
501 |
– |
* - hostname of server |
502 |
– |
* output - true (1) if both are found, otherwise return false (0) |
503 |
– |
* side effects - find connect block and attach them to connecting client |
504 |
– |
*/ |
505 |
– |
int |
506 |
– |
attach_connect_block(struct Client *client_p, const char *name, |
507 |
– |
const char *host) |
508 |
– |
{ |
509 |
– |
dlink_node *node = NULL; |
510 |
– |
|
511 |
– |
assert(host); |
512 |
– |
|
513 |
– |
DLINK_FOREACH(node, server_items.head) |
514 |
– |
{ |
515 |
– |
struct MaskItem *conf = node->data; |
516 |
– |
|
517 |
– |
if (match(conf->name, name) || match(conf->host, host)) |
518 |
– |
continue; |
519 |
– |
|
520 |
– |
attach_conf(client_p, conf); |
521 |
– |
return 1; |
522 |
– |
} |
523 |
– |
|
524 |
– |
return 0; |
525 |
– |
} |
526 |
– |
|
455 |
|
/* find_conf_name() |
456 |
|
* |
457 |
|
* inputs - pointer to conf link list to search |
480 |
|
return NULL; |
481 |
|
} |
482 |
|
|
483 |
< |
/* find_matching_name_conf() |
484 |
< |
* |
485 |
< |
* inputs - type of link list to look in |
558 |
< |
* - pointer to name string to find |
559 |
< |
* - pointer to user |
560 |
< |
* - pointer to host |
561 |
< |
* - optional flags to match on as well |
562 |
< |
* output - NULL or pointer to found struct MaskItem |
563 |
< |
* side effects - looks for a match on name field |
483 |
> |
/*! \brief Find a connect {} conf that has a name that matches \a name. |
484 |
> |
* \param name Name to match |
485 |
> |
* \param compare Pointer to function to be used for string matching |
486 |
|
*/ |
487 |
|
struct MaskItem * |
488 |
< |
find_matching_name_conf(enum maskitem_type type, const char *name, const char *user, |
567 |
< |
const char *host, unsigned int flags) |
488 |
> |
connect_find(const char *name, int (*compare)(const char *, const char *)) |
489 |
|
{ |
490 |
< |
dlink_node *node = NULL; |
570 |
< |
dlink_list *list = map_to_list(type); |
571 |
< |
struct MaskItem *conf = NULL; |
490 |
> |
dlink_node *node; |
491 |
|
|
492 |
< |
switch (type) |
492 |
> |
DLINK_FOREACH(node, connect_items.head) |
493 |
|
{ |
494 |
< |
case CONF_SERVICE: |
576 |
< |
DLINK_FOREACH(node, list->head) |
577 |
< |
{ |
578 |
< |
conf = node->data; |
579 |
< |
|
580 |
< |
if (EmptyString(conf->name)) |
581 |
< |
continue; |
582 |
< |
if (name && !irccmp(name, conf->name)) |
583 |
< |
return conf; |
584 |
< |
} |
585 |
< |
break; |
586 |
< |
|
587 |
< |
case CONF_XLINE: |
588 |
< |
case CONF_SHARED: |
589 |
< |
case CONF_NRESV: |
590 |
< |
case CONF_CRESV: |
591 |
< |
DLINK_FOREACH(node, list->head) |
592 |
< |
{ |
593 |
< |
conf = node->data; |
594 |
< |
|
595 |
< |
if (EmptyString(conf->name)) |
596 |
< |
continue; |
597 |
< |
if (name && !match(conf->name, name)) |
598 |
< |
{ |
599 |
< |
if ((user == NULL && (host == NULL))) |
600 |
< |
return conf; |
601 |
< |
if ((conf->modes & flags) != flags) |
602 |
< |
continue; |
603 |
< |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
604 |
< |
return conf; |
605 |
< |
if (!match(conf->user, user) && !match(conf->host, host)) |
606 |
< |
return conf; |
607 |
< |
} |
608 |
< |
} |
609 |
< |
break; |
610 |
< |
|
611 |
< |
case CONF_SERVER: |
612 |
< |
DLINK_FOREACH(node, list->head) |
613 |
< |
{ |
614 |
< |
conf = node->data; |
615 |
< |
|
616 |
< |
if (name && !match(name, conf->name)) |
617 |
< |
return conf; |
618 |
< |
if (host && !match(host, conf->host)) |
619 |
< |
return conf; |
620 |
< |
} |
621 |
< |
break; |
494 |
> |
struct MaskItem *conf = node->data; |
495 |
|
|
496 |
< |
default: |
497 |
< |
break; |
496 |
> |
if (!compare(name, conf->name)) |
497 |
> |
return conf; |
498 |
|
} |
499 |
+ |
|
500 |
|
return NULL; |
501 |
|
} |
502 |
|
|
510 |
|
* side effects - looks for an exact match on name field |
511 |
|
*/ |
512 |
|
struct MaskItem * |
513 |
< |
find_exact_name_conf(enum maskitem_type type, const struct Client *who, const char *name, |
640 |
< |
const char *user, const char *host) |
513 |
> |
operator_find(const struct Client *who, const char *name) |
514 |
|
{ |
515 |
|
dlink_node *node = NULL; |
643 |
– |
dlink_list *list = map_to_list(type); |
644 |
– |
struct MaskItem *conf = NULL; |
516 |
|
|
517 |
< |
switch(type) |
517 |
> |
DLINK_FOREACH(node, operator_items.head) |
518 |
|
{ |
519 |
< |
case CONF_XLINE: |
649 |
< |
case CONF_SHARED: |
650 |
< |
case CONF_NRESV: |
651 |
< |
case CONF_CRESV: |
652 |
< |
|
653 |
< |
DLINK_FOREACH(node, list->head) |
654 |
< |
{ |
655 |
< |
conf = node->data; |
656 |
< |
|
657 |
< |
if (EmptyString(conf->name)) |
658 |
< |
continue; |
659 |
< |
|
660 |
< |
if (irccmp(conf->name, name) == 0) |
661 |
< |
{ |
662 |
< |
if ((user == NULL && (host == NULL))) |
663 |
< |
return conf; |
664 |
< |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
665 |
< |
return conf; |
666 |
< |
if (!match(conf->user, user) && !match(conf->host, host)) |
667 |
< |
return conf; |
668 |
< |
} |
669 |
< |
} |
670 |
< |
break; |
519 |
> |
struct MaskItem *conf = node->data; |
520 |
|
|
521 |
< |
case CONF_OPER: |
673 |
< |
DLINK_FOREACH(node, list->head) |
521 |
> |
if (!irccmp(conf->name, name)) |
522 |
|
{ |
523 |
< |
conf = node->data; |
524 |
< |
|
677 |
< |
if (EmptyString(conf->name)) |
678 |
< |
continue; |
523 |
> |
if (!who) |
524 |
> |
return conf; |
525 |
|
|
526 |
< |
if (!irccmp(conf->name, name)) |
526 |
> |
if (!match(conf->user, who->username)) |
527 |
|
{ |
528 |
< |
if (!who) |
683 |
< |
return conf; |
684 |
< |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
685 |
< |
return NULL; |
686 |
< |
if (!match(conf->user, who->username)) |
528 |
> |
switch (conf->htype) |
529 |
|
{ |
530 |
< |
switch (conf->htype) |
531 |
< |
{ |
532 |
< |
case HM_HOST: |
533 |
< |
if (!match(conf->host, who->host) || !match(conf->host, who->sockhost)) |
530 |
> |
case HM_HOST: |
531 |
> |
if (!match(conf->host, who->host) || !match(conf->host, who->sockhost)) |
532 |
> |
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
533 |
> |
return conf; |
534 |
> |
break; |
535 |
> |
case HM_IPV4: |
536 |
> |
if (who->connection->aftype == AF_INET) |
537 |
> |
if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits)) |
538 |
|
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
539 |
|
return conf; |
540 |
< |
break; |
541 |
< |
case HM_IPV4: |
542 |
< |
if (who->connection->aftype == AF_INET) |
543 |
< |
if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits)) |
544 |
< |
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
545 |
< |
return conf; |
546 |
< |
break; |
547 |
< |
case HM_IPV6: |
548 |
< |
if (who->connection->aftype == AF_INET6) |
703 |
< |
if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits)) |
704 |
< |
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
705 |
< |
return conf; |
706 |
< |
break; |
707 |
< |
default: |
708 |
< |
assert(0); |
709 |
< |
} |
540 |
> |
break; |
541 |
> |
case HM_IPV6: |
542 |
> |
if (who->connection->aftype == AF_INET6) |
543 |
> |
if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits)) |
544 |
> |
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
545 |
> |
return conf; |
546 |
> |
break; |
547 |
> |
default: |
548 |
> |
assert(0); |
549 |
|
} |
550 |
|
} |
551 |
|
} |
713 |
– |
|
714 |
– |
break; |
715 |
– |
|
716 |
– |
case CONF_SERVER: |
717 |
– |
DLINK_FOREACH(node, list->head) |
718 |
– |
{ |
719 |
– |
conf = node->data; |
720 |
– |
|
721 |
– |
if (EmptyString(conf->name)) |
722 |
– |
continue; |
723 |
– |
|
724 |
– |
if (name == NULL) |
725 |
– |
{ |
726 |
– |
if (EmptyString(conf->host)) |
727 |
– |
continue; |
728 |
– |
if (irccmp(conf->host, host) == 0) |
729 |
– |
return conf; |
730 |
– |
} |
731 |
– |
else if (irccmp(conf->name, name) == 0) |
732 |
– |
return conf; |
733 |
– |
} |
734 |
– |
|
735 |
– |
break; |
736 |
– |
|
737 |
– |
default: |
738 |
– |
break; |
552 |
|
} |
553 |
|
|
554 |
|
return NULL; |
592 |
|
ConfigChannel.invite_client_count = 10; |
593 |
|
ConfigChannel.invite_client_time = 300; |
594 |
|
ConfigChannel.invite_delay_channel = 5; |
595 |
+ |
ConfigChannel.invite_expire_time = 1800; |
596 |
|
ConfigChannel.knock_client_count = 1; |
597 |
|
ConfigChannel.knock_client_time = 300; |
598 |
|
ConfigChannel.knock_delay_channel = 60; |
599 |
|
ConfigChannel.max_channels = 25; |
600 |
< |
ConfigChannel.max_bans = 25; |
600 |
> |
ConfigChannel.max_invites = 20; |
601 |
> |
ConfigChannel.max_bans = 100; |
602 |
> |
ConfigChannel.max_bans_large = 500; |
603 |
|
ConfigChannel.default_join_flood_count = 18; |
604 |
|
ConfigChannel.default_join_flood_time = 6; |
605 |
|
|
615 |
|
ConfigGeneral.away_count = 2; |
616 |
|
ConfigGeneral.away_time = 10; |
617 |
|
ConfigGeneral.max_watch = 50; |
618 |
+ |
ConfigGeneral.whowas_history_length = 15000; |
619 |
|
ConfigGeneral.cycle_on_host_change = 1; |
620 |
|
ConfigGeneral.dline_min_cidr = 16; |
621 |
|
ConfigGeneral.dline_min_cidr6 = 48; |
627 |
|
ConfigGeneral.disable_auth = 0; |
628 |
|
ConfigGeneral.kill_chase_time_limit = 90; |
629 |
|
ConfigGeneral.default_floodcount = 8; |
630 |
+ |
ConfigGeneral.default_floodtime = 1; |
631 |
|
ConfigGeneral.failed_oper_notice = 1; |
632 |
|
ConfigGeneral.dots_in_ident = 0; |
633 |
|
ConfigGeneral.min_nonwildcard = 4; |
648 |
|
ConfigGeneral.stats_P_oper_only = 0; |
649 |
|
ConfigGeneral.stats_u_oper_only = 0; |
650 |
|
ConfigGeneral.caller_id_wait = 60; |
651 |
< |
ConfigGeneral.opers_bypass_callerid = 0; |
651 |
> |
ConfigGeneral.opers_bypass_callerid = 1; |
652 |
|
ConfigGeneral.pace_wait = 10; |
653 |
|
ConfigGeneral.pace_wait_simple = 1; |
654 |
|
ConfigGeneral.short_motd = 0; |
682 |
|
static void |
683 |
|
read_conf(FILE *file) |
684 |
|
{ |
685 |
< |
lineno = 0; |
685 |
> |
lineno = 1; |
686 |
|
|
687 |
|
set_default_conf(); /* Set default values prior to conf parsing */ |
688 |
|
conf_parser_ctx.pass = 1; |
694 |
|
yyparse(); /* Load the values from the conf */ |
695 |
|
validate_conf(); /* Check to make sure some values are still okay. */ |
696 |
|
/* Some global values are also loaded here. */ |
697 |
+ |
whowas_trim(); /* Attempt to trim whowas list if necessary */ |
698 |
|
class_delete_marked(); /* Delete unused classes that are marked for deletion */ |
699 |
|
} |
700 |
|
|
708 |
|
conf_rehash(int sig) |
709 |
|
{ |
710 |
|
if (sig) |
711 |
+ |
{ |
712 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
713 |
|
"Got signal SIGHUP, reloading configuration file(s)"); |
714 |
+ |
ilog(LOG_TYPE_IRCD, "Got signal SIGHUP, reloading configuration file(s)"); |
715 |
+ |
} |
716 |
|
|
717 |
|
restart_resolver(); |
718 |
|
|
798 |
|
return 0; |
799 |
|
} |
800 |
|
|
979 |
– |
/* expire_tklines() |
980 |
– |
* |
981 |
– |
* inputs - tkline list pointer |
982 |
– |
* output - NONE |
983 |
– |
* side effects - expire tklines |
984 |
– |
*/ |
985 |
– |
static void |
986 |
– |
expire_tklines(dlink_list *list) |
987 |
– |
{ |
988 |
– |
dlink_node *node = NULL, *node_next = NULL; |
989 |
– |
|
990 |
– |
DLINK_FOREACH_SAFE(node, node_next, list->head) |
991 |
– |
{ |
992 |
– |
struct MaskItem *conf = node->data; |
993 |
– |
|
994 |
– |
if (!conf->until || conf->until > CurrentTime) |
995 |
– |
continue; |
996 |
– |
|
997 |
– |
if (ConfigGeneral.tkline_expire_notices) |
998 |
– |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "Temporary %s for [%s] expired", |
999 |
– |
(conf->type == CONF_XLINE) ? "X-line" : "RESV", conf->name); |
1000 |
– |
conf_free(conf); |
1001 |
– |
} |
1002 |
– |
} |
1003 |
– |
|
801 |
|
/* cleanup_tklines() |
802 |
|
* |
803 |
|
* inputs - NONE |
809 |
|
cleanup_tklines(void *unused) |
810 |
|
{ |
811 |
|
hostmask_expire_temporary(); |
812 |
< |
expire_tklines(&gecos_items); |
813 |
< |
expire_tklines(&nresv_items); |
1017 |
< |
expire_tklines(&cresv_items); |
812 |
> |
gecos_expire(); |
813 |
> |
resv_expire(); |
814 |
|
} |
815 |
|
|
816 |
|
/* oper_privs_as_string() |
819 |
|
* output - pointer to static string showing oper privs |
820 |
|
* side effects - return as string, the oper privs as derived from port |
821 |
|
*/ |
822 |
< |
static const struct oper_privs |
822 |
> |
static const struct oper_flags |
823 |
|
{ |
824 |
|
const unsigned int flag; |
825 |
|
const unsigned char c; |
826 |
< |
} flag_list[] = { |
826 |
> |
} flag_table[] = { |
827 |
|
{ OPER_FLAG_ADMIN, 'A' }, |
828 |
|
{ OPER_FLAG_CLOSE, 'B' }, |
829 |
|
{ OPER_FLAG_CONNECT, 'C' }, |
856 |
|
}; |
857 |
|
|
858 |
|
const char * |
859 |
< |
oper_privs_as_string(const unsigned int port) |
859 |
> |
oper_privs_as_string(const unsigned int flags) |
860 |
|
{ |
861 |
< |
static char privs_out[IRCD_BUFSIZE]; |
862 |
< |
char *privs_ptr = privs_out; |
861 |
> |
static char buf[sizeof(flag_table) / sizeof(flag_table[0])]; |
862 |
> |
char *p = buf; |
863 |
|
|
864 |
< |
for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv) |
865 |
< |
if (port & opriv->flag) |
866 |
< |
*privs_ptr++ = opriv->c; |
864 |
> |
for (const struct oper_flags *tab = flag_table; tab->flag; ++tab) |
865 |
> |
if (flags & tab->flag) |
866 |
> |
*p++ = tab->c; |
867 |
|
|
868 |
< |
if (privs_ptr == privs_out) |
869 |
< |
*privs_ptr++ = '0'; |
868 |
> |
if (p == buf) |
869 |
> |
*p++ = '0'; |
870 |
|
|
871 |
< |
*privs_ptr = '\0'; |
871 |
> |
*p = '\0'; |
872 |
|
|
873 |
< |
return privs_out; |
873 |
> |
return buf; |
874 |
|
} |
875 |
|
|
876 |
|
/* |
926 |
|
{ |
927 |
|
dlink_node *node = NULL, *node_next = NULL; |
928 |
|
dlink_list *free_items [] = { |
929 |
< |
&server_items, &operator_items, |
1134 |
< |
&shared_items, &gecos_items, |
1135 |
< |
&nresv_items, &cluster_items, &service_items, &cresv_items, NULL |
929 |
> |
&connect_items, &operator_items, NULL |
930 |
|
}; |
931 |
|
|
932 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
942 |
|
struct MaskItem *conf = node->data; |
943 |
|
|
944 |
|
conf->active = 0; |
945 |
+ |
dlinkDelete(&conf->node, *iterator); |
946 |
|
|
947 |
< |
if (!IsConfDatabase(conf)) |
948 |
< |
{ |
1154 |
< |
dlinkDelete(&conf->node, *iterator); |
1155 |
< |
|
1156 |
< |
if (!conf->ref_count) |
1157 |
< |
conf_free(conf); |
1158 |
< |
} |
947 |
> |
if (!conf->ref_count) |
948 |
> |
conf_free(conf); |
949 |
|
} |
950 |
|
} |
951 |
|
|
1162 |
– |
motd_clear(); |
1163 |
– |
|
952 |
|
/* |
953 |
|
* Don't delete the class table, rather mark all entries for deletion. |
954 |
|
* The table is cleaned up by class_delete_marked. - avalon |
957 |
|
|
958 |
|
clear_out_address_conf(); |
959 |
|
|
960 |
< |
/* Clean out module paths */ |
961 |
< |
mod_clear_paths(); |
960 |
> |
modules_conf_clear(); /* Clear modules {} items */ |
961 |
> |
|
962 |
> |
motd_clear(); /* Clear motd {} items and re-cache default motd */ |
963 |
> |
|
964 |
> |
cluster_clear(); /* Clear cluster {} items */ |
965 |
|
|
966 |
< |
pseudo_clear(); |
966 |
> |
gecos_clear(); /* Clear gecos {} items */ |
967 |
> |
|
968 |
> |
resv_clear(); /* Clear resv {} items */ |
969 |
> |
|
970 |
> |
service_clear(); /* Clear service {} items */ |
971 |
> |
|
972 |
> |
shared_clear(); /* Clear shared {} items */ |
973 |
> |
|
974 |
> |
pseudo_clear(); /* Clear pseudo {} items */ |
975 |
|
|
976 |
|
/* Clean out ConfigServerInfo */ |
977 |
|
xfree(ConfigServerInfo.description); |
980 |
|
ConfigServerInfo.network_name = NULL; |
981 |
|
xfree(ConfigServerInfo.network_desc); |
982 |
|
ConfigServerInfo.network_desc = NULL; |
1184 |
– |
|
983 |
|
xfree(ConfigServerInfo.rsa_private_key_file); |
984 |
|
ConfigServerInfo.rsa_private_key_file = NULL; |
985 |
|
xfree(ConfigServerInfo.ssl_certificate_file); |
1001 |
|
xfree(ConfigAdminInfo.description); |
1002 |
|
ConfigAdminInfo.description = NULL; |
1003 |
|
|
1004 |
+ |
/* Clean out ConfigServerHide */ |
1005 |
|
xfree(ConfigServerHide.flatten_links_file); |
1006 |
|
ConfigServerHide.flatten_links_file = NULL; |
1007 |
+ |
xfree(ConfigServerHide.hidden_name); |
1008 |
+ |
ConfigServerHide.hidden_name = NULL; |
1009 |
|
|
1010 |
|
/* Clean out listeners */ |
1011 |
|
listener_close_marked(); |
1019 |
|
if (cold) |
1020 |
|
{ |
1021 |
|
ilog(LOG_TYPE_IRCD, "Error while initializing TLS"); |
1022 |
< |
exit(-1); |
1022 |
> |
exit(EXIT_FAILURE); |
1023 |
|
} |
1024 |
|
else |
1025 |
|
{ |
1091 |
|
snprintf(chanlimit, sizeof(chanlimit), "#:%u", |
1092 |
|
ConfigChannel.max_channels); |
1093 |
|
isupport_add("CHANLIMIT", chanlimit, -1); |
1094 |
< |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORST"); |
1094 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstuCLMORST"); |
1095 |
|
isupport_add("CHANNELLEN", NULL, CHANNELLEN); |
1096 |
|
isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length); |
1097 |
|
isupport_add("CHANMODES", chanmodes, -1); |
1297 |
– |
|
1298 |
– |
/* |
1299 |
– |
* message_locale may have changed. rebuild isupport since it relies |
1300 |
– |
* on strlen(form_str(RPL_ISUPPORT)) |
1301 |
– |
*/ |
1302 |
– |
isupport_rebuild(); |
1098 |
|
} |
1099 |
|
|
1100 |
|
/* conf_add_class_to_conf() |
1130 |
|
void |
1131 |
|
yyerror(const char *msg) |
1132 |
|
{ |
1338 |
– |
char newlinebuf[IRCD_BUFSIZE]; |
1339 |
– |
|
1133 |
|
if (conf_parser_ctx.pass != 1) |
1134 |
|
return; |
1135 |
|
|
1136 |
< |
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
1136 |
> |
const char *p = stripws(linebuf); |
1137 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1138 |
|
"\"%s\", line %u: %s: %s", |
1139 |
< |
conffilebuf, lineno + 1, msg, newlinebuf); |
1139 |
> |
conffilebuf, lineno, msg, p); |
1140 |
|
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
1141 |
< |
conffilebuf, lineno + 1, msg, newlinebuf); |
1141 |
> |
conffilebuf, lineno, msg, p); |
1142 |
|
} |
1143 |
|
|
1144 |
|
void |
1145 |
|
conf_error_report(const char *msg) |
1146 |
|
{ |
1147 |
< |
char newlinebuf[IRCD_BUFSIZE]; |
1355 |
< |
|
1356 |
< |
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
1147 |
> |
const char *p = stripws(linebuf); |
1148 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1149 |
|
"\"%s\", line %u: %s: %s", |
1150 |
< |
conffilebuf, lineno + 1, msg, newlinebuf); |
1150 |
> |
conffilebuf, lineno, msg, p); |
1151 |
|
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
1152 |
< |
conffilebuf, lineno + 1, msg, newlinebuf); |
1152 |
> |
conffilebuf, lineno, msg, p); |
1153 |
|
} |
1154 |
|
|
1155 |
|
/* |
1162 |
|
* side effects - none |
1163 |
|
* Originally written by Dianora (Diane, db@db.net) |
1164 |
|
*/ |
1165 |
< |
time_t |
1165 |
> |
uintmax_t |
1166 |
|
valid_tkline(const char *data, const int minutes) |
1167 |
|
{ |
1168 |
|
const unsigned char *p = (const unsigned char *)data; |
1169 |
|
unsigned char tmpch = '\0'; |
1170 |
< |
time_t result = 0; |
1170 |
> |
uintmax_t result = 0; |
1171 |
|
|
1172 |
|
while ((tmpch = *p++)) |
1173 |
|
{ |
1243 |
|
* side effects - NOTICE is given to source_p if warn is 1 |
1244 |
|
*/ |
1245 |
|
int |
1246 |
< |
valid_wild_card(struct Client *source_p, int count, ...) |
1246 |
> |
valid_wild_card(int count, ...) |
1247 |
|
{ |
1248 |
|
unsigned char tmpch = '\0'; |
1249 |
|
unsigned int nonwild = 0; |
1286 |
|
} |
1287 |
|
} |
1288 |
|
|
1498 |
– |
if (IsClient(source_p)) |
1499 |
– |
sendto_one_notice(source_p, &me, |
1500 |
– |
":Please include at least %u non-wildcard characters with the mask", |
1501 |
– |
ConfigGeneral.min_nonwildcard); |
1289 |
|
va_end(args); |
1290 |
|
return 0; |
1291 |
|
} |
1402 |
|
int |
1403 |
|
parse_aline(const char *cmd, struct Client *source_p, |
1404 |
|
int parc, char **parv, |
1405 |
< |
int parse_flags, char **up_p, char **h_p, time_t *tkline_time, |
1405 |
> |
char **up_p, char **h_p, uintmax_t *tkline_time, |
1406 |
|
char **target_server, char **reason) |
1407 |
|
{ |
1408 |
< |
int found_tkline_time=0; |
1408 |
> |
uintmax_t found_tkline_time=0; |
1409 |
|
static char default_reason[] = CONF_NOREASON; |
1410 |
|
static char user[USERLEN*4+1]; |
1411 |
|
static char host[HOSTLEN*4+1]; |
1482 |
|
} |
1483 |
|
} |
1484 |
|
|
1698 |
– |
if (h_p) |
1699 |
– |
{ |
1700 |
– |
if (strchr(user, '!')) |
1701 |
– |
{ |
1702 |
– |
sendto_one_notice(source_p, &me, ":Invalid character '!' in kline"); |
1703 |
– |
return 0; |
1704 |
– |
} |
1705 |
– |
|
1706 |
– |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 2, *up_p, *h_p)) |
1707 |
– |
return 0; |
1708 |
– |
} |
1709 |
– |
else |
1710 |
– |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, *up_p)) |
1711 |
– |
return 0; |
1712 |
– |
|
1485 |
|
if (reason) |
1486 |
|
{ |
1487 |
|
if (parc && !EmptyString(*parv)) |
1517 |
|
} |
1518 |
|
|
1519 |
|
/* |
1748 |
– |
* cluster_a_line |
1749 |
– |
* |
1750 |
– |
* inputs - client sending the cluster |
1751 |
– |
* - command name "KLINE" "XLINE" etc. |
1752 |
– |
* - capab -- CAPAB_KLN etc. from server.h |
1753 |
– |
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
1754 |
– |
* - pattern and args to send along |
1755 |
– |
* output - none |
1756 |
– |
* side effects - Take source_p send the pattern with args given |
1757 |
– |
* along to all servers that match capab and cluster type |
1758 |
– |
*/ |
1759 |
– |
void |
1760 |
– |
cluster_a_line(struct Client *source_p, const char *command, unsigned int capab, |
1761 |
– |
unsigned int cluster_type, const char *pattern, ...) |
1762 |
– |
{ |
1763 |
– |
va_list args; |
1764 |
– |
char buffer[IRCD_BUFSIZE] = ""; |
1765 |
– |
const dlink_node *node = NULL; |
1766 |
– |
|
1767 |
– |
va_start(args, pattern); |
1768 |
– |
vsnprintf(buffer, sizeof(buffer), pattern, args); |
1769 |
– |
va_end(args); |
1770 |
– |
|
1771 |
– |
DLINK_FOREACH(node, cluster_items.head) |
1772 |
– |
{ |
1773 |
– |
const struct MaskItem *conf = node->data; |
1774 |
– |
|
1775 |
– |
if (conf->flags & cluster_type) |
1776 |
– |
sendto_match_servs(source_p, conf->name, CAPAB_CLUSTER | capab, |
1777 |
– |
"%s %s %s", command, conf->name, buffer); |
1778 |
– |
} |
1779 |
– |
} |
1780 |
– |
|
1781 |
– |
/* |
1520 |
|
* split_nuh |
1521 |
|
* |
1522 |
|
* inputs - pointer to original mask (modified in place) |