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" |
71 |
|
struct conf_parser_context conf_parser_ctx; |
72 |
|
|
73 |
|
/* general conf items link list root, other than k lines etc. */ |
70 |
– |
dlink_list service_items; |
74 |
|
dlink_list server_items; |
72 |
– |
dlink_list cluster_items; |
75 |
|
dlink_list operator_items; |
74 |
– |
dlink_list shared_items; |
75 |
– |
dlink_list gecos_items; |
76 |
– |
dlink_list nresv_items; |
77 |
– |
dlink_list cresv_items; |
76 |
|
|
77 |
|
extern unsigned int lineno; |
78 |
|
extern char linebuf[]; |
134 |
|
{ |
135 |
|
switch (type) |
136 |
|
{ |
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; |
137 |
|
case CONF_OPER: |
138 |
|
return &operator_items; |
139 |
|
break; |
140 |
|
case CONF_SERVER: |
141 |
|
return &server_items; |
142 |
|
break; |
157 |
– |
case CONF_SERVICE: |
158 |
– |
return &service_items; |
159 |
– |
break; |
160 |
– |
case CONF_CLUSTER: |
161 |
– |
return &cluster_items; |
162 |
– |
break; |
143 |
|
default: |
144 |
|
return NULL; |
145 |
|
} |
203 |
|
free_dlink_node(node); |
204 |
|
} |
205 |
|
|
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 |
– |
|
206 |
|
xfree(conf); |
207 |
|
} |
208 |
|
|
541 |
|
|
542 |
|
switch (type) |
543 |
|
{ |
575 |
– |
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 |
– |
|
544 |
|
case CONF_SERVER: |
545 |
|
DLINK_FOREACH(node, list->head) |
546 |
|
{ |
578 |
|
|
579 |
|
switch(type) |
580 |
|
{ |
648 |
– |
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; |
671 |
– |
|
581 |
|
case CONF_OPER: |
582 |
|
DLINK_FOREACH(node, list->head) |
583 |
|
{ |
679 |
|
ConfigServerInfo.max_nick_length = 9; |
680 |
|
ConfigServerInfo.max_topic_length = 80; |
681 |
|
ConfigServerInfo.hub = 0; |
682 |
+ |
ConfigServerInfo.libgeoip_database_options = 0; |
683 |
|
|
684 |
|
log_del_all(); |
685 |
|
|
886 |
|
return 0; |
887 |
|
} |
888 |
|
|
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 |
– |
|
889 |
|
/* cleanup_tklines() |
890 |
|
* |
891 |
|
* inputs - NONE |
897 |
|
cleanup_tklines(void *unused) |
898 |
|
{ |
899 |
|
hostmask_expire_temporary(); |
900 |
< |
expire_tklines(&gecos_items); |
901 |
< |
expire_tklines(&nresv_items); |
1017 |
< |
expire_tklines(&cresv_items); |
900 |
> |
gecos_expire(); |
901 |
> |
resv_expire(); |
902 |
|
} |
903 |
|
|
904 |
|
/* oper_privs_as_string() |
907 |
|
* output - pointer to static string showing oper privs |
908 |
|
* side effects - return as string, the oper privs as derived from port |
909 |
|
*/ |
910 |
< |
static const struct oper_privs |
910 |
> |
static const struct oper_flags |
911 |
|
{ |
912 |
|
const unsigned int flag; |
913 |
|
const unsigned char c; |
914 |
< |
} flag_list[] = { |
914 |
> |
} flag_table[] = { |
915 |
|
{ OPER_FLAG_ADMIN, 'A' }, |
916 |
|
{ OPER_FLAG_CLOSE, 'B' }, |
917 |
|
{ OPER_FLAG_CONNECT, 'C' }, |
944 |
|
}; |
945 |
|
|
946 |
|
const char * |
947 |
< |
oper_privs_as_string(const unsigned int port) |
947 |
> |
oper_privs_as_string(const unsigned int flags) |
948 |
|
{ |
949 |
< |
static char privs_out[IRCD_BUFSIZE]; |
950 |
< |
char *privs_ptr = privs_out; |
949 |
> |
static char buf[sizeof(flag_table) / sizeof(struct oper_flags)]; |
950 |
> |
char *p = buf; |
951 |
|
|
952 |
< |
for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv) |
953 |
< |
if (port & opriv->flag) |
954 |
< |
*privs_ptr++ = opriv->c; |
952 |
> |
for (const struct oper_flags *tab = flag_table; tab->flag; ++tab) |
953 |
> |
if (flags & tab->flag) |
954 |
> |
*p++ = tab->c; |
955 |
|
|
956 |
< |
if (privs_ptr == privs_out) |
957 |
< |
*privs_ptr++ = '0'; |
956 |
> |
if (p == buf) |
957 |
> |
*p++ = '0'; |
958 |
|
|
959 |
< |
*privs_ptr = '\0'; |
959 |
> |
*p = '\0'; |
960 |
|
|
961 |
< |
return privs_out; |
961 |
> |
return buf; |
962 |
|
} |
963 |
|
|
964 |
|
/* |
1014 |
|
{ |
1015 |
|
dlink_node *node = NULL, *node_next = NULL; |
1016 |
|
dlink_list *free_items [] = { |
1017 |
< |
&server_items, &operator_items, |
1134 |
< |
&shared_items, &gecos_items, |
1135 |
< |
&nresv_items, &cluster_items, &service_items, &cresv_items, NULL |
1017 |
> |
&server_items, &operator_items, NULL |
1018 |
|
}; |
1019 |
|
|
1020 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
1030 |
|
struct MaskItem *conf = node->data; |
1031 |
|
|
1032 |
|
conf->active = 0; |
1033 |
+ |
dlinkDelete(&conf->node, *iterator); |
1034 |
|
|
1035 |
< |
if (!IsConfDatabase(conf)) |
1036 |
< |
{ |
1154 |
< |
dlinkDelete(&conf->node, *iterator); |
1155 |
< |
|
1156 |
< |
if (!conf->ref_count) |
1157 |
< |
conf_free(conf); |
1158 |
< |
} |
1035 |
> |
if (!conf->ref_count) |
1036 |
> |
conf_free(conf); |
1037 |
|
} |
1038 |
|
} |
1039 |
|
|
1040 |
< |
motd_clear(); |
1040 |
> |
motd_clear(); /* Clear motd {} items and re-cache default motd */ |
1041 |
|
|
1042 |
|
/* |
1043 |
|
* Don't delete the class table, rather mark all entries for deletion. |
1047 |
|
|
1048 |
|
clear_out_address_conf(); |
1049 |
|
|
1050 |
< |
/* Clean out module paths */ |
1173 |
< |
mod_clear_paths(); |
1050 |
> |
modules_conf_clear(); /* Clear modules {} items */ |
1051 |
|
|
1052 |
< |
pseudo_clear(); |
1052 |
> |
motd_clear(); /* Clear motd {} items and re-cache default motd */ |
1053 |
> |
|
1054 |
> |
cluster_clear(); /* Clear cluster {} items */ |
1055 |
> |
|
1056 |
> |
gecos_clear(); /* Clear gecos {} items */ |
1057 |
> |
|
1058 |
> |
resv_clear(); /* Clear resv {} items */ |
1059 |
> |
|
1060 |
> |
service_clear(); /* Clear service {} items */ |
1061 |
> |
|
1062 |
> |
shared_clear(); /* Clear shared {} items */ |
1063 |
> |
|
1064 |
> |
pseudo_clear(); /* Clear pseudo {} items */ |
1065 |
> |
|
1066 |
> |
#ifdef HAVE_LIBGEOIP |
1067 |
> |
GeoIP_delete(GeoIPv4_ctx); |
1068 |
> |
GeoIPv4_ctx = NULL; |
1069 |
> |
GeoIP_delete(GeoIPv6_ctx); |
1070 |
> |
GeoIPv6_ctx = NULL; |
1071 |
> |
#endif |
1072 |
|
|
1073 |
|
/* Clean out ConfigServerInfo */ |
1074 |
|
xfree(ConfigServerInfo.description); |
1077 |
|
ConfigServerInfo.network_name = NULL; |
1078 |
|
xfree(ConfigServerInfo.network_desc); |
1079 |
|
ConfigServerInfo.network_desc = NULL; |
1080 |
< |
|
1080 |
> |
xfree(ConfigServerInfo.libgeoip_ipv6_database_file); |
1081 |
> |
ConfigServerInfo.libgeoip_ipv6_database_file = NULL; |
1082 |
> |
xfree(ConfigServerInfo.libgeoip_ipv4_database_file); |
1083 |
> |
ConfigServerInfo.libgeoip_ipv4_database_file = NULL; |
1084 |
|
xfree(ConfigServerInfo.rsa_private_key_file); |
1085 |
|
ConfigServerInfo.rsa_private_key_file = NULL; |
1086 |
|
xfree(ConfigServerInfo.ssl_certificate_file); |
1117 |
|
if (cold) |
1118 |
|
{ |
1119 |
|
ilog(LOG_TYPE_IRCD, "Error while initializing TLS"); |
1120 |
< |
exit(-1); |
1120 |
> |
exit(EXIT_FAILURE); |
1121 |
|
} |
1122 |
|
else |
1123 |
|
{ |
1644 |
|
} |
1645 |
|
|
1646 |
|
/* |
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 |
– |
/* |
1647 |
|
* split_nuh |
1648 |
|
* |
1649 |
|
* inputs - pointer to original mask (modified in place) |