1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* conf.c: Configuration file functions. |
2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
4 |
> |
* Copyright (c) 1997-2014 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 |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file conf.c |
23 |
> |
* \brief Configuration file functions. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
28 |
|
#include "list.h" |
29 |
|
#include "ircd_defs.h" |
30 |
|
#include "conf.h" |
31 |
< |
#include "s_serv.h" |
31 |
> |
#include "server.h" |
32 |
|
#include "resv.h" |
33 |
|
#include "channel.h" |
34 |
|
#include "client.h" |
35 |
|
#include "event.h" |
34 |
– |
#include "hook.h" |
36 |
|
#include "irc_string.h" |
37 |
|
#include "s_bsd.h" |
38 |
|
#include "ircd.h" |
43 |
|
#include "fdlist.h" |
44 |
|
#include "log.h" |
45 |
|
#include "send.h" |
45 |
– |
#include "s_gline.h" |
46 |
|
#include "memory.h" |
47 |
|
#include "mempool.h" |
48 |
< |
#include "irc_res.h" |
48 |
> |
#include "res.h" |
49 |
|
#include "userhost.h" |
50 |
< |
#include "s_user.h" |
50 |
> |
#include "user.h" |
51 |
|
#include "channel_mode.h" |
52 |
|
#include "parse.h" |
53 |
< |
#include "s_misc.h" |
53 |
> |
#include "misc.h" |
54 |
|
#include "conf_db.h" |
55 |
|
#include "conf_class.h" |
56 |
|
#include "motd.h" |
57 |
|
|
58 |
– |
struct config_server_hide ConfigServerHide; |
58 |
|
|
59 |
|
/* general conf items link list root, other than k lines etc. */ |
60 |
|
dlink_list service_items = { NULL, NULL, 0 }; |
64 |
|
dlink_list uconf_items = { NULL, NULL, 0 }; |
65 |
|
dlink_list xconf_items = { NULL, NULL, 0 }; |
66 |
|
dlink_list nresv_items = { NULL, NULL, 0 }; |
67 |
< |
dlink_list cresv_items = { NULL, NULL, 0 }; |
67 |
> |
dlink_list cresv_items = { NULL, NULL, 0 }; |
68 |
|
|
69 |
|
extern unsigned int lineno; |
70 |
|
extern char linebuf[]; |
71 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
72 |
|
extern int yyparse(); /* defined in y.tab.c */ |
73 |
|
|
75 |
– |
struct conf_parser_context conf_parser_ctx = { 0, 0, NULL }; |
76 |
– |
|
74 |
|
/* internally defined functions */ |
75 |
|
static void read_conf(FILE *); |
76 |
|
static void clear_out_old_conf(void); |
93 |
|
struct ip_entry |
94 |
|
{ |
95 |
|
struct irc_ssaddr ip; |
96 |
< |
unsigned int count; |
97 |
< |
time_t last_attempt; |
96 |
> |
unsigned int count; /**< Number of registered users using this IP */ |
97 |
> |
unsigned int connection_count; /**< Number of connections from this IP in the last throttle_time duration */ |
98 |
> |
time_t last_attempt; /**< The last time someone connected from this IP */ |
99 |
|
struct ip_entry *next; |
100 |
|
}; |
101 |
|
|
121 |
|
|
122 |
|
conf->dns_pending = 0; |
123 |
|
|
124 |
< |
if (addr != NULL) |
124 |
> |
if (addr) |
125 |
|
memcpy(&conf->addr, addr, sizeof(conf->addr)); |
126 |
|
else |
127 |
|
conf->dns_failed = 1; |
146 |
|
struct MaskItem * |
147 |
|
conf_make(enum maskitem_type type) |
148 |
|
{ |
149 |
< |
struct MaskItem *conf = MyMalloc(sizeof(*conf)); |
149 |
> |
struct MaskItem *conf = MyCalloc(sizeof(*conf)); |
150 |
|
dlink_list *list = NULL; |
151 |
|
|
152 |
|
conf->type = type; |
172 |
|
|
173 |
|
if (conf->dns_pending) |
174 |
|
delete_resolver_queries(conf); |
175 |
< |
if (conf->passwd != NULL) |
175 |
> |
if (conf->passwd) |
176 |
|
memset(conf->passwd, 0, strlen(conf->passwd)); |
177 |
< |
if (conf->spasswd != NULL) |
177 |
> |
if (conf->spasswd) |
178 |
|
memset(conf->spasswd, 0, strlen(conf->spasswd)); |
179 |
|
|
180 |
|
conf->class = NULL; |
194 |
|
DLINK_FOREACH_SAFE(ptr, ptr_next, conf->hub_list.head) |
195 |
|
{ |
196 |
|
MyFree(ptr->data); |
197 |
+ |
dlinkDelete(ptr, &conf->hub_list); |
198 |
|
free_dlink_node(ptr); |
199 |
|
} |
200 |
|
|
201 |
|
DLINK_FOREACH_SAFE(ptr, ptr_next, conf->leaf_list.head) |
202 |
|
{ |
203 |
|
MyFree(ptr->data); |
204 |
+ |
dlinkDelete(ptr, &conf->leaf_list); |
205 |
|
free_dlink_node(ptr); |
206 |
|
} |
207 |
|
|
209 |
|
{ |
210 |
|
struct exempt *exptr = ptr->data; |
211 |
|
|
212 |
+ |
dlinkDelete(ptr, &conf->exempt_list); |
213 |
|
MyFree(exptr->name); |
214 |
|
MyFree(exptr->user); |
215 |
|
MyFree(exptr->host); |
236 |
|
check_client(struct Client *source_p) |
237 |
|
{ |
238 |
|
int i; |
239 |
< |
|
239 |
> |
|
240 |
|
if ((i = verify_access(source_p))) |
241 |
< |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
241 |
> |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
242 |
|
source_p->name, source_p->sockhost); |
243 |
|
|
244 |
|
switch (i) |
251 |
|
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
252 |
|
get_client_name(source_p, SHOW_IP)); |
253 |
|
++ServerStats.is_ref; |
254 |
< |
exit_client(source_p, &me, "No more connections allowed on that IP"); |
254 |
> |
exit_client(source_p, "No more connections allowed on that IP"); |
255 |
|
break; |
256 |
|
|
257 |
|
case I_LINE_FULL: |
262 |
|
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
263 |
|
get_client_name(source_p, SHOW_IP)); |
264 |
|
++ServerStats.is_ref; |
265 |
< |
exit_client(source_p, &me, |
265 |
< |
"No more connections allowed in your connection class"); |
265 |
> |
exit_client(source_p, "No more connections allowed in your connection class"); |
266 |
|
break; |
267 |
|
|
268 |
|
case NOT_AUTHORIZED: |
281 |
|
source_p->localClient->listener->name, |
282 |
|
source_p->localClient->listener->port); |
283 |
|
|
284 |
< |
exit_client(source_p, &me, "You are not authorized to use this server"); |
284 |
> |
exit_client(source_p, "You are not authorized to use this server"); |
285 |
|
break; |
286 |
|
|
287 |
|
case BANNED_CLIENT: |
288 |
< |
exit_client(source_p, &me, "Banned"); |
288 |
> |
exit_client(source_p, "Banned"); |
289 |
|
++ServerStats.is_ref; |
290 |
|
break; |
291 |
|
|
307 |
|
verify_access(struct Client *client_p) |
308 |
|
{ |
309 |
|
struct MaskItem *conf = NULL; |
310 |
< |
char non_ident[USERLEN + 1] = { '~', '\0' }; |
310 |
> |
char non_ident[USERLEN + 1] = "~"; |
311 |
|
|
312 |
|
if (IsGotId(client_p)) |
313 |
|
{ |
325 |
|
client_p->localClient->passwd); |
326 |
|
} |
327 |
|
|
328 |
< |
if (conf != NULL) |
328 |
> |
if (conf) |
329 |
|
{ |
330 |
|
if (IsConfClient(conf)) |
331 |
|
{ |
332 |
|
if (IsConfRedir(conf)) |
333 |
|
{ |
334 |
< |
sendto_one(client_p, form_str(RPL_REDIR), |
335 |
< |
me.name, client_p->name, |
336 |
< |
conf->name ? conf->name : "", |
337 |
< |
conf->port); |
334 |
> |
sendto_one_numeric(client_p, &me, RPL_REDIR, |
335 |
> |
conf->name ? conf->name : "", |
336 |
> |
conf->port); |
337 |
|
return NOT_AUTHORIZED; |
338 |
|
} |
339 |
|
|
356 |
|
else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf))) |
357 |
|
{ |
358 |
|
if (IsConfGline(conf)) |
359 |
< |
sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name, |
360 |
< |
client_p->name); |
362 |
< |
sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s", |
363 |
< |
me.name, client_p->name, conf->reason); |
359 |
> |
sendto_one_notice(client_p, &me, ":*** G-lined"); |
360 |
> |
sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason); |
361 |
|
return BANNED_CLIENT; |
362 |
|
} |
363 |
|
} |
395 |
|
* setting a_limit_reached if any limit is reached. |
396 |
|
* - Dianora |
397 |
|
*/ |
398 |
< |
if (class->max_total != 0 && class->ref_count >= class->max_total) |
398 |
> |
if (class->max_total && class->ref_count >= class->max_total) |
399 |
|
a_limit_reached = 1; |
400 |
< |
else if (class->max_perip != 0 && ip_found->count > class->max_perip) |
400 |
> |
else if (class->max_perip && ip_found->count > class->max_perip) |
401 |
|
a_limit_reached = 1; |
402 |
< |
else if (class->max_local != 0 && local >= class->max_local) |
402 |
> |
else if (class->max_local && local >= class->max_local) |
403 |
|
a_limit_reached = 1; |
404 |
< |
else if (class->max_global != 0 && global >= class->max_global) |
404 |
> |
else if (class->max_global && global >= class->max_global) |
405 |
|
a_limit_reached = 1; |
406 |
< |
else if (class->max_ident != 0 && ident >= class->max_ident && |
406 |
> |
else if (class->max_ident && ident >= class->max_ident && |
407 |
|
client_p->username[0] != '~') |
408 |
|
a_limit_reached = 1; |
409 |
|
|
412 |
|
if (!IsConfExemptLimits(conf)) |
413 |
|
return TOO_MANY; /* Already at maximum allowed */ |
414 |
|
|
415 |
< |
sendto_one(client_p, |
416 |
< |
":%s NOTICE %s :*** Your connection class is full, " |
420 |
< |
"but you have exceed_limit = yes;", me.name, client_p->name); |
415 |
> |
sendto_one_notice(client_p, &me, ":*** Your connection class is full, " |
416 |
> |
"but you have exceed_limit = yes;"); |
417 |
|
} |
418 |
|
|
419 |
|
return attach_conf(client_p, conf); |
479 |
|
garbage_collect_ip_entries(); |
480 |
|
|
481 |
|
newptr = mp_pool_get(ip_entry_pool); |
482 |
< |
memset(newptr, 0, sizeof(*newptr)); |
482 |
> |
|
483 |
|
ip_entries_count++; |
484 |
|
memcpy(&newptr->ip, ip_in, sizeof(struct irc_ssaddr)); |
485 |
|
|
572 |
|
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
573 |
|
|
574 |
|
hash = ip[0] ^ ip[3]; |
575 |
< |
hash ^= hash >> 16; |
576 |
< |
hash ^= hash >> 8; |
575 |
> |
hash ^= hash >> 16; |
576 |
> |
hash ^= hash >> 8; |
577 |
|
hash = hash & (IP_HASH_SIZE - 1); |
578 |
|
return hash; |
579 |
|
} |
584 |
|
|
585 |
|
/* count_ip_hash() |
586 |
|
* |
587 |
< |
* inputs - pointer to counter of number of ips hashed |
587 |
> |
* inputs - pointer to counter of number of ips hashed |
588 |
|
* - pointer to memory used for ip hash |
589 |
|
* output - returned via pointers input |
590 |
|
* side effects - NONE |
596 |
|
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
597 |
|
{ |
598 |
|
struct ip_entry *ptr; |
603 |
– |
int i; |
599 |
|
|
600 |
|
*number_ips_stored = 0; |
601 |
|
*mem_ips_stored = 0; |
602 |
|
|
603 |
< |
for (i = 0; i < IP_HASH_SIZE; i++) |
603 |
> |
for (unsigned int i = 0; i < IP_HASH_SIZE; ++i) |
604 |
|
{ |
605 |
|
for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next) |
606 |
|
{ |
622 |
|
struct ip_entry *ptr; |
623 |
|
struct ip_entry *last_ptr; |
624 |
|
struct ip_entry *next_ptr; |
630 |
– |
int i; |
625 |
|
|
626 |
< |
for (i = 0; i < IP_HASH_SIZE; i++) |
626 |
> |
for (unsigned int i = 0; i < IP_HASH_SIZE; ++i) |
627 |
|
{ |
628 |
|
last_ptr = NULL; |
629 |
|
|
658 |
|
void |
659 |
|
detach_conf(struct Client *client_p, enum maskitem_type type) |
660 |
|
{ |
661 |
< |
dlink_node *ptr = NULL, *next_ptr = NULL; |
661 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
662 |
|
|
663 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->confs.head) |
663 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->confs.head) |
664 |
|
{ |
665 |
|
struct MaskItem *conf = ptr->data; |
666 |
|
|
701 |
|
int |
702 |
|
attach_conf(struct Client *client_p, struct MaskItem *conf) |
703 |
|
{ |
704 |
< |
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
704 |
> |
if (dlinkFind(&client_p->localClient->confs, conf)) |
705 |
|
return 1; |
706 |
|
|
707 |
|
if (conf->type == CONF_CLIENT) |
770 |
|
DLINK_FOREACH(ptr, list->head) |
771 |
|
{ |
772 |
|
conf = ptr->data; |
773 |
< |
|
773 |
> |
|
774 |
|
if (conf->type == type) |
775 |
|
{ |
776 |
< |
if (conf->name && (irccmp(conf->name, name) == 0 || |
776 |
> |
if (conf->name && (!irccmp(conf->name, name) || |
777 |
|
!match(conf->name, name))) |
778 |
|
return conf; |
779 |
|
} |
888 |
|
return conf; |
889 |
|
} |
890 |
|
break; |
891 |
< |
|
891 |
> |
|
892 |
|
default: |
893 |
|
break; |
894 |
|
} |
925 |
|
|
926 |
|
if (EmptyString(conf->name)) |
927 |
|
continue; |
928 |
< |
|
928 |
> |
|
929 |
|
if (irccmp(conf->name, name) == 0) |
930 |
|
{ |
931 |
|
if ((user == NULL && (host == NULL))) |
991 |
|
|
992 |
|
if (EmptyString(conf->name)) |
993 |
|
continue; |
994 |
< |
|
994 |
> |
|
995 |
|
if (name == NULL) |
996 |
|
{ |
997 |
|
if (EmptyString(conf->host)) |
1021 |
|
int |
1022 |
|
rehash(int sig) |
1023 |
|
{ |
1024 |
< |
if (sig != 0) |
1024 |
> |
if (sig) |
1025 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1026 |
< |
"Got signal SIGHUP, reloading ircd.conf file"); |
1026 |
> |
"Got signal SIGHUP, reloading configuration file(s)"); |
1027 |
|
|
1028 |
|
restart_resolver(); |
1029 |
|
|
1034 |
|
|
1035 |
|
read_conf_files(0); |
1036 |
|
|
1037 |
< |
if (ServerInfo.description != NULL) |
1037 |
> |
if (ServerInfo.description) |
1038 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
1039 |
|
|
1040 |
|
load_conf_modules(); |
1041 |
< |
|
1048 |
< |
rehashed_klines = 1; |
1041 |
> |
check_conf_klines(); |
1042 |
|
|
1043 |
|
return 0; |
1044 |
|
} |
1061 |
|
assert(class_default == class_get_list()->tail->data); |
1062 |
|
|
1063 |
|
#ifdef HAVE_LIBCRYPTO |
1064 |
+ |
ServerInfo.message_digest_algorithm = EVP_sha256(); |
1065 |
|
ServerInfo.rsa_private_key = NULL; |
1066 |
|
ServerInfo.rsa_private_key_file = NULL; |
1067 |
|
#endif |
1093 |
|
ConfigLoggingEntry.use_logging = 1; |
1094 |
|
|
1095 |
|
ConfigChannel.disable_fake_channels = 0; |
1096 |
< |
ConfigChannel.knock_delay = 300; |
1096 |
> |
ConfigChannel.invite_client_count = 10; |
1097 |
> |
ConfigChannel.invite_client_time = 300; |
1098 |
> |
ConfigChannel.knock_client_count = 1; |
1099 |
> |
ConfigChannel.knock_client_time = 300; |
1100 |
|
ConfigChannel.knock_delay_channel = 60; |
1101 |
< |
ConfigChannel.max_chans_per_user = 25; |
1105 |
< |
ConfigChannel.max_chans_per_oper = 50; |
1101 |
> |
ConfigChannel.max_channels = 25; |
1102 |
|
ConfigChannel.max_bans = 25; |
1103 |
|
ConfigChannel.default_split_user_count = 0; |
1104 |
|
ConfigChannel.default_split_server_count = 0; |
1114 |
|
ConfigServerHide.hide_server_ips = 0; |
1115 |
|
ConfigServerHide.disable_remote_commands = 0; |
1116 |
|
|
1121 |
– |
|
1117 |
|
ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
1118 |
|
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1119 |
|
ConfigFileEntry.cycle_on_host_change = 1; |
1140 |
|
ConfigFileEntry.anti_spam_exit_message_time = 0; |
1141 |
|
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1142 |
|
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1143 |
< |
ConfigFileEntry.warn_no_nline = 1; |
1143 |
> |
ConfigFileEntry.warn_no_connect_block = 1; |
1144 |
> |
ConfigFileEntry.stats_e_disabled = 0; |
1145 |
|
ConfigFileEntry.stats_o_oper_only = 0; |
1146 |
< |
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
1147 |
< |
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
1146 |
> |
ConfigFileEntry.stats_k_oper_only = 1; /* 1 = masked */ |
1147 |
> |
ConfigFileEntry.stats_i_oper_only = 1; /* 1 = masked */ |
1148 |
|
ConfigFileEntry.stats_P_oper_only = 0; |
1149 |
|
ConfigFileEntry.stats_u_oper_only = 0; |
1150 |
|
ConfigFileEntry.caller_id_wait = 60; |
1158 |
|
ConfigFileEntry.oper_pass_resv = 1; |
1159 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1160 |
|
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
1161 |
< |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1166 |
< |
UMODE_OPERWALL | UMODE_WALLOP; |
1161 |
> |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP; |
1162 |
|
ConfigFileEntry.use_egd = 0; |
1163 |
|
ConfigFileEntry.egdpool_path = NULL; |
1164 |
< |
ConfigFileEntry.throttle_time = 10; |
1164 |
> |
ConfigFileEntry.throttle_count = 1; |
1165 |
> |
ConfigFileEntry.throttle_time = 1; |
1166 |
|
} |
1167 |
|
|
1168 |
|
static void |
1186 |
|
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
1187 |
|
} |
1188 |
|
|
1189 |
< |
/* read_conf() |
1189 |
> |
/* read_conf() |
1190 |
|
* |
1191 |
|
* inputs - file descriptor pointing to config file to use |
1192 |
|
* output - None |
1197 |
|
{ |
1198 |
|
lineno = 0; |
1199 |
|
|
1200 |
< |
set_default_conf(); /* Set default values prior to conf parsing */ |
1200 |
> |
set_default_conf(); /* Set default values prior to conf parsing */ |
1201 |
|
conf_parser_ctx.pass = 1; |
1202 |
< |
yyparse(); /* pick up the classes first */ |
1202 |
> |
yyparse(); /* Pick up the classes first */ |
1203 |
|
|
1204 |
|
rewind(file); |
1205 |
|
|
1206 |
|
conf_parser_ctx.pass = 2; |
1207 |
< |
yyparse(); /* Load the values from the conf */ |
1208 |
< |
validate_conf(); /* Check to make sure some values are still okay. */ |
1209 |
< |
/* Some global values are also loaded here. */ |
1210 |
< |
class_delete_marked(); /* Make sure classes are valid */ |
1207 |
> |
yyparse(); /* Load the values from the conf */ |
1208 |
> |
validate_conf(); /* Check to make sure some values are still okay. */ |
1209 |
> |
/* Some global values are also loaded here. */ |
1210 |
> |
class_delete_marked(); /* Delete unused classes that are marked for deletion */ |
1211 |
|
} |
1212 |
|
|
1213 |
|
/* lookup_confhost() |
1220 |
|
{ |
1221 |
|
struct addrinfo hints, *res; |
1222 |
|
|
1223 |
< |
/* Do name lookup now on hostnames given and store the |
1223 |
> |
/* |
1224 |
> |
* Do name lookup now on hostnames given and store the |
1225 |
|
* ip numbers in conf structure. |
1226 |
|
*/ |
1227 |
|
memset(&hints, 0, sizeof(hints)); |
1238 |
|
return; |
1239 |
|
} |
1240 |
|
|
1241 |
< |
assert(res != NULL); |
1241 |
> |
assert(res); |
1242 |
|
|
1243 |
|
memcpy(&conf->addr, res->ai_addr, res->ai_addrlen); |
1244 |
|
conf->addr.ss_len = res->ai_addrlen; |
1257 |
|
int |
1258 |
|
conf_connect_allowed(struct irc_ssaddr *addr, int aftype) |
1259 |
|
{ |
1260 |
< |
struct ip_entry *ip_found; |
1260 |
> |
struct ip_entry *ip_found = NULL; |
1261 |
|
struct MaskItem *conf = find_dline_conf(addr, aftype); |
1262 |
|
|
1263 |
|
/* DLINE exempt also gets you out of static limits/pacing... */ |
1264 |
|
if (conf && (conf->type == CONF_EXEMPT)) |
1265 |
|
return 0; |
1266 |
|
|
1267 |
< |
if (conf != NULL) |
1267 |
> |
if (conf) |
1268 |
|
return BANNED_CLIENT; |
1269 |
|
|
1270 |
|
ip_found = find_or_add_ip(addr); |
1271 |
|
|
1272 |
< |
if ((CurrentTime - ip_found->last_attempt) < |
1276 |
< |
ConfigFileEntry.throttle_time) |
1272 |
> |
if ((CurrentTime - ip_found->last_attempt) < ConfigFileEntry.throttle_time) |
1273 |
|
{ |
1274 |
< |
ip_found->last_attempt = CurrentTime; |
1275 |
< |
return TOO_FAST; |
1274 |
> |
if (ip_found->connection_count >= ConfigFileEntry.throttle_count) |
1275 |
> |
return TOO_FAST; |
1276 |
> |
|
1277 |
> |
++ip_found->connection_count; |
1278 |
|
} |
1279 |
+ |
else |
1280 |
+ |
ip_found->connection_count = 1; |
1281 |
|
|
1282 |
|
ip_found->last_attempt = CurrentTime; |
1283 |
|
return 0; |
1294 |
|
cleanup_tklines(void *notused) |
1295 |
|
{ |
1296 |
|
hostmask_expire_temporary(); |
1297 |
< |
expire_tklines(&xconf_items); |
1297 |
> |
expire_tklines(&xconf_items); |
1298 |
|
expire_tklines(&nresv_items); |
1299 |
|
expire_tklines(&cresv_items); |
1300 |
|
} |
1308 |
|
static void |
1309 |
|
expire_tklines(dlink_list *tklist) |
1310 |
|
{ |
1311 |
< |
dlink_node *ptr; |
1312 |
< |
dlink_node *next_ptr; |
1313 |
< |
struct MaskItem *conf; |
1311 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
1312 |
> |
struct MaskItem *conf = NULL; |
1313 |
|
|
1314 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head) |
1314 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, tklist->head) |
1315 |
|
{ |
1316 |
|
conf = ptr->data; |
1317 |
|
|
1351 |
|
{ OPER_FLAG_DIE, 'D' }, |
1352 |
|
{ OPER_FLAG_GLINE, 'G' }, |
1353 |
|
{ OPER_FLAG_REHASH, 'H' }, |
1354 |
< |
{ OPER_FLAG_K, 'K' }, |
1356 |
< |
{ OPER_FLAG_OPERWALL, 'L' }, |
1354 |
> |
{ OPER_FLAG_KLINE, 'K' }, |
1355 |
|
{ OPER_FLAG_KILL, 'N' }, |
1356 |
|
{ OPER_FLAG_KILL_REMOTE, 'O' }, |
1357 |
|
{ OPER_FLAG_CONNECT, 'P' }, |
1359 |
|
{ OPER_FLAG_SQUIT, 'R' }, |
1360 |
|
{ OPER_FLAG_SQUIT_REMOTE, 'S' }, |
1361 |
|
{ OPER_FLAG_UNKLINE, 'U' }, |
1362 |
< |
{ OPER_FLAG_X, 'X' }, |
1362 |
> |
{ OPER_FLAG_XLINE, 'X' }, |
1363 |
|
{ 0, '\0' } |
1364 |
|
}; |
1365 |
|
|
1366 |
|
char * |
1367 |
|
oper_privs_as_string(const unsigned int port) |
1368 |
|
{ |
1369 |
< |
static char privs_out[16]; |
1369 |
> |
static char privs_out[IRCD_BUFSIZE]; |
1370 |
|
char *privs_ptr = privs_out; |
1373 |
– |
const struct oper_privs *opriv = flag_list; |
1371 |
|
|
1372 |
< |
for (; opriv->flag; ++opriv) |
1372 |
> |
for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv) |
1373 |
|
{ |
1374 |
|
if (port & opriv->flag) |
1375 |
|
*privs_ptr++ = opriv->c; |
1391 |
|
const char * |
1392 |
|
get_oper_name(const struct Client *client_p) |
1393 |
|
{ |
1394 |
< |
dlink_node *cnode = NULL; |
1394 |
> |
const dlink_node *cnode = NULL; |
1395 |
|
/* +5 for !,@,{,} and null */ |
1396 |
|
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
1397 |
|
|
1399 |
|
{ |
1400 |
|
if ((cnode = client_p->localClient->confs.head)) |
1401 |
|
{ |
1402 |
< |
struct MaskItem *conf = cnode->data; |
1402 |
> |
const struct MaskItem *conf = cnode->data; |
1403 |
|
|
1404 |
|
if (IsConfOperator(conf)) |
1405 |
|
{ |
1409 |
|
} |
1410 |
|
} |
1411 |
|
|
1412 |
< |
/* Probably should assert here for now. If there is an oper out there |
1412 |
> |
/* Probably should assert here for now. If there is an oper out there |
1413 |
|
* with no oper{} conf attached, it would be good for us to know... |
1414 |
|
*/ |
1415 |
|
assert(0); /* Oper without oper conf! */ |
1429 |
|
void |
1430 |
|
read_conf_files(int cold) |
1431 |
|
{ |
1432 |
< |
const char *filename; |
1433 |
< |
char chanmodes[32]; |
1434 |
< |
char chanlimit[32]; |
1432 |
> |
const char *filename = NULL; |
1433 |
> |
char chanmodes[IRCD_BUFSIZE] = ""; |
1434 |
> |
char chanlimit[IRCD_BUFSIZE] = ""; |
1435 |
|
|
1436 |
|
conf_parser_ctx.boot = cold; |
1437 |
|
filename = ConfigFileEntry.configfile; |
1440 |
|
FIXME: The full path is in conffilenamebuf first time since we |
1441 |
|
dont know anything else |
1442 |
|
|
1443 |
< |
- Gozem 2002-07-21 |
1443 |
> |
- Gozem 2002-07-21 |
1444 |
|
*/ |
1445 |
|
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
1446 |
|
|
1478 |
|
add_isupport("CHANTYPES", "#", -1); |
1479 |
|
|
1480 |
|
snprintf(chanlimit, sizeof(chanlimit), "#:%d", |
1481 |
< |
ConfigChannel.max_chans_per_user); |
1481 |
> |
ConfigChannel.max_channels); |
1482 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
1483 |
< |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS"); |
1484 |
< |
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
1483 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS"); |
1484 |
> |
add_isupport("CHANNELLEN", NULL, CHANNELLEN); |
1485 |
|
add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length); |
1486 |
|
add_isupport("CHANMODES", chanmodes, -1); |
1487 |
|
|
1514 |
|
/* We only need to free anything allocated by yyparse() here. |
1515 |
|
* Resetting structs, etc, is taken care of by set_default_conf(). |
1516 |
|
*/ |
1517 |
< |
|
1517 |
> |
|
1518 |
|
for (; *iterator != NULL; iterator++) |
1519 |
|
{ |
1520 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head) |
1562 |
|
MyFree(ConfigFileEntry.egdpool_path); |
1563 |
|
ConfigFileEntry.egdpool_path = NULL; |
1564 |
|
#ifdef HAVE_LIBCRYPTO |
1565 |
< |
if (ServerInfo.rsa_private_key != NULL) |
1565 |
> |
if (ServerInfo.rsa_private_key) |
1566 |
|
{ |
1567 |
|
RSA_free(ServerInfo.rsa_private_key); |
1568 |
|
ServerInfo.rsa_private_key = NULL; |
1570 |
|
|
1571 |
|
MyFree(ServerInfo.rsa_private_key_file); |
1572 |
|
ServerInfo.rsa_private_key_file = NULL; |
1576 |
– |
|
1577 |
– |
if (ServerInfo.server_ctx) |
1578 |
– |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2| |
1579 |
– |
SSL_OP_NO_SSLv3| |
1580 |
– |
SSL_OP_NO_TLSv1); |
1581 |
– |
if (ServerInfo.client_ctx) |
1582 |
– |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2| |
1583 |
– |
SSL_OP_NO_SSLv3| |
1584 |
– |
SSL_OP_NO_TLSv1); |
1573 |
|
#endif |
1574 |
|
|
1575 |
|
/* clean out AdminInfo */ |
1592 |
|
* |
1593 |
|
* inputs - pointer to config item |
1594 |
|
* output - NONE |
1595 |
< |
* side effects - Add a class pointer to a conf |
1595 |
> |
* side effects - Add a class pointer to a conf |
1596 |
|
*/ |
1597 |
|
void |
1598 |
|
conf_add_class_to_conf(struct MaskItem *conf, const char *class_name) |
1599 |
|
{ |
1600 |
< |
if (class_name == NULL) |
1600 |
> |
if (class_name == NULL) |
1601 |
|
{ |
1602 |
|
conf->class = class_default; |
1603 |
|
|
1664 |
|
|
1665 |
|
/* |
1666 |
|
* valid_tkline() |
1667 |
< |
* |
1667 |
> |
* |
1668 |
|
* inputs - pointer to ascii string to check |
1669 |
|
* - whether the specified time is in seconds or minutes |
1670 |
|
* output - -1 not enough parameters |
1689 |
|
} |
1690 |
|
|
1691 |
|
/* |
1692 |
< |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
1692 |
> |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
1693 |
|
* i.e. they specifically use 0, I am going to return 1 instead |
1694 |
|
* as a return value of non-zero is used to flag it as a temporary kline |
1695 |
|
*/ |
1696 |
|
if (result == 0) |
1697 |
|
result = 1; |
1698 |
|
|
1699 |
< |
/* |
1699 |
> |
/* |
1700 |
|
* If the incoming time is in seconds convert it to minutes for the purpose |
1701 |
|
* of this calculation |
1702 |
|
*/ |
1703 |
|
if (!minutes) |
1704 |
< |
result = result / 60; |
1704 |
> |
result = result / 60; |
1705 |
|
|
1706 |
|
if (result > MAX_TDKLINE_TIME) |
1707 |
|
result = MAX_TDKLINE_TIME; |
1722 |
|
{ |
1723 |
|
const unsigned char *p = (const unsigned char *)data; |
1724 |
|
unsigned char tmpch = '\0'; |
1725 |
< |
int nonwild = 0; |
1725 |
> |
unsigned int nonwild = 0; |
1726 |
|
|
1727 |
|
while ((tmpch = *p++)) |
1728 |
|
{ |
1753 |
|
int |
1754 |
|
valid_wild_card(struct Client *source_p, int warn, int count, ...) |
1755 |
|
{ |
1756 |
< |
char tmpch; |
1757 |
< |
int nonwild = 0; |
1756 |
> |
unsigned char tmpch = '\0'; |
1757 |
> |
unsigned int nonwild = 0; |
1758 |
|
va_list args; |
1759 |
|
|
1760 |
|
/* |
1773 |
|
|
1774 |
|
while (count--) |
1775 |
|
{ |
1776 |
< |
const char *p = va_arg(args, const char *); |
1776 |
> |
const unsigned char *p = va_arg(args, const unsigned char *); |
1777 |
|
if (p == NULL) |
1778 |
|
continue; |
1779 |
|
|
1786 |
|
* break - no point in searching further. |
1787 |
|
*/ |
1788 |
|
if (++nonwild >= ConfigFileEntry.min_nonwildcard) |
1789 |
+ |
{ |
1790 |
+ |
va_end(args); |
1791 |
|
return 1; |
1792 |
+ |
} |
1793 |
|
} |
1794 |
|
} |
1795 |
|
} |
1796 |
|
|
1797 |
|
if (warn) |
1798 |
< |
sendto_one(source_p, ":%s NOTICE %s :Please include at least %d non-wildcard characters with the mask", |
1799 |
< |
me.name, source_p->name, ConfigFileEntry.min_nonwildcard); |
1798 |
> |
sendto_one_notice(source_p, &me, |
1799 |
> |
":Please include at least %u non-wildcard characters with the mask", |
1800 |
> |
ConfigFileEntry.min_nonwildcard); |
1801 |
> |
va_end(args); |
1802 |
|
return 0; |
1803 |
|
} |
1804 |
|
|
1812 |
|
* - parse_flags bit map of things to test |
1813 |
|
* - pointer to user or string to parse into |
1814 |
|
* - pointer to host or NULL to parse into if non NULL |
1815 |
< |
* - pointer to optional tkline time or NULL |
1815 |
> |
* - pointer to optional tkline time or NULL |
1816 |
|
* - pointer to target_server to parse into if non NULL |
1817 |
|
* - pointer to reason to parse into |
1818 |
|
* |
1839 |
|
char **target_server, char **reason) |
1840 |
|
{ |
1841 |
|
int found_tkline_time=0; |
1842 |
< |
static char def_reason[] = "No Reason"; |
1842 |
> |
static char def_reason[] = CONF_NOREASON; |
1843 |
|
static char user[USERLEN*4+1]; |
1844 |
|
static char host[HOSTLEN*4+1]; |
1845 |
|
|
1857 |
|
*tkline_time = found_tkline_time; |
1858 |
|
else |
1859 |
|
{ |
1860 |
< |
sendto_one(source_p, ":%s NOTICE %s :temp_line not supported by %s", |
1868 |
< |
me.name, source_p->name, cmd); |
1860 |
> |
sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd); |
1861 |
|
return -1; |
1862 |
|
} |
1863 |
|
} |
1864 |
|
|
1865 |
|
if (parc == 0) |
1866 |
|
{ |
1867 |
< |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
1876 |
< |
me.name, source_p->name, cmd); |
1867 |
> |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1868 |
|
return -1; |
1869 |
|
} |
1870 |
|
|
1878 |
|
*up_p = user; |
1879 |
|
*h_p = host; |
1880 |
|
} |
1881 |
< |
|
1881 |
> |
|
1882 |
|
parc--; |
1883 |
|
parv++; |
1884 |
|
|
1891 |
|
|
1892 |
|
if (target_server == NULL) |
1893 |
|
{ |
1894 |
< |
sendto_one(source_p, ":%s NOTICE %s :ON server not supported by %s", |
1904 |
< |
me.name, source_p->name, cmd); |
1894 |
> |
sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd); |
1895 |
|
return -1; |
1896 |
|
} |
1897 |
|
|
1898 |
|
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
1899 |
|
{ |
1900 |
< |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
1911 |
< |
me.name, source_p->name, "remoteban"); |
1900 |
> |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban"); |
1901 |
|
return -1; |
1902 |
|
} |
1903 |
|
|
1904 |
|
if (parc == 0 || EmptyString(*parv)) |
1905 |
|
{ |
1906 |
< |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
1918 |
< |
me.name, source_p->name, cmd); |
1906 |
> |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1907 |
|
return -1; |
1908 |
|
} |
1909 |
|
|
1925 |
|
{ |
1926 |
|
if (strchr(user, '!') != NULL) |
1927 |
|
{ |
1928 |
< |
sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in kline", |
1941 |
< |
me.name, source_p->name); |
1928 |
> |
sendto_one_notice(source_p, &me, ":Invalid character '!' in kline"); |
1929 |
|
return -1; |
1930 |
|
} |
1931 |
|
|
1996 |
|
luser[1] = '\0'; |
1997 |
|
strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1); |
1998 |
|
} |
1999 |
< |
|
1999 |
> |
|
2000 |
|
return 1; |
2001 |
|
} |
2002 |
|
else |
2003 |
|
{ |
2004 |
|
/* Try to find user@host mask from nick */ |
2005 |
|
/* Okay to use source_p as the first param, because source_p == client_p */ |
2006 |
< |
if ((target_p = |
2007 |
< |
find_chasing(source_p, user_host_or_nick, NULL)) == NULL) |
2008 |
< |
return 0; |
2006 |
> |
if ((target_p = |
2007 |
> |
find_chasing(source_p, user_host_or_nick)) == NULL) |
2008 |
> |
return 0; /* find_chasing sends ERR_NOSUCHNICK */ |
2009 |
|
|
2010 |
|
if (IsExemptKline(target_p)) |
2011 |
|
{ |
2012 |
|
if (!IsServer(source_p)) |
2013 |
< |
sendto_one(source_p, |
2027 |
< |
":%s NOTICE %s :%s is E-lined", |
2028 |
< |
me.name, source_p->name, target_p->name); |
2013 |
> |
sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name); |
2014 |
|
return 0; |
2015 |
|
} |
2016 |
|
|
2071 |
|
else |
2072 |
|
encr = password; |
2073 |
|
|
2074 |
< |
return !strcmp(encr, conf->passwd); |
2074 |
> |
return encr && !strcmp(encr, conf->passwd); |
2075 |
|
} |
2076 |
|
|
2077 |
|
/* |
2079 |
|
* |
2080 |
|
* inputs - client sending the cluster |
2081 |
|
* - command name "KLINE" "XLINE" etc. |
2082 |
< |
* - capab -- CAP_KLN etc. from s_serv.h |
2082 |
> |
* - capab -- CAP_KLN etc. from server.h |
2083 |
|
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
2084 |
|
* - pattern and args to send along |
2085 |
|
* output - none |
2091 |
|
int capab, int cluster_type, const char *pattern, ...) |
2092 |
|
{ |
2093 |
|
va_list args; |
2094 |
< |
char buffer[IRCD_BUFSIZE]; |
2094 |
> |
char buffer[IRCD_BUFSIZE] = ""; |
2095 |
|
const dlink_node *ptr = NULL; |
2096 |
|
|
2097 |
|
va_start(args, pattern); |
2152 |
|
{ |
2153 |
|
*p = '\0'; |
2154 |
|
|
2155 |
< |
if (iptr->nickptr && *iptr->nuhmask != '\0') |
2155 |
> |
if (iptr->nickptr && *iptr->nuhmask) |
2156 |
|
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
2157 |
|
|
2158 |
|
if ((q = strchr(++p, '@'))) |
2159 |
|
{ |
2160 |
|
*q++ = '\0'; |
2161 |
|
|
2162 |
< |
if (*p != '\0') |
2162 |
> |
if (*p) |
2163 |
|
strlcpy(iptr->userptr, p, iptr->usersize); |
2164 |
|
|
2165 |
< |
if (*q != '\0') |
2165 |
> |
if (*q) |
2166 |
|
strlcpy(iptr->hostptr, q, iptr->hostsize); |
2167 |
|
} |
2168 |
|
else |
2169 |
|
{ |
2170 |
< |
if (*p != '\0') |
2170 |
> |
if (*p) |
2171 |
|
strlcpy(iptr->userptr, p, iptr->usersize); |
2172 |
|
} |
2173 |
|
} |
2179 |
|
/* if found a @ */ |
2180 |
|
*p++ = '\0'; |
2181 |
|
|
2182 |
< |
if (*iptr->nuhmask != '\0') |
2182 |
> |
if (*iptr->nuhmask) |
2183 |
|
strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize); |
2184 |
|
|
2185 |
< |
if (*p != '\0') |
2185 |
> |
if (*p) |
2186 |
|
strlcpy(iptr->hostptr, p, iptr->hostsize); |
2187 |
|
} |
2188 |
|
else |