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-8/src/ircd.c (file contents), Revision 1357 by michael, Sat Apr 21 20:47:01 2012 UTC vs.
ircd-hybrid/trunk/src/ircd.c (file contents), Revision 2253 by michael, Mon Jun 17 11:35:00 2013 UTC

# Line 36 | Line 36
36   #include "ircd_signal.h"
37   #include "s_gline.h"
38   #include "motd.h"
39 + #include "conf.h"
40   #include "hostmask.h"
41   #include "numeric.h"
42   #include "packet.h"
# Line 45 | Line 46
46   #include "rng_mt.h"
47   #include "s_auth.h"
48   #include "s_bsd.h"
48 #include "conf.h"
49   #include "log.h"
50   #include "s_misc.h"
51   #include "s_serv.h"      /* try_connections */
# Line 53 | Line 53
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"
58 #include "balloc.h"
59 #include "motd.h"
59   #include "supported.h"
60   #include "watch.h"
61 + #include "conf_db.h"
62 + #include "conf_class.h"
63  
64  
65 + #ifdef HAVE_LIBGEOIP
66 + GeoIP *geoip_ctx;
67 + #endif
68   /* /quote set variables */
69   struct SetOptions GlobalSetOptions;
70  
# Line 82 | Line 86 | const char *logFileName = LPATH;
86   const char *pidFileName = PPATH;
87  
88   char **myargv;
85 char ircd_platform[PLATFORMLEN];
89  
90   int dorehash = 0;
91   int doremotd = 0;
# Line 143 | Line 146 | make_daemon(void)
146   static int printVersion = 0;
147  
148   static struct lgetopt myopts[] = {
146  {"dlinefile",  &ConfigFileEntry.dlinefile,
147   STRING, "File to use for dline.conf"},
149    {"configfile", &ConfigFileEntry.configfile,
150     STRING, "File to use for ircd.conf"},
151 +  {"glinefile",  &ConfigFileEntry.glinefile,
152 +   STRING, "File to use for gline database"},
153    {"klinefile",  &ConfigFileEntry.klinefile,
154 <   STRING, "File to use for kline.conf"},
154 >   STRING, "File to use for kline database"},
155 >  {"dlinefile",  &ConfigFileEntry.dlinefile,
156 >   STRING, "File to use for dline database"},
157    {"xlinefile",  &ConfigFileEntry.xlinefile,
158 <   STRING, "File to use for xline.conf"},
158 >   STRING, "File to use for xline database"},
159 >  {"resvfile",  &ConfigFileEntry.resvfile,
160 >   STRING, "File to use for resv database"},
161    {"logfile",    &logFileName,
162     STRING, "File to use for ircd.log"},
163    {"pidfile",    &pidFileName,
# Line 175 | Line 182 | set_time(void)
182    {
183      ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted",
184           strerror(errno));
185 <    sendto_realops_flags(UMODE_ALL, L_ALL,
185 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
186                           "Clock Failure (%s), TS can be corrupted",
187                           strerror(errno));
188      restart("Clock Failure");
# Line 243 | Line 250 | io_loop(void)
250      }
251      if (doremotd)
252      {
253 <      read_message_file(&ConfigFileEntry.motd);
254 <      sendto_realops_flags(UMODE_ALL, L_ALL,
255 <                           "Got signal SIGUSR1, reloading ircd motd file");
253 >      motd_recache();
254 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
255 >                           "Got signal SIGUSR1, reloading motd files");
256        doremotd = 0;
257      }
258    }
# Line 289 | Line 296 | initialize_global_set_options(void)
296    /* End of global set options */
297   }
298  
292 /* initialize_message_files()
293 *
294 * inputs       - none
295 * output       - none
296 * side effects - Set up all message files needed, motd etc.
297 */
298 static void
299 initialize_message_files(void)
300 {
301  init_message_file(USER_MOTD, MPATH, &ConfigFileEntry.motd);
302  init_message_file(OPER_MOTD, OPATH, &ConfigFileEntry.opermotd);
303  init_message_file(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile);
304
305  read_message_file(&ConfigFileEntry.motd);
306  read_message_file(&ConfigFileEntry.opermotd);
307  read_message_file(&ConfigFileEntry.linksfile);
308
309  init_isupport();
310 }
311
299   /* initialize_server_capabs()
300   *
301   * inputs       - none
# Line 423 | Line 410 | setup_corefile(void)
410   #endif
411   }
412  
413 + #ifdef HAVE_LIBCRYPTO
414 + static int
415 + always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
416 + {
417 +  return 1;
418 + }
419 + #endif
420 +
421   /* init_ssl()
422   *
423   * inputs       - nothing
# Line 430 | Line 425 | setup_corefile(void)
425   * side effects - setups SSL context.
426   */
427   static void
428 < init_ssl(void)
428 > ssl_init(void)
429   {
430   #ifdef HAVE_LIBCRYPTO
431    SSL_load_error_strings();
# Line 447 | Line 442 | init_ssl(void)
442  
443    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
444    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
445 <  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_NONE, NULL);
445 >  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
446 >                     always_accept_verify_cb);
447  
448    if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
449    {
# Line 460 | Line 456 | init_ssl(void)
456  
457    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
458    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
459 <  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_NONE, NULL);
459 >  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
460 >                     always_accept_verify_cb);
461   #endif /* HAVE_LIBCRYPTO */
462   }
463  
467 /* init_callbacks()
468 *
469 * inputs       - nothing
470 * output       - nothing
471 * side effects - setups standard hook points
472 */
473 static void
474 init_callbacks(void)
475 {
476  iorecv_cb = register_callback("iorecv", iorecv_default);
477  iosend_cb = register_callback("iosend", iosend_default);
478 }
479
464   int
465   main(int argc, char *argv[])
466   {
467 <  /* Check to see if the user is running
484 <   * us as root, which is a nono
485 <   */
467 >  /* Check to see if the user is running us as root, which is a nono */
468    if (geteuid() == 0)
469    {
470      fprintf(stderr, "Don't run ircd as root!!!\n");
# Line 499 | Line 481 | main(int argc, char *argv[])
481    init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
482  
483    me.localClient = &meLocalUser;
484 <  dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
484 >  dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
485                                                     of Client list */
486    /* Initialise the channel capability usage counts... */
487    init_chcap_usage_counts();
488  
489    ConfigFileEntry.dpath      = DPATH;
490 <  ConfigFileEntry.configfile = CPATH;  /* Server configuration file */
491 <  ConfigFileEntry.klinefile  = KPATH;  /* Server kline file         */
492 <  ConfigFileEntry.xlinefile  = XPATH;  /* Server xline file         */
493 <  ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file   */
494 <  ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file   */
495 <  ConfigFileEntry.dlinefile  = DLPATH; /* dline file                */
496 <  ConfigFileEntry.glinefile  = GPATH;  /* gline log file            */
515 <  ConfigFileEntry.cresvfile  = CRESVPATH; /* channel resv file      */
516 <  ConfigFileEntry.nresvfile  = NRESVPATH; /* nick resv file         */
490 >  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
491 >  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
492 >  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
493 >  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
494 >  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
495 >  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
496 >
497    myargv = argv;
498    umask(077);                /* better safe than sorry --SRB */
499  
# Line 531 | Line 511 | main(int argc, char *argv[])
511      exit(EXIT_FAILURE);
512    }
513  
514 <  init_ssl();
514 >  ssl_init();
515  
516    if (!server_state.foreground)
517    {
# Line 543 | Line 523 | main(int argc, char *argv[])
523  
524    setup_signals();
525  
546  get_ircd_platform(ircd_platform);
547
526    /* Init the event subsystem */
527    eventInit();
528 +
529    /* We need this to initialise the fd array before anything else */
530    fdlist_init();
531 <  log_add_file(LOG_TYPE_IRCD, 0, logFileName);
531 >  log_set_file(LOG_TYPE_IRCD, 0, logFileName);
532    check_can_use_v6();
533    init_comm();         /* This needs to be setup early ! -- adrian */
534 +
535    /* Check if there is pidfile and daemon already running */
536    check_pidfile(pidFileName);
537  
538 <  initBlockHeap();
538 >  mp_pool_init();
539    init_dlink_nodes();
540 <  init_callbacks();
561 <  initialize_message_files();
540 >  init_isupport();
541    dbuf_init();
542 <  init_hash();
542 >  hash_init();
543    init_ip_hash_table();      /* client host ip hash table */
544    init_host_hash();          /* Host-hashtable. */
545 <  clear_tree_parse();
546 <  init_client();
547 <  init_class();
569 <  init_whowas();
545 >  client_init();
546 >  class_init();
547 >  whowas_init();
548    watch_init();
549 <  init_auth();          /* Initialise the auth code */
549 >  auth_init();          /* Initialise the auth code */
550    init_resolver();      /* Needs to be setup before the io loop */
551 +  modules_init();
552    read_conf_files(1);   /* cold start init conf files */
553    init_uid();
554    initialize_server_capabs();   /* Set up default_server_capabs */
555    initialize_global_set_options();
556 <  init_channels();
556 >  channel_init();
557 >  read_links_file();
558 >  motd_init();
559 > #ifdef HAVE_LIBGEOIP
560 >  geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
561 > #endif
562  
563    if (EmptyString(ServerInfo.sid))
564    {
# Line 616 | Line 600 | main(int argc, char *argv[])
600    /* add ourselves to global_serv_list */
601    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
602  
603 +  load_kline_database();
604 +  load_dline_database();
605 +  load_gline_database();
606 +  load_xline_database();
607 +  load_resv_database();
608 +
609    if (chdir(MODPATH))
610    {
611      ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
# Line 653 | Line 643 | main(int argc, char *argv[])
643    /* Setup the timeout check. I'll shift it later :)  -- adrian */
644    eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
645  
646 +  eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT);
647 +
648    if (ConfigServerHide.links_delay > 0)
649      eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
650    else

Diff Legend

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