| 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" |
| 141 |
|
static int printVersion = 0; |
| 142 |
|
|
| 143 |
|
static struct lgetopt myopts[] = { |
| 144 |
< |
{"configfile", &ConfigFileEntry.configfile, |
| 144 |
> |
{"configfile", &ConfigFileEntry.configfile, |
| 145 |
|
STRING, "File to use for ircd.conf"}, |
| 146 |
|
{"glinefile", &ConfigFileEntry.glinefile, |
| 147 |
|
STRING, "File to use for gline database"}, |
| 148 |
< |
{"klinefile", &ConfigFileEntry.klinefile, |
| 148 |
> |
{"klinefile", &ConfigFileEntry.klinefile, |
| 149 |
|
STRING, "File to use for kline database"}, |
| 150 |
|
{"dlinefile", &ConfigFileEntry.dlinefile, |
| 151 |
|
STRING, "File to use for dline database"}, |
| 152 |
< |
{"xlinefile", &ConfigFileEntry.xlinefile, |
| 152 |
> |
{"xlinefile", &ConfigFileEntry.xlinefile, |
| 153 |
|
STRING, "File to use for xline database"}, |
| 154 |
|
{"resvfile", &ConfigFileEntry.resvfile, |
| 155 |
|
STRING, "File to use for resv database"}, |
| 156 |
< |
{"logfile", &logFileName, |
| 156 |
> |
{"logfile", &logFileName, |
| 157 |
|
STRING, "File to use for ircd.log"}, |
| 158 |
|
{"pidfile", &pidFileName, |
| 159 |
|
STRING, "File to use for process ID"}, |
| 160 |
< |
{"foreground", &server_state.foreground, |
| 160 |
> |
{"foreground", &server_state.foreground, |
| 161 |
|
YESNO, "Run in foreground (don't detach)"}, |
| 162 |
< |
{"version", &printVersion, |
| 162 |
> |
{"version", &printVersion, |
| 163 |
|
YESNO, "Print version and exit"}, |
| 164 |
|
{"help", NULL, USAGE, "Print this text"}, |
| 165 |
|
{NULL, NULL, STRING, NULL}, |
| 168 |
|
void |
| 169 |
|
set_time(void) |
| 170 |
|
{ |
| 171 |
< |
static char to_send[IRCD_BUFSIZE]; |
| 170 |
< |
struct timeval newtime; |
| 171 |
< |
newtime.tv_sec = 0; |
| 172 |
< |
newtime.tv_usec = 0; |
| 171 |
> |
struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 }; |
| 172 |
|
|
| 173 |
|
if (gettimeofday(&newtime, NULL) == -1) |
| 174 |
|
{ |
| 182 |
|
|
| 183 |
|
if (newtime.tv_sec < CurrentTime) |
| 184 |
|
{ |
| 185 |
< |
snprintf(to_send, sizeof(to_send), |
| 186 |
< |
"System clock is running backwards - (%lu < %lu)", |
| 187 |
< |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
| 188 |
< |
report_error(L_ALL, to_send, me.name, 0); |
| 185 |
> |
ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)", |
| 186 |
> |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
| 187 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
| 188 |
> |
"System clock is running backwards - (%lu < %lu)", |
| 189 |
> |
(unsigned long)newtime.tv_sec, |
| 190 |
> |
(unsigned long)CurrentTime); |
| 191 |
|
set_back_events(CurrentTime - newtime.tv_sec); |
| 192 |
|
} |
| 193 |
|
|
| 202 |
|
{ |
| 203 |
|
/* |
| 204 |
|
* Maybe we want a flags word? |
| 205 |
< |
* ie. if (REHASHED_KLINES(global_flags)) |
| 205 |
> |
* ie. if (REHASHED_KLINES(global_flags)) |
| 206 |
|
* SET_REHASHED_KLINES(global_flags) |
| 207 |
|
* CLEAR_REHASHED_KLINES(global_flags) |
| 208 |
|
* |
| 234 |
|
comm_select(); |
| 235 |
|
exit_aborted_clients(); |
| 236 |
|
free_exited_clients(); |
| 236 |
– |
send_queued_all(); |
| 237 |
|
|
| 238 |
|
/* Check to see whether we have to rehash the configuration .. */ |
| 239 |
|
if (dorehash) |
| 245 |
|
{ |
| 246 |
|
motd_recache(); |
| 247 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 248 |
< |
"Got signal SIGUSR1, reloading motd files"); |
| 248 |
> |
"Got signal SIGUSR1, reloading motd file(s)"); |
| 249 |
|
doremotd = 0; |
| 250 |
|
} |
| 251 |
|
} |
| 255 |
|
* |
| 256 |
|
* inputs - none |
| 257 |
|
* output - none |
| 258 |
< |
* side effects - This sets all global set options needed |
| 258 |
> |
* side effects - This sets all global set options needed |
| 259 |
|
*/ |
| 260 |
|
static void |
| 261 |
|
initialize_global_set_options(void) |
| 301 |
|
add_capability("EOB", CAP_EOB, 1); |
| 302 |
|
add_capability("TS6", CAP_TS6, 0); |
| 303 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
| 304 |
– |
// add_capability("FAKEHOST", CAP_FAKEHOST, 1); |
| 304 |
|
add_capability("SVS", CAP_SVS, 1); |
| 305 |
|
#ifdef HALFOPS |
| 306 |
|
add_capability("HOPS", CAP_HOPS, 1); |
| 421 |
|
ssl_init(void) |
| 422 |
|
{ |
| 423 |
|
#ifdef HAVE_LIBCRYPTO |
| 424 |
+ |
const unsigned char session_id[] = "ircd-hybrid"; |
| 425 |
+ |
|
| 426 |
|
SSL_load_error_strings(); |
| 427 |
|
SSLeay_add_ssl_algorithms(); |
| 428 |
|
|
| 439 |
|
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
| 440 |
|
SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
| 441 |
|
always_accept_verify_cb); |
| 442 |
+ |
SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1); |
| 443 |
|
|
| 444 |
|
if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) |
| 445 |
|
{ |
| 479 |
|
me.localClient = &meLocalUser; |
| 480 |
|
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
| 481 |
|
of Client list */ |
| 480 |
– |
/* Initialise the channel capability usage counts... */ |
| 481 |
– |
init_chcap_usage_counts(); |
| 482 |
– |
|
| 482 |
|
ConfigFileEntry.dpath = DPATH; |
| 483 |
|
ConfigFileEntry.configfile = CPATH; /* Server configuration file */ |
| 484 |
|
ConfigFileEntry.klinefile = KPATH; /* Server kline file */ |
| 589 |
|
|
| 590 |
|
hash_add_id(&me); |
| 591 |
|
hash_add_client(&me); |
| 592 |
< |
|
| 592 |
> |
|
| 593 |
|
/* add ourselves to global_serv_list */ |
| 594 |
|
dlinkAdd(&me, make_dlink_node(), &global_serv_list); |
| 595 |
|
|