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 1117 by michael, Tue Dec 21 15:01:46 2010 UTC vs.
ircd-hybrid-8/src/ircd.c (file contents), Revision 1303 by michael, Fri Mar 23 10:52:19 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"
35   #include "irc_string.h"
37 – #include "sprintf_irc.h"
36   #include "ircd_signal.h"
37   #include "s_gline.h"
38   #include "motd.h"
41 – #include "ircd_handler.h"
42 – #include "msg.h"         /* msgtab */
39   #include "hostmask.h"
40   #include "numeric.h"
41   #include "packet.h"
# Line 64 | Line 60
60   #include "supported.h"
61   #include "watch.h"
62  
67 – /* Try and find the correct name to use with getrlimit() for setting the max.
68 – * number of files allowed to be open by this process.
69 – */
63  
64   /* /quote set variables */
65   struct SetOptions GlobalSetOptions;
# Line 77 | 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 = { 1, 1 };
76   struct ServerStatistics ServerStats;
77   struct timeval SystemTime;
78   struct Client me;             /* That's me */
# Line 185 | Line 178 | set_time(void)
178  
179    if (gettimeofday(&newtime, NULL) == -1)
180    {
181 <    ilog(L_ERROR, "Clock Failure (%s), TS can be corrupted",
181 >    ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted",
182           strerror(errno));
183      sendto_realops_flags(UMODE_ALL, L_ALL,
184                           "Clock Failure (%s), TS can be corrupted",
# Line 195 | Line 188 | set_time(void)
188  
189    if (newtime.tv_sec < CurrentTime)
190    {
191 <    ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)",
192 <               (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
191 >    snprintf(to_send, sizeof(to_send),
192 >             "System clock is running backwards - (%lu < %lu)",
193 >             (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
194      report_error(L_ALL, to_send, me.name, 0);
195      set_back_events(CurrentTime - newtime.tv_sec);
196    }
# Line 297 | Line 291 | initialize_global_set_options(void)
291    }
292  
293    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
300 –  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
294    /* End of global set options */
295   }
296  
# Line 332 | Line 325 | initialize_server_capabs(void)
325    add_capability("QS", CAP_QS, 1);
326    add_capability("EOB", CAP_EOB, 1);
327    add_capability("TS6", CAP_TS6, 0);
335 –  add_capability("ZIP", CAP_ZIP, 0);
328    add_capability("CLUSTER", CAP_CLUSTER, 1);
329 +  add_capability("SVS", CAP_SVS, 1);
330   #ifdef HALFOPS
331    add_capability("HOPS", CAP_HOPS, 1);
332   #endif
# Line 354 | Line 347 | write_pidfile(const char *filename)
347    {
348      char buff[32];
349      unsigned int pid = (unsigned int)getpid();
350 <    size_t nbytes = ircsprintf(buff, "%u\n", pid);
350 >    size_t nbytes = snprintf(buff, sizeof(buff), "%u\n", pid);
351  
352      if ((fbputs(buff, fb, nbytes) == -1))
353 <      ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
353 >      ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)",
354             pid, filename, strerror(errno));
355  
356      fbclose(fb);
# Line 365 | Line 358 | write_pidfile(const char *filename)
358    }
359    else
360    {
361 <    ilog(L_ERROR, "Error opening pid file %s", filename);
361 >    ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename);
362    }
363   }
364  
# Line 452 | Line 445 | init_ssl(void)
445    {
446      const char *s;
447  
448 <    fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n",
448 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
449              s = ERR_lib_error_string(ERR_get_error()));
450 <    ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s);
450 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
451    }
452  
453    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2);
454    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
455    SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_NONE, NULL);
456  
457 +  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
458 +  {
459 +    const char *s;
460 +
461 +    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
462 +            s = ERR_lib_error_string(ERR_get_error()));
463 +    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
464 +  }
465 +
466 +  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2);
467 +  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
468 +  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_NONE, NULL);
469 +
470    bio_spare_fd = save_spare_fd("SSL private key validation");
471   #endif /* HAVE_LIBCRYPTO */
472   }
# Line 476 | Line 482 | init_callbacks(void)
482   {
483    iorecv_cb = register_callback("iorecv", iorecv_default);
484    iosend_cb = register_callback("iosend", iosend_default);
479 –  iorecvctrl_cb = register_callback("iorecvctrl", NULL);
480 –  iosendctrl_cb = register_callback("iosendctrl", NULL);
485   }
486  
487   int
# Line 501 | Line 505 | main(int argc, char *argv[])
505    /* It ain't random, but it ought to be a little harder to guess */
506    init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
507  
504 –  memset(&me, 0, sizeof(me));
505 –  memset(&meLocalUser, 0, sizeof(meLocalUser));
508    me.localClient = &meLocalUser;
509    dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
510                                                     of Client list */
509 –
510 –  memset(&ServerInfo, 0, sizeof(ServerInfo));
511 –  memset(&ServerStats, 0, sizeof(ServerStats));
512 –
511    /* Initialise the channel capability usage counts... */
512    init_chcap_usage_counts();
513  
# Line 558 | Line 556 | main(int argc, char *argv[])
556    eventInit();
557    /* We need this to initialise the fd array before anything else */
558    fdlist_init();
559 <  init_log(logFileName);
559 >  log_add_file(LOG_TYPE_IRCD, 0, logFileName);
560    check_can_use_v6();
561    init_comm();         /* This needs to be setup early ! -- adrian */
562    /* Check if there is pidfile and daemon already running */
# Line 587 | Line 585 | main(int argc, char *argv[])
585  
586    if (EmptyString(ServerInfo.sid))
587    {
588 <    ilog(L_CRIT, "ERROR: No server id specified in serverinfo block.");
588 >    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
589      exit(EXIT_FAILURE);
590    }
591  
# Line 595 | Line 593 | main(int argc, char *argv[])
593  
594    if (EmptyString(ServerInfo.name))
595    {
596 <    ilog(L_CRIT, "ERROR: No server name specified in serverinfo block.");
596 >    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
597      exit(EXIT_FAILURE);
598    }
599  
# Line 604 | Line 602 | main(int argc, char *argv[])
602    /* serverinfo{} description must exist.  If not, error out.*/
603    if (EmptyString(ServerInfo.description))
604    {
605 <    ilog(L_CRIT, "ERROR: No server description specified in serverinfo block.");
605 >    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
606      exit(EXIT_FAILURE);
607    }
608  
609    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
610  
611 <  me.from    = &me;
612 <  me.servptr = &me;
611 >  me.from                   = &me;
612 >  me.servptr                = &me;
613 >  me.localClient->lasttime  = CurrentTime;
614 >  me.localClient->since     = CurrentTime;
615 >  me.localClient->firsttime = CurrentTime;
616  
617    SetMe(&me);
618    make_server(&me);
619  
619 –  me.lasttime = me.since = me.firsttime = CurrentTime;
620 –
620    hash_add_id(&me);
621    hash_add_client(&me);
622    
623    /* add ourselves to global_serv_list */
624    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
625  
627 – #ifndef STATIC_MODULES
626    if (chdir(MODPATH))
627    {
628 <    ilog(L_CRIT, "Could not load core modules. Terminating!");
628 >    ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
629      exit(EXIT_FAILURE);
630    }
631  
# Line 641 | Line 639 | main(int argc, char *argv[])
639      perror("chdir");
640      exit(EXIT_FAILURE);
641    }
642 < #else
645 <  load_all_modules(1);
646 < #endif
642 >
643    /*
644     * assemble_umode_buffer() has to be called after
645     * reading conf/loading modules.
# Line 652 | Line 648 | main(int argc, char *argv[])
648  
649    write_pidfile(pidFileName);
650  
651 <  ilog(L_NOTICE, "Server Ready");
651 >  ilog(LOG_TYPE_IRCD, "Server Ready");
652  
653    eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
654    eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
# Line 661 | Line 657 | main(int argc, char *argv[])
657    /* No, 'cause after a restart it would cause all sorts of nick collides */
658    eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
659  
664 –  eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
665 –
660    /* Setup the timeout check. I'll shift it later :)  -- adrian */
661    eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
662  

Diff Legend

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