| 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" |
| 41 |
– |
#include "numeric.h" |
| 42 |
– |
#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 "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 "mempool.h" |
| 57 |
– |
#include "hook.h" |
| 55 |
|
#include "ircd_getopt.h" |
| 56 |
|
#include "supported.h" |
| 57 |
|
#include "watch.h" |
| 135 |
|
|
| 136 |
|
static int printVersion = 0; |
| 137 |
|
|
| 138 |
< |
static struct lgetopt myopts[] = { |
| 139 |
< |
{"configfile", &ConfigFileEntry.configfile, |
| 138 |
> |
static struct lgetopt myopts[] = |
| 139 |
> |
{ |
| 140 |
> |
{"configfile", &ConfigFileEntry.configfile, |
| 141 |
|
STRING, "File to use for ircd.conf"}, |
| 142 |
|
{"glinefile", &ConfigFileEntry.glinefile, |
| 143 |
|
STRING, "File to use for gline database"}, |
| 144 |
< |
{"klinefile", &ConfigFileEntry.klinefile, |
| 144 |
> |
{"klinefile", &ConfigFileEntry.klinefile, |
| 145 |
|
STRING, "File to use for kline database"}, |
| 146 |
|
{"dlinefile", &ConfigFileEntry.dlinefile, |
| 147 |
|
STRING, "File to use for dline database"}, |
| 148 |
< |
{"xlinefile", &ConfigFileEntry.xlinefile, |
| 148 |
> |
{"xlinefile", &ConfigFileEntry.xlinefile, |
| 149 |
|
STRING, "File to use for xline database"}, |
| 150 |
|
{"resvfile", &ConfigFileEntry.resvfile, |
| 151 |
|
STRING, "File to use for resv database"}, |
| 152 |
< |
{"logfile", &logFileName, |
| 152 |
> |
{"logfile", &logFileName, |
| 153 |
|
STRING, "File to use for ircd.log"}, |
| 154 |
|
{"pidfile", &pidFileName, |
| 155 |
|
STRING, "File to use for process ID"}, |
| 156 |
< |
{"foreground", &server_state.foreground, |
| 156 |
> |
{"foreground", &server_state.foreground, |
| 157 |
|
YESNO, "Run in foreground (don't detach)"}, |
| 158 |
< |
{"version", &printVersion, |
| 158 |
> |
{"version", &printVersion, |
| 159 |
|
YESNO, "Print version and exit"}, |
| 160 |
|
{"help", NULL, USAGE, "Print this text"}, |
| 161 |
|
{NULL, NULL, STRING, NULL}, |
| 164 |
|
void |
| 165 |
|
set_time(void) |
| 166 |
|
{ |
| 167 |
< |
static char to_send[IRCD_BUFSIZE]; |
| 170 |
< |
struct timeval newtime; |
| 171 |
< |
newtime.tv_sec = 0; |
| 172 |
< |
newtime.tv_usec = 0; |
| 167 |
> |
struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 }; |
| 168 |
|
|
| 169 |
|
if (gettimeofday(&newtime, NULL) == -1) |
| 170 |
|
{ |
| 173 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 174 |
|
"Clock Failure (%s), TS can be corrupted", |
| 175 |
|
strerror(errno)); |
| 176 |
< |
restart("Clock Failure"); |
| 176 |
> |
server_die("Clock Failure", 1); |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
if (newtime.tv_sec < CurrentTime) |
| 180 |
|
{ |
| 181 |
< |
snprintf(to_send, sizeof(to_send), |
| 182 |
< |
"System clock is running backwards - (%lu < %lu)", |
| 183 |
< |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
| 184 |
< |
report_error(L_ALL, to_send, me.name, 0); |
| 181 |
> |
ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)", |
| 182 |
> |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
| 183 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
| 184 |
> |
"System clock is running backwards - (%lu < %lu)", |
| 185 |
> |
(unsigned long)newtime.tv_sec, |
| 186 |
> |
(unsigned long)CurrentTime); |
| 187 |
|
set_back_events(CurrentTime - newtime.tv_sec); |
| 188 |
|
} |
| 189 |
|
|
| 194 |
|
static void |
| 195 |
|
io_loop(void) |
| 196 |
|
{ |
| 197 |
< |
while (1 == 1) |
| 197 |
> |
while (1) |
| 198 |
|
{ |
| 199 |
|
/* |
| 200 |
|
* Maybe we want a flags word? |
| 201 |
< |
* ie. if (REHASHED_KLINES(global_flags)) |
| 201 |
> |
* ie. if (REHASHED_KLINES(global_flags)) |
| 202 |
|
* SET_REHASHED_KLINES(global_flags) |
| 203 |
|
* CLEAR_REHASHED_KLINES(global_flags) |
| 204 |
|
* |
| 214 |
|
{ |
| 215 |
|
dlink_node *ptr = NULL, *ptr_next = NULL; |
| 216 |
|
DLINK_FOREACH_SAFE(ptr, ptr_next, listing_client_list.head) |
| 217 |
< |
{ |
| 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 |
< |
} |
| 217 |
> |
safe_list_channels(ptr->data, 0); |
| 218 |
|
} |
| 219 |
|
|
| 220 |
|
/* Run pending events, then get the number of seconds to the next |
| 233 |
|
rehash(1); |
| 234 |
|
dorehash = 0; |
| 235 |
|
} |
| 236 |
+ |
|
| 237 |
|
if (doremotd) |
| 238 |
|
{ |
| 239 |
|
motd_recache(); |
| 240 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 241 |
< |
"Got signal SIGUSR1, reloading motd files"); |
| 241 |
> |
"Got signal SIGUSR1, reloading motd file(s)"); |
| 242 |
|
doremotd = 0; |
| 243 |
|
} |
| 244 |
|
} |
| 248 |
|
* |
| 249 |
|
* inputs - none |
| 250 |
|
* output - none |
| 251 |
< |
* side effects - This sets all global set options needed |
| 251 |
> |
* side effects - This sets all global set options needed |
| 252 |
|
*/ |
| 253 |
|
static void |
| 254 |
|
initialize_global_set_options(void) |
| 294 |
|
add_capability("EOB", CAP_EOB, 1); |
| 295 |
|
add_capability("TS6", CAP_TS6, 0); |
| 296 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
| 303 |
– |
// add_capability("FAKEHOST", CAP_FAKEHOST, 1); |
| 297 |
|
add_capability("SVS", CAP_SVS, 1); |
| 298 |
+ |
add_capability("CHW", CAP_CHW, 1); |
| 299 |
|
#ifdef HALFOPS |
| 300 |
|
add_capability("HOPS", CAP_HOPS, 1); |
| 301 |
|
#endif |
| 473 |
|
me.localClient = &meLocalUser; |
| 474 |
|
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
| 475 |
|
of Client list */ |
| 482 |
– |
/* Initialise the channel capability usage counts... */ |
| 483 |
– |
init_chcap_usage_counts(); |
| 484 |
– |
|
| 476 |
|
ConfigFileEntry.dpath = DPATH; |
| 477 |
+ |
ConfigFileEntry.spath = SPATH; |
| 478 |
+ |
ConfigFileEntry.mpath = MPATH; |
| 479 |
|
ConfigFileEntry.configfile = CPATH; /* Server configuration file */ |
| 480 |
|
ConfigFileEntry.klinefile = KPATH; /* Server kline file */ |
| 481 |
|
ConfigFileEntry.glinefile = GPATH; /* Server gline file */ |
| 585 |
|
|
| 586 |
|
hash_add_id(&me); |
| 587 |
|
hash_add_client(&me); |
| 588 |
< |
|
| 588 |
> |
|
| 589 |
|
/* add ourselves to global_serv_list */ |
| 590 |
|
dlinkAdd(&me, make_dlink_node(), &global_serv_list); |
| 591 |
|
|