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 2980 by michael, Fri Jan 31 19:15:05 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  ircd.c: Starts up and runs the ircd.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id: ircd.c,v 7.369 2005/09/24 09:27:18 michael Exp $
20 > */
21 >
22 > /*! \file ircd.c
23 > * \brief Starts up and runs the ircd.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
28   #include "s_user.h"
29 < #include "tools.h"
29 > #include "list.h"
30   #include "ircd.h"
31   #include "channel.h"
32   #include "channel_mode.h"
33   #include "client.h"
32 #include "common.h"
34   #include "event.h"
35   #include "fdlist.h"
36   #include "hash.h"
37   #include "irc_string.h"
37 #include "sprintf_irc.h"
38   #include "ircd_signal.h"
39 #include "list.h"
39   #include "s_gline.h"
40   #include "motd.h"
41 < #include "ircd_handler.h"
43 < #include "msg.h"         /* msgtab */
41 > #include "conf.h"
42   #include "hostmask.h"
43   #include "numeric.h"
44   #include "packet.h"
45   #include "parse.h"
46   #include "irc_res.h"
47   #include "restart.h"
48 + #include "rng_mt.h"
49   #include "s_auth.h"
50   #include "s_bsd.h"
51 < #include "s_conf.h"
53 < #include "s_log.h"
51 > #include "log.h"
52   #include "s_misc.h"
53   #include "s_serv.h"      /* try_connections */
56 #include "s_stats.h"
54   #include "send.h"
55   #include "whowas.h"
56   #include "modules.h"
57   #include "memory.h"
58 + #include "mempool.h"
59   #include "hook.h"
60   #include "ircd_getopt.h"
63 #include "balloc.h"
64 #include "motd.h"
61   #include "supported.h"
62 + #include "watch.h"
63 + #include "conf_db.h"
64 + #include "conf_class.h"
65  
66 < /* Try and find the correct name to use with getrlimit() for setting the max.
67 < * number of files allowed to be open by this process.
68 < */
66 >
67 > #ifdef HAVE_LIBGEOIP
68 > GeoIP *geoip_ctx;
69 > #endif
70  
71   /* /quote set variables */
72   struct SetOptions GlobalSetOptions;
73 <
74 < /* configuration set from ircd.conf */
75 < 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} };
73 > struct Counter Count;
74 > struct ServerState_t server_state;
75 > struct ServerStatistics ServerStats;
76   struct timeval SystemTime;
77   struct Client me;             /* That's me */
78   struct LocalUser meLocalUser; /* That's also part of me */
86 unsigned long connect_id = 0; /* unique connect ID */
79  
88 static unsigned long initialVMTop = 0;   /* top of virtual memory at init */
80   const char *logFileName = LPATH;
81   const char *pidFileName = PPATH;
82  
83   char **myargv;
93 char ircd_platform[PLATFORMLEN];
84  
85   int dorehash = 0;
86   int doremotd = 0;
97 time_t nextconnect = 1;       /* time for next try_connections call */
87  
88   /* Set to zero because it should be initialized later using
89   * initialize_server_capabs
90   */
91   int default_server_capabs = 0;
92 <
93 < #ifdef HAVE_LIBCRYPTO
94 < int bio_spare_fd = -1;
106 < #endif
107 <
108 < int splitmode;
109 < int splitchecking;
110 < int split_users;
92 > unsigned int splitmode;
93 > unsigned int splitchecking;
94 > unsigned int split_users;
95   unsigned int split_servers;
96  
97   /* Do klines the same way hybrid-6 did them, i.e. at the
# Line 122 | Line 106 | unsigned int split_servers;
106  
107   int rehashed_klines = 0;
108  
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 }
109  
110   /*
111   * print_startup - print startup information
# Line 150 | Line 113 | get_vm_top(void)
113   static void
114   print_startup(int pid)
115   {
116 <  printf("ircd: version %s\n", ircd_version);
116 >  printf("ircd: version %s(%s)\n", ircd_version, serno);
117    printf("ircd: pid %d\n", pid);
118    printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
119           : "foreground", ConfigFileEntry.dpath);
# Line 174 | Line 137 | make_daemon(void)
137  
138    setsid();
139   }
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 }
140  
141   static int printVersion = 0;
142  
143 < struct lgetopt myopts[] = {
144 <  {"dlinefile",  &ConfigFileEntry.dlinefile,
196 <   STRING, "File to use for dline.conf"},
197 <  {"configfile", &ConfigFileEntry.configfile,
143 > static struct lgetopt myopts[] = {
144 >  {"configfile", &ConfigFileEntry.configfile,
145     STRING, "File to use for ircd.conf"},
146 <  {"klinefile",  &ConfigFileEntry.klinefile,
147 <   STRING, "File to use for kline.conf"},
148 <  {"xlinefile",  &ConfigFileEntry.xlinefile,
149 <   STRING, "File to use for xline.conf"},
150 <  {"logfile",    &logFileName,
146 >  {"glinefile",  &ConfigFileEntry.glinefile,
147 >   STRING, "File to use for gline database"},
148 >  {"klinefile",  &ConfigFileEntry.klinefile,
149 >   STRING, "File to use for kline database"},
150 >  {"dlinefile",  &ConfigFileEntry.dlinefile,
151 >   STRING, "File to use for dline database"},
152 >  {"xlinefile",  &ConfigFileEntry.xlinefile,
153 >   STRING, "File to use for xline database"},
154 >  {"resvfile",  &ConfigFileEntry.resvfile,
155 >   STRING, "File to use for resv database"},
156 >  {"logfile",    &logFileName,
157     STRING, "File to use for ircd.log"},
158    {"pidfile",    &pidFileName,
159     STRING, "File to use for process ID"},
160 <  {"foreground", &server_state.foreground,
160 >  {"foreground", &server_state.foreground,
161     YESNO, "Run in foreground (don't detach)"},
162 <  {"version",    &printVersion,
162 >  {"version",    &printVersion,
163     YESNO, "Print version and exit"},
164    {"help", NULL, USAGE, "Print this text"},
165    {NULL, NULL, STRING, NULL},
# Line 215 | Line 168 | struct lgetopt myopts[] = {
168   void
169   set_time(void)
170   {
171 <  static char to_send[200];
219 <  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
232 <  newtime.tv_sec  = 0;
233 <  newtime.tv_usec = 0;
171 >  struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 };
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");
181    }
244 #endif
182  
183    if (newtime.tv_sec < CurrentTime)
184    {
185 <    ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)",
186 <               (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
187 <    report_error(L_ALL, to_send, me.name, 0);
185 >    ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)",
186 >         (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
187 >    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
188 >                         "System clock is running backwards - (%lu < %lu)",
189 >                         (unsigned long)newtime.tv_sec,
190 >                         (unsigned long)CurrentTime);
191      set_back_events(CurrentTime - newtime.tv_sec);
192    }
193  
# Line 262 | Line 202 | io_loop(void)
202    {
203      /*
204       * Maybe we want a flags word?
205 <     * ie. if (REHASHED_KLINES(global_flags))
205 >     * ie. if (REHASHED_KLINES(global_flags))
206       * SET_REHASHED_KLINES(global_flags)
207       * CLEAR_REHASHED_KLINES(global_flags)
208       *
# Line 281 | Line 221 | io_loop(void)
221        {
222          struct Client *client_p = ptr->data;
223          assert(client_p->localClient->list_task);
224 <        safe_list_channels(client_p, client_p->localClient->list_task, 0, 0);
224 >        safe_list_channels(client_p, client_p->localClient->list_task, 0);
225        }
226      }
227  
# Line 294 | Line 234 | io_loop(void)
234      comm_select();
235      exit_aborted_clients();
236      free_exited_clients();
297    send_queued_all();
237  
238      /* Check to see whether we have to rehash the configuration .. */
239      if (dorehash)
# Line 304 | 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 316 | Line 255 | io_loop(void)
255   *
256   * inputs       - none
257   * output       - none
258 < * side effects - This sets all global set options needed
258 > * side effects - This sets all global set options needed
259   */
260   static void
261   initialize_global_set_options(void)
# Line 347 | Line 286 | initialize_global_set_options(void)
286    }
287  
288    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
350  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
289    /* End of global set options */
290   }
291  
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
292   /* initialize_server_capabs()
293   *
294   * inputs       - none
# Line 380 | Line 298 | static void
298   initialize_server_capabs(void)
299   {
300    add_capability("QS", CAP_QS, 1);
383  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 */
386 <    add_capability("TS6", CAP_TS6, 0);
387 <  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 400 | 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();
409    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);
416 <    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 432 | Line 349 | write_pidfile(const char *filename)
349   static void
350   check_pidfile(const char *filename)
351   {
352 < #ifndef _WIN32
353 <  FBFILE *fb;
437 <  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 458 | 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    }
467 #endif
383   }
384  
385   /* setup_corefile()
# Line 489 | 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 496 | 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 +  const unsigned char session_id[] = "ircd-hybrid";
426 +
427    SSL_load_error_strings();
428    SSLeay_add_ssl_algorithms();
429  
430 <  ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method());
506 <  if (!ServerInfo.ctx)
430 >  if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
431    {
432      const char *s;
433  
434 <    fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n",
434 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
435              s = ERR_lib_error_string(ERR_get_error()));
436 <    ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s);
436 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
437    }
438  
439 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_NO_SSLv2);
440 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
441 <  SSL_CTX_set_verify(ServerInfo.ctx, SSL_VERIFY_NONE, NULL);
439 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
440 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
441 >  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
442 >                     always_accept_verify_cb);
443 >  SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
444  
445 <  bio_spare_fd = save_spare_fd("SSL private key validation");
446 < #endif /* HAVE_LIBCRYPTO */
447 < }
445 >  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
446 >  {
447 >    const char *s;
448  
449 < /* init_callbacks()
450 < *
451 < * inputs       - nothing
452 < * output       - nothing
453 < * side effects - setups standard hook points
454 < */
455 < static void
456 < init_callbacks(void)
457 < {
458 <  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);
449 >    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
450 >            s = ERR_lib_error_string(ERR_get_error()));
451 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
452 >  }
453 >
454 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
455 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
456 >  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
457 >                     always_accept_verify_cb);
458 > #endif /* HAVE_LIBCRYPTO */
459   }
460  
461   int
462   main(int argc, char *argv[])
463   {
464 <  /* Check to see if the user is running
542 <   * us as root, which is a nono
543 <   */
544 < #ifndef _WIN32
464 >  /* Check to see if the user is running us as root, which is a nono */
465    if (geteuid() == 0)
466    {
467      fprintf(stderr, "Don't run ircd as root!!!\n");
468 <    return(-1);
468 >    return -1;
469    }
470  
471    /* Setup corefile size immediately after boot -kre */
472    setup_corefile();
473  
554  /* set initialVMTop before we allocate any memory */
555  initialVMTop = get_vm_top();
556 #endif
557
474    /* save server boot time right away, so getrusage works correctly */
475    set_time();
476  
477 <    /* It ain't random, but it ought to be a little harder to guess */
478 <  srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
479 <  memset(&me, 0, sizeof(me));
564 <  memset(&meLocalUser, 0, sizeof(meLocalUser));
477 >  /* It ain't random, but it ought to be a little harder to guess */
478 >  init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
479 >
480    me.localClient = &meLocalUser;
481 <  dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
481 >  dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
482                                                     of Client list */
568
569  memset(&ServerInfo, 0, sizeof(ServerInfo));
570
483    /* Initialise the channel capability usage counts... */
484    init_chcap_usage_counts();
485  
486    ConfigFileEntry.dpath      = DPATH;
487 <  ConfigFileEntry.configfile = CPATH;  /* Server configuration file */
488 <  ConfigFileEntry.klinefile  = KPATH;  /* Server kline file         */
489 <  ConfigFileEntry.xlinefile  = XPATH;  /* Server xline file         */
490 <  ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file   */
491 <  ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file   */
492 <  ConfigFileEntry.dlinefile  = DLPATH; /* dline file                */
493 <  ConfigFileEntry.glinefile  = GPATH;  /* gline log file            */
582 <  ConfigFileEntry.cresvfile  = CRESVPATH; /* channel resv file      */
583 <  ConfigFileEntry.nresvfile  = NRESVPATH; /* nick resv file         */
487 >  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
488 >  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
489 >  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
490 >  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
491 >  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
492 >  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
493 >
494    myargv = argv;
495    umask(077);                /* better safe than sorry --SRB */
496  
# Line 588 | Line 498 | main(int argc, char *argv[])
498  
499    if (printVersion)
500    {
501 <    printf("ircd: version %s\n", ircd_version);
501 >    printf("ircd: version %s(%s)\n", ircd_version, serno);
502      exit(EXIT_SUCCESS);
503    }
504  
# Line 598 | Line 508 | main(int argc, char *argv[])
508      exit(EXIT_FAILURE);
509    }
510  
511 <  init_ssl();
511 >  ssl_init();
512  
603 #ifndef _WIN32
513    if (!server_state.foreground)
514    {
515      make_daemon();
# Line 610 | Line 519 | main(int argc, char *argv[])
519      print_startup(getpid());
520  
521    setup_signals();
613 #endif
614
615  get_ircd_platform(ircd_platform);
522  
523    /* Init the event subsystem */
524    eventInit();
525 +
526    /* We need this to initialise the fd array before anything else */
527    fdlist_init();
528 <  init_log(logFileName);
528 >  log_set_file(LOG_TYPE_IRCD, 0, logFileName);
529    check_can_use_v6();
530 <  init_comm();         /* This needs to be setup early ! -- adrian */
530 >  init_netio();         /* This needs to be setup early ! -- adrian */
531 >
532    /* Check if there is pidfile and daemon already running */
533    check_pidfile(pidFileName);
534  
535 < #ifndef NOBALLOC
628 <  initBlockHeap();
629 < #endif
535 >  mp_pool_init();
536    init_dlink_nodes();
537 <  init_callbacks();
632 <  initialize_message_files();
537 >  init_isupport();
538    dbuf_init();
539 <  init_hash();
539 >  hash_init();
540    init_ip_hash_table();      /* client host ip hash table */
541    init_host_hash();          /* Host-hashtable. */
542 <  clear_tree_parse();
543 <  init_client();
544 <  init_class();
545 <  init_whowas();
546 <  init_stats();
542 >  client_init();
543 >  class_init();
544 >  whowas_init();
545 >  watch_init();
546 >  auth_init();          /* Initialise the auth code */
547 >  init_resolver();      /* Needs to be setup before the io loop */
548 >  modules_init();
549    read_conf_files(1);   /* cold start init conf files */
643  initServerMask();
644  me.id[0] = '\0';
550    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
551    initialize_server_capabs();   /* Set up default_server_capabs */
552    initialize_global_set_options();
553 <  init_channels();
553 >  channel_init();
554 >  read_links_file();
555 >  motd_init();
556 > #ifdef HAVE_LIBGEOIP
557 >  geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
558 > #endif
559 >
560 >  if (EmptyString(ServerInfo.sid))
561 >  {
562 >    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
563 >    exit(EXIT_FAILURE);
564 >  }
565  
566 <  if (ServerInfo.name == NULL)
566 >  strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
567 >
568 >  if (EmptyString(ServerInfo.name))
569    {
570 <    ilog(L_CRIT, "No server name specified in serverinfo block.");
570 >    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
571      exit(EXIT_FAILURE);
572    }
573 +
574    strlcpy(me.name, ServerInfo.name, sizeof(me.name));
575  
576    /* serverinfo{} description must exist.  If not, error out.*/
577 <  if (ServerInfo.description == NULL)
577 >  if (EmptyString(ServerInfo.description))
578    {
579 <    ilog(L_CRIT,
665 <      "ERROR: No server description specified in serverinfo block.");
579 >    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
580      exit(EXIT_FAILURE);
581    }
582 +
583    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
584  
585 <  me.from    = &me;
586 <  me.servptr = &me;
585 >  me.from                   = &me;
586 >  me.servptr                = &me;
587 >  me.localClient->lasttime  = CurrentTime;
588 >  me.localClient->since     = CurrentTime;
589 >  me.localClient->firsttime = CurrentTime;
590  
591    SetMe(&me);
592    make_server(&me);
593  
594 <  me.lasttime = me.since = me.firsttime = CurrentTime;
594 >  hash_add_id(&me);
595    hash_add_client(&me);
596 <  
596 >
597    /* add ourselves to global_serv_list */
598    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
599  
600 <  check_class();
600 >  load_kline_database();
601 >  load_dline_database();
602 >  load_gline_database();
603 >  load_xline_database();
604 >  load_resv_database();
605  
684 #ifndef STATIC_MODULES
606    if (chdir(MODPATH))
607    {
608 <    ilog (L_CRIT, "Could not load core modules. Terminating!");
608 >    ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
609      exit(EXIT_FAILURE);
610    }
611  
612    load_all_modules(1);
613    load_conf_modules();
614    load_core_modules(1);
615 +
616    /* Go back to DPATH after checking to see if we can chdir to MODPATH */
617 <  chdir(ConfigFileEntry.dpath);
618 < #else
619 <  load_all_modules(1);
620 < #endif
617 >  if (chdir(ConfigFileEntry.dpath))
618 >  {
619 >    perror("chdir");
620 >    exit(EXIT_FAILURE);
621 >  }
622 >
623    /*
624     * assemble_umode_buffer() has to be called after
625     * reading conf/loading modules.
# Line 704 | Line 628 | main(int argc, char *argv[])
628  
629    write_pidfile(pidFileName);
630  
631 <  ilog(L_NOTICE, "Server Ready");
631 >  ilog(LOG_TYPE_IRCD, "Server Ready");
632  
633    eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
634    eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
# Line 713 | Line 637 | main(int argc, char *argv[])
637    /* No, 'cause after a restart it would cause all sorts of nick collides */
638    eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
639  
716  eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
717
640    /* Setup the timeout check. I'll shift it later :)  -- adrian */
641    eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
642  
643 +  eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT);
644 +
645    if (ConfigServerHide.links_delay > 0)
646      eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
647    else
# Line 727 | Line 651 | main(int argc, char *argv[])
651      eventAddIsh("check_splitmode", check_splitmode, NULL, 60);
652  
653    io_loop();
654 <  return(0);
654 >  return 0;
655   }

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 2980 by michael, Fri Jan 31 19:15:05 2014 UTC

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

Diff Legend

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