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-7.3/src/ircd.c (file contents), Revision 1124 by michael, Mon Feb 7 11:45:27 2011 UTC vs.
ircd-hybrid-8/src/ircd.c (file contents), Revision 1446 by michael, Mon Jun 25 20:05:12 2012 UTC

# Line 29 | Line 29
29   #include "channel.h"
30   #include "channel_mode.h"
31   #include "client.h"
32 #include "common.h"
32   #include "event.h"
33   #include "fdlist.h"
34   #include "hash.h"
# Line 37 | Line 36
36   #include "ircd_signal.h"
37   #include "s_gline.h"
38   #include "motd.h"
40 #include "ircd_handler.h"
41 #include "msg.h"         /* msgtab */
39   #include "hostmask.h"
40   #include "numeric.h"
41   #include "packet.h"
# Line 48 | Line 45
45   #include "rng_mt.h"
46   #include "s_auth.h"
47   #include "s_bsd.h"
48 < #include "s_conf.h"
49 < #include "s_log.h"
48 > #include "conf.h"
49 > #include "log.h"
50   #include "s_misc.h"
51   #include "s_serv.h"      /* try_connections */
52   #include "send.h"
# Line 63 | Line 60
60   #include "supported.h"
61   #include "watch.h"
62  
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 */
63  
64   /* /quote set variables */
65   struct SetOptions GlobalSetOptions;
# Line 76 | Line 70 | struct config_file_entry ConfigFileEntry
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 };
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 = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} };
75 > struct logging_entry ConfigLoggingEntry = { .use_logging = 1 };
76   struct ServerStatistics ServerStats;
77   struct timeval SystemTime;
78   struct Client me;             /* That's me */
# Line 88 | Line 82 | const char *logFileName = LPATH;
82   const char *pidFileName = PPATH;
83  
84   char **myargv;
91 char ircd_platform[PLATFORMLEN];
85  
86   int dorehash = 0;
87   int doremotd = 0;
# Line 97 | Line 90 | int doremotd = 0;
90   * initialize_server_capabs
91   */
92   int default_server_capabs = 0;
100
101 #ifdef HAVE_LIBCRYPTO
102 int bio_spare_fd = -1;
103 #endif
104
93   unsigned int splitmode;
94   unsigned int splitchecking;
95   unsigned int split_users;
# Line 153 | Line 141 | make_daemon(void)
141  
142   static int printVersion = 0;
143  
144 < struct lgetopt myopts[] = {
144 > static struct lgetopt myopts[] = {
145    {"dlinefile",  &ConfigFileEntry.dlinefile,
146     STRING, "File to use for dline.conf"},
147    {"configfile", &ConfigFileEntry.configfile,
# Line 184 | Line 172 | set_time(void)
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,
178                           "Clock Failure (%s), TS can be corrupted",
# Line 297 | Line 285 | initialize_global_set_options(void)
285    }
286  
287    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
300  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
288    /* End of global set options */
289   }
290  
# Line 311 | Line 298 | static void
298   initialize_message_files(void)
299   {
300    init_message_file(USER_MOTD, MPATH, &ConfigFileEntry.motd);
314  init_message_file(OPER_MOTD, OPATH, &ConfigFileEntry.opermotd);
301    init_message_file(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile);
302  
303    read_message_file(&ConfigFileEntry.motd);
318  read_message_file(&ConfigFileEntry.opermotd);
304    read_message_file(&ConfigFileEntry.linksfile);
305  
306    init_isupport();
# Line 332 | Line 317 | initialize_server_capabs(void)
317    add_capability("QS", CAP_QS, 1);
318    add_capability("EOB", CAP_EOB, 1);
319    add_capability("TS6", CAP_TS6, 0);
335  add_capability("ZIP", CAP_ZIP, 0);
320    add_capability("CLUSTER", CAP_CLUSTER, 1);
321 +  add_capability("SVS", CAP_SVS, 1);
322   #ifdef HALFOPS
323    add_capability("HOPS", CAP_HOPS, 1);
324   #endif
# Line 348 | Line 333 | initialize_server_capabs(void)
333   static void
334   write_pidfile(const char *filename)
335   {
336 <  FBFILE *fb;
336 >  FILE *fb;
337  
338 <  if ((fb = fbopen(filename, "w")))
338 >  if ((fb = fopen(filename, "w")))
339    {
340      char buff[32];
341      unsigned int pid = (unsigned int)getpid();
357    size_t nbytes = snprintf(buff, sizeof(buff), "%u\n", pid);
342  
343 <    if ((fbputs(buff, fb, nbytes) == -1))
344 <      ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
343 >    snprintf(buff, sizeof(buff), "%u\n", pid);
344 >
345 >    if ((fputs(buff, fb) == -1))
346 >      ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)",
347             pid, filename, strerror(errno));
348  
349 <    fbclose(fb);
364 <    return;
349 >    fclose(fb);
350    }
351    else
352    {
353 <    ilog(L_ERROR, "Error opening pid file %s", filename);
353 >    ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename);
354    }
355   }
356  
# Line 380 | Line 365 | write_pidfile(const char *filename)
365   static void
366   check_pidfile(const char *filename)
367   {
368 <  FBFILE *fb;
368 >  FILE *fb;
369    char buff[32];
370    pid_t pidfromfile;
371  
372    /* Don't do logging here, since we don't have log() initialised */
373 <  if ((fb = fbopen(filename, "r")))
373 >  if ((fb = fopen(filename, "r")))
374    {
375 <    if (fbgets(buff, 20, fb) == NULL)
375 >    if (fgets(buff, 20, fb) == NULL)
376      {
377        /* log(L_ERROR, "Error reading from pid file %s (%s)", filename,
378         * strerror(errno));
# Line 405 | Line 390 | check_pidfile(const char *filename)
390        }
391      }
392  
393 <    fbclose(fb);
393 >    fclose(fb);
394    }
395    else if (errno != ENOENT)
396    {
# Line 452 | Line 437 | init_ssl(void)
437    {
438      const char *s;
439  
440 <    fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n",
440 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
441              s = ERR_lib_error_string(ERR_get_error()));
442 <    ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s);
442 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
443    }
444  
445 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2);
445 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
446    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
447    SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_NONE, NULL);
448  
449 <  bio_spare_fd = save_spare_fd("SSL private key validation");
449 >  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
450 >  {
451 >    const char *s;
452 >
453 >    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
454 >            s = ERR_lib_error_string(ERR_get_error()));
455 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
456 >  }
457 >
458 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
459 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
460 >  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_NONE, NULL);
461   #endif /* HAVE_LIBCRYPTO */
462   }
463  
# Line 476 | Line 472 | init_callbacks(void)
472   {
473    iorecv_cb = register_callback("iorecv", iorecv_default);
474    iosend_cb = register_callback("iosend", iosend_default);
479  iorecvctrl_cb = register_callback("iorecvctrl", NULL);
480  iosendctrl_cb = register_callback("iosendctrl", NULL);
475   }
476  
477   int
# Line 501 | Line 495 | main(int argc, char *argv[])
495    /* It ain't random, but it ought to be a little harder to guess */
496    init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
497  
504  memset(&me, 0, sizeof(me));
505  memset(&meLocalUser, 0, sizeof(meLocalUser));
498    me.localClient = &meLocalUser;
499    dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
500                                                     of Client list */
509
510  memset(&ServerInfo, 0, sizeof(ServerInfo));
511  memset(&ServerStats, 0, sizeof(ServerStats));
512
501    /* Initialise the channel capability usage counts... */
502    init_chcap_usage_counts();
503  
# Line 552 | Line 540 | main(int argc, char *argv[])
540  
541    setup_signals();
542  
555  get_ircd_platform(ircd_platform);
556
543    /* Init the event subsystem */
544    eventInit();
545    /* We need this to initialise the fd array before anything else */
546    fdlist_init();
547 <  init_log(logFileName);
547 >  log_add_file(LOG_TYPE_IRCD, 0, logFileName);
548    check_can_use_v6();
549    init_comm();         /* This needs to be setup early ! -- adrian */
550    /* Check if there is pidfile and daemon already running */
# Line 572 | Line 558 | main(int argc, char *argv[])
558    init_hash();
559    init_ip_hash_table();      /* client host ip hash table */
560    init_host_hash();          /* Host-hashtable. */
575  clear_tree_parse();
561    init_client();
562    init_class();
563 <  init_whowas();
563 >  whowas_init();
564    watch_init();
565    init_auth();          /* Initialise the auth code */
566    init_resolver();      /* Needs to be setup before the io loop */
567 +  modules_init();
568    read_conf_files(1);   /* cold start init conf files */
569    init_uid();
570    initialize_server_capabs();   /* Set up default_server_capabs */
# Line 587 | Line 573 | main(int argc, char *argv[])
573  
574    if (EmptyString(ServerInfo.sid))
575    {
576 <    ilog(L_CRIT, "ERROR: No server id specified in serverinfo block.");
576 >    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
577      exit(EXIT_FAILURE);
578    }
579  
# Line 595 | Line 581 | main(int argc, char *argv[])
581  
582    if (EmptyString(ServerInfo.name))
583    {
584 <    ilog(L_CRIT, "ERROR: No server name specified in serverinfo block.");
584 >    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
585      exit(EXIT_FAILURE);
586    }
587  
# Line 604 | Line 590 | main(int argc, char *argv[])
590    /* serverinfo{} description must exist.  If not, error out.*/
591    if (EmptyString(ServerInfo.description))
592    {
593 <    ilog(L_CRIT, "ERROR: No server description specified in serverinfo block.");
593 >    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
594      exit(EXIT_FAILURE);
595    }
596  
597    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
598  
599 <  me.from    = &me;
600 <  me.servptr = &me;
599 >  me.from                   = &me;
600 >  me.servptr                = &me;
601 >  me.localClient->lasttime  = CurrentTime;
602 >  me.localClient->since     = CurrentTime;
603 >  me.localClient->firsttime = CurrentTime;
604  
605    SetMe(&me);
606    make_server(&me);
607  
619  me.lasttime = me.since = me.firsttime = CurrentTime;
620
608    hash_add_id(&me);
609    hash_add_client(&me);
610    
# Line 626 | Line 613 | main(int argc, char *argv[])
613  
614    if (chdir(MODPATH))
615    {
616 <    ilog(L_CRIT, "Could not load core modules. Terminating!");
616 >    ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
617      exit(EXIT_FAILURE);
618    }
619  
# Line 649 | Line 636 | main(int argc, char *argv[])
636  
637    write_pidfile(pidFileName);
638  
639 <  ilog(L_NOTICE, "Server Ready");
639 >  ilog(LOG_TYPE_IRCD, "Server Ready");
640  
641    eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
642    eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
# Line 658 | Line 645 | main(int argc, char *argv[])
645    /* No, 'cause after a restart it would cause all sorts of nick collides */
646    eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
647  
661  eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
662
648    /* Setup the timeout check. I'll shift it later :)  -- adrian */
649    eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
650  

Diff Legend

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