X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/b1d6fa8cd26295c1f68129d402ba7f1c597fb9e7..d25c6eb1b223d1a0993dde9a28c97ef95e54bceb:/src/ircd.c diff --git a/src/ircd.c b/src/ircd.c index 1a8efa1..8577081 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -66,6 +66,8 @@ #include "serno.h" #include "sslproc.h" #include "chmode.h" +#include "privilege.h" +#include "bandbi.h" /* /quote set variables */ struct SetOptions GlobalSetOptions; @@ -188,7 +190,7 @@ init_sys(void) if(maxconnections <= MAX_BUFFER) { fprintf(stderr, "ERROR: Shell FD limits are too low.\n"); - fprintf(stderr, "ERROR: ircd-ratbox reserves %d FDs, shell limits must be above this\n", MAX_BUFFER); + fprintf(stderr, "ERROR: charybdis reserves %d FDs, shell limits must be above this\n", MAX_BUFFER); exit(EXIT_FAILURE); } return; @@ -241,16 +243,8 @@ make_daemon(void) static int printVersion = 0; struct lgetopt myopts[] = { - {"dlinefile", &ConfigFileEntry.dlinefile, - STRING, "File to use for dlines.conf"}, {"configfile", &ConfigFileEntry.configfile, STRING, "File to use for ircd.conf"}, - {"klinefile", &ConfigFileEntry.klinefile, - STRING, "File to use for kline.conf"}, - {"xlinefile", &ConfigFileEntry.xlinefile, - STRING, "File to use for xline.conf"}, - {"resvfile", &ConfigFileEntry.resvfile, - STRING, "File to use for resv.conf"}, {"logfile", &logFileName, STRING, "File to use for ircd.log"}, {"pidfile", &pidFileName, @@ -447,12 +441,13 @@ setup_corefile(void) static void ircd_log_cb(const char *str) { - ilog(L_MAIN, "%s", str); + ilog(L_MAIN, "libratbox reports: %s", str); } static void ircd_restart_cb(const char *str) { + inotice("libratbox has called the restart callback: %s", str); restart(str); } @@ -469,9 +464,11 @@ ircd_die_cb(const char *str) if(str != NULL) { /* Try to get the message out to currently logged in operators. */ - sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Server panic! %s", str); - inotice("server panic: %s", str); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "libratbox has called the die callback..aborting: %s", str); + inotice("libratbox has called the die callback..aborting: %s", str); } + else + inotice("libratbox has called the die callback..aborting"); unlink(pidFileName); exit(EXIT_FAILURE); @@ -541,6 +538,23 @@ main(int argc, char *argv[]) return -1; } + init_sys(); + + ConfigFileEntry.dpath = DPATH; + ConfigFileEntry.configfile = CPATH; /* Server configuration file */ + ConfigFileEntry.connect_timeout = 30; /* Default to 30 */ + + umask(077); /* better safe than sorry --SRB */ + + myargv = argv; + parseargs(&argc, &argv, myopts); + + if(chdir(ConfigFileEntry.dpath)) + { + fprintf(stderr, "Unable to chdir to %s: %s\n", ConfigFileEntry.dpath, strerror(errno)); + exit(EXIT_FAILURE); + } + rb_set_time(); /* @@ -570,29 +584,14 @@ main(int argc, char *argv[]) /* Initialise the channel capability usage counts... */ init_chcap_usage_counts(); - ConfigFileEntry.dpath = DPATH; - ConfigFileEntry.configfile = CPATH; /* Server configuration file */ - ConfigFileEntry.klinefile = KPATH; /* Server kline file */ - ConfigFileEntry.dlinefile = DLPATH; /* dline file */ - ConfigFileEntry.xlinefile = XPATH; - ConfigFileEntry.resvfile = RESVPATH; - ConfigFileEntry.connect_timeout = 30; /* Default to 30 */ - myargv = argv; - umask(077); /* better safe than sorry --SRB */ - - parseargs(&argc, &argv, myopts); - if(printVersion) { printf("ircd: version %s(%s)\n", ircd_version, serno); + printf("ircd: %s\n", rb_lib_version()); exit(EXIT_SUCCESS); } - if(chdir(ConfigFileEntry.dpath)) - { - fprintf(stderr, "Unable to chdir to %s: %s\n", ConfigFileEntry.dpath, strerror(errno)); - exit(EXIT_FAILURE); - } + setup_signals(); @@ -617,13 +616,21 @@ main(int argc, char *argv[]) if(!server_state_foreground) make_daemon(); inotice("starting %s ...", ircd_version); + inotice("%s", rb_lib_version()); } /* Init the event subsystem */ - init_sys(); rb_lib_init(ircd_log_cb, ircd_restart_cb, ircd_die_cb, !server_state_foreground, maxconnections, DNODE_HEAP_SIZE, FD_HEAP_SIZE); rb_linebuf_init(LINEBUF_HEAP_SIZE); + if(ConfigFileEntry.use_egd && (ConfigFileEntry.egdpool_path != NULL)) + { + rb_init_prng(ConfigFileEntry.egdpool_path, RB_PRNG_EGD); + } else + rb_init_prng(NULL, RB_PRNG_DEFAULT); + + seed_random(NULL); + init_main_logfile(); newconf_init(); init_s_conf(); @@ -641,25 +648,37 @@ main(int argc, char *argv[]) init_cache(); init_monitor(); init_isupport(); + + /* noparam core modes have to be initialized before the module + * system is initialized, otherwise we have a table collision. + * + * modules call this after they are done initializing... + * --nenolod + */ + construct_noparam_modes(); + load_all_modules(1); #ifndef STATIC_MODULES load_core_modules(1); #endif init_auth(); /* Initialise the auth code */ init_resolver(); /* Needs to be setup before the io loop */ + privilegeset_set_new("default", "", 0); if (testing_conf) fprintf(stderr, "\nBeginning config test\n"); read_conf_files(YES); /* cold start init conf files */ - rehash_bans(0); #ifndef STATIC_MODULES mod_add_path(MODULE_DIR); mod_add_path(MODULE_DIR "/autoload"); #endif + init_bandb(); init_ssld(); + rehash_bans(0); + initialize_server_capabs(); /* Set up default_server_capabs */ initialize_global_set_options(); @@ -717,7 +736,6 @@ main(int argc, char *argv[]) rb_dlinkAddAlloc(&me, &global_serv_list); construct_umodebuf(); - construct_noparam_modes(); check_class(); write_pidfile(pidFileName);