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 |
+ |
|
59 |
+ |
struct config_channel_entry ConfigChannel; |
60 |
|
struct config_server_hide ConfigServerHide; |
61 |
+ |
struct config_file_entry ConfigFileEntry; |
62 |
+ |
struct logging_entry ConfigLoggingEntry = { .use_logging = 1 }; |
63 |
+ |
struct server_info ServerInfo; |
64 |
+ |
struct admin_info AdminInfo; |
65 |
|
|
66 |
|
/* general conf items link list root, other than k lines etc. */ |
67 |
|
dlink_list service_items = { NULL, NULL, 0 }; |
102 |
|
struct ip_entry |
103 |
|
{ |
104 |
|
struct irc_ssaddr ip; |
105 |
< |
unsigned int count; |
106 |
< |
time_t last_attempt; |
105 |
> |
unsigned int count; /**< Number of registered users using this IP */ |
106 |
> |
unsigned int connection_count; /**< Number of connections from this IP in the last throttle_time duration */ |
107 |
> |
time_t last_attempt; /**< The last time someone connected from this IP */ |
108 |
|
struct ip_entry *next; |
109 |
|
}; |
110 |
|
|
130 |
|
|
131 |
|
conf->dns_pending = 0; |
132 |
|
|
133 |
< |
if (addr != NULL) |
133 |
> |
if (addr) |
134 |
|
memcpy(&conf->addr, addr, sizeof(conf->addr)); |
135 |
|
else |
136 |
|
conf->dns_failed = 1; |
155 |
|
struct MaskItem * |
156 |
|
conf_make(enum maskitem_type type) |
157 |
|
{ |
158 |
< |
struct MaskItem *conf = MyMalloc(sizeof(*conf)); |
158 |
> |
struct MaskItem *conf = MyCalloc(sizeof(*conf)); |
159 |
|
dlink_list *list = NULL; |
160 |
|
|
161 |
|
conf->type = type; |
181 |
|
|
182 |
|
if (conf->dns_pending) |
183 |
|
delete_resolver_queries(conf); |
184 |
< |
if (conf->passwd != NULL) |
184 |
> |
if (conf->passwd) |
185 |
|
memset(conf->passwd, 0, strlen(conf->passwd)); |
186 |
< |
if (conf->spasswd != NULL) |
186 |
> |
if (conf->spasswd) |
187 |
|
memset(conf->spasswd, 0, strlen(conf->spasswd)); |
188 |
|
|
189 |
|
conf->class = NULL; |
245 |
|
check_client(struct Client *source_p) |
246 |
|
{ |
247 |
|
int i; |
248 |
< |
|
248 |
> |
|
249 |
|
if ((i = verify_access(source_p))) |
250 |
< |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
250 |
> |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
251 |
|
source_p->name, source_p->sockhost); |
252 |
|
|
253 |
|
switch (i) |
260 |
|
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
261 |
|
get_client_name(source_p, SHOW_IP)); |
262 |
|
++ServerStats.is_ref; |
263 |
< |
exit_client(source_p, &me, "No more connections allowed on that IP"); |
263 |
> |
exit_client(source_p, "No more connections allowed on that IP"); |
264 |
|
break; |
265 |
|
|
266 |
|
case I_LINE_FULL: |
271 |
|
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
272 |
|
get_client_name(source_p, SHOW_IP)); |
273 |
|
++ServerStats.is_ref; |
274 |
< |
exit_client(source_p, &me, |
268 |
< |
"No more connections allowed in your connection class"); |
274 |
> |
exit_client(source_p, "No more connections allowed in your connection class"); |
275 |
|
break; |
276 |
|
|
277 |
|
case NOT_AUTHORIZED: |
290 |
|
source_p->localClient->listener->name, |
291 |
|
source_p->localClient->listener->port); |
292 |
|
|
293 |
< |
exit_client(source_p, &me, "You are not authorized to use this server"); |
293 |
> |
exit_client(source_p, "You are not authorized to use this server"); |
294 |
|
break; |
295 |
|
|
296 |
|
case BANNED_CLIENT: |
297 |
< |
exit_client(source_p, &me, "Banned"); |
297 |
> |
exit_client(source_p, "Banned"); |
298 |
|
++ServerStats.is_ref; |
299 |
|
break; |
300 |
|
|
316 |
|
verify_access(struct Client *client_p) |
317 |
|
{ |
318 |
|
struct MaskItem *conf = NULL; |
319 |
< |
char non_ident[USERLEN + 1] = { '~', '\0' }; |
319 |
> |
char non_ident[USERLEN + 1] = "~"; |
320 |
|
|
321 |
|
if (IsGotId(client_p)) |
322 |
|
{ |
334 |
|
client_p->localClient->passwd); |
335 |
|
} |
336 |
|
|
337 |
< |
if (conf != NULL) |
337 |
> |
if (conf) |
338 |
|
{ |
339 |
|
if (IsConfClient(conf)) |
340 |
|
{ |
341 |
|
if (IsConfRedir(conf)) |
342 |
|
{ |
343 |
< |
sendto_one(client_p, form_str(RPL_REDIR), |
344 |
< |
me.name, client_p->name, |
345 |
< |
conf->name ? conf->name : "", |
340 |
< |
conf->port); |
343 |
> |
sendto_one_numeric(client_p, &me, RPL_REDIR, |
344 |
> |
conf->name ? conf->name : "", |
345 |
> |
conf->port); |
346 |
|
return NOT_AUTHORIZED; |
347 |
|
} |
348 |
|
|
365 |
|
else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf))) |
366 |
|
{ |
367 |
|
if (IsConfGline(conf)) |
368 |
< |
sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name, |
369 |
< |
client_p->name); |
365 |
< |
sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s", |
366 |
< |
me.name, client_p->name, conf->reason); |
368 |
> |
sendto_one_notice(client_p, &me, ":*** G-lined"); |
369 |
> |
sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason); |
370 |
|
return BANNED_CLIENT; |
371 |
|
} |
372 |
|
} |
404 |
|
* setting a_limit_reached if any limit is reached. |
405 |
|
* - Dianora |
406 |
|
*/ |
407 |
< |
if (class->max_total != 0 && class->ref_count >= class->max_total) |
407 |
> |
if (class->max_total && class->ref_count >= class->max_total) |
408 |
|
a_limit_reached = 1; |
409 |
< |
else if (class->max_perip != 0 && ip_found->count > class->max_perip) |
409 |
> |
else if (class->max_perip && ip_found->count > class->max_perip) |
410 |
|
a_limit_reached = 1; |
411 |
< |
else if (class->max_local != 0 && local >= class->max_local) |
411 |
> |
else if (class->max_local && local >= class->max_local) |
412 |
|
a_limit_reached = 1; |
413 |
< |
else if (class->max_global != 0 && global >= class->max_global) |
413 |
> |
else if (class->max_global && global >= class->max_global) |
414 |
|
a_limit_reached = 1; |
415 |
< |
else if (class->max_ident != 0 && ident >= class->max_ident && |
415 |
> |
else if (class->max_ident && ident >= class->max_ident && |
416 |
|
client_p->username[0] != '~') |
417 |
|
a_limit_reached = 1; |
418 |
|
|
421 |
|
if (!IsConfExemptLimits(conf)) |
422 |
|
return TOO_MANY; /* Already at maximum allowed */ |
423 |
|
|
424 |
< |
sendto_one(client_p, |
425 |
< |
":%s NOTICE %s :*** Your connection class is full, " |
423 |
< |
"but you have exceed_limit = yes;", me.name, client_p->name); |
424 |
> |
sendto_one_notice(client_p, &me, ":*** Your connection class is full, " |
425 |
> |
"but you have exceed_limit = yes;"); |
426 |
|
} |
427 |
|
|
428 |
|
return attach_conf(client_p, conf); |
581 |
|
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
582 |
|
|
583 |
|
hash = ip[0] ^ ip[3]; |
584 |
< |
hash ^= hash >> 16; |
585 |
< |
hash ^= hash >> 8; |
584 |
> |
hash ^= hash >> 16; |
585 |
> |
hash ^= hash >> 8; |
586 |
|
hash = hash & (IP_HASH_SIZE - 1); |
587 |
|
return hash; |
588 |
|
} |
593 |
|
|
594 |
|
/* count_ip_hash() |
595 |
|
* |
596 |
< |
* inputs - pointer to counter of number of ips hashed |
596 |
> |
* inputs - pointer to counter of number of ips hashed |
597 |
|
* - pointer to memory used for ip hash |
598 |
|
* output - returned via pointers input |
599 |
|
* side effects - NONE |
605 |
|
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
606 |
|
{ |
607 |
|
struct ip_entry *ptr; |
606 |
– |
int i; |
608 |
|
|
609 |
|
*number_ips_stored = 0; |
610 |
|
*mem_ips_stored = 0; |
611 |
|
|
612 |
< |
for (i = 0; i < IP_HASH_SIZE; i++) |
612 |
> |
for (unsigned int i = 0; i < IP_HASH_SIZE; ++i) |
613 |
|
{ |
614 |
|
for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next) |
615 |
|
{ |
631 |
|
struct ip_entry *ptr; |
632 |
|
struct ip_entry *last_ptr; |
633 |
|
struct ip_entry *next_ptr; |
633 |
– |
int i; |
634 |
|
|
635 |
< |
for (i = 0; i < IP_HASH_SIZE; i++) |
635 |
> |
for (unsigned int i = 0; i < IP_HASH_SIZE; ++i) |
636 |
|
{ |
637 |
|
last_ptr = NULL; |
638 |
|
|
667 |
|
void |
668 |
|
detach_conf(struct Client *client_p, enum maskitem_type type) |
669 |
|
{ |
670 |
< |
dlink_node *ptr = NULL, *next_ptr = NULL; |
670 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
671 |
|
|
672 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->confs.head) |
672 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->confs.head) |
673 |
|
{ |
674 |
|
struct MaskItem *conf = ptr->data; |
675 |
|
|
710 |
|
int |
711 |
|
attach_conf(struct Client *client_p, struct MaskItem *conf) |
712 |
|
{ |
713 |
< |
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
713 |
> |
if (dlinkFind(&client_p->localClient->confs, conf)) |
714 |
|
return 1; |
715 |
|
|
716 |
|
if (conf->type == CONF_CLIENT) |
779 |
|
DLINK_FOREACH(ptr, list->head) |
780 |
|
{ |
781 |
|
conf = ptr->data; |
782 |
< |
|
782 |
> |
|
783 |
|
if (conf->type == type) |
784 |
|
{ |
785 |
< |
if (conf->name && (irccmp(conf->name, name) == 0 || |
785 |
> |
if (conf->name && (!irccmp(conf->name, name) || |
786 |
|
!match(conf->name, name))) |
787 |
|
return conf; |
788 |
|
} |
897 |
|
return conf; |
898 |
|
} |
899 |
|
break; |
900 |
< |
|
900 |
> |
|
901 |
|
default: |
902 |
|
break; |
903 |
|
} |
934 |
|
|
935 |
|
if (EmptyString(conf->name)) |
936 |
|
continue; |
937 |
< |
|
937 |
> |
|
938 |
|
if (irccmp(conf->name, name) == 0) |
939 |
|
{ |
940 |
|
if ((user == NULL && (host == NULL))) |
1000 |
|
|
1001 |
|
if (EmptyString(conf->name)) |
1002 |
|
continue; |
1003 |
< |
|
1003 |
> |
|
1004 |
|
if (name == NULL) |
1005 |
|
{ |
1006 |
|
if (EmptyString(conf->host)) |
1030 |
|
int |
1031 |
|
rehash(int sig) |
1032 |
|
{ |
1033 |
< |
if (sig != 0) |
1033 |
> |
if (sig) |
1034 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1035 |
|
"Got signal SIGHUP, reloading configuration file(s)"); |
1036 |
|
|
1043 |
|
|
1044 |
|
read_conf_files(0); |
1045 |
|
|
1046 |
< |
if (ServerInfo.description != NULL) |
1046 |
> |
if (ServerInfo.description) |
1047 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
1048 |
|
|
1049 |
|
load_conf_modules(); |
1050 |
< |
|
1051 |
< |
rehashed_klines = 1; |
1050 |
> |
check_conf_klines(); |
1051 |
|
|
1052 |
|
return 0; |
1053 |
|
} |
1101 |
|
ConfigLoggingEntry.use_logging = 1; |
1102 |
|
|
1103 |
|
ConfigChannel.disable_fake_channels = 0; |
1104 |
< |
ConfigChannel.knock_delay = 300; |
1104 |
> |
ConfigChannel.invite_client_count = 10; |
1105 |
> |
ConfigChannel.invite_client_time = 300; |
1106 |
> |
ConfigChannel.knock_client_count = 1; |
1107 |
> |
ConfigChannel.knock_client_time = 300; |
1108 |
|
ConfigChannel.knock_delay_channel = 60; |
1109 |
< |
ConfigChannel.max_chans_per_user = 25; |
1108 |
< |
ConfigChannel.max_chans_per_oper = 50; |
1109 |
> |
ConfigChannel.max_channels = 25; |
1110 |
|
ConfigChannel.max_bans = 25; |
1111 |
|
ConfigChannel.default_split_user_count = 0; |
1112 |
|
ConfigChannel.default_split_server_count = 0; |
1122 |
|
ConfigServerHide.hide_server_ips = 0; |
1123 |
|
ConfigServerHide.disable_remote_commands = 0; |
1124 |
|
|
1124 |
– |
|
1125 |
|
ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
1126 |
|
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1127 |
|
ConfigFileEntry.cycle_on_host_change = 1; |
1148 |
|
ConfigFileEntry.anti_spam_exit_message_time = 0; |
1149 |
|
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1150 |
|
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1151 |
< |
ConfigFileEntry.warn_no_nline = 1; |
1151 |
> |
ConfigFileEntry.warn_no_connect_block = 1; |
1152 |
> |
ConfigFileEntry.stats_e_disabled = 0; |
1153 |
|
ConfigFileEntry.stats_o_oper_only = 0; |
1154 |
< |
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
1155 |
< |
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
1154 |
> |
ConfigFileEntry.stats_k_oper_only = 1; /* 1 = masked */ |
1155 |
> |
ConfigFileEntry.stats_i_oper_only = 1; /* 1 = masked */ |
1156 |
|
ConfigFileEntry.stats_P_oper_only = 0; |
1157 |
|
ConfigFileEntry.stats_u_oper_only = 0; |
1158 |
|
ConfigFileEntry.caller_id_wait = 60; |
1166 |
|
ConfigFileEntry.oper_pass_resv = 1; |
1167 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1168 |
|
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
1169 |
< |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1169 |
< |
UMODE_OPERWALL | UMODE_WALLOP; |
1169 |
> |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP; |
1170 |
|
ConfigFileEntry.use_egd = 0; |
1171 |
|
ConfigFileEntry.egdpool_path = NULL; |
1172 |
+ |
ConfigFileEntry.throttle_count = 0; |
1173 |
|
ConfigFileEntry.throttle_time = 10; |
1174 |
|
} |
1175 |
|
|
1194 |
|
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
1195 |
|
} |
1196 |
|
|
1197 |
< |
/* read_conf() |
1197 |
> |
/* read_conf() |
1198 |
|
* |
1199 |
|
* inputs - file descriptor pointing to config file to use |
1200 |
|
* output - None |
1205 |
|
{ |
1206 |
|
lineno = 0; |
1207 |
|
|
1208 |
< |
set_default_conf(); /* Set default values prior to conf parsing */ |
1208 |
> |
set_default_conf(); /* Set default values prior to conf parsing */ |
1209 |
|
conf_parser_ctx.pass = 1; |
1210 |
< |
yyparse(); /* pick up the classes first */ |
1210 |
> |
yyparse(); /* Pick up the classes first */ |
1211 |
|
|
1212 |
|
rewind(file); |
1213 |
|
|
1214 |
|
conf_parser_ctx.pass = 2; |
1215 |
< |
yyparse(); /* Load the values from the conf */ |
1216 |
< |
validate_conf(); /* Check to make sure some values are still okay. */ |
1217 |
< |
/* Some global values are also loaded here. */ |
1218 |
< |
class_delete_marked(); /* Make sure classes are valid */ |
1215 |
> |
yyparse(); /* Load the values from the conf */ |
1216 |
> |
validate_conf(); /* Check to make sure some values are still okay. */ |
1217 |
> |
/* Some global values are also loaded here. */ |
1218 |
> |
class_delete_marked(); /* Delete unused classes that are marked for deletion */ |
1219 |
|
} |
1220 |
|
|
1221 |
|
/* lookup_confhost() |
1228 |
|
{ |
1229 |
|
struct addrinfo hints, *res; |
1230 |
|
|
1231 |
< |
/* Do name lookup now on hostnames given and store the |
1231 |
> |
/* |
1232 |
> |
* Do name lookup now on hostnames given and store the |
1233 |
|
* ip numbers in conf structure. |
1234 |
|
*/ |
1235 |
|
memset(&hints, 0, sizeof(hints)); |
1246 |
|
return; |
1247 |
|
} |
1248 |
|
|
1249 |
< |
assert(res != NULL); |
1249 |
> |
assert(res); |
1250 |
|
|
1251 |
|
memcpy(&conf->addr, res->ai_addr, res->ai_addrlen); |
1252 |
|
conf->addr.ss_len = res->ai_addrlen; |
1265 |
|
int |
1266 |
|
conf_connect_allowed(struct irc_ssaddr *addr, int aftype) |
1267 |
|
{ |
1268 |
< |
struct ip_entry *ip_found; |
1268 |
> |
struct ip_entry *ip_found = NULL; |
1269 |
|
struct MaskItem *conf = find_dline_conf(addr, aftype); |
1270 |
|
|
1271 |
|
/* DLINE exempt also gets you out of static limits/pacing... */ |
1272 |
|
if (conf && (conf->type == CONF_EXEMPT)) |
1273 |
|
return 0; |
1274 |
|
|
1275 |
< |
if (conf != NULL) |
1275 |
> |
if (conf) |
1276 |
|
return BANNED_CLIENT; |
1277 |
|
|
1278 |
|
ip_found = find_or_add_ip(addr); |
1279 |
|
|
1280 |
< |
if ((CurrentTime - ip_found->last_attempt) < |
1279 |
< |
ConfigFileEntry.throttle_time) |
1280 |
> |
if ((CurrentTime - ip_found->last_attempt) < ConfigFileEntry.throttle_time) |
1281 |
|
{ |
1282 |
< |
ip_found->last_attempt = CurrentTime; |
1283 |
< |
return TOO_FAST; |
1282 |
> |
if (ip_found->connection_count >= ConfigFileEntry.throttle_count) |
1283 |
> |
return TOO_FAST; |
1284 |
> |
|
1285 |
> |
++ip_found->connection_count; |
1286 |
|
} |
1287 |
+ |
else |
1288 |
+ |
ip_found->connection_count = 1; |
1289 |
|
|
1290 |
|
ip_found->last_attempt = CurrentTime; |
1291 |
|
return 0; |
1302 |
|
cleanup_tklines(void *notused) |
1303 |
|
{ |
1304 |
|
hostmask_expire_temporary(); |
1305 |
< |
expire_tklines(&xconf_items); |
1305 |
> |
expire_tklines(&xconf_items); |
1306 |
|
expire_tklines(&nresv_items); |
1307 |
|
expire_tklines(&cresv_items); |
1308 |
|
} |
1316 |
|
static void |
1317 |
|
expire_tklines(dlink_list *tklist) |
1318 |
|
{ |
1319 |
< |
dlink_node *ptr; |
1320 |
< |
dlink_node *next_ptr; |
1316 |
< |
struct MaskItem *conf; |
1319 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
1320 |
> |
struct MaskItem *conf = NULL; |
1321 |
|
|
1322 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head) |
1322 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, tklist->head) |
1323 |
|
{ |
1324 |
|
conf = ptr->data; |
1325 |
|
|
1359 |
|
{ OPER_FLAG_DIE, 'D' }, |
1360 |
|
{ OPER_FLAG_GLINE, 'G' }, |
1361 |
|
{ OPER_FLAG_REHASH, 'H' }, |
1362 |
< |
{ OPER_FLAG_K, 'K' }, |
1359 |
< |
{ OPER_FLAG_OPERWALL, 'L' }, |
1362 |
> |
{ OPER_FLAG_KLINE, 'K' }, |
1363 |
|
{ OPER_FLAG_KILL, 'N' }, |
1364 |
|
{ OPER_FLAG_KILL_REMOTE, 'O' }, |
1365 |
|
{ OPER_FLAG_CONNECT, 'P' }, |
1376 |
|
{ |
1377 |
|
static char privs_out[IRCD_BUFSIZE]; |
1378 |
|
char *privs_ptr = privs_out; |
1376 |
– |
const struct oper_privs *opriv = flag_list; |
1379 |
|
|
1380 |
< |
for (; opriv->flag; ++opriv) |
1380 |
> |
for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv) |
1381 |
|
{ |
1382 |
|
if (port & opriv->flag) |
1383 |
|
*privs_ptr++ = opriv->c; |
1399 |
|
const char * |
1400 |
|
get_oper_name(const struct Client *client_p) |
1401 |
|
{ |
1402 |
< |
dlink_node *cnode = NULL; |
1402 |
> |
const dlink_node *cnode = NULL; |
1403 |
|
/* +5 for !,@,{,} and null */ |
1404 |
|
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
1405 |
|
|
1407 |
|
{ |
1408 |
|
if ((cnode = client_p->localClient->confs.head)) |
1409 |
|
{ |
1410 |
< |
struct MaskItem *conf = cnode->data; |
1410 |
> |
const struct MaskItem *conf = cnode->data; |
1411 |
|
|
1412 |
|
if (IsConfOperator(conf)) |
1413 |
|
{ |
1417 |
|
} |
1418 |
|
} |
1419 |
|
|
1420 |
< |
/* Probably should assert here for now. If there is an oper out there |
1420 |
> |
/* Probably should assert here for now. If there is an oper out there |
1421 |
|
* with no oper{} conf attached, it would be good for us to know... |
1422 |
|
*/ |
1423 |
|
assert(0); /* Oper without oper conf! */ |
1437 |
|
void |
1438 |
|
read_conf_files(int cold) |
1439 |
|
{ |
1440 |
< |
const char *filename; |
1441 |
< |
char chanmodes[IRCD_BUFSIZE]; |
1442 |
< |
char chanlimit[IRCD_BUFSIZE]; |
1440 |
> |
const char *filename = NULL; |
1441 |
> |
char chanmodes[IRCD_BUFSIZE] = ""; |
1442 |
> |
char chanlimit[IRCD_BUFSIZE] = ""; |
1443 |
|
|
1444 |
|
conf_parser_ctx.boot = cold; |
1445 |
|
filename = ConfigFileEntry.configfile; |
1448 |
|
FIXME: The full path is in conffilenamebuf first time since we |
1449 |
|
dont know anything else |
1450 |
|
|
1451 |
< |
- Gozem 2002-07-21 |
1451 |
> |
- Gozem 2002-07-21 |
1452 |
|
*/ |
1453 |
|
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
1454 |
|
|
1486 |
|
add_isupport("CHANTYPES", "#", -1); |
1487 |
|
|
1488 |
|
snprintf(chanlimit, sizeof(chanlimit), "#:%d", |
1489 |
< |
ConfigChannel.max_chans_per_user); |
1489 |
> |
ConfigChannel.max_channels); |
1490 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
1491 |
< |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS"); |
1492 |
< |
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
1491 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS"); |
1492 |
> |
add_isupport("CHANNELLEN", NULL, CHANNELLEN); |
1493 |
|
add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length); |
1494 |
|
add_isupport("CHANMODES", chanmodes, -1); |
1495 |
|
|
1522 |
|
/* We only need to free anything allocated by yyparse() here. |
1523 |
|
* Resetting structs, etc, is taken care of by set_default_conf(). |
1524 |
|
*/ |
1525 |
< |
|
1525 |
> |
|
1526 |
|
for (; *iterator != NULL; iterator++) |
1527 |
|
{ |
1528 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head) |
1570 |
|
MyFree(ConfigFileEntry.egdpool_path); |
1571 |
|
ConfigFileEntry.egdpool_path = NULL; |
1572 |
|
#ifdef HAVE_LIBCRYPTO |
1573 |
< |
if (ServerInfo.rsa_private_key != NULL) |
1573 |
> |
if (ServerInfo.rsa_private_key) |
1574 |
|
{ |
1575 |
|
RSA_free(ServerInfo.rsa_private_key); |
1576 |
|
ServerInfo.rsa_private_key = NULL; |
1609 |
|
* |
1610 |
|
* inputs - pointer to config item |
1611 |
|
* output - NONE |
1612 |
< |
* side effects - Add a class pointer to a conf |
1612 |
> |
* side effects - Add a class pointer to a conf |
1613 |
|
*/ |
1614 |
|
void |
1615 |
|
conf_add_class_to_conf(struct MaskItem *conf, const char *class_name) |
1616 |
|
{ |
1617 |
< |
if (class_name == NULL) |
1617 |
> |
if (class_name == NULL) |
1618 |
|
{ |
1619 |
|
conf->class = class_default; |
1620 |
|
|
1681 |
|
|
1682 |
|
/* |
1683 |
|
* valid_tkline() |
1684 |
< |
* |
1684 |
> |
* |
1685 |
|
* inputs - pointer to ascii string to check |
1686 |
|
* - whether the specified time is in seconds or minutes |
1687 |
|
* output - -1 not enough parameters |
1706 |
|
} |
1707 |
|
|
1708 |
|
/* |
1709 |
< |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
1709 |
> |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
1710 |
|
* i.e. they specifically use 0, I am going to return 1 instead |
1711 |
|
* as a return value of non-zero is used to flag it as a temporary kline |
1712 |
|
*/ |
1713 |
|
if (result == 0) |
1714 |
|
result = 1; |
1715 |
|
|
1716 |
< |
/* |
1716 |
> |
/* |
1717 |
|
* If the incoming time is in seconds convert it to minutes for the purpose |
1718 |
|
* of this calculation |
1719 |
|
*/ |
1720 |
|
if (!minutes) |
1721 |
< |
result = result / 60; |
1721 |
> |
result = result / 60; |
1722 |
|
|
1723 |
|
if (result > MAX_TDKLINE_TIME) |
1724 |
|
result = MAX_TDKLINE_TIME; |
1739 |
|
{ |
1740 |
|
const unsigned char *p = (const unsigned char *)data; |
1741 |
|
unsigned char tmpch = '\0'; |
1742 |
< |
int nonwild = 0; |
1742 |
> |
unsigned int nonwild = 0; |
1743 |
|
|
1744 |
|
while ((tmpch = *p++)) |
1745 |
|
{ |
1770 |
|
int |
1771 |
|
valid_wild_card(struct Client *source_p, int warn, int count, ...) |
1772 |
|
{ |
1773 |
< |
char tmpch; |
1774 |
< |
int nonwild = 0; |
1773 |
> |
unsigned char tmpch = '\0'; |
1774 |
> |
unsigned int nonwild = 0; |
1775 |
|
va_list args; |
1776 |
|
|
1777 |
|
/* |
1790 |
|
|
1791 |
|
while (count--) |
1792 |
|
{ |
1793 |
< |
const char *p = va_arg(args, const char *); |
1793 |
> |
const unsigned char *p = va_arg(args, const unsigned char *); |
1794 |
|
if (p == NULL) |
1795 |
|
continue; |
1796 |
|
|
1812 |
|
} |
1813 |
|
|
1814 |
|
if (warn) |
1815 |
< |
sendto_one(source_p, ":%s NOTICE %s :Please include at least %d non-wildcard characters with the mask", |
1816 |
< |
me.name, source_p->name, ConfigFileEntry.min_nonwildcard); |
1815 |
> |
sendto_one_notice(source_p, &me, |
1816 |
> |
":Please include at least %u non-wildcard characters with the mask", |
1817 |
> |
ConfigFileEntry.min_nonwildcard); |
1818 |
|
va_end(args); |
1819 |
|
return 0; |
1820 |
|
} |
1829 |
|
* - parse_flags bit map of things to test |
1830 |
|
* - pointer to user or string to parse into |
1831 |
|
* - pointer to host or NULL to parse into if non NULL |
1832 |
< |
* - pointer to optional tkline time or NULL |
1832 |
> |
* - pointer to optional tkline time or NULL |
1833 |
|
* - pointer to target_server to parse into if non NULL |
1834 |
|
* - pointer to reason to parse into |
1835 |
|
* |
1856 |
|
char **target_server, char **reason) |
1857 |
|
{ |
1858 |
|
int found_tkline_time=0; |
1859 |
< |
static char def_reason[] = "No Reason"; |
1859 |
> |
static char def_reason[] = CONF_NOREASON; |
1860 |
|
static char user[USERLEN*4+1]; |
1861 |
|
static char host[HOSTLEN*4+1]; |
1862 |
|
|
1874 |
|
*tkline_time = found_tkline_time; |
1875 |
|
else |
1876 |
|
{ |
1877 |
< |
sendto_one(source_p, ":%s NOTICE %s :temp_line not supported by %s", |
1875 |
< |
me.name, source_p->name, cmd); |
1877 |
> |
sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd); |
1878 |
|
return -1; |
1879 |
|
} |
1880 |
|
} |
1881 |
|
|
1882 |
|
if (parc == 0) |
1883 |
|
{ |
1884 |
< |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
1883 |
< |
me.name, source_p->name, cmd); |
1884 |
> |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1885 |
|
return -1; |
1886 |
|
} |
1887 |
|
|
1895 |
|
*up_p = user; |
1896 |
|
*h_p = host; |
1897 |
|
} |
1898 |
< |
|
1898 |
> |
|
1899 |
|
parc--; |
1900 |
|
parv++; |
1901 |
|
|
1908 |
|
|
1909 |
|
if (target_server == NULL) |
1910 |
|
{ |
1911 |
< |
sendto_one(source_p, ":%s NOTICE %s :ON server not supported by %s", |
1911 |
< |
me.name, source_p->name, cmd); |
1911 |
> |
sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd); |
1912 |
|
return -1; |
1913 |
|
} |
1914 |
|
|
1915 |
|
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
1916 |
|
{ |
1917 |
< |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
1918 |
< |
me.name, source_p->name, "remoteban"); |
1917 |
> |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban"); |
1918 |
|
return -1; |
1919 |
|
} |
1920 |
|
|
1921 |
|
if (parc == 0 || EmptyString(*parv)) |
1922 |
|
{ |
1923 |
< |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
1925 |
< |
me.name, source_p->name, cmd); |
1923 |
> |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1924 |
|
return -1; |
1925 |
|
} |
1926 |
|
|
1942 |
|
{ |
1943 |
|
if (strchr(user, '!') != NULL) |
1944 |
|
{ |
1945 |
< |
sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in kline", |
1948 |
< |
me.name, source_p->name); |
1945 |
> |
sendto_one_notice(source_p, &me, ":Invalid character '!' in kline"); |
1946 |
|
return -1; |
1947 |
|
} |
1948 |
|
|
2013 |
|
luser[1] = '\0'; |
2014 |
|
strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1); |
2015 |
|
} |
2016 |
< |
|
2016 |
> |
|
2017 |
|
return 1; |
2018 |
|
} |
2019 |
|
else |
2020 |
|
{ |
2021 |
|
/* Try to find user@host mask from nick */ |
2022 |
|
/* Okay to use source_p as the first param, because source_p == client_p */ |
2023 |
< |
if ((target_p = |
2024 |
< |
find_chasing(source_p, user_host_or_nick, NULL)) == NULL) |
2025 |
< |
return 0; |
2023 |
> |
if ((target_p = |
2024 |
> |
find_chasing(source_p, user_host_or_nick)) == NULL) |
2025 |
> |
return 0; /* find_chasing sends ERR_NOSUCHNICK */ |
2026 |
|
|
2027 |
|
if (IsExemptKline(target_p)) |
2028 |
|
{ |
2029 |
|
if (!IsServer(source_p)) |
2030 |
< |
sendto_one(source_p, |
2034 |
< |
":%s NOTICE %s :%s is E-lined", |
2035 |
< |
me.name, source_p->name, target_p->name); |
2030 |
> |
sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name); |
2031 |
|
return 0; |
2032 |
|
} |
2033 |
|
|
2088 |
|
else |
2089 |
|
encr = password; |
2090 |
|
|
2091 |
< |
return !strcmp(encr, conf->passwd); |
2091 |
> |
return encr && !strcmp(encr, conf->passwd); |
2092 |
|
} |
2093 |
|
|
2094 |
|
/* |
2096 |
|
* |
2097 |
|
* inputs - client sending the cluster |
2098 |
|
* - command name "KLINE" "XLINE" etc. |
2099 |
< |
* - capab -- CAP_KLN etc. from s_serv.h |
2099 |
> |
* - capab -- CAP_KLN etc. from server.h |
2100 |
|
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
2101 |
|
* - pattern and args to send along |
2102 |
|
* output - none |
2108 |
|
int capab, int cluster_type, const char *pattern, ...) |
2109 |
|
{ |
2110 |
|
va_list args; |
2111 |
< |
char buffer[IRCD_BUFSIZE]; |
2111 |
> |
char buffer[IRCD_BUFSIZE] = ""; |
2112 |
|
const dlink_node *ptr = NULL; |
2113 |
|
|
2114 |
|
va_start(args, pattern); |
2169 |
|
{ |
2170 |
|
*p = '\0'; |
2171 |
|
|
2172 |
< |
if (iptr->nickptr && *iptr->nuhmask != '\0') |
2172 |
> |
if (iptr->nickptr && *iptr->nuhmask) |
2173 |
|
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
2174 |
|
|
2175 |
|
if ((q = strchr(++p, '@'))) |
2176 |
|
{ |
2177 |
|
*q++ = '\0'; |
2178 |
|
|
2179 |
< |
if (*p != '\0') |
2179 |
> |
if (*p) |
2180 |
|
strlcpy(iptr->userptr, p, iptr->usersize); |
2181 |
|
|
2182 |
< |
if (*q != '\0') |
2182 |
> |
if (*q) |
2183 |
|
strlcpy(iptr->hostptr, q, iptr->hostsize); |
2184 |
|
} |
2185 |
|
else |
2186 |
|
{ |
2187 |
< |
if (*p != '\0') |
2187 |
> |
if (*p) |
2188 |
|
strlcpy(iptr->userptr, p, iptr->usersize); |
2189 |
|
} |
2190 |
|
} |
2196 |
|
/* if found a @ */ |
2197 |
|
*p++ = '\0'; |
2198 |
|
|
2199 |
< |
if (*iptr->nuhmask != '\0') |
2199 |
> |
if (*iptr->nuhmask) |
2200 |
|
strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize); |
2201 |
|
|
2202 |
< |
if (*p != '\0') |
2202 |
> |
if (*p) |
2203 |
|
strlcpy(iptr->hostptr, p, iptr->hostsize); |
2204 |
|
} |
2205 |
|
else |