| 1 |
|
/* |
| 2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
< |
* ircd.c: Starts up and runs the ircd. |
| 2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
* |
| 4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
| 4 |
> |
* Copyright (c) 1997-2014 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 |
| 17 |
|
* along with this program; if not, write to the Free Software |
| 18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 19 |
|
* USA |
| 20 |
< |
* |
| 21 |
< |
* $Id$ |
| 20 |
> |
*/ |
| 21 |
> |
|
| 22 |
> |
/*! \file ircd.c |
| 23 |
> |
* \brief Starts up and runs the ircd. |
| 24 |
> |
* \version $Id$ |
| 25 |
|
*/ |
| 26 |
|
|
| 27 |
|
#include "stdinc.h" |
| 28 |
< |
#include "s_user.h" |
| 28 |
> |
#include "user.h" |
| 29 |
|
#include "list.h" |
| 30 |
|
#include "ircd.h" |
| 31 |
|
#include "channel.h" |
| 30 |
– |
#include "channel_mode.h" |
| 32 |
|
#include "client.h" |
| 33 |
|
#include "event.h" |
| 34 |
|
#include "fdlist.h" |
| 35 |
|
#include "hash.h" |
| 36 |
|
#include "irc_string.h" |
| 37 |
|
#include "ircd_signal.h" |
| 38 |
< |
#include "s_gline.h" |
| 38 |
> |
#include "gline.h" |
| 39 |
|
#include "motd.h" |
| 40 |
+ |
#include "conf.h" |
| 41 |
|
#include "hostmask.h" |
| 40 |
– |
#include "numeric.h" |
| 41 |
– |
#include "packet.h" |
| 42 |
|
#include "parse.h" |
| 43 |
< |
#include "irc_res.h" |
| 43 |
> |
#include "res.h" |
| 44 |
|
#include "restart.h" |
| 45 |
|
#include "rng_mt.h" |
| 46 |
< |
#include "s_auth.h" |
| 46 |
> |
#include "auth.h" |
| 47 |
|
#include "s_bsd.h" |
| 48 |
– |
#include "conf.h" |
| 48 |
|
#include "log.h" |
| 49 |
< |
#include "s_misc.h" |
| 51 |
< |
#include "s_serv.h" /* try_connections */ |
| 49 |
> |
#include "server.h" /* try_connections */ |
| 50 |
|
#include "send.h" |
| 51 |
|
#include "whowas.h" |
| 52 |
|
#include "modules.h" |
| 53 |
|
#include "memory.h" |
| 54 |
< |
#include "hook.h" |
| 54 |
> |
#include "mempool.h" |
| 55 |
|
#include "ircd_getopt.h" |
| 58 |
– |
#include "balloc.h" |
| 59 |
– |
#include "motd.h" |
| 60 |
– |
#include "supported.h" |
| 56 |
|
#include "watch.h" |
| 57 |
+ |
#include "conf_db.h" |
| 58 |
+ |
#include "conf_class.h" |
| 59 |
|
|
| 60 |
|
|
| 61 |
< |
/* /quote set variables */ |
| 62 |
< |
struct SetOptions GlobalSetOptions; |
| 61 |
> |
#ifdef HAVE_LIBGEOIP |
| 62 |
> |
GeoIP *geoip_ctx; |
| 63 |
> |
#endif |
| 64 |
|
|
| 67 |
– |
/* configuration set from ircd.conf */ |
| 68 |
– |
struct config_file_entry ConfigFileEntry; |
| 69 |
– |
/* server info set from ircd.conf */ |
| 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, 0, 0 }; |
| 74 |
– |
struct ServerState_t server_state = { 0 }; |
| 75 |
– |
struct logging_entry ConfigLoggingEntry = { .use_logging = 1 }; |
| 65 |
|
struct ServerStatistics ServerStats; |
| 66 |
|
struct timeval SystemTime; |
| 67 |
|
struct Client me; /* That's me */ |
| 71 |
|
const char *pidFileName = PPATH; |
| 72 |
|
|
| 73 |
|
char **myargv; |
| 85 |
– |
char ircd_platform[PLATFORMLEN]; |
| 74 |
|
|
| 75 |
|
int dorehash = 0; |
| 76 |
|
int doremotd = 0; |
| 78 |
|
/* Set to zero because it should be initialized later using |
| 79 |
|
* initialize_server_capabs |
| 80 |
|
*/ |
| 81 |
< |
int default_server_capabs = 0; |
| 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 |
< |
/* Do klines the same way hybrid-6 did them, i.e. at the |
| 88 |
< |
* top of the next io_loop instead of in the same loop as |
| 89 |
< |
* the klines are being applied. |
| 90 |
< |
* |
| 91 |
< |
* This should fix strange CPU starvation as very indirectly reported. |
| 92 |
< |
* (Why do you people not email bug reports? WHY? WHY?) |
| 93 |
< |
* |
| 94 |
< |
* - Dianora |
| 95 |
< |
*/ |
| 87 |
> |
static struct event event_cleanup_glines = |
| 88 |
> |
{ |
| 89 |
> |
.name = "cleanup_glines", |
| 90 |
> |
.handler = cleanup_glines, |
| 91 |
> |
.when = CLEANUP_GLINES_TIME |
| 92 |
> |
}; |
| 93 |
> |
|
| 94 |
> |
static struct event event_cleanup_tklines = |
| 95 |
> |
{ |
| 96 |
> |
.name = "cleanup_tklines", |
| 97 |
> |
.handler = cleanup_tklines, |
| 98 |
> |
.when = CLEANUP_TKLINES_TIME |
| 99 |
> |
}; |
| 100 |
> |
|
| 101 |
> |
static struct event event_try_connections = |
| 102 |
> |
{ |
| 103 |
> |
.name = "try_connections", |
| 104 |
> |
.handler = try_connections, |
| 105 |
> |
.when = STARTUP_CONNECTIONS_TIME |
| 106 |
> |
}; |
| 107 |
> |
|
| 108 |
> |
static struct event event_comm_checktimeouts = |
| 109 |
> |
{ |
| 110 |
> |
.name = "comm_checktimeouts", |
| 111 |
> |
.handler = comm_checktimeouts, |
| 112 |
> |
.when = 1 |
| 113 |
> |
}; |
| 114 |
|
|
| 115 |
< |
int rehashed_klines = 0; |
| 115 |
> |
static struct event event_save_all_databases = |
| 116 |
> |
{ |
| 117 |
> |
.name = "save_all_databases", |
| 118 |
> |
.handler = save_all_databases, |
| 119 |
> |
.when = DATABASE_UPDATE_TIMEOUT |
| 120 |
> |
}; |
| 121 |
> |
|
| 122 |
> |
struct event event_write_links_file = |
| 123 |
> |
{ |
| 124 |
> |
.name = "write_links_file", |
| 125 |
> |
.handler = write_links_file, |
| 126 |
> |
}; |
| 127 |
|
|
| 128 |
+ |
struct event event_check_splitmode = |
| 129 |
+ |
{ |
| 130 |
+ |
.name = "check_splitmode", |
| 131 |
+ |
.handler = check_splitmode, |
| 132 |
+ |
.when = 60 |
| 133 |
+ |
}; |
| 134 |
|
|
| 135 |
|
/* |
| 136 |
|
* print_startup - print startup information |
| 138 |
|
static void |
| 139 |
|
print_startup(int pid) |
| 140 |
|
{ |
| 141 |
< |
printf("ircd: version %s\n", ircd_version); |
| 141 |
> |
printf("ircd: version %s(%s)\n", ircd_version, serno); |
| 142 |
|
printf("ircd: pid %d\n", pid); |
| 143 |
|
printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background" |
| 144 |
|
: "foreground", ConfigFileEntry.dpath); |
| 165 |
|
|
| 166 |
|
static int printVersion = 0; |
| 167 |
|
|
| 168 |
< |
static struct lgetopt myopts[] = { |
| 169 |
< |
{"dlinefile", &ConfigFileEntry.dlinefile, |
| 170 |
< |
STRING, "File to use for dline.conf"}, |
| 148 |
< |
{"configfile", &ConfigFileEntry.configfile, |
| 168 |
> |
static struct lgetopt myopts[] = |
| 169 |
> |
{ |
| 170 |
> |
{"configfile", &ConfigFileEntry.configfile, |
| 171 |
|
STRING, "File to use for ircd.conf"}, |
| 172 |
< |
{"klinefile", &ConfigFileEntry.klinefile, |
| 173 |
< |
STRING, "File to use for kline.conf"}, |
| 174 |
< |
{"xlinefile", &ConfigFileEntry.xlinefile, |
| 175 |
< |
STRING, "File to use for xline.conf"}, |
| 176 |
< |
{"logfile", &logFileName, |
| 172 |
> |
{"glinefile", &ConfigFileEntry.glinefile, |
| 173 |
> |
STRING, "File to use for gline database"}, |
| 174 |
> |
{"klinefile", &ConfigFileEntry.klinefile, |
| 175 |
> |
STRING, "File to use for kline database"}, |
| 176 |
> |
{"dlinefile", &ConfigFileEntry.dlinefile, |
| 177 |
> |
STRING, "File to use for dline database"}, |
| 178 |
> |
{"xlinefile", &ConfigFileEntry.xlinefile, |
| 179 |
> |
STRING, "File to use for xline database"}, |
| 180 |
> |
{"resvfile", &ConfigFileEntry.resvfile, |
| 181 |
> |
STRING, "File to use for resv database"}, |
| 182 |
> |
{"logfile", &logFileName, |
| 183 |
|
STRING, "File to use for ircd.log"}, |
| 184 |
|
{"pidfile", &pidFileName, |
| 185 |
|
STRING, "File to use for process ID"}, |
| 186 |
< |
{"foreground", &server_state.foreground, |
| 186 |
> |
{"foreground", &server_state.foreground, |
| 187 |
|
YESNO, "Run in foreground (don't detach)"}, |
| 188 |
< |
{"version", &printVersion, |
| 188 |
> |
{"version", &printVersion, |
| 189 |
|
YESNO, "Print version and exit"}, |
| 190 |
|
{"help", NULL, USAGE, "Print this text"}, |
| 191 |
|
{NULL, NULL, STRING, NULL}, |
| 194 |
|
void |
| 195 |
|
set_time(void) |
| 196 |
|
{ |
| 197 |
< |
static char to_send[200]; |
| 170 |
< |
struct timeval newtime; |
| 171 |
< |
newtime.tv_sec = 0; |
| 172 |
< |
newtime.tv_usec = 0; |
| 197 |
> |
struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 }; |
| 198 |
|
|
| 199 |
|
if (gettimeofday(&newtime, NULL) == -1) |
| 200 |
|
{ |
| 201 |
|
ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted", |
| 202 |
|
strerror(errno)); |
| 203 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 203 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 204 |
|
"Clock Failure (%s), TS can be corrupted", |
| 205 |
|
strerror(errno)); |
| 206 |
< |
restart("Clock Failure"); |
| 206 |
> |
server_die("Clock Failure", 1); |
| 207 |
|
} |
| 208 |
|
|
| 209 |
|
if (newtime.tv_sec < CurrentTime) |
| 210 |
|
{ |
| 211 |
< |
snprintf(to_send, sizeof(to_send), |
| 212 |
< |
"System clock is running backwards - (%lu < %lu)", |
| 213 |
< |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
| 214 |
< |
report_error(L_ALL, to_send, me.name, 0); |
| 211 |
> |
ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)", |
| 212 |
> |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
| 213 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
| 214 |
> |
"System clock is running backwards - (%lu < %lu)", |
| 215 |
> |
(unsigned long)newtime.tv_sec, |
| 216 |
> |
(unsigned long)CurrentTime); |
| 217 |
|
set_back_events(CurrentTime - newtime.tv_sec); |
| 218 |
|
} |
| 219 |
|
|
| 224 |
|
static void |
| 225 |
|
io_loop(void) |
| 226 |
|
{ |
| 227 |
< |
while (1 == 1) |
| 227 |
> |
while (1) |
| 228 |
|
{ |
| 202 |
– |
/* |
| 203 |
– |
* Maybe we want a flags word? |
| 204 |
– |
* ie. if (REHASHED_KLINES(global_flags)) |
| 205 |
– |
* SET_REHASHED_KLINES(global_flags) |
| 206 |
– |
* CLEAR_REHASHED_KLINES(global_flags) |
| 207 |
– |
* |
| 208 |
– |
* - Dianora |
| 209 |
– |
*/ |
| 210 |
– |
if (rehashed_klines) |
| 211 |
– |
{ |
| 212 |
– |
check_conf_klines(); |
| 213 |
– |
rehashed_klines = 0; |
| 214 |
– |
} |
| 215 |
– |
|
| 229 |
|
if (listing_client_list.head) |
| 230 |
|
{ |
| 231 |
|
dlink_node *ptr = NULL, *ptr_next = NULL; |
| 232 |
|
DLINK_FOREACH_SAFE(ptr, ptr_next, listing_client_list.head) |
| 233 |
< |
{ |
| 221 |
< |
struct Client *client_p = ptr->data; |
| 222 |
< |
assert(client_p->localClient->list_task); |
| 223 |
< |
safe_list_channels(client_p, client_p->localClient->list_task, 0); |
| 224 |
< |
} |
| 233 |
> |
safe_list_channels(ptr->data, 0); |
| 234 |
|
} |
| 235 |
|
|
| 236 |
< |
/* Run pending events, then get the number of seconds to the next |
| 237 |
< |
* event |
| 229 |
< |
*/ |
| 230 |
< |
while (eventNextTime() <= CurrentTime) |
| 231 |
< |
eventRun(); |
| 236 |
> |
/* Run pending events */ |
| 237 |
> |
event_run(); |
| 238 |
|
|
| 239 |
|
comm_select(); |
| 240 |
|
exit_aborted_clients(); |
| 241 |
|
free_exited_clients(); |
| 236 |
– |
send_queued_all(); |
| 242 |
|
|
| 243 |
|
/* Check to see whether we have to rehash the configuration .. */ |
| 244 |
|
if (dorehash) |
| 246 |
|
rehash(1); |
| 247 |
|
dorehash = 0; |
| 248 |
|
} |
| 249 |
+ |
|
| 250 |
|
if (doremotd) |
| 251 |
|
{ |
| 252 |
< |
read_message_file(&ConfigFileEntry.motd); |
| 253 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 254 |
< |
"Got signal SIGUSR1, reloading ircd motd file"); |
| 252 |
> |
motd_recache(); |
| 253 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 254 |
> |
"Got signal SIGUSR1, reloading motd file(s)"); |
| 255 |
|
doremotd = 0; |
| 256 |
|
} |
| 257 |
|
} |
| 261 |
|
* |
| 262 |
|
* inputs - none |
| 263 |
|
* output - none |
| 264 |
< |
* side effects - This sets all global set options needed |
| 264 |
> |
* side effects - This sets all global set options needed |
| 265 |
|
*/ |
| 266 |
|
static void |
| 267 |
|
initialize_global_set_options(void) |
| 295 |
|
/* End of global set options */ |
| 296 |
|
} |
| 297 |
|
|
| 292 |
– |
/* initialize_message_files() |
| 293 |
– |
* |
| 294 |
– |
* inputs - none |
| 295 |
– |
* output - none |
| 296 |
– |
* side effects - Set up all message files needed, motd etc. |
| 297 |
– |
*/ |
| 298 |
– |
static void |
| 299 |
– |
initialize_message_files(void) |
| 300 |
– |
{ |
| 301 |
– |
init_message_file(USER_MOTD, MPATH, &ConfigFileEntry.motd); |
| 302 |
– |
init_message_file(OPER_MOTD, OPATH, &ConfigFileEntry.opermotd); |
| 303 |
– |
init_message_file(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile); |
| 304 |
– |
|
| 305 |
– |
read_message_file(&ConfigFileEntry.motd); |
| 306 |
– |
read_message_file(&ConfigFileEntry.opermotd); |
| 307 |
– |
read_message_file(&ConfigFileEntry.linksfile); |
| 308 |
– |
|
| 309 |
– |
init_isupport(); |
| 310 |
– |
} |
| 311 |
– |
|
| 298 |
|
/* initialize_server_capabs() |
| 299 |
|
* |
| 300 |
|
* inputs - none |
| 308 |
|
add_capability("TS6", CAP_TS6, 0); |
| 309 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
| 310 |
|
add_capability("SVS", CAP_SVS, 1); |
| 311 |
< |
#ifdef HALFOPS |
| 311 |
> |
add_capability("CHW", CAP_CHW, 1); |
| 312 |
|
add_capability("HOPS", CAP_HOPS, 1); |
| 327 |
– |
#endif |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
/* write_pidfile() |
| 325 |
|
|
| 326 |
|
if ((fb = fopen(filename, "w"))) |
| 327 |
|
{ |
| 328 |
< |
char buff[32]; |
| 328 |
> |
char buff[IRCD_BUFSIZE]; |
| 329 |
|
unsigned int pid = (unsigned int)getpid(); |
| 330 |
|
|
| 331 |
|
snprintf(buff, sizeof(buff), "%u\n", pid); |
| 354 |
|
check_pidfile(const char *filename) |
| 355 |
|
{ |
| 356 |
|
FILE *fb; |
| 357 |
< |
char buff[32]; |
| 357 |
> |
char buff[IRCD_BUFSIZE]; |
| 358 |
|
pid_t pidfromfile; |
| 359 |
|
|
| 360 |
|
/* Don't do logging here, since we don't have log() initialised */ |
| 408 |
|
#endif |
| 409 |
|
} |
| 410 |
|
|
| 411 |
+ |
#ifdef HAVE_LIBCRYPTO |
| 412 |
+ |
static int |
| 413 |
+ |
always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx) |
| 414 |
+ |
{ |
| 415 |
+ |
return 1; |
| 416 |
+ |
} |
| 417 |
+ |
#endif |
| 418 |
+ |
|
| 419 |
|
/* init_ssl() |
| 420 |
|
* |
| 421 |
|
* inputs - nothing |
| 423 |
|
* side effects - setups SSL context. |
| 424 |
|
*/ |
| 425 |
|
static void |
| 426 |
< |
init_ssl(void) |
| 426 |
> |
ssl_init(void) |
| 427 |
|
{ |
| 428 |
|
#ifdef HAVE_LIBCRYPTO |
| 429 |
+ |
const unsigned char session_id[] = "ircd-hybrid"; |
| 430 |
+ |
|
| 431 |
|
SSL_load_error_strings(); |
| 432 |
|
SSLeay_add_ssl_algorithms(); |
| 433 |
|
|
| 441 |
|
} |
| 442 |
|
|
| 443 |
|
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
| 444 |
< |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
| 445 |
< |
SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_NONE, NULL); |
| 444 |
> |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG); |
| 445 |
> |
SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
| 446 |
> |
always_accept_verify_cb); |
| 447 |
> |
SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1); |
| 448 |
> |
|
| 449 |
> |
#if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH) |
| 450 |
> |
{ |
| 451 |
> |
EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); |
| 452 |
> |
|
| 453 |
> |
if (key) |
| 454 |
> |
{ |
| 455 |
> |
SSL_CTX_set_tmp_ecdh(ServerInfo.server_ctx, key); |
| 456 |
> |
EC_KEY_free(key); |
| 457 |
> |
} |
| 458 |
> |
} |
| 459 |
> |
|
| 460 |
> |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE); |
| 461 |
> |
#endif |
| 462 |
|
|
| 463 |
|
if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) |
| 464 |
|
{ |
| 470 |
|
} |
| 471 |
|
|
| 472 |
|
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
| 473 |
< |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
| 474 |
< |
SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_NONE, NULL); |
| 473 |
> |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG); |
| 474 |
> |
SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
| 475 |
> |
always_accept_verify_cb); |
| 476 |
|
#endif /* HAVE_LIBCRYPTO */ |
| 477 |
|
} |
| 478 |
|
|
| 467 |
– |
/* init_callbacks() |
| 468 |
– |
* |
| 469 |
– |
* inputs - nothing |
| 470 |
– |
* output - nothing |
| 471 |
– |
* side effects - setups standard hook points |
| 472 |
– |
*/ |
| 473 |
– |
static void |
| 474 |
– |
init_callbacks(void) |
| 475 |
– |
{ |
| 476 |
– |
iorecv_cb = register_callback("iorecv", iorecv_default); |
| 477 |
– |
iosend_cb = register_callback("iosend", iosend_default); |
| 478 |
– |
} |
| 479 |
– |
|
| 479 |
|
int |
| 480 |
|
main(int argc, char *argv[]) |
| 481 |
|
{ |
| 482 |
< |
/* Check to see if the user is running |
| 484 |
< |
* us as root, which is a nono |
| 485 |
< |
*/ |
| 482 |
> |
/* Check to see if the user is running us as root, which is a nono */ |
| 483 |
|
if (geteuid() == 0) |
| 484 |
|
{ |
| 485 |
< |
fprintf(stderr, "Don't run ircd as root!!!\n"); |
| 485 |
> |
fprintf(stderr, "ERROR: This server won't run as root/superuser\n"); |
| 486 |
|
return -1; |
| 487 |
|
} |
| 488 |
|
|
| 496 |
|
init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); |
| 497 |
|
|
| 498 |
|
me.localClient = &meLocalUser; |
| 499 |
< |
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
| 499 |
> |
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
| 500 |
|
of Client list */ |
| 501 |
< |
/* Initialise the channel capability usage counts... */ |
| 505 |
< |
init_chcap_usage_counts(); |
| 506 |
< |
|
| 501 |
> |
ConfigLoggingEntry.use_logging = 1; |
| 502 |
|
ConfigFileEntry.dpath = DPATH; |
| 503 |
< |
ConfigFileEntry.configfile = CPATH; /* Server configuration file */ |
| 504 |
< |
ConfigFileEntry.klinefile = KPATH; /* Server kline file */ |
| 505 |
< |
ConfigFileEntry.xlinefile = XPATH; /* Server xline file */ |
| 506 |
< |
ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file */ |
| 507 |
< |
ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file */ |
| 508 |
< |
ConfigFileEntry.dlinefile = DLPATH; /* dline file */ |
| 509 |
< |
ConfigFileEntry.glinefile = GPATH; /* gline log file */ |
| 510 |
< |
ConfigFileEntry.cresvfile = CRESVPATH; /* channel resv file */ |
| 511 |
< |
ConfigFileEntry.nresvfile = NRESVPATH; /* nick resv file */ |
| 503 |
> |
ConfigFileEntry.spath = SPATH; |
| 504 |
> |
ConfigFileEntry.mpath = MPATH; |
| 505 |
> |
ConfigFileEntry.configfile = CPATH; /* Server configuration file */ |
| 506 |
> |
ConfigFileEntry.klinefile = KPATH; /* Server kline file */ |
| 507 |
> |
ConfigFileEntry.glinefile = GPATH; /* Server gline file */ |
| 508 |
> |
ConfigFileEntry.xlinefile = XPATH; /* Server xline file */ |
| 509 |
> |
ConfigFileEntry.dlinefile = DLPATH; /* dline file */ |
| 510 |
> |
ConfigFileEntry.resvfile = RESVPATH; /* resv file */ |
| 511 |
> |
|
| 512 |
|
myargv = argv; |
| 513 |
|
umask(077); /* better safe than sorry --SRB */ |
| 514 |
|
|
| 516 |
|
|
| 517 |
|
if (printVersion) |
| 518 |
|
{ |
| 519 |
< |
printf("ircd: version %s\n", ircd_version); |
| 519 |
> |
printf("ircd: version %s(%s)\n", ircd_version, serno); |
| 520 |
|
exit(EXIT_SUCCESS); |
| 521 |
|
} |
| 522 |
|
|
| 526 |
|
exit(EXIT_FAILURE); |
| 527 |
|
} |
| 528 |
|
|
| 529 |
< |
init_ssl(); |
| 529 |
> |
ssl_init(); |
| 530 |
|
|
| 531 |
|
if (!server_state.foreground) |
| 532 |
|
{ |
| 538 |
|
|
| 539 |
|
setup_signals(); |
| 540 |
|
|
| 546 |
– |
get_ircd_platform(ircd_platform); |
| 547 |
– |
|
| 548 |
– |
/* Init the event subsystem */ |
| 549 |
– |
eventInit(); |
| 541 |
|
/* We need this to initialise the fd array before anything else */ |
| 542 |
|
fdlist_init(); |
| 543 |
< |
log_add_file(LOG_TYPE_IRCD, 0, logFileName); |
| 543 |
> |
log_set_file(LOG_TYPE_IRCD, 0, logFileName); |
| 544 |
|
check_can_use_v6(); |
| 545 |
< |
init_comm(); /* This needs to be setup early ! -- adrian */ |
| 545 |
> |
init_netio(); /* This needs to be setup early ! -- adrian */ |
| 546 |
> |
|
| 547 |
|
/* Check if there is pidfile and daemon already running */ |
| 548 |
|
check_pidfile(pidFileName); |
| 549 |
|
|
| 550 |
< |
initBlockHeap(); |
| 550 |
> |
mp_pool_init(); |
| 551 |
|
init_dlink_nodes(); |
| 552 |
< |
init_callbacks(); |
| 561 |
< |
initialize_message_files(); |
| 552 |
> |
init_isupport(); |
| 553 |
|
dbuf_init(); |
| 554 |
< |
init_hash(); |
| 554 |
> |
hash_init(); |
| 555 |
|
init_ip_hash_table(); /* client host ip hash table */ |
| 556 |
|
init_host_hash(); /* Host-hashtable. */ |
| 557 |
< |
init_client(); |
| 558 |
< |
init_class(); |
| 557 |
> |
client_init(); |
| 558 |
> |
class_init(); |
| 559 |
|
whowas_init(); |
| 560 |
|
watch_init(); |
| 561 |
< |
init_auth(); /* Initialise the auth code */ |
| 561 |
> |
auth_init(); /* Initialise the auth code */ |
| 562 |
|
init_resolver(); /* Needs to be setup before the io loop */ |
| 563 |
+ |
modules_init(); |
| 564 |
|
read_conf_files(1); /* cold start init conf files */ |
| 565 |
|
init_uid(); |
| 566 |
|
initialize_server_capabs(); /* Set up default_server_capabs */ |
| 567 |
|
initialize_global_set_options(); |
| 568 |
< |
init_channels(); |
| 568 |
> |
channel_init(); |
| 569 |
> |
read_links_file(); |
| 570 |
> |
motd_init(); |
| 571 |
> |
#ifdef HAVE_LIBGEOIP |
| 572 |
> |
geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE); |
| 573 |
> |
#endif |
| 574 |
|
|
| 575 |
|
if (EmptyString(ServerInfo.sid)) |
| 576 |
|
{ |
| 608 |
|
|
| 609 |
|
hash_add_id(&me); |
| 610 |
|
hash_add_client(&me); |
| 611 |
< |
|
| 611 |
> |
|
| 612 |
|
/* add ourselves to global_serv_list */ |
| 613 |
|
dlinkAdd(&me, make_dlink_node(), &global_serv_list); |
| 614 |
|
|
| 615 |
+ |
load_kline_database(); |
| 616 |
+ |
load_dline_database(); |
| 617 |
+ |
load_gline_database(); |
| 618 |
+ |
load_xline_database(); |
| 619 |
+ |
load_resv_database(); |
| 620 |
+ |
|
| 621 |
|
if (chdir(MODPATH)) |
| 622 |
|
{ |
| 623 |
|
ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!"); |
| 645 |
|
|
| 646 |
|
ilog(LOG_TYPE_IRCD, "Server Ready"); |
| 647 |
|
|
| 648 |
< |
eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME); |
| 649 |
< |
eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME); |
| 648 |
> |
event_addish(&event_cleanup_glines, NULL); |
| 649 |
> |
event_addish(&event_cleanup_tklines, NULL); |
| 650 |
|
|
| 651 |
|
/* We want try_connections to be called as soon as possible now! -- adrian */ |
| 652 |
|
/* No, 'cause after a restart it would cause all sorts of nick collides */ |
| 653 |
< |
eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME); |
| 653 |
> |
event_addish(&event_try_connections, NULL); |
| 654 |
|
|
| 655 |
|
/* Setup the timeout check. I'll shift it later :) -- adrian */ |
| 656 |
< |
eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1); |
| 656 |
> |
event_addish(&event_comm_checktimeouts, NULL); |
| 657 |
> |
|
| 658 |
> |
event_addish(&event_save_all_databases, NULL); |
| 659 |
|
|
| 660 |
|
if (ConfigServerHide.links_delay > 0) |
| 661 |
< |
eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay); |
| 661 |
> |
{ |
| 662 |
> |
event_write_links_file.when = ConfigServerHide.links_delay; |
| 663 |
> |
event_addish(&event_write_links_file, NULL); |
| 664 |
> |
} |
| 665 |
|
else |
| 666 |
|
ConfigServerHide.links_disabled = 1; |
| 667 |
|
|
| 668 |
|
if (splitmode) |
| 669 |
< |
eventAddIsh("check_splitmode", check_splitmode, NULL, 60); |
| 669 |
> |
event_addish(&event_check_splitmode, NULL); |
| 670 |
|
|
| 671 |
|
io_loop(); |
| 672 |
|
return 0; |