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/src/ircd.c (file contents), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/src/ircd.c (file contents), Revision 2914 by michael, Fri Jan 24 19:45:36 2014 UTC

# Line 19 | Line 19
19   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
20   *  USA
21   *
22 < *  $Id: ircd.c,v 7.369 2005/09/24 09:27:18 michael Exp $
22 > *  $Id$
23   */
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;
76 < /* server info set from ircd.conf */
77 < struct server_info ServerInfo;
78 < /* admin info set from ircd.conf */
79 < struct admin_info AdminInfo = { NULL, NULL, NULL };
80 < struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0 };
81 < struct ServerState_t server_state = { 0 };
82 < 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 */
86 unsigned long connect_id = 0; /* unique connect ID */
77  
88 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;
93 char ircd_platform[PLATFORMLEN];
82  
83   int dorehash = 0;
84   int doremotd = 0;
97 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;
106 < #endif
107 <
108 < int splitmode;
109 < int splitchecking;
110 < 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 122 | Line 104 | unsigned int split_servers;
104  
105   int rehashed_klines = 0;
106  
125 /*
126 * get_vm_top - get the operating systems notion of the resident set size
127 */
128 #ifndef _WIN32
129 static unsigned long
130 get_vm_top(void)
131 {
132  /*
133   * NOTE: sbrk is not part of the ANSI C library or the POSIX.1 standard
134   * however it seems that everyone defines it. Calling sbrk with a 0
135   * argument will return a pointer to the top of the process virtual
136   * memory without changing the process size, so this call should be
137   * reasonably safe (sbrk returns the new value for the top of memory).
138   * This code relies on the notion that the address returned will be an
139   * offset from 0 (NULL), so the result of sbrk is cast to a size_t and
140   * returned. We really shouldn't be using it here but...
141   */
142
143  void *vptr = sbrk(0);
144  return((unsigned long)vptr);
145 }
107  
108   /*
109   * print_startup - print startup information
# Line 150 | 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 174 | Line 135 | make_daemon(void)
135  
136    setsid();
137   }
177 #endif
178
179 /*
180 * get_maxrss - get the operating systems notion of the resident set size
181 */
182 unsigned long
183 get_maxrss(void)
184 {
185 #ifdef _WIN32
186  return (0);   /* FIXME */
187 #else
188  return (get_vm_top() - initialVMTop);
189 #endif
190 }
138  
139   static int printVersion = 0;
140  
141 < struct lgetopt myopts[] = {
195 <  {"dlinefile",  &ConfigFileEntry.dlinefile,
196 <   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 215 | 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;
220 #ifdef _WIN32
221  FILETIME ft;
222
223  GetSystemTimeAsFileTime(&ft);
224  if (ft.dwLowDateTime < 0xd53e8000)
225    ft.dwHighDateTime--;
226  ft.dwLowDateTime -= 0xd53e8000;
227  ft.dwHighDateTime -= 0x19db1de;
228
229  newtime.tv_sec  = (*(uint64_t *) &ft) / 10000000;
230  newtime.tv_usec = (*(uint64_t *) &ft) / 10 % 1000000;
231 #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    }
244 #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 281 | 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 294 | Line 233 | io_loop(void)
233      comm_select();
234      exit_aborted_clients();
235      free_exited_clients();
297    send_queued_all();
236  
237      /* Check to see whether we have to rehash the configuration .. */
238      if (dorehash)
# Line 304 | Line 242 | io_loop(void)
242      }
243      if (doremotd)
244      {
245 <      read_message_file(&ConfigFileEntry.motd);
246 <      sendto_realops_flags(UMODE_ALL, L_ALL,
247 <                           "Got signal SIGUSR1, reloading ircd motd file");
245 >      motd_recache();
246 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
247 >                           "Got signal SIGUSR1, reloading motd files");
248        doremotd = 0;
249      }
250    }
# Line 347 | Line 285 | initialize_global_set_options(void)
285    }
286  
287    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
350  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
288    /* End of global set options */
289   }
290  
354 /* initialize_message_files()
355 *
356 * inputs       - none
357 * output       - none
358 * side effects - Set up all message files needed, motd etc.
359 */
360 static void
361 initialize_message_files(void)
362 {
363  init_message_file(USER_MOTD, MPATH, &ConfigFileEntry.motd);
364  init_message_file(OPER_MOTD, OPATH, &ConfigFileEntry.opermotd);
365  init_message_file(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile);
366
367  read_message_file(&ConfigFileEntry.motd);
368  read_message_file(&ConfigFileEntry.opermotd);
369  read_message_file(&ConfigFileEntry.linksfile);
370
371  init_isupport();
372 }
373
291   /* initialize_server_capabs()
292   *
293   * inputs       - none
# Line 380 | Line 297 | static void
297   initialize_server_capabs(void)
298   {
299    add_capability("QS", CAP_QS, 1);
383  add_capability("LL", CAP_LL, 1);
300    add_capability("EOB", CAP_EOB, 1);
301 <  if (ServerInfo.sid != NULL)   /* only enable TS6 if we have an SID */
386 <    add_capability("TS6", CAP_TS6, 0);
387 <  add_capability("ZIP", CAP_ZIP, 0);
301 >  add_capability("TS6", CAP_TS6, 0);
302    add_capability("CLUSTER", CAP_CLUSTER, 1);
303 + //  add_capability("FAKEHOST", CAP_FAKEHOST, 1);
304 +  add_capability("SVS", CAP_SVS, 1);
305   #ifdef HALFOPS
306    add_capability("HOPS", CAP_HOPS, 1);
307   #endif
# Line 400 | Line 316 | initialize_server_capabs(void)
316   static void
317   write_pidfile(const char *filename)
318   {
319 <  FBFILE *fb;
319 >  FILE *fb;
320  
321 <  if ((fb = fbopen(filename, "w")))
321 >  if ((fb = fopen(filename, "w")))
322    {
323 <    char buff[32];
323 >    char buff[IRCD_BUFSIZE];
324      unsigned int pid = (unsigned int)getpid();
409    size_t nbytes = ircsprintf(buff, "%u\n", pid);
325  
326 <    if ((fbputs(buff, fb, nbytes) == -1))
327 <      ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
326 >    snprintf(buff, sizeof(buff), "%u\n", pid);
327 >
328 >    if ((fputs(buff, fb) == -1))
329 >      ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)",
330             pid, filename, strerror(errno));
331  
332 <    fbclose(fb);
416 <    return;
332 >    fclose(fb);
333    }
334    else
335    {
336 <    ilog(L_ERROR, "Error opening pid file %s", filename);
336 >    ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename);
337    }
338   }
339  
# Line 432 | Line 348 | write_pidfile(const char *filename)
348   static void
349   check_pidfile(const char *filename)
350   {
351 < #ifndef _WIN32
352 <  FBFILE *fb;
437 <  char buff[32];
351 >  FILE *fb;
352 >  char buff[IRCD_BUFSIZE];
353    pid_t pidfromfile;
354  
355    /* Don't do logging here, since we don't have log() initialised */
356 <  if ((fb = fbopen(filename, "r")))
356 >  if ((fb = fopen(filename, "r")))
357    {
358 <    if (fbgets(buff, 20, fb) == NULL)
358 >    if (fgets(buff, 20, fb) == NULL)
359      {
360        /* log(L_ERROR, "Error reading from pid file %s (%s)", filename,
361         * strerror(errno));
# Line 458 | Line 373 | check_pidfile(const char *filename)
373        }
374      }
375  
376 <    fbclose(fb);
376 >    fclose(fb);
377    }
378    else if (errno != ENOENT)
379    {
380      /* log(L_ERROR, "Error opening pid file %s", filename); */
381    }
467 #endif
382   }
383  
384   /* setup_corefile()
# Line 489 | Line 403 | setup_corefile(void)
403   #endif
404   }
405  
406 + #ifdef HAVE_LIBCRYPTO
407 + static int
408 + always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
409 + {
410 +  return 1;
411 + }
412 + #endif
413 +
414   /* init_ssl()
415   *
416   * inputs       - nothing
# Line 496 | Line 418 | setup_corefile(void)
418   * side effects - setups SSL context.
419   */
420   static void
421 < init_ssl(void)
421 > ssl_init(void)
422   {
423   #ifdef HAVE_LIBCRYPTO
424 +  const unsigned char session_id[] = "ircd-hybrid";
425 +
426    SSL_load_error_strings();
427    SSLeay_add_ssl_algorithms();
428  
429 <  ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method());
506 <  if (!ServerInfo.ctx)
429 >  if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
430    {
431      const char *s;
432  
433 <    fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n",
433 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
434              s = ERR_lib_error_string(ERR_get_error()));
435 <    ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s);
435 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
436    }
437  
438 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_NO_SSLv2);
439 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
440 <  SSL_CTX_set_verify(ServerInfo.ctx, SSL_VERIFY_NONE, NULL);
438 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
439 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
440 >  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
441 >                     always_accept_verify_cb);
442 >  SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
443  
444 <  bio_spare_fd = save_spare_fd("SSL private key validation");
445 < #endif /* HAVE_LIBCRYPTO */
446 < }
444 >  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
445 >  {
446 >    const char *s;
447  
448 < /* init_callbacks()
449 < *
450 < * inputs       - nothing
451 < * output       - nothing
452 < * side effects - setups standard hook points
453 < */
454 < static void
455 < init_callbacks(void)
456 < {
457 <  iorecv_cb = register_callback("iorecv", NULL);
533 <  iosend_cb = register_callback("iosend", NULL);
534 <  iorecvctrl_cb = register_callback("iorecvctrl", NULL);
535 <  iosendctrl_cb = register_callback("iosendctrl", NULL);
448 >    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
449 >            s = ERR_lib_error_string(ERR_get_error()));
450 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
451 >  }
452 >
453 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
454 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
455 >  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
456 >                     always_accept_verify_cb);
457 > #endif /* HAVE_LIBCRYPTO */
458   }
459  
460   int
461   main(int argc, char *argv[])
462   {
463 <  /* Check to see if the user is running
542 <   * us as root, which is a nono
543 <   */
544 < #ifndef _WIN32
463 >  /* Check to see if the user is running us as root, which is a nono */
464    if (geteuid() == 0)
465    {
466      fprintf(stderr, "Don't run ircd as root!!!\n");
467 <    return(-1);
467 >    return -1;
468    }
469  
470    /* Setup corefile size immediately after boot -kre */
471    setup_corefile();
472  
554  /* set initialVMTop before we allocate any memory */
555  initialVMTop = get_vm_top();
556 #endif
557
473    /* save server boot time right away, so getrusage works correctly */
474    set_time();
475  
476 <    /* It ain't random, but it ought to be a little harder to guess */
477 <  srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
478 <  memset(&me, 0, sizeof(me));
564 <  memset(&meLocalUser, 0, sizeof(meLocalUser));
476 >  /* It ain't random, but it ought to be a little harder to guess */
477 >  init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
478 >
479    me.localClient = &meLocalUser;
480 <  dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
480 >  dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
481                                                     of Client list */
568
569  memset(&ServerInfo, 0, sizeof(ServerInfo));
570
482    /* Initialise the channel capability usage counts... */
483    init_chcap_usage_counts();
484  
485    ConfigFileEntry.dpath      = DPATH;
486 <  ConfigFileEntry.configfile = CPATH;  /* Server configuration file */
487 <  ConfigFileEntry.klinefile  = KPATH;  /* Server kline file         */
488 <  ConfigFileEntry.xlinefile  = XPATH;  /* Server xline file         */
489 <  ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file   */
490 <  ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file   */
491 <  ConfigFileEntry.dlinefile  = DLPATH; /* dline file                */
492 <  ConfigFileEntry.glinefile  = GPATH;  /* gline log file            */
582 <  ConfigFileEntry.cresvfile  = CRESVPATH; /* channel resv file      */
583 <  ConfigFileEntry.nresvfile  = NRESVPATH; /* nick resv file         */
486 >  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
487 >  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
488 >  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
489 >  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
490 >  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
491 >  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
492 >
493    myargv = argv;
494    umask(077);                /* better safe than sorry --SRB */
495  
# Line 588 | Line 497 | main(int argc, char *argv[])
497  
498    if (printVersion)
499    {
500 <    printf("ircd: version %s\n", ircd_version);
500 >    printf("ircd: version %s(%s)\n", ircd_version, serno);
501      exit(EXIT_SUCCESS);
502    }
503  
# Line 598 | Line 507 | main(int argc, char *argv[])
507      exit(EXIT_FAILURE);
508    }
509  
510 <  init_ssl();
510 >  ssl_init();
511  
603 #ifndef _WIN32
512    if (!server_state.foreground)
513    {
514      make_daemon();
# Line 610 | Line 518 | main(int argc, char *argv[])
518      print_startup(getpid());
519  
520    setup_signals();
613 #endif
614
615  get_ircd_platform(ircd_platform);
521  
522    /* Init the event subsystem */
523    eventInit();
524 +
525    /* We need this to initialise the fd array before anything else */
526    fdlist_init();
527 <  init_log(logFileName);
527 >  log_set_file(LOG_TYPE_IRCD, 0, logFileName);
528    check_can_use_v6();
529 <  init_comm();         /* This needs to be setup early ! -- adrian */
529 >  init_netio();         /* This needs to be setup early ! -- adrian */
530 >
531    /* Check if there is pidfile and daemon already running */
532    check_pidfile(pidFileName);
533  
534 < #ifndef NOBALLOC
628 <  initBlockHeap();
629 < #endif
534 >  mp_pool_init();
535    init_dlink_nodes();
536 <  init_callbacks();
632 <  initialize_message_files();
536 >  init_isupport();
537    dbuf_init();
538 <  init_hash();
538 >  hash_init();
539    init_ip_hash_table();      /* client host ip hash table */
540    init_host_hash();          /* Host-hashtable. */
541 <  clear_tree_parse();
542 <  init_client();
543 <  init_class();
544 <  init_whowas();
545 <  init_stats();
541 >  client_init();
542 >  class_init();
543 >  whowas_init();
544 >  watch_init();
545 >  auth_init();          /* Initialise the auth code */
546 >  init_resolver();      /* Needs to be setup before the io loop */
547 >  modules_init();
548    read_conf_files(1);   /* cold start init conf files */
643  initServerMask();
644  me.id[0] = '\0';
549    init_uid();
646  init_auth();          /* Initialise the auth code */
647 #ifndef _WIN32
648  init_resolver();      /* Needs to be setup before the io loop */
649 #endif
550    initialize_server_capabs();   /* Set up default_server_capabs */
551    initialize_global_set_options();
552 <  init_channels();
552 >  channel_init();
553 >  read_links_file();
554 >  motd_init();
555 > #ifdef HAVE_LIBGEOIP
556 >  geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
557 > #endif
558 >
559 >  if (EmptyString(ServerInfo.sid))
560 >  {
561 >    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
562 >    exit(EXIT_FAILURE);
563 >  }
564  
565 <  if (ServerInfo.name == NULL)
565 >  strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
566 >
567 >  if (EmptyString(ServerInfo.name))
568    {
569 <    ilog(L_CRIT, "No server name specified in serverinfo block.");
569 >    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
570      exit(EXIT_FAILURE);
571    }
572 +
573    strlcpy(me.name, ServerInfo.name, sizeof(me.name));
574  
575    /* serverinfo{} description must exist.  If not, error out.*/
576 <  if (ServerInfo.description == NULL)
576 >  if (EmptyString(ServerInfo.description))
577    {
578 <    ilog(L_CRIT,
665 <      "ERROR: No server description specified in serverinfo block.");
578 >    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
579      exit(EXIT_FAILURE);
580    }
581 +
582    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
583  
584 <  me.from    = &me;
585 <  me.servptr = &me;
584 >  me.from                   = &me;
585 >  me.servptr                = &me;
586 >  me.localClient->lasttime  = CurrentTime;
587 >  me.localClient->since     = CurrentTime;
588 >  me.localClient->firsttime = CurrentTime;
589  
590    SetMe(&me);
591    make_server(&me);
592  
593 <  me.lasttime = me.since = me.firsttime = CurrentTime;
593 >  hash_add_id(&me);
594    hash_add_client(&me);
595    
596    /* add ourselves to global_serv_list */
597    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
598  
599 <  check_class();
599 >  load_kline_database();
600 >  load_dline_database();
601 >  load_gline_database();
602 >  load_xline_database();
603 >  load_resv_database();
604  
684 #ifndef STATIC_MODULES
605    if (chdir(MODPATH))
606    {
607 <    ilog (L_CRIT, "Could not load core modules. Terminating!");
607 >    ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
608      exit(EXIT_FAILURE);
609    }
610  
611    load_all_modules(1);
612    load_conf_modules();
613    load_core_modules(1);
614 +
615    /* Go back to DPATH after checking to see if we can chdir to MODPATH */
616 <  chdir(ConfigFileEntry.dpath);
617 < #else
618 <  load_all_modules(1);
619 < #endif
616 >  if (chdir(ConfigFileEntry.dpath))
617 >  {
618 >    perror("chdir");
619 >    exit(EXIT_FAILURE);
620 >  }
621 >
622    /*
623     * assemble_umode_buffer() has to be called after
624     * reading conf/loading modules.
# Line 704 | Line 627 | main(int argc, char *argv[])
627  
628    write_pidfile(pidFileName);
629  
630 <  ilog(L_NOTICE, "Server Ready");
630 >  ilog(LOG_TYPE_IRCD, "Server Ready");
631  
632    eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
633    eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
# Line 713 | Line 636 | main(int argc, char *argv[])
636    /* No, 'cause after a restart it would cause all sorts of nick collides */
637    eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
638  
716  eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
717
639    /* Setup the timeout check. I'll shift it later :)  -- adrian */
640    eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
641  
642 +  eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT);
643 +
644    if (ConfigServerHide.links_delay > 0)
645      eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
646    else
# Line 727 | Line 650 | main(int argc, char *argv[])
650      eventAddIsh("check_splitmode", check_splitmode, NULL, 60);
651  
652    io_loop();
653 <  return(0);
653 >  return 0;
654   }

Comparing:
ircd-hybrid/src/ircd.c (property svn:keywords), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/src/ircd.c (property svn:keywords), Revision 2914 by michael, Fri Jan 24 19:45:36 2014 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

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