]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/ircd.c
Change config option for ident_timeout to default_ident_timeout as jilles
[irc/rqf/shadowircd.git] / src / ircd.c
index b4f69e1da9123d0d4f1e8c6f24905ad7d273c637..b5f8076ac3fc667635d5696bc2da9482eebb42ef 100644 (file)
@@ -1,10 +1,11 @@
 /*
- *  ircd-ratbox: A slightly useful ircd.
+ *  charybdis: A slightly useful ircd.
  *  ircd.c: Starts up and runs the ircd.
  *
  *  Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
  *  Copyright (C) 1996-2002 Hybrid Development Team
- *  Copyright (C) 2002-2005 ircd-ratbox development team
+ *  Copyright (C) 2002-2008 ircd-ratbox development team
+ *  Copyright (C) 2005-2008 charybdis development team
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -21,7 +22,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: ircd.c 3380 2007-04-03 22:25:11Z jilles $
+ *  $Id$
  */
 
 #include "ratbox_lib.h"
@@ -65,6 +66,8 @@
 #include "serno.h"
 #include "sslproc.h"
 #include "chmode.h"
+#include "privilege.h"
+#include "bandbi.h"
 
 /* /quote set variables */
 struct SetOptions GlobalSetOptions;
@@ -93,17 +96,6 @@ rb_dlink_list global_serv_list;    /* global servers on the network */
 rb_dlink_list local_oper_list;     /* our opers, duplicated in lclient_list */
 rb_dlink_list oper_list;           /* network opers */
 
-time_t startup_time;
-
-int default_server_capabs = CAP_MASK;
-
-int splitmode;
-int splitchecking;
-int split_users;
-int split_servers;
-int eob_count;
-
-unsigned long initialVMTop = 0;  /* top of virtual memory at init */
 const char *logFileName = LPATH;
 const char *pidFileName = PPATH;
 
@@ -118,15 +110,15 @@ int ssl_ok = 0;
 int zlib_ok = 1;
 
 int testing_conf = 0;
+time_t startup_time;
 
-/* patricia */
-rb_bh *prefix_heap;
-rb_bh *node_heap;
-rb_bh *patricia_heap;
-
-rb_bh *linebuf_heap;
+int default_server_capabs = CAP_MASK;
 
-rb_bh *dnode_heap;
+int splitmode;
+int splitchecking;
+int split_users;
+int split_servers;
+int eob_count;
 
 void
 ircd_shutdown(const char *reason)
@@ -179,39 +171,6 @@ print_startup(int pid)
        dup2(0, 2);
 }
 
-static void
-ircd_log_cb(const char *str)
-{
-       ilog(L_MAIN, "%s", str);
-}
-
-static void
-ircd_restart_cb(const char *str)
-{
-       restart(str);
-}
-
-/*
- * Why EXIT_FAILURE here?
- * Because if ircd_die_cb() is called it's because of a fatal
- * error inside libcharybdis, and we don't know how to handle the
- * exception, so it is logical to return a FAILURE exit code here.
- *    --nenolod
- */
-static void
-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);
-       }
-
-       unlink(pidFileName);
-       exit(EXIT_FAILURE);
-}
-
 /*
  * init_sys
  *
@@ -231,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;
@@ -284,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,
@@ -373,7 +324,10 @@ initialize_global_set_options(void)
                splitchecking = 1;
        }
 
-       GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
+       if(ConfigFileEntry.default_ident_timeout)
+               GlobalSetOptions.ident_timeout = ConfigFileEntry.default_ident_timeout;
+       else
+               GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
 
        rb_strlcpy(GlobalSetOptions.operstring,
                ConfigFileEntry.default_operstring,
@@ -487,6 +441,42 @@ setup_corefile(void)
 #endif
 }
 
+static void
+ircd_log_cb(const char *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);
+}
+
+/*
+ * Why EXIT_FAILURE here?
+ * Because if ircd_die_cb() is called it's because of a fatal
+ * error inside libcharybdis, and we don't know how to handle the
+ * exception, so it is logical to return a FAILURE exit code here.
+ *    --nenolod
+ */
+static void
+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, "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);
+}
+
 struct ev_entry *check_splitmode_ev = NULL;
 
 static int
@@ -551,6 +541,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();
 
        /*
@@ -580,35 +587,16 @@ 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();
 
-#ifdef __CYGWIN__
-       server_state_foreground = 1;
-#endif
+       setup_signals();
 
        if (testing_conf)
                server_state_foreground = 1;
@@ -631,13 +619,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();
@@ -655,25 +651,31 @@ main(int argc, char *argv[])
        init_cache();
        init_monitor();
        init_isupport();
+
+        construct_cflags_strings();
+
        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();
 
@@ -731,7 +733,6 @@ main(int argc, char *argv[])
        rb_dlinkAddAlloc(&me, &global_serv_list);
 
        construct_umodebuf();
-        construct_noparam_modes();
 
        check_class();
        write_pidfile(pidFileName);
@@ -746,12 +747,12 @@ main(int argc, char *argv[])
         * nick collisions.  what a stupid idea. set an event for the IO loop --fl
         */
        rb_event_addish("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
-       rb_event_addonce("try_connections_startup", try_connections, NULL, 0);
-       rb_event_add("check_rehash", check_rehash, NULL, 1);
+       rb_event_addonce("try_connections_startup", try_connections, NULL, 2);
+       rb_event_add("check_rehash", check_rehash, NULL, 3);
        rb_event_addish("reseed_srand", seed_random, NULL, 300); /* reseed every 10 minutes */
 
        if(splitmode)
-               check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 2);
+               check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 5);
 
        print_startup(getpid());