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 3724 by michael, Sat May 31 16:27:09 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"
28 > #include "user.h"
29 > #include "list.h"
30   #include "ircd.h"
31   #include "channel.h"
30 #include "channel_mode.h"
32   #include "client.h"
32 #include "common.h"
33   #include "event.h"
34   #include "fdlist.h"
35   #include "hash.h"
36   #include "irc_string.h"
37 #include "sprintf_irc.h"
37   #include "ircd_signal.h"
38 < #include "list.h"
40 < #include "s_gline.h"
38 > #include "gline.h"
39   #include "motd.h"
40 < #include "ircd_handler.h"
43 < #include "msg.h"         /* msgtab */
40 > #include "conf.h"
41   #include "hostmask.h"
45 #include "numeric.h"
46 #include "packet.h"
42   #include "parse.h"
43 < #include "irc_res.h"
43 > #include "res.h"
44   #include "restart.h"
45 < #include "s_auth.h"
45 > #include "rng_mt.h"
46 > #include "auth.h"
47   #include "s_bsd.h"
48 < #include "s_conf.h"
49 < #include "s_log.h"
54 < #include "s_misc.h"
55 < #include "s_serv.h"      /* try_connections */
56 < #include "s_stats.h"
48 > #include "log.h"
49 > #include "server.h"      /* try_connections */
50   #include "send.h"
51   #include "whowas.h"
52   #include "modules.h"
53   #include "memory.h"
54 < #include "hook.h"
54 > #include "mempool.h"
55   #include "ircd_getopt.h"
63 #include "balloc.h"
64 #include "motd.h"
56   #include "supported.h"
57 + #include "watch.h"
58 + #include "conf_db.h"
59 + #include "conf_class.h"
60  
61 < /* Try and find the correct name to use with getrlimit() for setting the max.
62 < * number of files allowed to be open by this process.
63 < */
61 >
62 > #ifdef HAVE_LIBGEOIP
63 > GeoIP *geoip_ctx;
64 > #endif
65  
66   /* /quote set variables */
67   struct SetOptions GlobalSetOptions;
68 <
69 < /* configuration set from ircd.conf */
70 < 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} };
68 > struct Counter Count;
69 > struct ServerState_t server_state;
70 > struct ServerStatistics ServerStats;
71   struct timeval SystemTime;
72   struct Client me;             /* That's me */
73   struct LocalUser meLocalUser; /* That's also part of me */
86 unsigned long connect_id = 0; /* unique connect ID */
74  
88 static unsigned long initialVMTop = 0;   /* top of virtual memory at init */
75   const char *logFileName = LPATH;
76   const char *pidFileName = PPATH;
77  
78   char **myargv;
93 char ircd_platform[PLATFORMLEN];
79  
80   int dorehash = 0;
81   int doremotd = 0;
97 time_t nextconnect = 1;       /* time for next try_connections call */
82  
83   /* Set to zero because it should be initialized later using
84   * initialize_server_capabs
85   */
86   int default_server_capabs = 0;
87 <
88 < #ifdef HAVE_LIBCRYPTO
89 < int bio_spare_fd = -1;
106 < #endif
107 <
108 < int splitmode;
109 < int splitchecking;
110 < int split_users;
87 > unsigned int splitmode;
88 > unsigned int splitchecking;
89 > unsigned int split_users;
90   unsigned int split_servers;
91  
92   /* Do klines the same way hybrid-6 did them, i.e. at the
# Line 122 | Line 101 | unsigned int split_servers;
101  
102   int rehashed_klines = 0;
103  
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 }
104  
105   /*
106   * print_startup - print startup information
# Line 150 | Line 108 | get_vm_top(void)
108   static void
109   print_startup(int pid)
110   {
111 <  printf("ircd: version %s\n", ircd_version);
111 >  printf("ircd: version %s(%s)\n", ircd_version, serno);
112    printf("ircd: pid %d\n", pid);
113    printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
114           : "foreground", ConfigFileEntry.dpath);
# Line 174 | Line 132 | make_daemon(void)
132  
133    setsid();
134   }
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 }
135  
136   static int printVersion = 0;
137  
138 < struct lgetopt myopts[] = {
139 <  {"dlinefile",  &ConfigFileEntry.dlinefile,
140 <   STRING, "File to use for dline.conf"},
197 <  {"configfile", &ConfigFileEntry.configfile,
138 > static struct lgetopt myopts[] =
139 > {
140 >  {"configfile", &ConfigFileEntry.configfile,
141     STRING, "File to use for ircd.conf"},
142 <  {"klinefile",  &ConfigFileEntry.klinefile,
143 <   STRING, "File to use for kline.conf"},
144 <  {"xlinefile",  &ConfigFileEntry.xlinefile,
145 <   STRING, "File to use for xline.conf"},
146 <  {"logfile",    &logFileName,
142 >  {"glinefile",  &ConfigFileEntry.glinefile,
143 >   STRING, "File to use for gline database"},
144 >  {"klinefile",  &ConfigFileEntry.klinefile,
145 >   STRING, "File to use for kline database"},
146 >  {"dlinefile",  &ConfigFileEntry.dlinefile,
147 >   STRING, "File to use for dline database"},
148 >  {"xlinefile",  &ConfigFileEntry.xlinefile,
149 >   STRING, "File to use for xline database"},
150 >  {"resvfile",  &ConfigFileEntry.resvfile,
151 >   STRING, "File to use for resv database"},
152 >  {"logfile",    &logFileName,
153     STRING, "File to use for ircd.log"},
154    {"pidfile",    &pidFileName,
155     STRING, "File to use for process ID"},
156 <  {"foreground", &server_state.foreground,
156 >  {"foreground", &server_state.foreground,
157     YESNO, "Run in foreground (don't detach)"},
158 <  {"version",    &printVersion,
158 >  {"version",    &printVersion,
159     YESNO, "Print version and exit"},
160    {"help", NULL, USAGE, "Print this text"},
161    {NULL, NULL, STRING, NULL},
# Line 215 | Line 164 | struct lgetopt myopts[] = {
164   void
165   set_time(void)
166   {
167 <  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;
167 >  struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 };
168  
169    if (gettimeofday(&newtime, NULL) == -1)
170    {
171 <    ilog(L_ERROR, "Clock Failure (%s), TS can be corrupted",
171 >    ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted",
172           strerror(errno));
173 <    sendto_realops_flags(UMODE_ALL, L_ALL,
173 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
174                           "Clock Failure (%s), TS can be corrupted",
175                           strerror(errno));
176 <    restart("Clock Failure");
176 >    server_die("Clock Failure", 1);
177    }
244 #endif
178  
179    if (newtime.tv_sec < CurrentTime)
180    {
181 <    ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)",
182 <               (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
183 <    report_error(L_ALL, to_send, me.name, 0);
181 >    ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)",
182 >         (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
183 >    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
184 >                         "System clock is running backwards - (%lu < %lu)",
185 >                         (unsigned long)newtime.tv_sec,
186 >                         (unsigned long)CurrentTime);
187      set_back_events(CurrentTime - newtime.tv_sec);
188    }
189  
# Line 258 | Line 194 | set_time(void)
194   static void
195   io_loop(void)
196   {
197 <  while (1 == 1)
197 >  while (1)
198    {
199      /*
200       * Maybe we want a flags word?
201 <     * ie. if (REHASHED_KLINES(global_flags))
201 >     * ie. if (REHASHED_KLINES(global_flags))
202       * SET_REHASHED_KLINES(global_flags)
203       * CLEAR_REHASHED_KLINES(global_flags)
204       *
# Line 278 | Line 214 | io_loop(void)
214      {
215        dlink_node *ptr = NULL, *ptr_next = NULL;
216        DLINK_FOREACH_SAFE(ptr, ptr_next, listing_client_list.head)
217 <      {
282 <        struct Client *client_p = ptr->data;
283 <        assert(client_p->localClient->list_task);
284 <        safe_list_channels(client_p, client_p->localClient->list_task, 0, 0);
285 <      }
217 >        safe_list_channels(ptr->data, 0);
218      }
219  
220      /* Run pending events, then get the number of seconds to the next
# Line 294 | Line 226 | io_loop(void)
226      comm_select();
227      exit_aborted_clients();
228      free_exited_clients();
297    send_queued_all();
229  
230      /* Check to see whether we have to rehash the configuration .. */
231      if (dorehash)
# Line 302 | Line 233 | io_loop(void)
233        rehash(1);
234        dorehash = 0;
235      }
236 +
237      if (doremotd)
238      {
239 <      read_message_file(&ConfigFileEntry.motd);
240 <      sendto_realops_flags(UMODE_ALL, L_ALL,
241 <                           "Got signal SIGUSR1, reloading ircd motd file");
239 >      motd_recache();
240 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
241 >                           "Got signal SIGUSR1, reloading motd file(s)");
242        doremotd = 0;
243      }
244    }
# Line 316 | Line 248 | io_loop(void)
248   *
249   * inputs       - none
250   * output       - none
251 < * side effects - This sets all global set options needed
251 > * side effects - This sets all global set options needed
252   */
253   static void
254   initialize_global_set_options(void)
# Line 347 | Line 279 | initialize_global_set_options(void)
279    }
280  
281    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
350  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
282    /* End of global set options */
283   }
284  
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
285   /* initialize_server_capabs()
286   *
287   * inputs       - none
# Line 380 | Line 291 | static void
291   initialize_server_capabs(void)
292   {
293    add_capability("QS", CAP_QS, 1);
383  add_capability("LL", CAP_LL, 1);
294    add_capability("EOB", CAP_EOB, 1);
295 <  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);
295 >  add_capability("TS6", CAP_TS6, 0);
296    add_capability("CLUSTER", CAP_CLUSTER, 1);
297 < #ifdef HALFOPS
297 >  add_capability("SVS", CAP_SVS, 1);
298 >  add_capability("CHW", CAP_CHW, 1);
299    add_capability("HOPS", CAP_HOPS, 1);
391 #endif
300   }
301  
302   /* write_pidfile()
# Line 400 | Line 308 | initialize_server_capabs(void)
308   static void
309   write_pidfile(const char *filename)
310   {
311 <  FBFILE *fb;
311 >  FILE *fb;
312  
313 <  if ((fb = fbopen(filename, "w")))
313 >  if ((fb = fopen(filename, "w")))
314    {
315 <    char buff[32];
315 >    char buff[IRCD_BUFSIZE];
316      unsigned int pid = (unsigned int)getpid();
409    size_t nbytes = ircsprintf(buff, "%u\n", pid);
317  
318 <    if ((fbputs(buff, fb, nbytes) == -1))
319 <      ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
318 >    snprintf(buff, sizeof(buff), "%u\n", pid);
319 >
320 >    if ((fputs(buff, fb) == -1))
321 >      ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)",
322             pid, filename, strerror(errno));
323  
324 <    fbclose(fb);
416 <    return;
324 >    fclose(fb);
325    }
326    else
327    {
328 <    ilog(L_ERROR, "Error opening pid file %s", filename);
328 >    ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename);
329    }
330   }
331  
# Line 432 | Line 340 | write_pidfile(const char *filename)
340   static void
341   check_pidfile(const char *filename)
342   {
343 < #ifndef _WIN32
344 <  FBFILE *fb;
437 <  char buff[32];
343 >  FILE *fb;
344 >  char buff[IRCD_BUFSIZE];
345    pid_t pidfromfile;
346  
347    /* Don't do logging here, since we don't have log() initialised */
348 <  if ((fb = fbopen(filename, "r")))
348 >  if ((fb = fopen(filename, "r")))
349    {
350 <    if (fbgets(buff, 20, fb) == NULL)
350 >    if (fgets(buff, 20, fb) == NULL)
351      {
352        /* log(L_ERROR, "Error reading from pid file %s (%s)", filename,
353         * strerror(errno));
# Line 458 | Line 365 | check_pidfile(const char *filename)
365        }
366      }
367  
368 <    fbclose(fb);
368 >    fclose(fb);
369    }
370    else if (errno != ENOENT)
371    {
372      /* log(L_ERROR, "Error opening pid file %s", filename); */
373    }
467 #endif
374   }
375  
376   /* setup_corefile()
# Line 489 | Line 395 | setup_corefile(void)
395   #endif
396   }
397  
398 + #ifdef HAVE_LIBCRYPTO
399 + static int
400 + always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
401 + {
402 +  return 1;
403 + }
404 + #endif
405 +
406   /* init_ssl()
407   *
408   * inputs       - nothing
# Line 496 | Line 410 | setup_corefile(void)
410   * side effects - setups SSL context.
411   */
412   static void
413 < init_ssl(void)
413 > ssl_init(void)
414   {
415   #ifdef HAVE_LIBCRYPTO
416 +  const unsigned char session_id[] = "ircd-hybrid";
417 +
418    SSL_load_error_strings();
419    SSLeay_add_ssl_algorithms();
420  
421 <  ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method());
506 <  if (!ServerInfo.ctx)
421 >  if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
422    {
423      const char *s;
424  
425 <    fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n",
425 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
426              s = ERR_lib_error_string(ERR_get_error()));
427 <    ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s);
427 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
428    }
429  
430 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_NO_SSLv2);
431 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
432 <  SSL_CTX_set_verify(ServerInfo.ctx, SSL_VERIFY_NONE, NULL);
430 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
431 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
432 >  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
433 >                     always_accept_verify_cb);
434 >  SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
435  
436 <  bio_spare_fd = save_spare_fd("SSL private key validation");
437 < #endif /* HAVE_LIBCRYPTO */
438 < }
436 >  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
437 >  {
438 >    const char *s;
439  
440 < /* init_callbacks()
441 < *
442 < * inputs       - nothing
443 < * output       - nothing
444 < * side effects - setups standard hook points
445 < */
446 < static void
447 < init_callbacks(void)
448 < {
449 <  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);
440 >    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
441 >            s = ERR_lib_error_string(ERR_get_error()));
442 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
443 >  }
444 >
445 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
446 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
447 >  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
448 >                     always_accept_verify_cb);
449 > #endif /* HAVE_LIBCRYPTO */
450   }
451  
452   int
453   main(int argc, char *argv[])
454   {
455 <  /* Check to see if the user is running
542 <   * us as root, which is a nono
543 <   */
544 < #ifndef _WIN32
455 >  /* Check to see if the user is running us as root, which is a nono */
456    if (geteuid() == 0)
457    {
458 <    fprintf(stderr, "Don't run ircd as root!!!\n");
459 <    return(-1);
458 >    fprintf(stderr, "ERROR: This server won't run as root/superuser\n");
459 >    return -1;
460    }
461  
462    /* Setup corefile size immediately after boot -kre */
463    setup_corefile();
464  
554  /* set initialVMTop before we allocate any memory */
555  initialVMTop = get_vm_top();
556 #endif
557
465    /* save server boot time right away, so getrusage works correctly */
466    set_time();
467  
468 <    /* It ain't random, but it ought to be a little harder to guess */
469 <  srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
470 <  memset(&me, 0, sizeof(me));
564 <  memset(&meLocalUser, 0, sizeof(meLocalUser));
468 >  /* It ain't random, but it ought to be a little harder to guess */
469 >  init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
470 >
471    me.localClient = &meLocalUser;
472 <  dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
472 >  dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
473                                                     of Client list */
568
569  memset(&ServerInfo, 0, sizeof(ServerInfo));
570
571  /* Initialise the channel capability usage counts... */
572  init_chcap_usage_counts();
573
474    ConfigFileEntry.dpath      = DPATH;
475 <  ConfigFileEntry.configfile = CPATH;  /* Server configuration file */
476 <  ConfigFileEntry.klinefile  = KPATH;  /* Server kline file         */
477 <  ConfigFileEntry.xlinefile  = XPATH;  /* Server xline file         */
478 <  ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file   */
479 <  ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file   */
480 <  ConfigFileEntry.dlinefile  = DLPATH; /* dline file                */
481 <  ConfigFileEntry.glinefile  = GPATH;  /* gline log file            */
482 <  ConfigFileEntry.cresvfile  = CRESVPATH; /* channel resv file      */
483 <  ConfigFileEntry.nresvfile  = NRESVPATH; /* nick resv file         */
475 >  ConfigFileEntry.spath      = SPATH;
476 >  ConfigFileEntry.mpath      = MPATH;
477 >  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
478 >  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
479 >  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
480 >  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
481 >  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
482 >  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
483 >
484    myargv = argv;
485    umask(077);                /* better safe than sorry --SRB */
486  
# Line 588 | Line 488 | main(int argc, char *argv[])
488  
489    if (printVersion)
490    {
491 <    printf("ircd: version %s\n", ircd_version);
491 >    printf("ircd: version %s(%s)\n", ircd_version, serno);
492      exit(EXIT_SUCCESS);
493    }
494  
# Line 598 | Line 498 | main(int argc, char *argv[])
498      exit(EXIT_FAILURE);
499    }
500  
501 <  init_ssl();
501 >  ssl_init();
502  
603 #ifndef _WIN32
503    if (!server_state.foreground)
504    {
505      make_daemon();
# Line 610 | Line 509 | main(int argc, char *argv[])
509      print_startup(getpid());
510  
511    setup_signals();
613 #endif
614
615  get_ircd_platform(ircd_platform);
512  
513    /* Init the event subsystem */
514    eventInit();
515 +
516    /* We need this to initialise the fd array before anything else */
517    fdlist_init();
518 <  init_log(logFileName);
518 >  log_set_file(LOG_TYPE_IRCD, 0, logFileName);
519    check_can_use_v6();
520 <  init_comm();         /* This needs to be setup early ! -- adrian */
520 >  init_netio();         /* This needs to be setup early ! -- adrian */
521 >
522    /* Check if there is pidfile and daemon already running */
523    check_pidfile(pidFileName);
524  
525 < #ifndef NOBALLOC
628 <  initBlockHeap();
629 < #endif
525 >  mp_pool_init();
526    init_dlink_nodes();
527 <  init_callbacks();
632 <  initialize_message_files();
527 >  init_isupport();
528    dbuf_init();
529 <  init_hash();
529 >  hash_init();
530    init_ip_hash_table();      /* client host ip hash table */
531    init_host_hash();          /* Host-hashtable. */
532 <  clear_tree_parse();
533 <  init_client();
534 <  init_class();
535 <  init_whowas();
536 <  init_stats();
532 >  client_init();
533 >  class_init();
534 >  whowas_init();
535 >  watch_init();
536 >  auth_init();          /* Initialise the auth code */
537 >  init_resolver();      /* Needs to be setup before the io loop */
538 >  modules_init();
539    read_conf_files(1);   /* cold start init conf files */
643  initServerMask();
644  me.id[0] = '\0';
540    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
541    initialize_server_capabs();   /* Set up default_server_capabs */
542    initialize_global_set_options();
543 <  init_channels();
543 >  channel_init();
544 >  read_links_file();
545 >  motd_init();
546 > #ifdef HAVE_LIBGEOIP
547 >  geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
548 > #endif
549  
550 <  if (ServerInfo.name == NULL)
550 >  if (EmptyString(ServerInfo.sid))
551    {
552 <    ilog(L_CRIT, "No server name specified in serverinfo block.");
552 >    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
553      exit(EXIT_FAILURE);
554    }
555 +
556 +  strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
557 +
558 +  if (EmptyString(ServerInfo.name))
559 +  {
560 +    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
561 +    exit(EXIT_FAILURE);
562 +  }
563 +
564    strlcpy(me.name, ServerInfo.name, sizeof(me.name));
565  
566    /* serverinfo{} description must exist.  If not, error out.*/
567 <  if (ServerInfo.description == NULL)
567 >  if (EmptyString(ServerInfo.description))
568    {
569 <    ilog(L_CRIT,
665 <      "ERROR: No server description specified in serverinfo block.");
569 >    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
570      exit(EXIT_FAILURE);
571    }
572 +
573    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
574  
575 <  me.from    = &me;
576 <  me.servptr = &me;
575 >  me.from                   = &me;
576 >  me.servptr                = &me;
577 >  me.localClient->lasttime  = CurrentTime;
578 >  me.localClient->since     = CurrentTime;
579 >  me.localClient->firsttime = CurrentTime;
580  
581    SetMe(&me);
582    make_server(&me);
583  
584 <  me.lasttime = me.since = me.firsttime = CurrentTime;
584 >  hash_add_id(&me);
585    hash_add_client(&me);
586 <  
586 >
587    /* add ourselves to global_serv_list */
588    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
589  
590 <  check_class();
590 >  load_kline_database();
591 >  load_dline_database();
592 >  load_gline_database();
593 >  load_xline_database();
594 >  load_resv_database();
595  
684 #ifndef STATIC_MODULES
596    if (chdir(MODPATH))
597    {
598 <    ilog (L_CRIT, "Could not load core modules. Terminating!");
598 >    ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
599      exit(EXIT_FAILURE);
600    }
601  
602    load_all_modules(1);
603    load_conf_modules();
604    load_core_modules(1);
605 +
606    /* Go back to DPATH after checking to see if we can chdir to MODPATH */
607 <  chdir(ConfigFileEntry.dpath);
608 < #else
609 <  load_all_modules(1);
610 < #endif
607 >  if (chdir(ConfigFileEntry.dpath))
608 >  {
609 >    perror("chdir");
610 >    exit(EXIT_FAILURE);
611 >  }
612 >
613    /*
614     * assemble_umode_buffer() has to be called after
615     * reading conf/loading modules.
# Line 704 | Line 618 | main(int argc, char *argv[])
618  
619    write_pidfile(pidFileName);
620  
621 <  ilog(L_NOTICE, "Server Ready");
621 >  ilog(LOG_TYPE_IRCD, "Server Ready");
622  
623    eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
624    eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
# Line 713 | Line 627 | main(int argc, char *argv[])
627    /* No, 'cause after a restart it would cause all sorts of nick collides */
628    eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
629  
716  eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
717
630    /* Setup the timeout check. I'll shift it later :)  -- adrian */
631    eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
632  
633 +  eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT);
634 +
635    if (ConfigServerHide.links_delay > 0)
636      eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
637    else
# Line 727 | Line 641 | main(int argc, char *argv[])
641      eventAddIsh("check_splitmode", check_splitmode, NULL, 60);
642  
643    io_loop();
644 <  return(0);
644 >  return 0;
645   }

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 3724 by michael, Sat May 31 16:27:09 2014 UTC

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

Diff Legend

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