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/trunk/src/ircd.c (file contents):
Revision 4161 by michael, Thu Jul 3 18:25:53 2014 UTC vs.
Revision 6470 by michael, Thu Sep 3 13:06:17 2015 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2014 ircd-hybrid development team
4 > *  Copyright (c) 1997-2015 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 15 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20   */
21  
# Line 33 | Line 33
33   #include "event.h"
34   #include "fdlist.h"
35   #include "hash.h"
36 + #include "id.h"
37   #include "irc_string.h"
38   #include "ircd_signal.h"
38 #include "gline.h"
39   #include "motd.h"
40   #include "conf.h"
41   #include "hostmask.h"
# Line 56 | Line 56
56   #include "watch.h"
57   #include "conf_db.h"
58   #include "conf_class.h"
59 + #include "ipcache.h"
60 + #include "isupport.h"
61 + #include "userhost.h"
62  
63  
64   #ifdef HAVE_LIBGEOIP
65   GeoIP *geoip_ctx;
66   #endif
67  
68 + struct SetOptions GlobalSetOptions;  /* /quote set variables */
69 + struct Counter Count;
70 + struct ServerState_t server_state;
71   struct ServerStatistics ServerStats;
72   struct timeval SystemTime;
73 < struct Client me;             /* That's me */
74 < struct LocalUser meLocalUser; /* That's also part of me */
73 > struct Connection meConnection;  /* That's also part of me */
74 > struct Client me = { .connection = &meConnection };  /* That's me */
75  
76 + char **myargv;
77   const char *logFileName = LPATH;
78   const char *pidFileName = PPATH;
79  
80 < char **myargv;
81 <
75 < int dorehash = 0;
76 < int doremotd = 0;
77 <
78 < /* Set to zero because it should be initialized later using
79 < * initialize_server_capabs
80 < */
81 < unsigned int default_server_capabs;
82 < unsigned int splitmode;
83 < unsigned int splitchecking;
84 < unsigned int split_users;
85 < unsigned int split_servers;
86 <
87 < static struct event event_cleanup_glines =
88 < {
89 <  .name = "cleanup_glines",
90 <  .handler = cleanup_glines,
91 <  .when = CLEANUP_GLINES_TIME
92 < };
80 > unsigned int dorehash;
81 > unsigned int doremotd;
82  
83   static struct event event_cleanup_tklines =
84   {
# Line 135 | Line 124 | print_startup(int pid)
124    printf("ircd: version %s(%s)\n", ircd_version, serno);
125    printf("ircd: pid %d\n", pid);
126    printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
127 <         : "foreground", ConfigFileEntry.dpath);
127 >         : "foreground", ConfigGeneral.dpath);
128   }
129  
130   static void
# Line 157 | Line 146 | make_daemon(void)
146    setsid();
147   }
148  
149 < static int printVersion = 0;
149 > static int printVersion;
150  
151   static struct lgetopt myopts[] =
152   {
153 <  {"configfile", &ConfigFileEntry.configfile,
154 <   STRING, "File to use for ircd.conf"},
155 <  {"glinefile",  &ConfigFileEntry.glinefile,
156 <   STRING, "File to use for gline database"},
157 <  {"klinefile",  &ConfigFileEntry.klinefile,
158 <   STRING, "File to use for kline database"},
159 <  {"dlinefile",  &ConfigFileEntry.dlinefile,
160 <   STRING, "File to use for dline database"},
161 <  {"xlinefile",  &ConfigFileEntry.xlinefile,
162 <   STRING, "File to use for xline database"},
163 <  {"resvfile",  &ConfigFileEntry.resvfile,
164 <   STRING, "File to use for resv database"},
165 <  {"logfile",    &logFileName,
166 <   STRING, "File to use for ircd.log"},
167 <  {"pidfile",    &pidFileName,
168 <   STRING, "File to use for process ID"},
169 <  {"foreground", &server_state.foreground,
170 <   YESNO, "Run in foreground (don't detach)"},
171 <  {"version",    &printVersion,
172 <   YESNO, "Print version and exit"},
184 <  {"help", NULL, USAGE, "Print this text"},
185 <  {NULL, NULL, STRING, NULL},
153 >  { "configfile", &ConfigGeneral.configfile,
154 >   STRING, "File to use for ircd.conf" },
155 >  { "klinefile",  &ConfigGeneral.klinefile,
156 >   STRING, "File to use for kline database" },
157 >  { "dlinefile",  &ConfigGeneral.dlinefile,
158 >   STRING, "File to use for dline database" },
159 >  { "xlinefile",  &ConfigGeneral.xlinefile,
160 >   STRING, "File to use for xline database" },
161 >  { "resvfile",   &ConfigGeneral.resvfile,
162 >   STRING, "File to use for resv database" },
163 >  { "logfile",    &logFileName,
164 >   STRING, "File to use for ircd.log" },
165 >  { "pidfile",    &pidFileName,
166 >   STRING, "File to use for process ID" },
167 >  { "foreground", &server_state.foreground,
168 >   YESNO, "Run in foreground (don't detach)" },
169 >  { "version",    &printVersion,
170 >   YESNO, "Print version and exit" },
171 >  { "help", NULL, USAGE, "Print this text" },
172 >  { NULL, NULL, STRING, NULL },
173   };
174  
175   void
# Line 194 | Line 181 | set_time(void)
181    {
182      ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted",
183           strerror(errno));
184 <    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
184 >    sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
185                           "Clock Failure (%s), TS can be corrupted",
186                           strerror(errno));
187 <    server_die("Clock Failure", 1);
187 >    server_die("Clock Failure", SERVER_SHUTDOWN);
188    }
189  
190    if (newtime.tv_sec < CurrentTime)
# Line 208 | Line 195 | set_time(void)
195                           "System clock is running backwards - (%lu < %lu)",
196                           (unsigned long)newtime.tv_sec,
197                           (unsigned long)CurrentTime);
198 <    set_back_events(CurrentTime - newtime.tv_sec);
198 >    event_set_back_events(CurrentTime - newtime.tv_sec);
199    }
200  
201    SystemTime.tv_sec  = newtime.tv_sec;
# Line 222 | Line 209 | io_loop(void)
209    {
210      if (listing_client_list.head)
211      {
212 <      dlink_node *ptr = NULL, *ptr_next = NULL;
213 <      DLINK_FOREACH_SAFE(ptr, ptr_next, listing_client_list.head)
214 <        safe_list_channels(ptr->data, 0);
212 >      dlink_node *node = NULL, *node_next = NULL;
213 >      DLINK_FOREACH_SAFE(node, node_next, listing_client_list.head)
214 >        safe_list_channels(node->data, 0);
215      }
216  
217      /* Run pending events */
# Line 237 | Line 224 | io_loop(void)
224      /* Check to see whether we have to rehash the configuration .. */
225      if (dorehash)
226      {
227 <      rehash(1);
227 >      conf_rehash(1);
228        dorehash = 0;
229      }
230  
231      if (doremotd)
232      {
233        motd_recache();
234 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
234 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
235                             "Got signal SIGUSR1, reloading motd file(s)");
236        doremotd = 0;
237      }
# Line 260 | Line 247 | io_loop(void)
247   static void
248   initialize_global_set_options(void)
249   {
250 <  memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
251 <
265 <  GlobalSetOptions.autoconn  = 1;
250 >  GlobalSetOptions.maxclients = ConfigServerInfo.default_max_clients;
251 >  GlobalSetOptions.autoconn = 1;
252    GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
253 <  GlobalSetOptions.spam_num  = MAX_JOIN_LEAVE_COUNT;
254 <
255 <  if (ConfigFileEntry.default_floodcount)
256 <    GlobalSetOptions.floodcount = ConfigFileEntry.default_floodcount;
271 <  else
272 <    GlobalSetOptions.floodcount = 10;
273 <
274 <  /* XXX I have no idea what to try here - Dianora */
275 <  GlobalSetOptions.joinfloodcount = 16;
276 <  GlobalSetOptions.joinfloodtime = 8;
277 <
278 <  split_servers = ConfigChannel.default_split_server_count;
279 <  split_users   = ConfigChannel.default_split_user_count;
280 <
281 <  if (split_users && split_servers && (ConfigChannel.no_create_on_split ||
282 <                                       ConfigChannel.no_join_on_split))
283 <  {
284 <    splitmode     = 1;
285 <    splitchecking = 1;
286 <  }
287 <
253 >  GlobalSetOptions.spam_num = MAX_JOIN_LEAVE_COUNT;
254 >  GlobalSetOptions.floodcount = ConfigGeneral.default_floodcount;
255 >  GlobalSetOptions.joinfloodcount = ConfigChannel.default_join_flood_count;
256 >  GlobalSetOptions.joinfloodtime = ConfigChannel.default_join_flood_time;
257    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
289  /* End of global set options */
258   }
259  
260   /* initialize_server_capabs()
# Line 297 | Line 265 | initialize_global_set_options(void)
265   static void
266   initialize_server_capabs(void)
267   {
268 <  add_capability("QS", CAP_QS, 1);
269 <  add_capability("EOB", CAP_EOB, 1);
270 <  add_capability("TS6", CAP_TS6, 0);
271 <  add_capability("CLUSTER", CAP_CLUSTER, 1);
272 <  add_capability("SVS", CAP_SVS, 1);
273 <  add_capability("CHW", CAP_CHW, 1);
306 <  add_capability("HOPS", CAP_HOPS, 1);
268 >  add_capability("QS", CAPAB_QS);
269 >  add_capability("EOB", CAPAB_EOB);
270 >  add_capability("CLUSTER", CAPAB_CLUSTER);
271 >  add_capability("SVS", CAPAB_SVS);
272 >  add_capability("CHW", CAPAB_CHW);
273 >  add_capability("HOPS", CAPAB_HOPS);
274   }
275  
276   /* write_pidfile()
# Line 319 | Line 286 | write_pidfile(const char *filename)
286  
287    if ((fb = fopen(filename, "w")))
288    {
289 <    char buff[IRCD_BUFSIZE];
289 >    char buf[IRCD_BUFSIZE];
290      unsigned int pid = (unsigned int)getpid();
291  
292 <    snprintf(buff, sizeof(buff), "%u\n", pid);
292 >    snprintf(buf, sizeof(buf), "%u\n", pid);
293  
294 <    if ((fputs(buff, fb) == -1))
295 <      ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)",
296 <           pid, filename, strerror(errno));
294 >    if (fputs(buf, fb) == -1)
295 >      ilog(LOG_TYPE_IRCD, "Error writing to pid file %s: %s",
296 >           filename, strerror(errno));
297  
298      fclose(fb);
299    }
300    else
301 <  {
302 <    ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename);
336 <  }
301 >    ilog(LOG_TYPE_IRCD, "Error opening pid file %s: %s",
302 >         filename, strerror(errno));
303   }
304  
305   /* check_pidfile()
# Line 348 | Line 314 | static void
314   check_pidfile(const char *filename)
315   {
316    FILE *fb;
317 <  char buff[IRCD_BUFSIZE];
352 <  pid_t pidfromfile;
317 >  char buf[IRCD_BUFSIZE];
318  
354  /* Don't do logging here, since we don't have log() initialised */
319    if ((fb = fopen(filename, "r")))
320    {
321 <    if (fgets(buff, 20, fb) == NULL)
322 <    {
323 <      /* log(L_ERROR, "Error reading from pid file %s (%s)", filename,
360 <       * strerror(errno));
361 <       */
362 <    }
321 >    if (!fgets(buf, 20, fb))
322 >      ilog(LOG_TYPE_IRCD, "Error reading from pid file %s: %s",
323 >           filename, strerror(errno));
324      else
325      {
326 <      pidfromfile = atoi(buff);
326 >      pid_t pidfromfile = atoi(buf);
327  
328        if (!kill(pidfromfile, 0))
329        {
# Line 375 | Line 336 | check_pidfile(const char *filename)
336      fclose(fb);
337    }
338    else if (errno != ENOENT)
339 <  {
340 <    /* log(L_ERROR, "Error opening pid file %s", filename); */
380 <  }
339 >    ilog(LOG_TYPE_IRCD, "Error opening pid file %s: %s",
340 >         filename, strerror(errno));
341   }
342  
343   /* setup_corefile()
# Line 420 | Line 380 | static void
380   ssl_init(void)
381   {
382   #ifdef HAVE_LIBCRYPTO
423  const unsigned char session_id[] = "ircd-hybrid";
424
383    SSL_load_error_strings();
384    SSLeay_add_ssl_algorithms();
385  
386 <  if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
386 >  if (!(ConfigServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())))
387    {
388      const char *s = ERR_lib_error_string(ERR_get_error());
389  
390      fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
391 <    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
391 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s", s);
392 >    exit(EXIT_FAILURE);
393 >    return;  /* Not reached */
394    }
395  
396 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
397 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_DH_USE);
398 <  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
396 >  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET);
397 >  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_DH_USE|SSL_OP_CIPHER_SERVER_PREFERENCE);
398 >  SSL_CTX_set_verify(ConfigServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
399                       always_accept_verify_cb);
400 <  SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
400 >  SSL_CTX_set_session_cache_mode(ConfigServerInfo.server_ctx, SSL_SESS_CACHE_OFF);
401 >  SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");
402  
403 < #if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH)
403 > #if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH)
404    {
405      EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
406  
407      if (key)
408      {
409 <      SSL_CTX_set_tmp_ecdh(ServerInfo.server_ctx, key);
409 >      SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
410        EC_KEY_free(key);
411      }
412    }
413  
414 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
414 >  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
415   #endif
416  
417 <  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
417 >  if (!(ConfigServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())))
418    {
419      const char *s = ERR_lib_error_string(ERR_get_error());
420  
421      fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
422 <    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
422 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s", s);
423 >    exit(EXIT_FAILURE);
424 >    return;  /* Not reached */
425    }
426  
427 <  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
428 <  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_SINGLE_DH_USE);
429 <  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
427 >  SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET);
428 >  SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_SINGLE_DH_USE);
429 >  SSL_CTX_set_verify(ConfigServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
430                       always_accept_verify_cb);
431 +  SSL_CTX_set_session_cache_mode(ConfigServerInfo.client_ctx, SSL_SESS_CACHE_OFF);
432   #endif /* HAVE_LIBCRYPTO */
433   }
434  
# Line 472 | Line 436 | int
436   main(int argc, char *argv[])
437   {
438    /* Check to see if the user is running us as root, which is a nono */
439 <  if (geteuid() == 0)
439 >  if (!geteuid())
440    {
441      fprintf(stderr, "ERROR: This server won't run as root/superuser\n");
442      return -1;
# Line 481 | Line 445 | main(int argc, char *argv[])
445    /* Setup corefile size immediately after boot -kre */
446    setup_corefile();
447  
448 <  /* save server boot time right away, so getrusage works correctly */
448 >  /* Save server boot time right away, so getrusage works correctly */
449    set_time();
450  
451 <  /* It ain't random, but it ought to be a little harder to guess */
451 >  /* It's not random, but it ought to be a little harder to guess */
452    init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
453  
454 <  me.localClient = &meLocalUser;
455 <  dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
456 <                                                   of Client list */
457 <  ConfigLoggingEntry.use_logging = 1;
458 <  ConfigFileEntry.dpath      = DPATH;
459 <  ConfigFileEntry.spath      = SPATH;
460 <  ConfigFileEntry.mpath      = MPATH;
461 <  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
498 <  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
499 <  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
500 <  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
501 <  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
502 <  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
454 >  ConfigGeneral.dpath      = DPATH;
455 >  ConfigGeneral.spath      = SPATH;
456 >  ConfigGeneral.mpath      = MPATH;
457 >  ConfigGeneral.configfile = CPATH;    /* Server configuration file */
458 >  ConfigGeneral.klinefile  = KPATH;    /* Server kline file         */
459 >  ConfigGeneral.xlinefile  = XPATH;    /* Server xline file         */
460 >  ConfigGeneral.dlinefile  = DLPATH;   /* dline file                */
461 >  ConfigGeneral.resvfile   = RESVPATH; /* resv file                 */
462  
463    myargv = argv;
464 <  umask(077);                /* better safe than sorry --SRB */
464 >  umask(077);  /* umask 077: u=rwx,g=,o= */
465  
466    parseargs(&argc, &argv, myopts);
467  
# Line 512 | Line 471 | main(int argc, char *argv[])
471      exit(EXIT_SUCCESS);
472    }
473  
474 <  if (chdir(ConfigFileEntry.dpath))
474 >  if (chdir(ConfigGeneral.dpath))
475    {
476      perror("chdir");
477      exit(EXIT_FAILURE);
# Line 533 | Line 492 | main(int argc, char *argv[])
492    /* We need this to initialise the fd array before anything else */
493    fdlist_init();
494    log_set_file(LOG_TYPE_IRCD, 0, logFileName);
495 <  check_can_use_v6();
495 >
496    init_netio();         /* This needs to be setup early ! -- adrian */
497  
498    /* Check if there is pidfile and daemon already running */
# Line 541 | Line 500 | main(int argc, char *argv[])
500  
501    mp_pool_init();
502    init_dlink_nodes();
503 <  init_isupport();
503 >  isupport_init();
504    dbuf_init();
505    hash_init();
506 <  init_ip_hash_table();      /* client host ip hash table */
507 <  init_host_hash();          /* Host-hashtable. */
506 >  userhost_init();
507 >  ipcache_init();
508    client_init();
509    class_init();
510    whowas_init();
# Line 554 | Line 513 | main(int argc, char *argv[])
513    init_resolver();      /* Needs to be setup before the io loop */
514    modules_init();
515    read_conf_files(1);   /* cold start init conf files */
557  init_uid();
516    initialize_server_capabs();   /* Set up default_server_capabs */
517 <  initialize_global_set_options();
517 >  initialize_global_set_options();  /* Has to be called after read_conf_files() */
518    channel_init();
519    read_links_file();
520    motd_init();
521 +  user_modes_init();
522   #ifdef HAVE_LIBGEOIP
523    geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
524   #endif
525  
526 <  if (EmptyString(ServerInfo.sid))
526 >  if (EmptyString(ConfigServerInfo.name))
527    {
528 <    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
528 >    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
529      exit(EXIT_FAILURE);
530    }
531  
532 <  strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
532 >  strlcpy(me.name, ConfigServerInfo.name, sizeof(me.name));
533  
534 <  if (EmptyString(ServerInfo.name))
534 >  /* serverinfo{} description must exist.  If not, error out.*/
535 >  if (EmptyString(ConfigServerInfo.description))
536    {
537 <    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
537 >    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
538      exit(EXIT_FAILURE);
539    }
540  
541 <  strlcpy(me.name, ServerInfo.name, sizeof(me.name));
541 >  strlcpy(me.info, ConfigServerInfo.description, sizeof(me.info));
542  
543 <  /* serverinfo{} description must exist.  If not, error out.*/
584 <  if (EmptyString(ServerInfo.description))
543 >  if (EmptyString(ConfigServerInfo.sid))
544    {
545 <    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
546 <    exit(EXIT_FAILURE);
545 >    ilog(LOG_TYPE_IRCD, "Generating server ID");
546 >    generate_sid();
547    }
548 +  else
549 +    strlcpy(me.id, ConfigServerInfo.sid, sizeof(me.id));
550  
551 <  strlcpy(me.info, ServerInfo.description, sizeof(me.info));
551 >  init_uid();
552  
553 <  me.from                   = &me;
554 <  me.servptr                = &me;
555 <  me.localClient->lasttime  = CurrentTime;
556 <  me.localClient->since     = CurrentTime;
557 <  me.localClient->firsttime = CurrentTime;
553 >  me.from = &me;
554 >  me.servptr = &me;
555 >  me.connection->lasttime = CurrentTime;
556 >  me.connection->since = CurrentTime;
557 >  me.connection->firsttime = CurrentTime;
558  
559    SetMe(&me);
560    make_server(&me);
# Line 601 | Line 562 | main(int argc, char *argv[])
562    hash_add_id(&me);
563    hash_add_client(&me);
564  
565 <  /* add ourselves to global_serv_list */
566 <  dlinkAdd(&me, make_dlink_node(), &global_serv_list);
565 >  dlinkAdd(&me, make_dlink_node(), &global_server_list);
566 >  dlinkAdd(&me, &me.node, &global_client_list);
567  
568    load_kline_database();
569    load_dline_database();
609  load_gline_database();
570    load_xline_database();
571    load_resv_database();
572  
613  if (chdir(MODPATH))
614  {
615    ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
616    exit(EXIT_FAILURE);
617  }
618
573    load_all_modules(1);
574    load_conf_modules();
575    load_core_modules(1);
576  
623  /* Go back to DPATH after checking to see if we can chdir to MODPATH */
624  if (chdir(ConfigFileEntry.dpath))
625  {
626    perror("chdir");
627    exit(EXIT_FAILURE);
628  }
629
630  /*
631   * assemble_umode_buffer() has to be called after
632   * reading conf/loading modules.
633   */
634  assemble_umode_buffer();
635
577    write_pidfile(pidFileName);
578  
638  ilog(LOG_TYPE_IRCD, "Server Ready");
639
640  event_addish(&event_cleanup_glines, NULL);
579    event_addish(&event_cleanup_tklines, NULL);
580  
581    /* We want try_connections to be called as soon as possible now! -- adrian */
# Line 645 | Line 583 | main(int argc, char *argv[])
583    event_addish(&event_try_connections, NULL);
584  
585    /* Setup the timeout check. I'll shift it later :)  -- adrian */
586 <  event_addish(&event_comm_checktimeouts, NULL);
586 >  event_add(&event_comm_checktimeouts, NULL);
587  
588    event_addish(&event_save_all_databases, NULL);
589  
# Line 657 | Line 595 | main(int argc, char *argv[])
595    else
596      ConfigServerHide.links_disabled = 1;
597  
598 <  if (splitmode)
661 <    event_addish(&splitmode_event, NULL);
662 <
598 >  ilog(LOG_TYPE_IRCD, "Server Ready");
599    io_loop();
600 +
601    return 0;
602   }

Diff Legend

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