| 24 |
|
|
| 25 |
|
#include "stdinc.h" |
| 26 |
|
#include "s_user.h" |
| 27 |
< |
#include "tools.h" |
| 27 |
> |
#include "list.h" |
| 28 |
|
#include "ircd.h" |
| 29 |
|
#include "channel.h" |
| 30 |
|
#include "channel_mode.h" |
| 36 |
|
#include "irc_string.h" |
| 37 |
|
#include "sprintf_irc.h" |
| 38 |
|
#include "ircd_signal.h" |
| 39 |
– |
#include "list.h" |
| 39 |
|
#include "s_gline.h" |
| 40 |
|
#include "motd.h" |
| 41 |
|
#include "ircd_handler.h" |
| 46 |
|
#include "parse.h" |
| 47 |
|
#include "irc_res.h" |
| 48 |
|
#include "restart.h" |
| 49 |
+ |
#include "rng_mt.h" |
| 50 |
|
#include "s_auth.h" |
| 51 |
|
#include "s_bsd.h" |
| 52 |
|
#include "s_conf.h" |
| 85 |
|
struct Client me; /* That's me */ |
| 86 |
|
struct LocalUser meLocalUser; /* That's also part of me */ |
| 87 |
|
|
| 88 |
– |
static unsigned long initialVMTop = 0; /* top of virtual memory at init */ |
| 88 |
|
const char *logFileName = LPATH; |
| 89 |
|
const char *pidFileName = PPATH; |
| 90 |
|
|
| 93 |
|
|
| 94 |
|
int dorehash = 0; |
| 95 |
|
int doremotd = 0; |
| 97 |
– |
time_t nextconnect = 1; /* time for next try_connections call */ |
| 96 |
|
|
| 97 |
|
/* Set to zero because it should be initialized later using |
| 98 |
|
* initialize_server_capabs |
| 103 |
|
int bio_spare_fd = -1; |
| 104 |
|
#endif |
| 105 |
|
|
| 106 |
< |
int splitmode; |
| 107 |
< |
int splitchecking; |
| 108 |
< |
int split_users; |
| 106 |
> |
unsigned int splitmode; |
| 107 |
> |
unsigned int splitchecking; |
| 108 |
> |
unsigned int split_users; |
| 109 |
|
unsigned int split_servers; |
| 110 |
|
|
| 111 |
|
/* Do klines the same way hybrid-6 did them, i.e. at the |
| 121 |
|
int rehashed_klines = 0; |
| 122 |
|
|
| 123 |
|
|
| 126 |
– |
#ifndef _WIN32 |
| 124 |
|
/* |
| 125 |
|
* print_startup - print startup information |
| 126 |
|
*/ |
| 151 |
|
|
| 152 |
|
setsid(); |
| 153 |
|
} |
| 157 |
– |
#endif |
| 154 |
|
|
| 155 |
|
static int printVersion = 0; |
| 156 |
|
|
| 180 |
|
{ |
| 181 |
|
static char to_send[200]; |
| 182 |
|
struct timeval newtime; |
| 187 |
– |
#ifdef _WIN32 |
| 188 |
– |
FILETIME ft; |
| 189 |
– |
|
| 190 |
– |
GetSystemTimeAsFileTime(&ft); |
| 191 |
– |
if (ft.dwLowDateTime < 0xd53e8000) |
| 192 |
– |
ft.dwHighDateTime--; |
| 193 |
– |
ft.dwLowDateTime -= 0xd53e8000; |
| 194 |
– |
ft.dwHighDateTime -= 0x19db1de; |
| 195 |
– |
|
| 196 |
– |
newtime.tv_sec = (*(uint64_t *) &ft) / 10000000; |
| 197 |
– |
newtime.tv_usec = (*(uint64_t *) &ft) / 10 % 1000000; |
| 198 |
– |
#else |
| 183 |
|
newtime.tv_sec = 0; |
| 184 |
|
newtime.tv_usec = 0; |
| 185 |
|
|
| 192 |
|
strerror(errno)); |
| 193 |
|
restart("Clock Failure"); |
| 194 |
|
} |
| 211 |
– |
#endif |
| 195 |
|
|
| 196 |
|
if (newtime.tv_sec < CurrentTime) |
| 197 |
|
{ |
| 331 |
|
{ |
| 332 |
|
add_capability("QS", CAP_QS, 1); |
| 333 |
|
add_capability("EOB", CAP_EOB, 1); |
| 334 |
< |
|
| 352 |
< |
if (ServerInfo.sid != NULL) /* only enable TS6 if we have an SID */ |
| 353 |
< |
add_capability("TS6", CAP_TS6, 0); |
| 354 |
< |
|
| 334 |
> |
add_capability("TS6", CAP_TS6, 0); |
| 335 |
|
add_capability("ZIP", CAP_ZIP, 0); |
| 336 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
| 337 |
|
#ifdef HALFOPS |
| 380 |
|
static void |
| 381 |
|
check_pidfile(const char *filename) |
| 382 |
|
{ |
| 403 |
– |
#ifndef _WIN32 |
| 383 |
|
FBFILE *fb; |
| 384 |
|
char buff[32]; |
| 385 |
|
pid_t pidfromfile; |
| 411 |
|
{ |
| 412 |
|
/* log(L_ERROR, "Error opening pid file %s", filename); */ |
| 413 |
|
} |
| 435 |
– |
#endif |
| 414 |
|
} |
| 415 |
|
|
| 416 |
|
/* setup_corefile() |
| 486 |
|
/* Check to see if the user is running |
| 487 |
|
* us as root, which is a nono |
| 488 |
|
*/ |
| 511 |
– |
#ifndef _WIN32 |
| 489 |
|
if (geteuid() == 0) |
| 490 |
|
{ |
| 491 |
|
fprintf(stderr, "Don't run ircd as root!!!\n"); |
| 492 |
< |
return(-1); |
| 492 |
> |
return -1; |
| 493 |
|
} |
| 494 |
|
|
| 495 |
|
/* Setup corefile size immediately after boot -kre */ |
| 496 |
|
setup_corefile(); |
| 520 |
– |
#endif |
| 497 |
|
|
| 498 |
|
/* save server boot time right away, so getrusage works correctly */ |
| 499 |
|
set_time(); |
| 500 |
|
|
| 501 |
< |
/* It ain't random, but it ought to be a little harder to guess */ |
| 502 |
< |
srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); |
| 501 |
> |
/* It ain't random, but it ought to be a little harder to guess */ |
| 502 |
> |
init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); |
| 503 |
> |
|
| 504 |
|
memset(&me, 0, sizeof(me)); |
| 505 |
|
memset(&meLocalUser, 0, sizeof(meLocalUser)); |
| 506 |
|
me.localClient = &meLocalUser; |
| 542 |
|
|
| 543 |
|
init_ssl(); |
| 544 |
|
|
| 568 |
– |
#ifndef _WIN32 |
| 545 |
|
if (!server_state.foreground) |
| 546 |
|
{ |
| 547 |
|
make_daemon(); |
| 551 |
|
print_startup(getpid()); |
| 552 |
|
|
| 553 |
|
setup_signals(); |
| 578 |
– |
#endif |
| 554 |
|
|
| 555 |
|
get_ircd_platform(ircd_platform); |
| 556 |
|
|
| 564 |
|
/* Check if there is pidfile and daemon already running */ |
| 565 |
|
check_pidfile(pidFileName); |
| 566 |
|
|
| 592 |
– |
#ifndef NOBALLOC |
| 567 |
|
initBlockHeap(); |
| 594 |
– |
#endif |
| 568 |
|
init_dlink_nodes(); |
| 569 |
|
init_callbacks(); |
| 570 |
|
initialize_message_files(); |
| 577 |
|
init_class(); |
| 578 |
|
init_whowas(); |
| 579 |
|
watch_init(); |
| 607 |
– |
read_conf_files(1); /* cold start init conf files */ |
| 608 |
– |
me.id[0] = '\0'; |
| 609 |
– |
init_uid(); |
| 580 |
|
init_auth(); /* Initialise the auth code */ |
| 611 |
– |
#ifndef _WIN32 |
| 581 |
|
init_resolver(); /* Needs to be setup before the io loop */ |
| 582 |
< |
#endif |
| 582 |
> |
read_conf_files(1); /* cold start init conf files */ |
| 583 |
> |
init_uid(); |
| 584 |
|
initialize_server_capabs(); /* Set up default_server_capabs */ |
| 585 |
|
initialize_global_set_options(); |
| 586 |
|
init_channels(); |
| 587 |
|
|
| 588 |
< |
if (ServerInfo.name == NULL) |
| 588 |
> |
if (EmptyString(ServerInfo.sid)) |
| 589 |
> |
{ |
| 590 |
> |
ilog(L_CRIT, "ERROR: No server id specified in serverinfo block."); |
| 591 |
> |
exit(EXIT_FAILURE); |
| 592 |
> |
} |
| 593 |
> |
|
| 594 |
> |
strlcpy(me.id, ServerInfo.sid, sizeof(me.id)); |
| 595 |
> |
|
| 596 |
> |
if (EmptyString(ServerInfo.name)) |
| 597 |
|
{ |
| 598 |
< |
ilog(L_CRIT, "No server name specified in serverinfo block."); |
| 598 |
> |
ilog(L_CRIT, "ERROR: No server name specified in serverinfo block."); |
| 599 |
|
exit(EXIT_FAILURE); |
| 600 |
|
} |
| 601 |
|
|
| 602 |
|
strlcpy(me.name, ServerInfo.name, sizeof(me.name)); |
| 603 |
|
|
| 604 |
|
/* serverinfo{} description must exist. If not, error out.*/ |
| 605 |
< |
if (ServerInfo.description == NULL) |
| 605 |
> |
if (EmptyString(ServerInfo.description)) |
| 606 |
|
{ |
| 607 |
< |
ilog(L_CRIT, |
| 630 |
< |
"ERROR: No server description specified in serverinfo block."); |
| 607 |
> |
ilog(L_CRIT, "ERROR: No server description specified in serverinfo block."); |
| 608 |
|
exit(EXIT_FAILURE); |
| 609 |
|
} |
| 610 |
|
|
| 617 |
|
make_server(&me); |
| 618 |
|
|
| 619 |
|
me.lasttime = me.since = me.firsttime = CurrentTime; |
| 620 |
+ |
|
| 621 |
+ |
hash_add_id(&me); |
| 622 |
|
hash_add_client(&me); |
| 623 |
|
|
| 624 |
|
/* add ourselves to global_serv_list */ |
| 625 |
|
dlinkAdd(&me, make_dlink_node(), &global_serv_list); |
| 626 |
|
|
| 648 |
– |
check_class(); |
| 649 |
– |
|
| 627 |
|
#ifndef STATIC_MODULES |
| 628 |
|
if (chdir(MODPATH)) |
| 629 |
|
{ |
| 630 |
< |
ilog (L_CRIT, "Could not load core modules. Terminating!"); |
| 630 |
> |
ilog(L_CRIT, "Could not load core modules. Terminating!"); |
| 631 |
|
exit(EXIT_FAILURE); |
| 632 |
|
} |
| 633 |
|
|
| 634 |
|
load_all_modules(1); |
| 635 |
|
load_conf_modules(); |
| 636 |
|
load_core_modules(1); |
| 637 |
+ |
|
| 638 |
|
/* Go back to DPATH after checking to see if we can chdir to MODPATH */ |
| 639 |
< |
chdir(ConfigFileEntry.dpath); |
| 639 |
> |
if (chdir(ConfigFileEntry.dpath)) |
| 640 |
> |
{ |
| 641 |
> |
perror("chdir"); |
| 642 |
> |
exit(EXIT_FAILURE); |
| 643 |
> |
} |
| 644 |
|
#else |
| 645 |
|
load_all_modules(1); |
| 646 |
|
#endif |