1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (c) 1997-2014 ircd-hybrid development team |
4 |
> |
* Copyright (c) 1997-2015 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 |
15 |
|
* |
16 |
|
* You should have received a copy of the GNU General Public License |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
< |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
18 |
> |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
|
* USA |
20 |
|
*/ |
21 |
|
|
63 |
|
GeoIP *geoip_ctx; |
64 |
|
#endif |
65 |
|
|
66 |
– |
struct ServerStatistics ServerStats; |
66 |
|
struct timeval SystemTime; |
67 |
< |
struct Client me; /* That's me */ |
68 |
< |
struct LocalUser meLocalUser; /* That's also part of me */ |
67 |
> |
struct Connection meConnection; /* That's also part of me */ |
68 |
> |
struct Client me = { .connection = &meConnection }; /* That's me */ |
69 |
|
|
70 |
+ |
char **myargv; |
71 |
|
const char *logFileName = LPATH; |
72 |
|
const char *pidFileName = PPATH; |
73 |
|
|
74 |
< |
char **myargv; |
75 |
< |
|
76 |
< |
int dorehash = 0; |
77 |
< |
int doremotd = 0; |
78 |
< |
|
79 |
< |
/* Set to zero because it should be initialized later using |
80 |
< |
* initialize_server_capabs |
81 |
< |
*/ |
74 |
> |
unsigned int dorehash; |
75 |
> |
unsigned int doremotd; |
76 |
|
unsigned int default_server_capabs; |
77 |
|
unsigned int splitmode; |
78 |
|
unsigned int splitchecking; |
217 |
|
{ |
218 |
|
if (listing_client_list.head) |
219 |
|
{ |
220 |
< |
dlink_node *ptr = NULL, *ptr_next = NULL; |
221 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, listing_client_list.head) |
222 |
< |
safe_list_channels(ptr->data, 0); |
220 |
> |
dlink_node *node = NULL, *node_next = NULL; |
221 |
> |
DLINK_FOREACH_SAFE(node, node_next, listing_client_list.head) |
222 |
> |
safe_list_channels(node->data, 0); |
223 |
|
} |
224 |
|
|
225 |
|
/* Run pending events */ |
232 |
|
/* Check to see whether we have to rehash the configuration .. */ |
233 |
|
if (dorehash) |
234 |
|
{ |
235 |
< |
rehash(1); |
235 |
> |
conf_rehash(1); |
236 |
|
dorehash = 0; |
237 |
|
} |
238 |
|
|
264 |
|
else |
265 |
|
GlobalSetOptions.floodcount = 10; |
266 |
|
|
267 |
< |
/* XXX I have no idea what to try here - Dianora */ |
268 |
< |
GlobalSetOptions.joinfloodcount = 16; |
275 |
< |
GlobalSetOptions.joinfloodtime = 8; |
267 |
> |
GlobalSetOptions.joinfloodcount = 18; |
268 |
> |
GlobalSetOptions.joinfloodtime = 6; |
269 |
|
|
270 |
|
split_servers = ConfigChannel.default_split_server_count; |
271 |
|
split_users = ConfigChannel.default_split_user_count; |
315 |
|
|
316 |
|
snprintf(buff, sizeof(buff), "%u\n", pid); |
317 |
|
|
318 |
< |
if ((fputs(buff, fb) == -1)) |
318 |
> |
if (fputs(buff, fb) == -1) |
319 |
|
ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)", |
320 |
|
pid, filename, strerror(errno)); |
321 |
|
|
323 |
|
} |
324 |
|
else |
325 |
|
{ |
326 |
< |
ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename); |
326 |
> |
ilog(LOG_TYPE_IRCD, "Error opening pid file %s (%s)", |
327 |
> |
filename, strerror(errno)); |
328 |
|
} |
329 |
|
} |
330 |
|
|
346 |
|
/* Don't do logging here, since we don't have log() initialised */ |
347 |
|
if ((fb = fopen(filename, "r"))) |
348 |
|
{ |
349 |
< |
if (fgets(buff, 20, fb) == NULL) |
349 |
> |
if (!fgets(buff, 20, fb)) |
350 |
|
{ |
351 |
|
/* log(L_ERROR, "Error reading from pid file %s (%s)", filename, |
352 |
|
* strerror(errno)); |
412 |
|
ssl_init(void) |
413 |
|
{ |
414 |
|
#ifdef HAVE_LIBCRYPTO |
421 |
– |
const unsigned char session_id[] = "ircd-hybrid"; |
422 |
– |
|
415 |
|
SSL_load_error_strings(); |
416 |
|
SSLeay_add_ssl_algorithms(); |
417 |
|
|
418 |
< |
if ((ConfigServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) |
418 |
> |
if (!(ConfigServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method()))) |
419 |
|
{ |
420 |
|
const char *s = ERR_lib_error_string(ERR_get_error()); |
421 |
|
|
422 |
|
fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", s); |
423 |
< |
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s); |
423 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s", s); |
424 |
|
exit(EXIT_FAILURE); |
425 |
+ |
return; /* Not reached */ |
426 |
|
} |
427 |
|
|
428 |
< |
SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3); |
429 |
< |
SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_DH_USE); |
428 |
> |
SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET); |
429 |
> |
SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_DH_USE|SSL_OP_CIPHER_SERVER_PREFERENCE); |
430 |
|
SSL_CTX_set_verify(ConfigServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
431 |
|
always_accept_verify_cb); |
432 |
< |
SSL_CTX_set_session_id_context(ConfigServerInfo.server_ctx, session_id, sizeof(session_id) - 1); |
432 |
> |
SSL_CTX_set_session_cache_mode(ConfigServerInfo.server_ctx, SSL_SESS_CACHE_OFF); |
433 |
> |
SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL"); |
434 |
|
|
435 |
< |
#if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH) |
435 |
> |
#if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH) |
436 |
|
{ |
437 |
|
EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); |
438 |
|
|
446 |
|
SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE); |
447 |
|
#endif |
448 |
|
|
449 |
< |
if ((ConfigServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) |
449 |
> |
if (!(ConfigServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method()))) |
450 |
|
{ |
451 |
|
const char *s = ERR_lib_error_string(ERR_get_error()); |
452 |
|
|
453 |
|
fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", s); |
454 |
< |
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s); |
454 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s", s); |
455 |
|
exit(EXIT_FAILURE); |
456 |
+ |
return; /* Not reached */ |
457 |
|
} |
458 |
|
|
459 |
< |
SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3); |
459 |
> |
SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET); |
460 |
|
SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_SINGLE_DH_USE); |
461 |
|
SSL_CTX_set_verify(ConfigServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
462 |
|
always_accept_verify_cb); |
463 |
+ |
SSL_CTX_set_session_cache_mode(ConfigServerInfo.client_ctx, SSL_SESS_CACHE_OFF); |
464 |
|
#endif /* HAVE_LIBCRYPTO */ |
465 |
|
} |
466 |
|
|
468 |
|
main(int argc, char *argv[]) |
469 |
|
{ |
470 |
|
/* Check to see if the user is running us as root, which is a nono */ |
471 |
< |
if (geteuid() == 0) |
471 |
> |
if (!geteuid()) |
472 |
|
{ |
473 |
|
fprintf(stderr, "ERROR: This server won't run as root/superuser\n"); |
474 |
|
return -1; |
483 |
|
/* It ain't random, but it ought to be a little harder to guess */ |
484 |
|
init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); |
485 |
|
|
490 |
– |
me.localClient = &meLocalUser; |
486 |
|
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
487 |
|
of Client list */ |
488 |
|
ConfigLog.use_logging = 1; |
540 |
|
dbuf_init(); |
541 |
|
hash_init(); |
542 |
|
ipcache_init(); |
548 |
– |
init_host_hash(); /* Host-hashtable. */ |
543 |
|
client_init(); |
544 |
|
class_init(); |
545 |
|
whowas_init(); |
554 |
|
channel_init(); |
555 |
|
read_links_file(); |
556 |
|
motd_init(); |
557 |
+ |
user_usermodes_init(); |
558 |
|
#ifdef HAVE_LIBGEOIP |
559 |
|
geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE); |
560 |
|
#endif |
586 |
|
|
587 |
|
me.from = &me; |
588 |
|
me.servptr = &me; |
589 |
< |
me.localClient->lasttime = CurrentTime; |
590 |
< |
me.localClient->since = CurrentTime; |
591 |
< |
me.localClient->firsttime = CurrentTime; |
589 |
> |
me.connection->lasttime = CurrentTime; |
590 |
> |
me.connection->since = CurrentTime; |
591 |
> |
me.connection->firsttime = CurrentTime; |
592 |
|
|
593 |
|
SetMe(&me); |
594 |
|
make_server(&me); |
604 |
|
load_xline_database(); |
605 |
|
load_resv_database(); |
606 |
|
|
612 |
– |
if (chdir(MODPATH)) |
613 |
– |
{ |
614 |
– |
ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!"); |
615 |
– |
exit(EXIT_FAILURE); |
616 |
– |
} |
617 |
– |
|
607 |
|
load_all_modules(1); |
608 |
|
load_conf_modules(); |
609 |
|
load_core_modules(1); |
610 |
|
|
622 |
– |
/* Go back to DPATH after checking to see if we can chdir to MODPATH */ |
623 |
– |
if (chdir(ConfigGeneral.dpath)) |
624 |
– |
{ |
625 |
– |
perror("chdir"); |
626 |
– |
exit(EXIT_FAILURE); |
627 |
– |
} |
628 |
– |
|
629 |
– |
/* |
630 |
– |
* assemble_umode_buffer() has to be called after |
631 |
– |
* reading conf/loading modules. |
632 |
– |
*/ |
633 |
– |
assemble_umode_buffer(); |
634 |
– |
|
611 |
|
write_pidfile(pidFileName); |
612 |
|
|
613 |
|
ilog(LOG_TYPE_IRCD, "Server Ready"); |