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 3929 by michael, Mon Jun 9 14:56:25 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;
86 > unsigned int default_server_capabs;
87 > unsigned int splitmode;
88 > unsigned int splitchecking;
89 > unsigned int split_users;
90   unsigned int split_servers;
91  
113 /* Do klines the same way hybrid-6 did them, i.e. at the
114 * top of the next io_loop instead of in the same loop as
115 * the klines are being applied.
116 *
117 * This should fix strange CPU starvation as very indirectly reported.
118 * (Why do you people not email bug reports? WHY? WHY?)
119 *
120 * - Dianora
121 */
122
123 int rehashed_klines = 0;
124
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 }
146
92   /*
93   * print_startup - print startup information
94   */
95   static void
96   print_startup(int pid)
97   {
98 <  printf("ircd: version %s\n", ircd_version);
98 >  printf("ircd: version %s(%s)\n", ircd_version, serno);
99    printf("ircd: pid %d\n", pid);
100    printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
101           : "foreground", ConfigFileEntry.dpath);
# Line 174 | Line 119 | make_daemon(void)
119  
120    setsid();
121   }
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 }
122  
123   static int printVersion = 0;
124  
125 < struct lgetopt myopts[] = {
126 <  {"dlinefile",  &ConfigFileEntry.dlinefile,
127 <   STRING, "File to use for dline.conf"},
197 <  {"configfile", &ConfigFileEntry.configfile,
125 > static struct lgetopt myopts[] =
126 > {
127 >  {"configfile", &ConfigFileEntry.configfile,
128     STRING, "File to use for ircd.conf"},
129 <  {"klinefile",  &ConfigFileEntry.klinefile,
130 <   STRING, "File to use for kline.conf"},
131 <  {"xlinefile",  &ConfigFileEntry.xlinefile,
132 <   STRING, "File to use for xline.conf"},
133 <  {"logfile",    &logFileName,
129 >  {"glinefile",  &ConfigFileEntry.glinefile,
130 >   STRING, "File to use for gline database"},
131 >  {"klinefile",  &ConfigFileEntry.klinefile,
132 >   STRING, "File to use for kline database"},
133 >  {"dlinefile",  &ConfigFileEntry.dlinefile,
134 >   STRING, "File to use for dline database"},
135 >  {"xlinefile",  &ConfigFileEntry.xlinefile,
136 >   STRING, "File to use for xline database"},
137 >  {"resvfile",  &ConfigFileEntry.resvfile,
138 >   STRING, "File to use for resv database"},
139 >  {"logfile",    &logFileName,
140     STRING, "File to use for ircd.log"},
141    {"pidfile",    &pidFileName,
142     STRING, "File to use for process ID"},
143 <  {"foreground", &server_state.foreground,
143 >  {"foreground", &server_state.foreground,
144     YESNO, "Run in foreground (don't detach)"},
145 <  {"version",    &printVersion,
145 >  {"version",    &printVersion,
146     YESNO, "Print version and exit"},
147    {"help", NULL, USAGE, "Print this text"},
148    {NULL, NULL, STRING, NULL},
# Line 215 | Line 151 | struct lgetopt myopts[] = {
151   void
152   set_time(void)
153   {
154 <  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;
154 >  struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 };
155  
156    if (gettimeofday(&newtime, NULL) == -1)
157    {
158 <    ilog(L_ERROR, "Clock Failure (%s), TS can be corrupted",
158 >    ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted",
159           strerror(errno));
160 <    sendto_realops_flags(UMODE_ALL, L_ALL,
160 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
161                           "Clock Failure (%s), TS can be corrupted",
162                           strerror(errno));
163 <    restart("Clock Failure");
163 >    server_die("Clock Failure", 1);
164    }
244 #endif
165  
166    if (newtime.tv_sec < CurrentTime)
167    {
168 <    ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)",
169 <               (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
170 <    report_error(L_ALL, to_send, me.name, 0);
168 >    ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)",
169 >         (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
170 >    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
171 >                         "System clock is running backwards - (%lu < %lu)",
172 >                         (unsigned long)newtime.tv_sec,
173 >                         (unsigned long)CurrentTime);
174      set_back_events(CurrentTime - newtime.tv_sec);
175    }
176  
# Line 258 | Line 181 | set_time(void)
181   static void
182   io_loop(void)
183   {
184 <  while (1 == 1)
184 >  while (1)
185    {
263    /*
264     * Maybe we want a flags word?
265     * ie. if (REHASHED_KLINES(global_flags))
266     * SET_REHASHED_KLINES(global_flags)
267     * CLEAR_REHASHED_KLINES(global_flags)
268     *
269     * - Dianora
270     */
271    if (rehashed_klines)
272    {
273      check_conf_klines();
274      rehashed_klines = 0;
275    }
276
186      if (listing_client_list.head)
187      {
188        dlink_node *ptr = NULL, *ptr_next = NULL;
189        DLINK_FOREACH_SAFE(ptr, ptr_next, listing_client_list.head)
190 <      {
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 <      }
190 >        safe_list_channels(ptr->data, 0);
191      }
192  
193      /* Run pending events, then get the number of seconds to the next
# Line 294 | Line 199 | io_loop(void)
199      comm_select();
200      exit_aborted_clients();
201      free_exited_clients();
297    send_queued_all();
202  
203      /* Check to see whether we have to rehash the configuration .. */
204      if (dorehash)
# Line 302 | Line 206 | io_loop(void)
206        rehash(1);
207        dorehash = 0;
208      }
209 +
210      if (doremotd)
211      {
212 <      read_message_file(&ConfigFileEntry.motd);
213 <      sendto_realops_flags(UMODE_ALL, L_ALL,
214 <                           "Got signal SIGUSR1, reloading ircd motd file");
212 >      motd_recache();
213 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
214 >                           "Got signal SIGUSR1, reloading motd file(s)");
215        doremotd = 0;
216      }
217    }
# Line 316 | Line 221 | io_loop(void)
221   *
222   * inputs       - none
223   * output       - none
224 < * side effects - This sets all global set options needed
224 > * side effects - This sets all global set options needed
225   */
226   static void
227   initialize_global_set_options(void)
# Line 347 | Line 252 | initialize_global_set_options(void)
252    }
253  
254    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
350  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
255    /* End of global set options */
256   }
257  
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
258   /* initialize_server_capabs()
259   *
260   * inputs       - none
# Line 380 | Line 264 | static void
264   initialize_server_capabs(void)
265   {
266    add_capability("QS", CAP_QS, 1);
383  add_capability("LL", CAP_LL, 1);
267    add_capability("EOB", CAP_EOB, 1);
268 <  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);
268 >  add_capability("TS6", CAP_TS6, 0);
269    add_capability("CLUSTER", CAP_CLUSTER, 1);
270 < #ifdef HALFOPS
270 >  add_capability("SVS", CAP_SVS, 1);
271 >  add_capability("CHW", CAP_CHW, 1);
272    add_capability("HOPS", CAP_HOPS, 1);
391 #endif
273   }
274  
275   /* write_pidfile()
# Line 400 | Line 281 | initialize_server_capabs(void)
281   static void
282   write_pidfile(const char *filename)
283   {
284 <  FBFILE *fb;
284 >  FILE *fb;
285  
286 <  if ((fb = fbopen(filename, "w")))
286 >  if ((fb = fopen(filename, "w")))
287    {
288 <    char buff[32];
288 >    char buff[IRCD_BUFSIZE];
289      unsigned int pid = (unsigned int)getpid();
409    size_t nbytes = ircsprintf(buff, "%u\n", pid);
290  
291 <    if ((fbputs(buff, fb, nbytes) == -1))
292 <      ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
291 >    snprintf(buff, sizeof(buff), "%u\n", pid);
292 >
293 >    if ((fputs(buff, fb) == -1))
294 >      ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)",
295             pid, filename, strerror(errno));
296  
297 <    fbclose(fb);
416 <    return;
297 >    fclose(fb);
298    }
299    else
300    {
301 <    ilog(L_ERROR, "Error opening pid file %s", filename);
301 >    ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename);
302    }
303   }
304  
# Line 432 | Line 313 | write_pidfile(const char *filename)
313   static void
314   check_pidfile(const char *filename)
315   {
316 < #ifndef _WIN32
317 <  FBFILE *fb;
437 <  char buff[32];
316 >  FILE *fb;
317 >  char buff[IRCD_BUFSIZE];
318    pid_t pidfromfile;
319  
320    /* Don't do logging here, since we don't have log() initialised */
321 <  if ((fb = fbopen(filename, "r")))
321 >  if ((fb = fopen(filename, "r")))
322    {
323 <    if (fbgets(buff, 20, fb) == NULL)
323 >    if (fgets(buff, 20, fb) == NULL)
324      {
325        /* log(L_ERROR, "Error reading from pid file %s (%s)", filename,
326         * strerror(errno));
# Line 458 | Line 338 | check_pidfile(const char *filename)
338        }
339      }
340  
341 <    fbclose(fb);
341 >    fclose(fb);
342    }
343    else if (errno != ENOENT)
344    {
345      /* log(L_ERROR, "Error opening pid file %s", filename); */
346    }
467 #endif
347   }
348  
349   /* setup_corefile()
# Line 489 | Line 368 | setup_corefile(void)
368   #endif
369   }
370  
371 + #ifdef HAVE_LIBCRYPTO
372 + static int
373 + always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
374 + {
375 +  return 1;
376 + }
377 + #endif
378 +
379   /* init_ssl()
380   *
381   * inputs       - nothing
# Line 496 | Line 383 | setup_corefile(void)
383   * side effects - setups SSL context.
384   */
385   static void
386 < init_ssl(void)
386 > ssl_init(void)
387   {
388   #ifdef HAVE_LIBCRYPTO
389 +  const unsigned char session_id[] = "ircd-hybrid";
390 +
391    SSL_load_error_strings();
392    SSLeay_add_ssl_algorithms();
393  
394 <  ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method());
506 <  if (!ServerInfo.ctx)
394 >  if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
395    {
396      const char *s;
397  
398 <    fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n",
398 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
399              s = ERR_lib_error_string(ERR_get_error()));
400 <    ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s);
400 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
401    }
402  
403 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_NO_SSLv2);
404 <  SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
405 <  SSL_CTX_set_verify(ServerInfo.ctx, SSL_VERIFY_NONE, NULL);
403 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
404 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
405 >  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
406 >                     always_accept_verify_cb);
407 >  SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
408  
409 <  bio_spare_fd = save_spare_fd("SSL private key validation");
410 < #endif /* HAVE_LIBCRYPTO */
411 < }
409 >  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
410 >  {
411 >    const char *s;
412  
413 < /* init_callbacks()
414 < *
415 < * inputs       - nothing
416 < * output       - nothing
417 < * side effects - setups standard hook points
418 < */
419 < static void
420 < init_callbacks(void)
421 < {
422 <  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);
413 >    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
414 >            s = ERR_lib_error_string(ERR_get_error()));
415 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
416 >  }
417 >
418 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
419 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
420 >  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
421 >                     always_accept_verify_cb);
422 > #endif /* HAVE_LIBCRYPTO */
423   }
424  
425   int
426   main(int argc, char *argv[])
427   {
428 <  /* Check to see if the user is running
542 <   * us as root, which is a nono
543 <   */
544 < #ifndef _WIN32
428 >  /* Check to see if the user is running us as root, which is a nono */
429    if (geteuid() == 0)
430    {
431 <    fprintf(stderr, "Don't run ircd as root!!!\n");
432 <    return(-1);
431 >    fprintf(stderr, "ERROR: This server won't run as root/superuser\n");
432 >    return -1;
433    }
434  
435    /* Setup corefile size immediately after boot -kre */
436    setup_corefile();
437  
554  /* set initialVMTop before we allocate any memory */
555  initialVMTop = get_vm_top();
556 #endif
557
438    /* save server boot time right away, so getrusage works correctly */
439    set_time();
440  
441 <    /* It ain't random, but it ought to be a little harder to guess */
442 <  srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
443 <  memset(&me, 0, sizeof(me));
564 <  memset(&meLocalUser, 0, sizeof(meLocalUser));
441 >  /* It ain't random, but it ought to be a little harder to guess */
442 >  init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
443 >
444    me.localClient = &meLocalUser;
445 <  dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
445 >  dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
446                                                     of Client list */
568
569  memset(&ServerInfo, 0, sizeof(ServerInfo));
570
571  /* Initialise the channel capability usage counts... */
572  init_chcap_usage_counts();
573
447    ConfigFileEntry.dpath      = DPATH;
448 <  ConfigFileEntry.configfile = CPATH;  /* Server configuration file */
449 <  ConfigFileEntry.klinefile  = KPATH;  /* Server kline file         */
450 <  ConfigFileEntry.xlinefile  = XPATH;  /* Server xline file         */
451 <  ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file   */
452 <  ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file   */
453 <  ConfigFileEntry.dlinefile  = DLPATH; /* dline file                */
454 <  ConfigFileEntry.glinefile  = GPATH;  /* gline log file            */
455 <  ConfigFileEntry.cresvfile  = CRESVPATH; /* channel resv file      */
456 <  ConfigFileEntry.nresvfile  = NRESVPATH; /* nick resv file         */
448 >  ConfigFileEntry.spath      = SPATH;
449 >  ConfigFileEntry.mpath      = MPATH;
450 >  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
451 >  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
452 >  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
453 >  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
454 >  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
455 >  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
456 >
457    myargv = argv;
458    umask(077);                /* better safe than sorry --SRB */
459  
# Line 588 | Line 461 | main(int argc, char *argv[])
461  
462    if (printVersion)
463    {
464 <    printf("ircd: version %s\n", ircd_version);
464 >    printf("ircd: version %s(%s)\n", ircd_version, serno);
465      exit(EXIT_SUCCESS);
466    }
467  
# Line 598 | Line 471 | main(int argc, char *argv[])
471      exit(EXIT_FAILURE);
472    }
473  
474 <  init_ssl();
474 >  ssl_init();
475  
603 #ifndef _WIN32
476    if (!server_state.foreground)
477    {
478      make_daemon();
# Line 610 | Line 482 | main(int argc, char *argv[])
482      print_startup(getpid());
483  
484    setup_signals();
613 #endif
614
615  get_ircd_platform(ircd_platform);
485  
486    /* Init the event subsystem */
487    eventInit();
488 +
489    /* We need this to initialise the fd array before anything else */
490    fdlist_init();
491 <  init_log(logFileName);
491 >  log_set_file(LOG_TYPE_IRCD, 0, logFileName);
492    check_can_use_v6();
493 <  init_comm();         /* This needs to be setup early ! -- adrian */
493 >  init_netio();         /* This needs to be setup early ! -- adrian */
494 >
495    /* Check if there is pidfile and daemon already running */
496    check_pidfile(pidFileName);
497  
498 < #ifndef NOBALLOC
628 <  initBlockHeap();
629 < #endif
498 >  mp_pool_init();
499    init_dlink_nodes();
500 <  init_callbacks();
632 <  initialize_message_files();
500 >  init_isupport();
501    dbuf_init();
502 <  init_hash();
502 >  hash_init();
503    init_ip_hash_table();      /* client host ip hash table */
504    init_host_hash();          /* Host-hashtable. */
505 <  clear_tree_parse();
506 <  init_client();
507 <  init_class();
508 <  init_whowas();
509 <  init_stats();
505 >  client_init();
506 >  class_init();
507 >  whowas_init();
508 >  watch_init();
509 >  auth_init();          /* Initialise the auth code */
510 >  init_resolver();      /* Needs to be setup before the io loop */
511 >  modules_init();
512    read_conf_files(1);   /* cold start init conf files */
643  initServerMask();
644  me.id[0] = '\0';
513    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
514    initialize_server_capabs();   /* Set up default_server_capabs */
515    initialize_global_set_options();
516 <  init_channels();
516 >  channel_init();
517 >  read_links_file();
518 >  motd_init();
519 > #ifdef HAVE_LIBGEOIP
520 >  geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
521 > #endif
522 >
523 >  if (EmptyString(ServerInfo.sid))
524 >  {
525 >    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
526 >    exit(EXIT_FAILURE);
527 >  }
528 >
529 >  strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
530  
531 <  if (ServerInfo.name == NULL)
531 >  if (EmptyString(ServerInfo.name))
532    {
533 <    ilog(L_CRIT, "No server name specified in serverinfo block.");
533 >    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
534      exit(EXIT_FAILURE);
535    }
536 +
537    strlcpy(me.name, ServerInfo.name, sizeof(me.name));
538  
539    /* serverinfo{} description must exist.  If not, error out.*/
540 <  if (ServerInfo.description == NULL)
540 >  if (EmptyString(ServerInfo.description))
541    {
542 <    ilog(L_CRIT,
665 <      "ERROR: No server description specified in serverinfo block.");
542 >    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
543      exit(EXIT_FAILURE);
544    }
545 +
546    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
547  
548 <  me.from    = &me;
549 <  me.servptr = &me;
548 >  me.from                   = &me;
549 >  me.servptr                = &me;
550 >  me.localClient->lasttime  = CurrentTime;
551 >  me.localClient->since     = CurrentTime;
552 >  me.localClient->firsttime = CurrentTime;
553  
554    SetMe(&me);
555    make_server(&me);
556  
557 <  me.lasttime = me.since = me.firsttime = CurrentTime;
557 >  hash_add_id(&me);
558    hash_add_client(&me);
559 <  
559 >
560    /* add ourselves to global_serv_list */
561    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
562  
563 <  check_class();
563 >  load_kline_database();
564 >  load_dline_database();
565 >  load_gline_database();
566 >  load_xline_database();
567 >  load_resv_database();
568  
684 #ifndef STATIC_MODULES
569    if (chdir(MODPATH))
570    {
571 <    ilog (L_CRIT, "Could not load core modules. Terminating!");
571 >    ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
572      exit(EXIT_FAILURE);
573    }
574  
575    load_all_modules(1);
576    load_conf_modules();
577    load_core_modules(1);
578 +
579    /* Go back to DPATH after checking to see if we can chdir to MODPATH */
580 <  chdir(ConfigFileEntry.dpath);
581 < #else
582 <  load_all_modules(1);
583 < #endif
580 >  if (chdir(ConfigFileEntry.dpath))
581 >  {
582 >    perror("chdir");
583 >    exit(EXIT_FAILURE);
584 >  }
585 >
586    /*
587     * assemble_umode_buffer() has to be called after
588     * reading conf/loading modules.
# Line 704 | Line 591 | main(int argc, char *argv[])
591  
592    write_pidfile(pidFileName);
593  
594 <  ilog(L_NOTICE, "Server Ready");
594 >  ilog(LOG_TYPE_IRCD, "Server Ready");
595  
596    eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
597    eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
# Line 713 | Line 600 | main(int argc, char *argv[])
600    /* No, 'cause after a restart it would cause all sorts of nick collides */
601    eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
602  
716  eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
717
603    /* Setup the timeout check. I'll shift it later :)  -- adrian */
604    eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
605  
606 +  eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT);
607 +
608    if (ConfigServerHide.links_delay > 0)
609      eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
610    else
# Line 727 | Line 614 | main(int argc, char *argv[])
614      eventAddIsh("check_splitmode", check_splitmode, NULL, 60);
615  
616    io_loop();
617 <  return(0);
617 >  return 0;
618   }

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 3929 by michael, Mon Jun 9 14:56:25 2014 UTC

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

Diff Legend

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