ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/ircd.c
(Generate patch)

Comparing:
ircd-hybrid-7.2/src/ircd.c (file contents), Revision 876 by michael, Wed Oct 24 21:51:21 2007 UTC vs.
ircd-hybrid/trunk/src/ircd.c (file contents), Revision 2872 by michael, Sun Jan 19 17:25:38 2014 UTC

# Line 24 | Line 24
24  
25   #include "stdinc.h"
26   #include "s_user.h"
27 < #include "tools.h"
27 > #include "list.h"
28   #include "ircd.h"
29   #include "channel.h"
30   #include "channel_mode.h"
31   #include "client.h"
32 – #include "common.h"
32   #include "event.h"
33   #include "fdlist.h"
34   #include "hash.h"
35   #include "irc_string.h"
37 – #include "sprintf_irc.h"
36   #include "ircd_signal.h"
39 – #include "list.h"
37   #include "s_gline.h"
38   #include "motd.h"
39 < #include "ircd_handler.h"
43 < #include "msg.h"         /* msgtab */
39 > #include "conf.h"
40   #include "hostmask.h"
41   #include "numeric.h"
42   #include "packet.h"
43   #include "parse.h"
44   #include "irc_res.h"
45   #include "restart.h"
46 + #include "rng_mt.h"
47   #include "s_auth.h"
48   #include "s_bsd.h"
49 < #include "s_conf.h"
53 < #include "s_log.h"
49 > #include "log.h"
50   #include "s_misc.h"
51   #include "s_serv.h"      /* try_connections */
56 – #include "s_stats.h"
52   #include "send.h"
53   #include "whowas.h"
54   #include "modules.h"
55   #include "memory.h"
56 + #include "mempool.h"
57   #include "hook.h"
58   #include "ircd_getopt.h"
63 – #include "balloc.h"
64 – #include "motd.h"
59   #include "supported.h"
60   #include "watch.h"
61 + #include "conf_db.h"
62 + #include "conf_class.h"
63  
64 < /* Try and find the correct name to use with getrlimit() for setting the max.
65 < * number of files allowed to be open by this process.
66 < */
64 >
65 > #ifdef HAVE_LIBGEOIP
66 > GeoIP *geoip_ctx;
67 > #endif
68  
69   /* /quote set variables */
70   struct SetOptions GlobalSetOptions;
71 <
72 < /* configuration set from ircd.conf */
73 < struct config_file_entry ConfigFileEntry;
77 < /* server info set from ircd.conf */
78 < struct server_info ServerInfo;
79 < /* admin info set from ircd.conf */
80 < struct admin_info AdminInfo = { NULL, NULL, NULL };
81 < struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0 };
82 < struct ServerState_t server_state = { 0 };
83 < struct logging_entry ConfigLoggingEntry = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} };
71 > struct Counter Count;
72 > struct ServerState_t server_state;
73 > struct ServerStatistics ServerStats;
74   struct timeval SystemTime;
75   struct Client me;             /* That's me */
76   struct LocalUser meLocalUser; /* That's also part of me */
87 – unsigned long connect_id = 0; /* unique connect ID */
77  
89 – static unsigned long initialVMTop = 0;   /* top of virtual memory at init */
78   const char *logFileName = LPATH;
79   const char *pidFileName = PPATH;
80  
81   char **myargv;
94 – char ircd_platform[PLATFORMLEN];
82  
83   int dorehash = 0;
84   int doremotd = 0;
98 – time_t nextconnect = 1;       /* time for next try_connections call */
85  
86   /* Set to zero because it should be initialized later using
87   * initialize_server_capabs
88   */
89   int default_server_capabs = 0;
90 <
91 < #ifdef HAVE_LIBCRYPTO
92 < int bio_spare_fd = -1;
107 < #endif
108 <
109 < int splitmode;
110 < int splitchecking;
111 < int split_users;
90 > unsigned int splitmode;
91 > unsigned int splitchecking;
92 > unsigned int split_users;
93   unsigned int split_servers;
94  
95   /* Do klines the same way hybrid-6 did them, i.e. at the
# Line 123 | Line 104 | unsigned int split_servers;
104  
105   int rehashed_klines = 0;
106  
126 – /*
127 – * get_vm_top - get the operating systems notion of the resident set size
128 – */
129 – #ifndef _WIN32
130 – static unsigned long
131 – get_vm_top(void)
132 – {
133 –  /*
134 –   * NOTE: sbrk is not part of the ANSI C library or the POSIX.1 standard
135 –   * however it seems that everyone defines it. Calling sbrk with a 0
136 –   * argument will return a pointer to the top of the process virtual
137 –   * memory without changing the process size, so this call should be
138 –   * reasonably safe (sbrk returns the new value for the top of memory).
139 –   * This code relies on the notion that the address returned will be an
140 –   * offset from 0 (NULL), so the result of sbrk is cast to a size_t and
141 –   * returned. We really shouldn't be using it here but...
142 –   */
143 –
144 –  void *vptr = sbrk(0);
145 –  return((unsigned long)vptr);
146 – }
107  
108   /*
109   * print_startup - print startup information
# Line 151 | Line 111 | get_vm_top(void)
111   static void
112   print_startup(int pid)
113   {
114 <  printf("ircd: version %s\n", ircd_version);
114 >  printf("ircd: version %s(%s)\n", ircd_version, serno);
115    printf("ircd: pid %d\n", pid);
116    printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
117           : "foreground", ConfigFileEntry.dpath);
# Line 175 | Line 135 | make_daemon(void)
135  
136    setsid();
137   }
178 – #endif
179 –
180 – /*
181 – * get_maxrss - get the operating systems notion of the resident set size
182 – */
183 – unsigned long
184 – get_maxrss(void)
185 – {
186 – #ifdef _WIN32
187 –  return (0);   /* FIXME */
188 – #else
189 –  return (get_vm_top() - initialVMTop);
190 – #endif
191 – }
138  
139   static int printVersion = 0;
140  
141 < struct lgetopt myopts[] = {
196 <  {"dlinefile",  &ConfigFileEntry.dlinefile,
197 <   STRING, "File to use for dline.conf"},
141 > static struct lgetopt myopts[] = {
142    {"configfile", &ConfigFileEntry.configfile,
143     STRING, "File to use for ircd.conf"},
144 +  {"glinefile",  &ConfigFileEntry.glinefile,
145 +   STRING, "File to use for gline database"},
146    {"klinefile",  &ConfigFileEntry.klinefile,
147 <   STRING, "File to use for kline.conf"},
147 >   STRING, "File to use for kline database"},
148 >  {"dlinefile",  &ConfigFileEntry.dlinefile,
149 >   STRING, "File to use for dline database"},
150    {"xlinefile",  &ConfigFileEntry.xlinefile,
151 <   STRING, "File to use for xline.conf"},
151 >   STRING, "File to use for xline database"},
152 >  {"resvfile",  &ConfigFileEntry.resvfile,
153 >   STRING, "File to use for resv database"},
154    {"logfile",    &logFileName,
155     STRING, "File to use for ircd.log"},
156    {"pidfile",    &pidFileName,
# Line 216 | Line 166 | struct lgetopt myopts[] = {
166   void
167   set_time(void)
168   {
169 <  static char to_send[200];
169 >  static char to_send[IRCD_BUFSIZE];
170    struct timeval newtime;
221 – #ifdef _WIN32
222 –  FILETIME ft;
223 –
224 –  GetSystemTimeAsFileTime(&ft);
225 –  if (ft.dwLowDateTime < 0xd53e8000)
226 –    ft.dwHighDateTime--;
227 –  ft.dwLowDateTime -= 0xd53e8000;
228 –  ft.dwHighDateTime -= 0x19db1de;
229 –
230 –  newtime.tv_sec  = (*(uint64_t *) &ft) / 10000000;
231 –  newtime.tv_usec = (*(uint64_t *) &ft) / 10 % 1000000;
232 – #else
171    newtime.tv_sec  = 0;
172    newtime.tv_usec = 0;
173  
174    if (gettimeofday(&newtime, NULL) == -1)
175    {
176 <    ilog(L_ERROR, "Clock Failure (%s), TS can be corrupted",
176 >    ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted",
177           strerror(errno));
178 <    sendto_realops_flags(UMODE_ALL, L_ALL,
178 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
179                           "Clock Failure (%s), TS can be corrupted",
180                           strerror(errno));
181      restart("Clock Failure");
182    }
245 – #endif
183  
184    if (newtime.tv_sec < CurrentTime)
185    {
186 <    ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)",
187 <               (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
186 >    snprintf(to_send, sizeof(to_send),
187 >             "System clock is running backwards - (%lu < %lu)",
188 >             (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
189      report_error(L_ALL, to_send, me.name, 0);
190      set_back_events(CurrentTime - newtime.tv_sec);
191    }
# Line 282 | Line 220 | io_loop(void)
220        {
221          struct Client *client_p = ptr->data;
222          assert(client_p->localClient->list_task);
223 <        safe_list_channels(client_p, client_p->localClient->list_task, 0, 0);
223 >        safe_list_channels(client_p, client_p->localClient->list_task, 0);
224        }
225      }
226  
# Line 305 | Line 243 | io_loop(void)
243      }
244      if (doremotd)
245      {
246 <      read_message_file(&ConfigFileEntry.motd);
247 <      sendto_realops_flags(UMODE_ALL, L_ALL,
248 <                           "Got signal SIGUSR1, reloading ircd motd file");
246 >      motd_recache();
247 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
248 >                           "Got signal SIGUSR1, reloading motd files");
249        doremotd = 0;
250      }
251    }
# Line 348 | Line 286 | initialize_global_set_options(void)
286    }
287  
288    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
351 –  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
289    /* End of global set options */
290   }
291  
355 – /* initialize_message_files()
356 – *
357 – * inputs       - none
358 – * output       - none
359 – * side effects - Set up all message files needed, motd etc.
360 – */
361 – static void
362 – initialize_message_files(void)
363 – {
364 –  init_message_file(USER_MOTD, MPATH, &ConfigFileEntry.motd);
365 –  init_message_file(OPER_MOTD, OPATH, &ConfigFileEntry.opermotd);
366 –  init_message_file(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile);
367 –
368 –  read_message_file(&ConfigFileEntry.motd);
369 –  read_message_file(&ConfigFileEntry.opermotd);
370 –  read_message_file(&ConfigFileEntry.linksfile);
371 –
372 –  init_isupport();
373 – }
374 –
292   /* initialize_server_capabs()
293   *
294   * inputs       - none
# Line 381 | Line 298 | static void
298   initialize_server_capabs(void)
299   {
300    add_capability("QS", CAP_QS, 1);
384 –  add_capability("LL", CAP_LL, 1);
301    add_capability("EOB", CAP_EOB, 1);
302 <  if (ServerInfo.sid != NULL)   /* only enable TS6 if we have an SID */
387 <    add_capability("TS6", CAP_TS6, 0);
388 <  add_capability("ZIP", CAP_ZIP, 0);
302 >  add_capability("TS6", CAP_TS6, 0);
303    add_capability("CLUSTER", CAP_CLUSTER, 1);
304 + //  add_capability("FAKEHOST", CAP_FAKEHOST, 1);
305 +  add_capability("SVS", CAP_SVS, 1);
306   #ifdef HALFOPS
307    add_capability("HOPS", CAP_HOPS, 1);
308   #endif
# Line 401 | Line 317 | initialize_server_capabs(void)
317   static void
318   write_pidfile(const char *filename)
319   {
320 <  FBFILE *fb;
320 >  FILE *fb;
321  
322 <  if ((fb = fbopen(filename, "w")))
322 >  if ((fb = fopen(filename, "w")))
323    {
324 <    char buff[32];
324 >    char buff[IRCD_BUFSIZE];
325      unsigned int pid = (unsigned int)getpid();
410 –    size_t nbytes = ircsprintf(buff, "%u\n", pid);
326  
327 <    if ((fbputs(buff, fb, nbytes) == -1))
328 <      ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
327 >    snprintf(buff, sizeof(buff), "%u\n", pid);
328 >
329 >    if ((fputs(buff, fb) == -1))
330 >      ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)",
331             pid, filename, strerror(errno));
332  
333 <    fbclose(fb);
417 <    return;
333 >    fclose(fb);
334    }
335    else
336    {
337 <    ilog(L_ERROR, "Error opening pid file %s", filename);
337 >    ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename);
338    }
339   }
340  
# Line 433 | Line 349 | write_pidfile(const char *filename)
349   static void
350   check_pidfile(const char *filename)
351   {
352 < #ifndef _WIN32
353 <  FBFILE *fb;
438 <  char buff[32];
352 >  FILE *fb;
353 >  char buff[IRCD_BUFSIZE];
354    pid_t pidfromfile;
355  
356    /* Don't do logging here, since we don't have log() initialised */
357 <  if ((fb = fbopen(filename, "r")))
357 >  if ((fb = fopen(filename, "r")))
358    {
359 <    if (fbgets(buff, 20, fb) == NULL)
359 >    if (fgets(buff, 20, fb) == NULL)
360      {
361        /* log(L_ERROR, "Error reading from pid file %s (%s)", filename,
362         * strerror(errno));
# Line 459 | Line 374 | check_pidfile(const char *filename)
374        }
375      }
376  
377 <    fbclose(fb);
377 >    fclose(fb);
378    }
379    else if (errno != ENOENT)
380    {
381      /* log(L_ERROR, "Error opening pid file %s", filename); */
382    }
468 – #endif
383   }
384  
385   /* setup_corefile()
# Line 490 | Line 404 | setup_corefile(void)
404   #endif
405   }
406  
407 + #ifdef HAVE_LIBCRYPTO
408 + static int
409 + always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
410 + {
411 +  return 1;
412 + }
413 + #endif
414 +
415   /* init_ssl()
416   *
417   * inputs       - nothing
# Line 497 | Line 419 | setup_corefile(void)
419   * side effects - setups SSL context.
420   */
421   static void
422 < init_ssl(void)
422 > ssl_init(void)
423   {
424   #ifdef HAVE_LIBCRYPTO
425    SSL_load_error_strings();
426    SSLeay_add_ssl_algorithms();
427  
428 <  ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method());
507 <  if (!ServerInfo.ctx)
428 >  if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
429    {
430      const char *s;
431  
432 <    fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n",
432 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
433              s = ERR_lib_error_string(ERR_get_error()));
434 <    ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s);
434 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
435    }
436  
437 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_NO_SSLv2);
438 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
439 <  SSL_CTX_set_verify(ServerInfo.ctx, SSL_VERIFY_NONE, NULL);
437 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
438 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
439 >  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
440 >                     always_accept_verify_cb);
441  
442 <  bio_spare_fd = save_spare_fd("SSL private key validation");
443 < #endif /* HAVE_LIBCRYPTO */
444 < }
442 >  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
443 >  {
444 >    const char *s;
445  
446 < /* init_callbacks()
447 < *
448 < * inputs       - nothing
449 < * output       - nothing
450 < * side effects - setups standard hook points
451 < */
452 < static void
453 < init_callbacks(void)
454 < {
455 <  iorecv_cb = register_callback("iorecv", iorecv_default);
534 <  iosend_cb = register_callback("iosend", iosend_default);
535 <  iorecvctrl_cb = register_callback("iorecvctrl", NULL);
536 <  iosendctrl_cb = register_callback("iosendctrl", NULL);
446 >    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
447 >            s = ERR_lib_error_string(ERR_get_error()));
448 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
449 >  }
450 >
451 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
452 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
453 >  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
454 >                     always_accept_verify_cb);
455 > #endif /* HAVE_LIBCRYPTO */
456   }
457  
458   int
459   main(int argc, char *argv[])
460   {
461 <  /* Check to see if the user is running
543 <   * us as root, which is a nono
544 <   */
545 < #ifndef _WIN32
461 >  /* Check to see if the user is running us as root, which is a nono */
462    if (geteuid() == 0)
463    {
464      fprintf(stderr, "Don't run ircd as root!!!\n");
465 <    return(-1);
465 >    return -1;
466    }
467  
468    /* Setup corefile size immediately after boot -kre */
469    setup_corefile();
470  
555 –  /* set initialVMTop before we allocate any memory */
556 –  initialVMTop = get_vm_top();
557 – #endif
558 –
471    /* save server boot time right away, so getrusage works correctly */
472    set_time();
473  
474 <    /* It ain't random, but it ought to be a little harder to guess */
475 <  srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
476 <  memset(&me, 0, sizeof(me));
565 <  memset(&meLocalUser, 0, sizeof(meLocalUser));
474 >  /* It ain't random, but it ought to be a little harder to guess */
475 >  init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
476 >
477    me.localClient = &meLocalUser;
478 <  dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
478 >  dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
479                                                     of Client list */
569 –
570 –  memset(&ServerInfo, 0, sizeof(ServerInfo));
571 –
480    /* Initialise the channel capability usage counts... */
481    init_chcap_usage_counts();
482  
483    ConfigFileEntry.dpath      = DPATH;
484 <  ConfigFileEntry.configfile = CPATH;  /* Server configuration file */
485 <  ConfigFileEntry.klinefile  = KPATH;  /* Server kline file         */
486 <  ConfigFileEntry.xlinefile  = XPATH;  /* Server xline file         */
487 <  ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file   */
488 <  ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file   */
489 <  ConfigFileEntry.dlinefile  = DLPATH; /* dline file                */
490 <  ConfigFileEntry.glinefile  = GPATH;  /* gline log file            */
583 <  ConfigFileEntry.cresvfile  = CRESVPATH; /* channel resv file      */
584 <  ConfigFileEntry.nresvfile  = NRESVPATH; /* nick resv file         */
484 >  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
485 >  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
486 >  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
487 >  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
488 >  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
489 >  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
490 >
491    myargv = argv;
492    umask(077);                /* better safe than sorry --SRB */
493  
# Line 589 | Line 495 | main(int argc, char *argv[])
495  
496    if (printVersion)
497    {
498 <    printf("ircd: version %s\n", ircd_version);
498 >    printf("ircd: version %s(%s)\n", ircd_version, serno);
499      exit(EXIT_SUCCESS);
500    }
501  
# Line 599 | Line 505 | main(int argc, char *argv[])
505      exit(EXIT_FAILURE);
506    }
507  
508 <  init_ssl();
508 >  ssl_init();
509  
604 – #ifndef _WIN32
510    if (!server_state.foreground)
511    {
512      make_daemon();
# Line 611 | Line 516 | main(int argc, char *argv[])
516      print_startup(getpid());
517  
518    setup_signals();
614 – #endif
615 –
616 –  get_ircd_platform(ircd_platform);
519  
520    /* Init the event subsystem */
521    eventInit();
522 +
523    /* We need this to initialise the fd array before anything else */
524    fdlist_init();
525 <  init_log(logFileName);
525 >  log_set_file(LOG_TYPE_IRCD, 0, logFileName);
526    check_can_use_v6();
527 <  init_comm();         /* This needs to be setup early ! -- adrian */
527 >  init_netio();         /* This needs to be setup early ! -- adrian */
528 >
529    /* Check if there is pidfile and daemon already running */
530    check_pidfile(pidFileName);
531  
532 < #ifndef NOBALLOC
629 <  initBlockHeap();
630 < #endif
532 >  mp_pool_init();
533    init_dlink_nodes();
534 <  init_callbacks();
633 <  initialize_message_files();
534 >  init_isupport();
535    dbuf_init();
536 <  init_hash();
536 >  hash_init();
537    init_ip_hash_table();      /* client host ip hash table */
538    init_host_hash();          /* Host-hashtable. */
539 <  clear_tree_parse();
540 <  init_client();
541 <  init_class();
641 <  init_whowas();
539 >  client_init();
540 >  class_init();
541 >  whowas_init();
542    watch_init();
543 <  init_stats();
543 >  auth_init();          /* Initialise the auth code */
544 >  init_resolver();      /* Needs to be setup before the io loop */
545 >  modules_init();
546    read_conf_files(1);   /* cold start init conf files */
645 –  initServerMask();
646 –  me.id[0] = '\0';
547    init_uid();
648 –  init_auth();          /* Initialise the auth code */
649 – #ifndef _WIN32
650 –  init_resolver();      /* Needs to be setup before the io loop */
651 – #endif
548    initialize_server_capabs();   /* Set up default_server_capabs */
549    initialize_global_set_options();
550 <  init_channels();
550 >  channel_init();
551 >  read_links_file();
552 >  motd_init();
553 > #ifdef HAVE_LIBGEOIP
554 >  geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
555 > #endif
556 >
557 >  if (EmptyString(ServerInfo.sid))
558 >  {
559 >    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
560 >    exit(EXIT_FAILURE);
561 >  }
562  
563 <  if (ServerInfo.name == NULL)
563 >  strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
564 >
565 >  if (EmptyString(ServerInfo.name))
566    {
567 <    ilog(L_CRIT, "No server name specified in serverinfo block.");
567 >    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
568      exit(EXIT_FAILURE);
569    }
570 +
571    strlcpy(me.name, ServerInfo.name, sizeof(me.name));
572  
573    /* serverinfo{} description must exist.  If not, error out.*/
574 <  if (ServerInfo.description == NULL)
574 >  if (EmptyString(ServerInfo.description))
575    {
576 <    ilog(L_CRIT,
667 <      "ERROR: No server description specified in serverinfo block.");
576 >    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
577      exit(EXIT_FAILURE);
578    }
579 +
580    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
581  
582 <  me.from    = &me;
583 <  me.servptr = &me;
582 >  me.from                   = &me;
583 >  me.servptr                = &me;
584 >  me.localClient->lasttime  = CurrentTime;
585 >  me.localClient->since     = CurrentTime;
586 >  me.localClient->firsttime = CurrentTime;
587  
588    SetMe(&me);
589    make_server(&me);
590  
591 <  me.lasttime = me.since = me.firsttime = CurrentTime;
591 >  hash_add_id(&me);
592    hash_add_client(&me);
593    
594    /* add ourselves to global_serv_list */
595    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
596  
597 <  check_class();
597 >  load_kline_database();
598 >  load_dline_database();
599 >  load_gline_database();
600 >  load_xline_database();
601 >  load_resv_database();
602  
686 – #ifndef STATIC_MODULES
603    if (chdir(MODPATH))
604    {
605 <    ilog (L_CRIT, "Could not load core modules. Terminating!");
605 >    ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
606      exit(EXIT_FAILURE);
607    }
608  
609    load_all_modules(1);
610    load_conf_modules();
611    load_core_modules(1);
612 +
613    /* Go back to DPATH after checking to see if we can chdir to MODPATH */
614 <  chdir(ConfigFileEntry.dpath);
615 < #else
616 <  load_all_modules(1);
617 < #endif
614 >  if (chdir(ConfigFileEntry.dpath))
615 >  {
616 >    perror("chdir");
617 >    exit(EXIT_FAILURE);
618 >  }
619 >
620    /*
621     * assemble_umode_buffer() has to be called after
622     * reading conf/loading modules.
# Line 706 | Line 625 | main(int argc, char *argv[])
625  
626    write_pidfile(pidFileName);
627  
628 <  ilog(L_NOTICE, "Server Ready");
628 >  ilog(LOG_TYPE_IRCD, "Server Ready");
629  
630    eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
631    eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
# Line 715 | Line 634 | main(int argc, char *argv[])
634    /* No, 'cause after a restart it would cause all sorts of nick collides */
635    eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
636  
718 –  eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
719 –
637    /* Setup the timeout check. I'll shift it later :)  -- adrian */
638    eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
639  
640 +  eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT);
641 +
642    if (ConfigServerHide.links_delay > 0)
643      eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
644    else
# Line 729 | Line 648 | main(int argc, char *argv[])
648      eventAddIsh("check_splitmode", check_splitmode, NULL, 60);
649  
650    io_loop();
651 <  return(0);
651 >  return 0;
652   }

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)