45 |
|
#include "rng_mt.h" |
46 |
|
#include "s_auth.h" |
47 |
|
#include "s_bsd.h" |
48 |
< |
#include "s_conf.h" |
49 |
< |
#include "s_log.h" |
48 |
> |
#include "conf.h" |
49 |
> |
#include "log.h" |
50 |
|
#include "s_misc.h" |
51 |
|
#include "s_serv.h" /* try_connections */ |
52 |
|
#include "send.h" |
59 |
|
#include "motd.h" |
60 |
|
#include "supported.h" |
61 |
|
#include "watch.h" |
62 |
< |
|
62 |
> |
#include "conf_db.h" |
63 |
|
|
64 |
|
/* /quote set variables */ |
65 |
|
struct SetOptions GlobalSetOptions; |
72 |
|
struct admin_info AdminInfo = { NULL, NULL, NULL }; |
73 |
|
struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
74 |
|
struct ServerState_t server_state = { 0 }; |
75 |
< |
struct logging_entry ConfigLoggingEntry = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} }; |
75 |
> |
struct logging_entry ConfigLoggingEntry = { .use_logging = 1 }; |
76 |
|
struct ServerStatistics ServerStats; |
77 |
|
struct timeval SystemTime; |
78 |
|
struct Client me; /* That's me */ |
82 |
|
const char *pidFileName = PPATH; |
83 |
|
|
84 |
|
char **myargv; |
85 |
– |
char ircd_platform[PLATFORMLEN]; |
85 |
|
|
86 |
|
int dorehash = 0; |
87 |
|
int doremotd = 0; |
90 |
|
* initialize_server_capabs |
91 |
|
*/ |
92 |
|
int default_server_capabs = 0; |
94 |
– |
|
95 |
– |
#ifdef HAVE_LIBCRYPTO |
96 |
– |
int bio_spare_fd = -1; |
97 |
– |
#endif |
98 |
– |
|
93 |
|
unsigned int splitmode; |
94 |
|
unsigned int splitchecking; |
95 |
|
unsigned int split_users; |
141 |
|
|
142 |
|
static int printVersion = 0; |
143 |
|
|
144 |
< |
struct lgetopt myopts[] = { |
144 |
> |
static struct lgetopt myopts[] = { |
145 |
|
{"dlinefile", &ConfigFileEntry.dlinefile, |
146 |
|
STRING, "File to use for dline.conf"}, |
147 |
|
{"configfile", &ConfigFileEntry.configfile, |
172 |
|
|
173 |
|
if (gettimeofday(&newtime, NULL) == -1) |
174 |
|
{ |
175 |
< |
ilog(L_ERROR, "Clock Failure (%s), TS can be corrupted", |
175 |
> |
ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted", |
176 |
|
strerror(errno)); |
177 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
177 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
178 |
|
"Clock Failure (%s), TS can be corrupted", |
179 |
|
strerror(errno)); |
180 |
|
restart("Clock Failure"); |
243 |
|
if (doremotd) |
244 |
|
{ |
245 |
|
read_message_file(&ConfigFileEntry.motd); |
246 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
246 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
247 |
|
"Got signal SIGUSR1, reloading ircd motd file"); |
248 |
|
doremotd = 0; |
249 |
|
} |
298 |
|
initialize_message_files(void) |
299 |
|
{ |
300 |
|
init_message_file(USER_MOTD, MPATH, &ConfigFileEntry.motd); |
307 |
– |
init_message_file(OPER_MOTD, OPATH, &ConfigFileEntry.opermotd); |
301 |
|
init_message_file(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile); |
302 |
|
|
303 |
|
read_message_file(&ConfigFileEntry.motd); |
311 |
– |
read_message_file(&ConfigFileEntry.opermotd); |
304 |
|
read_message_file(&ConfigFileEntry.linksfile); |
305 |
|
|
306 |
|
init_isupport(); |
317 |
|
add_capability("QS", CAP_QS, 1); |
318 |
|
add_capability("EOB", CAP_EOB, 1); |
319 |
|
add_capability("TS6", CAP_TS6, 0); |
328 |
– |
add_capability("ZIP", CAP_ZIP, 0); |
320 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
321 |
|
add_capability("SVS", CAP_SVS, 1); |
322 |
|
#ifdef HALFOPS |
333 |
|
static void |
334 |
|
write_pidfile(const char *filename) |
335 |
|
{ |
336 |
< |
FBFILE *fb; |
336 |
> |
FILE *fb; |
337 |
|
|
338 |
< |
if ((fb = fbopen(filename, "w"))) |
338 |
> |
if ((fb = fopen(filename, "w"))) |
339 |
|
{ |
340 |
|
char buff[32]; |
341 |
|
unsigned int pid = (unsigned int)getpid(); |
351 |
– |
size_t nbytes = snprintf(buff, sizeof(buff), "%u\n", pid); |
342 |
|
|
343 |
< |
if ((fbputs(buff, fb, nbytes) == -1)) |
344 |
< |
ilog(L_ERROR, "Error writing %u to pid file %s (%s)", |
343 |
> |
snprintf(buff, sizeof(buff), "%u\n", pid); |
344 |
> |
|
345 |
> |
if ((fputs(buff, fb) == -1)) |
346 |
> |
ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)", |
347 |
|
pid, filename, strerror(errno)); |
348 |
|
|
349 |
< |
fbclose(fb); |
358 |
< |
return; |
349 |
> |
fclose(fb); |
350 |
|
} |
351 |
|
else |
352 |
|
{ |
353 |
< |
ilog(L_ERROR, "Error opening pid file %s", filename); |
353 |
> |
ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename); |
354 |
|
} |
355 |
|
} |
356 |
|
|
365 |
|
static void |
366 |
|
check_pidfile(const char *filename) |
367 |
|
{ |
368 |
< |
FBFILE *fb; |
368 |
> |
FILE *fb; |
369 |
|
char buff[32]; |
370 |
|
pid_t pidfromfile; |
371 |
|
|
372 |
|
/* Don't do logging here, since we don't have log() initialised */ |
373 |
< |
if ((fb = fbopen(filename, "r"))) |
373 |
> |
if ((fb = fopen(filename, "r"))) |
374 |
|
{ |
375 |
< |
if (fbgets(buff, 20, fb) == NULL) |
375 |
> |
if (fgets(buff, 20, fb) == NULL) |
376 |
|
{ |
377 |
|
/* log(L_ERROR, "Error reading from pid file %s (%s)", filename, |
378 |
|
* strerror(errno)); |
390 |
|
} |
391 |
|
} |
392 |
|
|
393 |
< |
fbclose(fb); |
393 |
> |
fclose(fb); |
394 |
|
} |
395 |
|
else if (errno != ENOENT) |
396 |
|
{ |
437 |
|
{ |
438 |
|
const char *s; |
439 |
|
|
440 |
< |
fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n", |
440 |
> |
fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", |
441 |
|
s = ERR_lib_error_string(ERR_get_error())); |
442 |
< |
ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s); |
442 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s); |
443 |
|
} |
444 |
|
|
445 |
< |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2); |
445 |
> |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
446 |
|
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
447 |
|
SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_NONE, NULL); |
448 |
|
|
449 |
< |
bio_spare_fd = save_spare_fd("SSL private key validation"); |
449 |
> |
if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) |
450 |
> |
{ |
451 |
> |
const char *s; |
452 |
> |
|
453 |
> |
fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", |
454 |
> |
s = ERR_lib_error_string(ERR_get_error())); |
455 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s); |
456 |
> |
} |
457 |
> |
|
458 |
> |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
459 |
> |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
460 |
> |
SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_NONE, NULL); |
461 |
|
#endif /* HAVE_LIBCRYPTO */ |
462 |
|
} |
463 |
|
|
472 |
|
{ |
473 |
|
iorecv_cb = register_callback("iorecv", iorecv_default); |
474 |
|
iosend_cb = register_callback("iosend", iosend_default); |
473 |
– |
iorecvctrl_cb = register_callback("iorecvctrl", NULL); |
474 |
– |
iosendctrl_cb = register_callback("iosendctrl", NULL); |
475 |
|
} |
476 |
|
|
477 |
|
int |
505 |
|
ConfigFileEntry.configfile = CPATH; /* Server configuration file */ |
506 |
|
ConfigFileEntry.klinefile = KPATH; /* Server kline file */ |
507 |
|
ConfigFileEntry.xlinefile = XPATH; /* Server xline file */ |
508 |
– |
ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file */ |
509 |
– |
ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file */ |
508 |
|
ConfigFileEntry.dlinefile = DLPATH; /* dline file */ |
509 |
< |
ConfigFileEntry.glinefile = GPATH; /* gline log file */ |
510 |
< |
ConfigFileEntry.cresvfile = CRESVPATH; /* channel resv file */ |
513 |
< |
ConfigFileEntry.nresvfile = NRESVPATH; /* nick resv file */ |
509 |
> |
// ConfigFileEntry.cresvfile = CRESVPATH; /* channel resv file */ |
510 |
> |
// ConfigFileEntry.nresvfile = NRESVPATH; /* nick resv file */ |
511 |
|
myargv = argv; |
512 |
|
umask(077); /* better safe than sorry --SRB */ |
513 |
|
|
537 |
|
|
538 |
|
setup_signals(); |
539 |
|
|
543 |
– |
get_ircd_platform(ircd_platform); |
544 |
– |
|
540 |
|
/* Init the event subsystem */ |
541 |
|
eventInit(); |
542 |
|
/* We need this to initialise the fd array before anything else */ |
543 |
|
fdlist_init(); |
544 |
< |
init_log(logFileName); |
544 |
> |
log_add_file(LOG_TYPE_IRCD, 0, logFileName); |
545 |
|
check_can_use_v6(); |
546 |
|
init_comm(); /* This needs to be setup early ! -- adrian */ |
547 |
|
/* Check if there is pidfile and daemon already running */ |
555 |
|
init_hash(); |
556 |
|
init_ip_hash_table(); /* client host ip hash table */ |
557 |
|
init_host_hash(); /* Host-hashtable. */ |
563 |
– |
clear_tree_parse(); |
558 |
|
init_client(); |
559 |
|
init_class(); |
560 |
< |
init_whowas(); |
560 |
> |
whowas_init(); |
561 |
|
watch_init(); |
562 |
|
init_auth(); /* Initialise the auth code */ |
563 |
|
init_resolver(); /* Needs to be setup before the io loop */ |
564 |
+ |
modules_init(); |
565 |
|
read_conf_files(1); /* cold start init conf files */ |
566 |
|
init_uid(); |
567 |
|
initialize_server_capabs(); /* Set up default_server_capabs */ |
570 |
|
|
571 |
|
if (EmptyString(ServerInfo.sid)) |
572 |
|
{ |
573 |
< |
ilog(L_CRIT, "ERROR: No server id specified in serverinfo block."); |
573 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block."); |
574 |
|
exit(EXIT_FAILURE); |
575 |
|
} |
576 |
|
|
578 |
|
|
579 |
|
if (EmptyString(ServerInfo.name)) |
580 |
|
{ |
581 |
< |
ilog(L_CRIT, "ERROR: No server name specified in serverinfo block."); |
581 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block."); |
582 |
|
exit(EXIT_FAILURE); |
583 |
|
} |
584 |
|
|
587 |
|
/* serverinfo{} description must exist. If not, error out.*/ |
588 |
|
if (EmptyString(ServerInfo.description)) |
589 |
|
{ |
590 |
< |
ilog(L_CRIT, "ERROR: No server description specified in serverinfo block."); |
590 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block."); |
591 |
|
exit(EXIT_FAILURE); |
592 |
|
} |
593 |
|
|
608 |
|
/* add ourselves to global_serv_list */ |
609 |
|
dlinkAdd(&me, make_dlink_node(), &global_serv_list); |
610 |
|
|
611 |
+ |
load_kline_database(); |
612 |
+ |
load_dline_database(); |
613 |
+ |
load_gline_database(); |
614 |
+ |
load_xline_database(); |
615 |
+ |
load_resv_database(); |
616 |
+ |
|
617 |
|
if (chdir(MODPATH)) |
618 |
|
{ |
619 |
< |
ilog(L_CRIT, "Could not load core modules. Terminating!"); |
619 |
> |
ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!"); |
620 |
|
exit(EXIT_FAILURE); |
621 |
|
} |
622 |
|
|
639 |
|
|
640 |
|
write_pidfile(pidFileName); |
641 |
|
|
642 |
< |
ilog(L_NOTICE, "Server Ready"); |
642 |
> |
ilog(LOG_TYPE_IRCD, "Server Ready"); |
643 |
|
|
644 |
|
eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME); |
645 |
|
eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME); |
648 |
|
/* No, 'cause after a restart it would cause all sorts of nick collides */ |
649 |
|
eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME); |
650 |
|
|
650 |
– |
eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME); |
651 |
– |
|
651 |
|
/* Setup the timeout check. I'll shift it later :) -- adrian */ |
652 |
|
eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1); |
653 |
|
|
654 |
+ |
eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT); |
655 |
+ |
|
656 |
|
if (ConfigServerHide.links_delay > 0) |
657 |
|
eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay); |
658 |
|
else |