]> jfr.im git - solanum.git/blame - ircd/ircd.c
ircd: _WIN32 checks on geteuid() too
[solanum.git] / ircd / ircd.c
CommitLineData
212380e3 1/*
6fce54ff 2 * charybdis: A slightly useful ircd.
212380e3
AC
3 * ircd.c: Starts up and runs the ircd.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
6fce54ff 7 * Copyright (C) 2002-2008 ircd-ratbox development team
adef4da1 8 * Copyright (C) 2005-2013 charybdis development team
212380e3
AC
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
212380e3
AC
24 */
25
fe037171 26#include "rb_lib.h"
212380e3
AC
27#include "stdinc.h"
28#include "setup.h"
9b8e9eb3 29#include "defaults.h"
212380e3
AC
30#include "ircd.h"
31#include "channel.h"
32#include "class.h"
33#include "client.h"
34#include "common.h"
212380e3 35#include "hash.h"
4562c604 36#include "match.h"
212380e3 37#include "ircd_signal.h"
212380e3
AC
38#include "msg.h" /* msgtab */
39#include "hostmask.h"
40#include "numeric.h"
41#include "parse.h"
212380e3
AC
42#include "restart.h"
43#include "s_auth.h"
212380e3 44#include "s_conf.h"
4016731b 45#include "logger.h"
212380e3
AC
46#include "s_serv.h" /* try_connections */
47#include "s_user.h"
48#include "s_stats.h"
49#include "scache.h"
50#include "send.h"
51#include "supported.h"
52#include "whowas.h"
53#include "modules.h"
212380e3
AC
54#include "hook.h"
55#include "ircd_getopt.h"
212380e3 56#include "newconf.h"
212380e3
AC
57#include "reject.h"
58#include "s_conf.h"
59#include "s_newconf.h"
60#include "cache.h"
61#include "monitor.h"
212380e3
AC
62#include "patchlevel.h"
63#include "serno.h"
c6d72037 64#include "sslproc.h"
efccc22c 65#include "chmode.h"
39a68b53 66#include "privilege.h"
6eebc373 67#include "bandbi.h"
6d063f05 68#include "authd.h"
b02a913b 69#include "operhash.h"
212380e3 70
8bd5767b 71/* /quote set variables */
2af8c7ff 72struct SetOptions GlobalSetOptions;
8bd5767b
JT
73
74/* configuration set from ircd.conf */
75struct config_file_entry ConfigFileEntry;
76/* server info set from ircd.conf */
77struct server_info ServerInfo;
78/* admin info set from ircd.conf */
1aad9782
VY
79struct admin_info AdminInfo;
80
8bd5767b 81struct Counter Count;
47adde3d
VY
82struct ServerStatistics ServerStats;
83
1aad9782 84int maxconnections;
8bd5767b 85struct Client me; /* That's me */
1aad9782
VY
86struct LocalUser meLocalUser; /* That's also part of me */
87
3d3d1a95 88rb_dlink_list global_client_list;
8bd5767b 89
3d3d1a95 90/* unknown/client pointer lists */
8bd5767b 91rb_dlink_list unknown_list; /* unknown clients ON this server only */
3d3d1a95 92rb_dlink_list lclient_list; /* local clients only ON this server */
8bd5767b
JT
93rb_dlink_list serv_list; /* local servers to this server ONLY */
94rb_dlink_list global_serv_list; /* global servers on the network */
95rb_dlink_list local_oper_list; /* our opers, duplicated in lclient_list */
b5b84cad
VY
96rb_dlink_list oper_list; /* network opers */
97
8bd5767b 98const char *logFileName = LPATH;
b5b84cad
VY
99const char *pidFileName = PPATH;
100
1aad9782 101char **myargv;
1b916de5
EM
102bool dorehash = false;
103bool dorehashbans = false;
104bool doremotd = false;
f66f0baa 105bool kline_queued = false;
503727d1
EM
106bool server_state_foreground = false;
107bool opers_see_all_users = false;
bfc44622
AC
108bool ircd_ssl_ok = false;
109bool ircd_zlib_ok = true;
8bd5767b
JT
110
111int testing_conf = 0;
cd27d99c 112time_t startup_time;
8bd5767b 113
346fba92 114int default_server_capabs;
8bd5767b 115
cd27d99c
VY
116int splitmode;
117int splitchecking;
118int split_users;
119int split_servers;
120int eob_count;
c6d72037 121
fd5af3d0
VY
122void
123ircd_shutdown(const char *reason)
124{
125 struct Client *target_p;
126 rb_dlink_node *ptr;
127
128 RB_DLINK_FOREACH(ptr, lclient_list.head)
129 {
130 target_p = ptr->data;
131
132 sendto_one(target_p, ":%s NOTICE %s :Server Terminating. %s",
133 me.name, target_p->name, reason);
134 }
135
136 RB_DLINK_FOREACH(ptr, serv_list.head)
137 {
138 target_p = ptr->data;
139
140 sendto_one(target_p, ":%s ERROR :Terminated by %s",
141 me.name, reason);
142 }
143
144 ilog(L_MAIN, "Server Terminating. %s", reason);
ea82a3ca 145 close_logfiles();
fd5af3d0
VY
146
147 unlink(pidFileName);
148 exit(0);
149}
150
212380e3
AC
151/*
152 * print_startup - print startup information
153 */
154static void
155print_startup(int pid)
156{
b45b2dae
JT
157 int fd;
158
159 close(1);
160 fd = open("/dev/null", O_RDWR);
161 if (fd == -1) {
162 perror("open /dev/null");
163 exit(EXIT_FAILURE);
164 }
165 if (fd == 0)
166 fd = dup(fd);
167 if (fd != 1)
168 abort();
169
212380e3
AC
170 inotice("now running in %s mode from %s as pid %d ...",
171 !server_state_foreground ? "background" : "foreground",
172 ConfigFileEntry.dpath, pid);
173
174 /* let the parent process know the initialization was successful
175 * -- jilles */
176 if (!server_state_foreground)
c084fcaf
EM
177 {
178 if(write(0, ".", 1) < 1)
179 /* The circumstances in which this could fail are pretty implausible.
180 * However, this shuts GCC up about warning the result of write is unused,
181 * and is "standards compliant" behaviour.
182 * --Elizabeth
183 */
184 abort();
185 }
b45b2dae
JT
186 if (dup2(1, 0) == -1)
187 abort();
188 if (dup2(1, 2) == -1)
189 abort();
212380e3
AC
190}
191
212380e3
AC
192/*
193 * init_sys
194 *
195 * inputs - boot_daemon flag
196 * output - none
197 * side effects - if boot_daemon flag is not set, don't daemonize
198 */
199static void
200init_sys(void)
201{
8bd5767b
JT
202#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
203 struct rlimit limit;
204
205 if(!getrlimit(RLIMIT_NOFILE, &limit))
206 {
207 maxconnections = limit.rlim_cur;
208 if(maxconnections <= MAX_BUFFER)
209 {
210 fprintf(stderr, "ERROR: Shell FD limits are too low.\n");
ec86417c 211 fprintf(stderr, "ERROR: charybdis reserves %d FDs, shell limits must be above this\n", MAX_BUFFER);
8bd5767b
JT
212 exit(EXIT_FAILURE);
213 }
214 return;
215 }
216#endif /* RLIMIT_FD_MAX */
101db4c4 217 maxconnections = MAXCONNECTIONS;
212380e3
AC
218}
219
220static int
221make_daemon(void)
222{
538d2089 223#ifndef _WIN32
212380e3
AC
224 int pid;
225 int pip[2];
226 char c;
227
228 if (pipe(pip) < 0)
229 {
230 perror("pipe");
231 exit(EXIT_FAILURE);
232 }
233 dup2(pip[1], 0);
234 close(pip[1]);
235 if((pid = fork()) < 0)
236 {
237 perror("fork");
238 exit(EXIT_FAILURE);
239 }
240 else if(pid > 0)
241 {
242 close(0);
243 /* Wait for initialization to finish, successfully or
244 * unsuccessfully. Until this point the child may still
245 * write to stdout/stderr.
246 * -- jilles */
247 if (read(pip[0], &c, 1) > 0)
248 exit(EXIT_SUCCESS);
249 else
250 exit(EXIT_FAILURE);
251 }
252
253 close(pip[0]);
254 setsid();
255/* fclose(stdin);
256 fclose(stdout);
257 fclose(stderr); */
538d2089 258#endif
212380e3
AC
259 return 0;
260}
261
262static int printVersion = 0;
263
264struct lgetopt myopts[] = {
212380e3
AC
265 {"configfile", &ConfigFileEntry.configfile,
266 STRING, "File to use for ircd.conf"},
212380e3
AC
267 {"logfile", &logFileName,
268 STRING, "File to use for ircd.log"},
269 {"pidfile", &pidFileName,
270 STRING, "File to use for process ID"},
271 {"foreground", &server_state_foreground,
272 YESNO, "Run in foreground (don't detach)"},
273 {"version", &printVersion,
274 YESNO, "Print version and exit"},
275 {"conftest", &testing_conf,
276 YESNO, "Test the configuration files and exit"},
277 {"help", NULL, USAGE, "Print this text"},
278 {NULL, NULL, STRING, NULL},
279};
280
212380e3
AC
281static void
282check_rehash(void *unused)
283{
284 /*
285 * Check to see whether we have to rehash the configuration ..
286 */
287 if(dorehash)
288 {
289 rehash(1);
1b916de5 290 dorehash = false;
212380e3
AC
291 }
292
293 if(dorehashbans)
294 {
295 rehash_bans(1);
1b916de5 296 dorehashbans = false;
212380e3
AC
297 }
298
299 if(doremotd)
300 {
301 sendto_realops_snomask(SNO_GENERAL, L_ALL,
302 "Got signal SIGUSR1, reloading ircd motd file");
041d54ff 303 cache_user_motd();
1b916de5 304 doremotd = false;
212380e3
AC
305 }
306}
307
212380e3
AC
308/*
309 * initalialize_global_set_options
310 *
311 * inputs - none
312 * output - none
55abcbb2 313 * side effects - This sets all global set options needed
212380e3
AC
314 */
315static void
316initialize_global_set_options(void)
317{
318 memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
319 /* memset( &ConfigFileEntry, 0, sizeof(ConfigFileEntry)); */
320
8bd5767b
JT
321 GlobalSetOptions.maxclients = ServerInfo.default_max_clients;
322
323 if(GlobalSetOptions.maxclients > (maxconnections - MAX_BUFFER) || (GlobalSetOptions.maxclients <= 0))
101db4c4
VY
324 GlobalSetOptions.maxclients = maxconnections - MAX_BUFFER;
325
212380e3
AC
326 GlobalSetOptions.autoconn = 1;
327
328 GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
329 GlobalSetOptions.spam_num = MAX_JOIN_LEAVE_COUNT;
330
7f3382fe 331 GlobalSetOptions.floodcount = ConfigFileEntry.default_floodcount;
212380e3
AC
332
333 split_servers = ConfigChannel.default_split_server_count;
334 split_users = ConfigChannel.default_split_user_count;
335
336 if(split_users && split_servers
337 && (ConfigChannel.no_create_on_split || ConfigChannel.no_join_on_split))
338 {
339 splitmode = 1;
340 splitchecking = 1;
341 }
342
7f3382fe 343 GlobalSetOptions.ident_timeout = ConfigFileEntry.default_ident_timeout;
212380e3 344
f427c8b0 345 rb_strlcpy(GlobalSetOptions.operstring,
212380e3
AC
346 ConfigFileEntry.default_operstring,
347 sizeof(GlobalSetOptions.operstring));
f427c8b0 348 rb_strlcpy(GlobalSetOptions.adminstring,
212380e3
AC
349 ConfigFileEntry.default_adminstring,
350 sizeof(GlobalSetOptions.adminstring));
351
352 /* memset( &ConfigChannel, 0, sizeof(ConfigChannel)); */
353
354 /* End of global set options */
355
356}
357
358/*
359 * initialize_server_capabs
360 *
361 * inputs - none
362 * output - none
363 */
364static void
365initialize_server_capabs(void)
366{
367 default_server_capabs &= ~CAP_ZIP;
368}
369
370
371/*
372 * write_pidfile
373 *
374 * inputs - filename+path of pid file
375 * output - none
376 * side effects - write the pid of the ircd to filename
377 */
378static void
379write_pidfile(const char *filename)
380{
381 FILE *fb;
382 char buff[32];
383 if((fb = fopen(filename, "w")))
384 {
385 unsigned int pid = (unsigned int) getpid();
386
5203cba5 387 snprintf(buff, sizeof(buff), "%u\n", pid);
212380e3
AC
388 if((fputs(buff, fb) == -1))
389 {
390 ilog(L_MAIN, "Error writing %u to pid file %s (%s)",
391 pid, filename, strerror(errno));
392 }
393 fclose(fb);
394 return;
395 }
396 else
397 {
398 ilog(L_MAIN, "Error opening pid file %s", filename);
399 }
400}
401
402/*
403 * check_pidfile
404 *
405 * inputs - filename+path of pid file
406 * output - none
407 * side effects - reads pid from pidfile and checks if ircd is in process
408 * list. if it is, gracefully exits
409 * -kre
410 */
411static void
412check_pidfile(const char *filename)
413{
414 FILE *fb;
415 char buff[32];
416 pid_t pidfromfile;
417
418 /* Don't do logging here, since we don't have log() initialised */
419 if((fb = fopen(filename, "r")))
420 {
421 if(fgets(buff, 20, fb) != NULL)
422 {
423 pidfromfile = atoi(buff);
538d2089 424 if(!rb_kill(pidfromfile, 0))
212380e3
AC
425 {
426 printf("ircd: daemon is already running\n");
427 exit(-1);
428 }
429 }
430 fclose(fb);
431 }
432}
433
434/*
435 * setup_corefile
436 *
437 * inputs - nothing
438 * output - nothing
439 * side effects - setups corefile to system limits.
440 * -kre
441 */
442static void
443setup_corefile(void)
444{
445#ifdef HAVE_SYS_RESOURCE_H
446 struct rlimit rlim; /* resource limits */
447
448 /* Set corefilesize to maximum */
449 if(!getrlimit(RLIMIT_CORE, &rlim))
450 {
451 rlim.rlim_cur = rlim.rlim_max;
452 setrlimit(RLIMIT_CORE, &rlim);
453 }
454#endif
455}
456
6fce54ff
VY
457static void
458ircd_log_cb(const char *str)
459{
fe037171 460 ilog(L_MAIN, "librb reports: %s", str);
6fce54ff
VY
461}
462
463static void
464ircd_restart_cb(const char *str)
465{
fe037171 466 inotice("librb has called the restart callback: %s", str);
6fce54ff
VY
467 restart(str);
468}
469
470/*
471 * Why EXIT_FAILURE here?
472 * Because if ircd_die_cb() is called it's because of a fatal
473 * error inside libcharybdis, and we don't know how to handle the
474 * exception, so it is logical to return a FAILURE exit code here.
475 * --nenolod
476 */
477static void
478ircd_die_cb(const char *str)
479{
480 if(str != NULL)
481 {
482 /* Try to get the message out to currently logged in operators. */
fe037171
EM
483 sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "librb has called the die callback..aborting: %s", str);
484 inotice("librb has called the die callback..aborting: %s", str);
6fce54ff 485 }
6643434b 486 else
fe037171 487 inotice("librb has called the die callback..aborting");
6fce54ff
VY
488
489 unlink(pidFileName);
490 exit(EXIT_FAILURE);
491}
492
fa832850
AC
493struct ev_entry *check_splitmode_ev = NULL;
494
d80645d0
VY
495static int
496seed_with_urandom(void)
497{
498 unsigned int seed;
499 int fd;
500
501 fd = open("/dev/urandom", O_RDONLY);
502 if(fd >= 0)
503 {
504 if(read(fd, &seed, sizeof(seed)) == sizeof(seed))
505 {
506 close(fd);
507 srand(seed);
508 return 1;
509 }
5457b102 510 close(fd);
d80645d0
VY
511 }
512 return 0;
513}
514
515static void
516seed_with_clock(void)
517{
55abcbb2 518 const struct timeval *tv;
d80645d0
VY
519 rb_set_time();
520 tv = rb_current_time_tv();
521 srand(tv->tv_sec ^ (tv->tv_usec | (getpid() << 20)));
522}
523
524static void
525seed_random(void *unused)
526{
527 unsigned int seed;
528 if(rb_get_random(&seed, sizeof(seed)) == -1)
529 {
530 if(!seed_with_urandom())
531 seed_with_clock();
532 return;
533 }
534 srand(seed);
535}
536
212380e3
AC
537/*
538 * main
539 *
540 * Initializes the IRCd.
541 *
542 * Inputs - number of commandline args, args themselves
543 * Outputs - none
544 * Side Effects - this is where the ircd gets going right now
545 */
546int
bc38c72c 547charybdis_main(int argc, char *argv[])
212380e3
AC
548{
549 int fd;
550
1ba9eba5 551#ifndef _WIN32
212380e3
AC
552 /* Check to see if the user is running us as root, which is a nono */
553 if(geteuid() == 0)
554 {
555 fprintf(stderr, "Don't run ircd as root!!!\n");
556 return -1;
557 }
1ba9eba5 558#endif
212380e3 559
adc7be98
VY
560 init_sys();
561
befa24c8
JT
562 ConfigFileEntry.dpath = DPATH;
563 ConfigFileEntry.configfile = CPATH; /* Server configuration file */
befa24c8 564 ConfigFileEntry.connect_timeout = 30; /* Default to 30 */
346fba92 565
befa24c8 566 umask(077); /* better safe than sorry --SRB */
adc7be98
VY
567
568 myargv = argv;
569 parseargs(&argc, &argv, myopts);
570
571 if(chdir(ConfigFileEntry.dpath))
572 {
573 fprintf(stderr, "Unable to chdir to %s: %s\n", ConfigFileEntry.dpath, strerror(errno));
574 exit(EXIT_FAILURE);
575 }
576
3d3d1a95
VY
577 rb_set_time();
578
212380e3
AC
579 /*
580 * Setup corefile size immediately after boot -kre
581 */
582 setup_corefile();
583
b02a913b
AC
584 /* initialise operhash fairly early. */
585 init_operhash();
586
212380e3
AC
587 memset(&me, 0, sizeof(me));
588 memset(&meLocalUser, 0, sizeof(meLocalUser));
589 me.localClient = &meLocalUser;
590
591 /* Make sure all lists are zeroed */
592 memset(&unknown_list, 0, sizeof(unknown_list));
593 memset(&lclient_list, 0, sizeof(lclient_list));
594 memset(&serv_list, 0, sizeof(serv_list));
595 memset(&global_serv_list, 0, sizeof(global_serv_list));
596 memset(&local_oper_list, 0, sizeof(local_oper_list));
597 memset(&oper_list, 0, sizeof(oper_list));
598
330fc5c1 599 rb_dlinkAddTail(&me, &me.node, &global_client_list);
212380e3 600
2af8c7ff
VY
601 memset(&Count, 0, sizeof(Count));
602 memset(&ServerInfo, 0, sizeof(ServerInfo));
603 memset(&AdminInfo, 0, sizeof(AdminInfo));
604 memset(&ServerStats, 0, sizeof(struct ServerStatistics));
212380e3 605
212380e3
AC
606 if(printVersion)
607 {
b3803848 608 printf("ircd: version %s(%s)\n", ircd_version, serno);
8bd1c8a1
AC
609#ifdef CUSTOM_BRANDING
610 printf("ircd: based on %s-%s\n", PACKAGE_NAME, PACKAGE_VERSION);
611#endif
d2b6b9f3 612 printf("ircd: %s\n", rb_lib_version());
212380e3
AC
613 exit(EXIT_SUCCESS);
614 }
615
212380e3
AC
616 setup_signals();
617
212380e3 618 if (testing_conf)
503727d1 619 server_state_foreground = true;
212380e3
AC
620
621 /* Make sure fd 0, 1 and 2 are in use -- jilles */
622 do
623 {
624 fd = open("/dev/null", O_RDWR);
625 } while (fd < 2 && fd != -1);
626 if (fd > 2)
627 close(fd);
628 else if (fd == -1)
629 exit(1);
630
631 /* Check if there is pidfile and daemon already running */
632 if(!testing_conf)
633 {
634 check_pidfile(pidFileName);
635
636 if(!server_state_foreground)
637 make_daemon();
638 inotice("starting %s ...", ircd_version);
31c86ea8 639 inotice("%s", rb_lib_version());
212380e3
AC
640 }
641
642 /* Init the event subsystem */
0edb29fa 643 rb_lib_init(ircd_log_cb, ircd_restart_cb, ircd_die_cb, !server_state_foreground, maxconnections, DNODE_HEAP_SIZE, FD_HEAP_SIZE);
150f35f7 644 rb_linebuf_init(LINEBUF_HEAP_SIZE);
212380e3 645
e861902f 646 rb_init_prng(NULL, RB_PRNG_DEFAULT);
37cd159e 647
e1db84d8
VY
648 seed_random(NULL);
649
346fba92
AC
650 init_builtin_capabs();
651 default_server_capabs = CAP_MASK;
652
212380e3 653 init_main_logfile();
212380e3
AC
654 newconf_init();
655 init_s_conf();
656 init_s_newconf();
657 init_hash();
658 clear_scache_hash_table(); /* server cache name table */
659 init_host_hash();
660 clear_hash_parse();
661 init_client();
212380e3
AC
662 init_hook();
663 init_channels();
664 initclass();
b47f8a4f 665 whowas_init();
212380e3
AC
666 init_reject();
667 init_cache();
668 init_monitor();
030cdce7 669
19716b9f 670 construct_cflags_strings();
030cdce7 671
212380e3 672 load_all_modules(1);
212380e3 673 load_core_modules(1);
2a19fc3f 674
212380e3 675 init_auth(); /* Initialise the auth code */
6d063f05 676 init_authd(); /* Start up authd. */
068c6c4a 677 init_dns(); /* Start up DNS query system */
8a26cd19 678
39a68b53 679 privilegeset_set_new("default", "", 0);
212380e3
AC
680
681 if (testing_conf)
682 fprintf(stderr, "\nBeginning config test\n");
ea111ea5 683 read_conf_files(true); /* cold start init conf files */
212380e3 684
55abcbb2
KB
685 mod_add_path(MODULE_DIR);
686 mod_add_path(MODULE_DIR "/autoload");
212380e3 687
b583faf9
AC
688 init_isupport();
689
6eebc373 690 init_bandb();
c6d72037
VY
691 init_ssld();
692
80c9ac51
AC
693 rehash_bans(0);
694
212380e3
AC
695 initialize_server_capabs(); /* Set up default_server_capabs */
696 initialize_global_set_options();
697
698 if(ServerInfo.name == NULL)
699 {
700 ierror("no server name specified in serverinfo block.");
701 return -1;
702 }
f427c8b0 703 rb_strlcpy(me.name, ServerInfo.name, sizeof(me.name));
212380e3
AC
704
705 if(ServerInfo.sid[0] == '\0')
706 {
707 ierror("no server sid specified in serverinfo block.");
708 return -2;
709 }
710 strcpy(me.id, ServerInfo.sid);
711 init_uid();
712
713 /* serverinfo{} description must exist. If not, error out. */
714 if(ServerInfo.description == NULL)
715 {
716 ierror("no server description specified in serverinfo block.");
717 return -3;
718 }
f427c8b0 719 rb_strlcpy(me.info, ServerInfo.description, sizeof(me.info));
212380e3 720
8bd5767b
JT
721 if(ServerInfo.ssl_cert != NULL && ServerInfo.ssl_private_key != NULL)
722 {
723 /* just do the rb_setup_ssl_server to validate the config */
c1725bda 724 if(!rb_setup_ssl_server(ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list))
8bd5767b
JT
725 {
726 ilog(L_MAIN, "WARNING: Unable to setup SSL.");
bfc44622 727 ircd_ssl_ok = false;
8bd5767b
JT
728 }
729 else
bfc44622 730 ircd_ssl_ok = true;
c6d72037
VY
731 }
732
212380e3
AC
733 if (testing_conf)
734 {
735 fprintf(stderr, "\nConfig testing complete.\n");
736 fflush(stderr);
737 return 0; /* Why? We want the launcher to exit out. */
738 }
739
740 me.from = &me;
741 me.servptr = &me;
742 SetMe(&me);
743 make_server(&me);
e3354945 744 startup_time = rb_current_time();
212380e3
AC
745 add_to_client_hash(me.name, &me);
746 add_to_id_hash(me.id, &me);
994544c2 747 me.serv->nameinfo = scache_connect(me.name, me.info, 0);
212380e3 748
330fc5c1 749 rb_dlinkAddAlloc(&me, &global_serv_list);
212380e3
AC
750
751 construct_umodebuf();
752
753 check_class();
754 write_pidfile(pidFileName);
755 load_help();
756 open_logfiles();
757
758 ilog(L_MAIN, "Server Ready");
759
212380e3
AC
760 /* We want try_connections to be called as soon as possible now! -- adrian */
761 /* No, 'cause after a restart it would cause all sorts of nick collides */
762 /* um. by waiting even longer, that just means we have even *more*
763 * nick collisions. what a stupid idea. set an event for the IO loop --fl
764 */
12aea5fe 765 rb_event_addish("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
36645728
VY
766 rb_event_addonce("try_connections_startup", try_connections, NULL, 2);
767 rb_event_add("check_rehash", check_rehash, NULL, 3);
d80645d0 768 rb_event_addish("reseed_srand", seed_random, NULL, 300); /* reseed every 10 minutes */
212380e3 769
212380e3 770 if(splitmode)
36645728 771 check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 5);
212380e3 772
212380e3
AC
773 print_startup(getpid());
774
39944e1f 775 rb_lib_loop(0);
212380e3
AC
776
777 return 0;
778}