ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/ircd.c
(Generate patch)

Comparing:
ircd-hybrid-8/src/ircd.c (file contents), Revision 1361 by michael, Sun Apr 22 19:01:51 2012 UTC vs.
ircd-hybrid/trunk/src/ircd.c (file contents), Revision 2872 by michael, Sun Jan 19 17:25:38 2014 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 +
69   /* /quote set variables */
70   struct SetOptions GlobalSetOptions;
71 <
72 < /* configuration set from ircd.conf */
68 < struct config_file_entry ConfigFileEntry;
69 < /* server info set from ircd.conf */
70 < struct server_info ServerInfo;
71 < /* admin info set from ircd.conf */
72 < struct admin_info AdminInfo = { NULL, NULL, NULL };
73 < struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
74 < struct ServerState_t server_state = { 0 };
75 < struct logging_entry ConfigLoggingEntry = { .use_logging = 1 };
71 > struct Counter Count;
72 > struct ServerState_t server_state;
73   struct ServerStatistics ServerStats;
74   struct timeval SystemTime;
75   struct Client me;             /* That's me */
# Line 82 | Line 79 | const char *logFileName = LPATH;
79   const char *pidFileName = PPATH;
80  
81   char **myargv;
85 char ircd_platform[PLATFORMLEN];
82  
83   int dorehash = 0;
84   int doremotd = 0;
# Line 115 | Line 111 | int rehashed_klines = 0;
111   static void
112   print_startup(int pid)
113   {
114 <  printf("ircd: version %s\n", ircd_version);
114 >  printf("ircd: version %s(%s)\n", ircd_version, serno);
115    printf("ircd: pid %d\n", pid);
116    printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
117           : "foreground", ConfigFileEntry.dpath);
# Line 143 | Line 139 | make_daemon(void)
139   static int printVersion = 0;
140  
141   static struct lgetopt myopts[] = {
146  {"dlinefile",  &ConfigFileEntry.dlinefile,
147   STRING, "File to use for dline.conf"},
142    {"configfile", &ConfigFileEntry.configfile,
143     STRING, "File to use for ircd.conf"},
144 +  {"glinefile",  &ConfigFileEntry.glinefile,
145 +   STRING, "File to use for gline database"},
146    {"klinefile",  &ConfigFileEntry.klinefile,
147 <   STRING, "File to use for kline.conf"},
147 >   STRING, "File to use for kline database"},
148 >  {"dlinefile",  &ConfigFileEntry.dlinefile,
149 >   STRING, "File to use for dline database"},
150    {"xlinefile",  &ConfigFileEntry.xlinefile,
151 <   STRING, "File to use for xline.conf"},
151 >   STRING, "File to use for xline database"},
152 >  {"resvfile",  &ConfigFileEntry.resvfile,
153 >   STRING, "File to use for resv database"},
154    {"logfile",    &logFileName,
155     STRING, "File to use for ircd.log"},
156    {"pidfile",    &pidFileName,
# Line 166 | Line 166 | static struct lgetopt myopts[] = {
166   void
167   set_time(void)
168   {
169 <  static char to_send[200];
169 >  static char to_send[IRCD_BUFSIZE];
170    struct timeval newtime;
171    newtime.tv_sec  = 0;
172    newtime.tv_usec = 0;
# Line 175 | Line 175 | set_time(void)
175    {
176      ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted",
177           strerror(errno));
178 <    sendto_realops_flags(UMODE_ALL, L_ALL,
178 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
179                           "Clock Failure (%s), TS can be corrupted",
180                           strerror(errno));
181      restart("Clock Failure");
# Line 243 | 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 289 | Line 289 | initialize_global_set_options(void)
289    /* End of global set options */
290   }
291  
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
292   /* initialize_server_capabs()
293   *
294   * inputs       - none
# Line 321 | Line 301 | initialize_server_capabs(void)
301    add_capability("EOB", CAP_EOB, 1);
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);
# Line 340 | Line 321 | write_pidfile(const char *filename)
321  
322    if ((fb = fopen(filename, "w")))
323    {
324 <    char buff[32];
324 >    char buff[IRCD_BUFSIZE];
325      unsigned int pid = (unsigned int)getpid();
326  
327      snprintf(buff, sizeof(buff), "%u\n", pid);
# Line 369 | Line 350 | static void
350   check_pidfile(const char *filename)
351   {
352    FILE *fb;
353 <  char buff[32];
353 >  char buff[IRCD_BUFSIZE];
354    pid_t pidfromfile;
355  
356    /* Don't do logging here, since we don't have log() initialised */
# Line 423 | 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 430 | 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    SSL_load_error_strings();
# Line 447 | Line 436 | init_ssl(void)
436  
437    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
438    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
439 <  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_NONE, NULL);
439 >  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
440 >                     always_accept_verify_cb);
441  
442    if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
443    {
# Line 460 | Line 450 | init_ssl(void)
450  
451    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
452    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
453 <  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_NONE, NULL);
453 >  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
454 >                     always_accept_verify_cb);
455   #endif /* HAVE_LIBCRYPTO */
456   }
457  
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
458   int
459   main(int argc, char *argv[])
460   {
461 <  /* Check to see if the user is running
484 <   * us as root, which is a nono
485 <   */
461 >  /* Check to see if the user is running us as root, which is a nono */
462    if (geteuid() == 0)
463    {
464      fprintf(stderr, "Don't run ircd as root!!!\n");
# Line 499 | Line 475 | main(int argc, char *argv[])
475    init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
476  
477    me.localClient = &meLocalUser;
478 <  dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
478 >  dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
479                                                     of Client list */
480    /* Initialise the channel capability usage counts... */
481    init_chcap_usage_counts();
482  
483    ConfigFileEntry.dpath      = DPATH;
484 <  ConfigFileEntry.configfile = CPATH;  /* Server configuration file */
485 <  ConfigFileEntry.klinefile  = KPATH;  /* Server kline file         */
486 <  ConfigFileEntry.xlinefile  = XPATH;  /* Server xline file         */
487 <  ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file   */
488 <  ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file   */
489 <  ConfigFileEntry.dlinefile  = DLPATH; /* dline file                */
490 <  ConfigFileEntry.glinefile  = GPATH;  /* gline log file            */
515 <  ConfigFileEntry.cresvfile  = CRESVPATH; /* channel resv file      */
516 <  ConfigFileEntry.nresvfile  = NRESVPATH; /* nick resv file         */
484 >  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
485 >  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
486 >  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
487 >  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
488 >  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
489 >  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
490 >
491    myargv = argv;
492    umask(077);                /* better safe than sorry --SRB */
493  
# Line 521 | Line 495 | main(int argc, char *argv[])
495  
496    if (printVersion)
497    {
498 <    printf("ircd: version %s\n", ircd_version);
498 >    printf("ircd: version %s(%s)\n", ircd_version, serno);
499      exit(EXIT_SUCCESS);
500    }
501  
# Line 531 | Line 505 | main(int argc, char *argv[])
505      exit(EXIT_FAILURE);
506    }
507  
508 <  init_ssl();
508 >  ssl_init();
509  
510    if (!server_state.foreground)
511    {
# Line 543 | Line 517 | main(int argc, char *argv[])
517  
518    setup_signals();
519  
546  get_ircd_platform(ircd_platform);
547
520    /* Init the event subsystem */
521    eventInit();
522 +
523    /* We need this to initialise the fd array before anything else */
524    fdlist_init();
525 <  log_add_file(LOG_TYPE_IRCD, 0, logFileName);
525 >  log_set_file(LOG_TYPE_IRCD, 0, logFileName);
526    check_can_use_v6();
527 <  init_comm();         /* This needs to be setup early ! -- adrian */
527 >  init_netio();         /* This needs to be setup early ! -- adrian */
528 >
529    /* Check if there is pidfile and daemon already running */
530    check_pidfile(pidFileName);
531  
532 <  initBlockHeap();
532 >  mp_pool_init();
533    init_dlink_nodes();
534 <  init_callbacks();
561 <  initialize_message_files();
534 >  init_isupport();
535    dbuf_init();
536 <  init_hash();
536 >  hash_init();
537    init_ip_hash_table();      /* client host ip hash table */
538    init_host_hash();          /* Host-hashtable. */
539 <  init_client();
540 <  init_class();
539 >  client_init();
540 >  class_init();
541    whowas_init();
542    watch_init();
543 <  init_auth();          /* Initialise the auth code */
543 >  auth_init();          /* Initialise the auth code */
544    init_resolver();      /* Needs to be setup before the io loop */
545 +  modules_init();
546    read_conf_files(1);   /* cold start init conf files */
547    init_uid();
548    initialize_server_capabs();   /* Set up default_server_capabs */
549    initialize_global_set_options();
550 <  init_channels();
550 >  channel_init();
551 >  read_links_file();
552 >  motd_init();
553 > #ifdef HAVE_LIBGEOIP
554 >  geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
555 > #endif
556  
557    if (EmptyString(ServerInfo.sid))
558    {
# Line 615 | Line 594 | main(int argc, char *argv[])
594    /* add ourselves to global_serv_list */
595    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
596  
597 +  load_kline_database();
598 +  load_dline_database();
599 +  load_gline_database();
600 +  load_xline_database();
601 +  load_resv_database();
602 +
603    if (chdir(MODPATH))
604    {
605      ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
# Line 652 | Line 637 | main(int argc, char *argv[])
637    /* Setup the timeout check. I'll shift it later :)  -- adrian */
638    eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
639  
640 +  eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT);
641 +
642    if (ConfigServerHide.links_delay > 0)
643      eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
644    else

Diff Legend

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