Large diffs are not rendered by default.

@@ -177,6 +177,8 @@ farconnect { return T_FARCONNECT; }
file { return T_FILE; }
flags { return IRCD_FLAGS; }
flatten_links { return FLATTEN_LINKS; }
flatten_links_delay { return FLATTEN_LINKS_DELAY; }
flatten_links_file { return FLATTEN_LINKS_FILE; }
full { return T_FULL; }
gecos { return GECOS; }
general { return GENERAL; }
@@ -212,7 +214,6 @@ knock_client_count { return KNOCK_CLIENT_COUNT; }
knock_client_time { return KNOCK_CLIENT_TIME; }
knock_delay_channel { return KNOCK_DELAY_CHANNEL; }
leaf_mask { return LEAF_MASK; }
links_delay { return LINKS_DELAY; }
listen { return LISTEN; }
locops { return T_LOCOPS; }
log { return T_LOG; }
@@ -280,7 +281,6 @@ restart { return T_RESTART; }
resv { return RESV; }
resv_exempt { return RESV_EXEMPT; }
rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; }
rsa_public_key_file { return RSA_PUBLIC_KEY_FILE; }
send_password { return SEND_PASSWORD; }
sendq { return SENDQ; }
server { return T_SERVER; }

Large diffs are not rendered by default.

@@ -85,95 +85,95 @@ extern int yydebug;
EXEMPT = 295,
FAILED_OPER_NOTICE = 296,
FLATTEN_LINKS = 297,
GECOS = 298,
GENERAL = 299,
HIDDEN = 300,
HIDDEN_NAME = 301,
HIDE_CHANS = 302,
HIDE_IDLE = 303,
HIDE_IDLE_FROM_OPERS = 304,
HIDE_SERVER_IPS = 305,
HIDE_SERVERS = 306,
HIDE_SERVICES = 307,
HOST = 308,
HUB = 309,
HUB_MASK = 310,
IGNORE_BOGUS_TS = 311,
INVISIBLE_ON_CONNECT = 312,
INVITE_CLIENT_COUNT = 313,
INVITE_CLIENT_TIME = 314,
IP = 315,
IRCD_AUTH = 316,
IRCD_FLAGS = 317,
IRCD_SID = 318,
JOIN = 319,
KILL = 320,
KILL_CHASE_TIME_LIMIT = 321,
KLINE = 322,
KLINE_EXEMPT = 323,
KLINE_MIN_CIDR = 324,
KLINE_MIN_CIDR6 = 325,
KNOCK_CLIENT_COUNT = 326,
KNOCK_CLIENT_TIME = 327,
KNOCK_DELAY_CHANNEL = 328,
LEAF_MASK = 329,
LINKS_DELAY = 330,
LISTEN = 331,
MASK = 332,
MAX_ACCEPT = 333,
MAX_BANS = 334,
MAX_CHANNELS = 335,
MAX_GLOBAL = 336,
MAX_IDENT = 337,
MAX_IDLE = 338,
MAX_LOCAL = 339,
MAX_NICK_CHANGES = 340,
MAX_NICK_LENGTH = 341,
MAX_NICK_TIME = 342,
MAX_NUMBER = 343,
MAX_TARGETS = 344,
MAX_TOPIC_LENGTH = 345,
MAX_WATCH = 346,
MIN_IDLE = 347,
MIN_NONWILDCARD = 348,
MIN_NONWILDCARD_SIMPLE = 349,
MODULE = 350,
MODULES = 351,
MOTD = 352,
NAME = 353,
NEED_IDENT = 354,
NEED_PASSWORD = 355,
NETWORK_DESC = 356,
NETWORK_NAME = 357,
NICK = 358,
NO_OPER_FLOOD = 359,
NO_TILDE = 360,
NUMBER = 361,
NUMBER_PER_CIDR = 362,
NUMBER_PER_IP = 363,
OPER_ONLY_UMODES = 364,
OPER_UMODES = 365,
OPERATOR = 366,
OPERS_BYPASS_CALLERID = 367,
PACE_WAIT = 368,
PACE_WAIT_SIMPLE = 369,
PASSWORD = 370,
PATH = 371,
PING_COOKIE = 372,
PING_TIME = 373,
PORT = 374,
QSTRING = 375,
RANDOM_IDLE = 376,
REASON = 377,
REDIRPORT = 378,
REDIRSERV = 379,
REHASH = 380,
REMOTE = 381,
REMOTEBAN = 382,
RESV = 383,
RESV_EXEMPT = 384,
RSA_PRIVATE_KEY_FILE = 385,
RSA_PUBLIC_KEY_FILE = 386,
FLATTEN_LINKS_DELAY = 298,
FLATTEN_LINKS_FILE = 299,
GECOS = 300,
GENERAL = 301,
HIDDEN = 302,
HIDDEN_NAME = 303,
HIDE_CHANS = 304,
HIDE_IDLE = 305,
HIDE_IDLE_FROM_OPERS = 306,
HIDE_SERVER_IPS = 307,
HIDE_SERVERS = 308,
HIDE_SERVICES = 309,
HOST = 310,
HUB = 311,
HUB_MASK = 312,
IGNORE_BOGUS_TS = 313,
INVISIBLE_ON_CONNECT = 314,
INVITE_CLIENT_COUNT = 315,
INVITE_CLIENT_TIME = 316,
IP = 317,
IRCD_AUTH = 318,
IRCD_FLAGS = 319,
IRCD_SID = 320,
JOIN = 321,
KILL = 322,
KILL_CHASE_TIME_LIMIT = 323,
KLINE = 324,
KLINE_EXEMPT = 325,
KLINE_MIN_CIDR = 326,
KLINE_MIN_CIDR6 = 327,
KNOCK_CLIENT_COUNT = 328,
KNOCK_CLIENT_TIME = 329,
KNOCK_DELAY_CHANNEL = 330,
LEAF_MASK = 331,
LISTEN = 332,
MASK = 333,
MAX_ACCEPT = 334,
MAX_BANS = 335,
MAX_CHANNELS = 336,
MAX_GLOBAL = 337,
MAX_IDENT = 338,
MAX_IDLE = 339,
MAX_LOCAL = 340,
MAX_NICK_CHANGES = 341,
MAX_NICK_LENGTH = 342,
MAX_NICK_TIME = 343,
MAX_NUMBER = 344,
MAX_TARGETS = 345,
MAX_TOPIC_LENGTH = 346,
MAX_WATCH = 347,
MIN_IDLE = 348,
MIN_NONWILDCARD = 349,
MIN_NONWILDCARD_SIMPLE = 350,
MODULE = 351,
MODULES = 352,
MOTD = 353,
NAME = 354,
NEED_IDENT = 355,
NEED_PASSWORD = 356,
NETWORK_DESC = 357,
NETWORK_NAME = 358,
NICK = 359,
NO_OPER_FLOOD = 360,
NO_TILDE = 361,
NUMBER = 362,
NUMBER_PER_CIDR = 363,
NUMBER_PER_IP = 364,
OPER_ONLY_UMODES = 365,
OPER_UMODES = 366,
OPERATOR = 367,
OPERS_BYPASS_CALLERID = 368,
PACE_WAIT = 369,
PACE_WAIT_SIMPLE = 370,
PASSWORD = 371,
PATH = 372,
PING_COOKIE = 373,
PING_TIME = 374,
PORT = 375,
QSTRING = 376,
RANDOM_IDLE = 377,
REASON = 378,
REDIRPORT = 379,
REDIRSERV = 380,
REHASH = 381,
REMOTE = 382,
REMOTEBAN = 383,
RESV = 384,
RESV_EXEMPT = 385,
RSA_PRIVATE_KEY_FILE = 386,
SECONDS = 387,
MINUTES = 388,
HOURS = 389,
@@ -311,95 +311,95 @@ extern int yydebug;
#define EXEMPT 295
#define FAILED_OPER_NOTICE 296
#define FLATTEN_LINKS 297
#define GECOS 298
#define GENERAL 299
#define HIDDEN 300
#define HIDDEN_NAME 301
#define HIDE_CHANS 302
#define HIDE_IDLE 303
#define HIDE_IDLE_FROM_OPERS 304
#define HIDE_SERVER_IPS 305
#define HIDE_SERVERS 306
#define HIDE_SERVICES 307
#define HOST 308
#define HUB 309
#define HUB_MASK 310
#define IGNORE_BOGUS_TS 311
#define INVISIBLE_ON_CONNECT 312
#define INVITE_CLIENT_COUNT 313
#define INVITE_CLIENT_TIME 314
#define IP 315
#define IRCD_AUTH 316
#define IRCD_FLAGS 317
#define IRCD_SID 318
#define JOIN 319
#define KILL 320
#define KILL_CHASE_TIME_LIMIT 321
#define KLINE 322
#define KLINE_EXEMPT 323
#define KLINE_MIN_CIDR 324
#define KLINE_MIN_CIDR6 325
#define KNOCK_CLIENT_COUNT 326
#define KNOCK_CLIENT_TIME 327
#define KNOCK_DELAY_CHANNEL 328
#define LEAF_MASK 329
#define LINKS_DELAY 330
#define LISTEN 331
#define MASK 332
#define MAX_ACCEPT 333
#define MAX_BANS 334
#define MAX_CHANNELS 335
#define MAX_GLOBAL 336
#define MAX_IDENT 337
#define MAX_IDLE 338
#define MAX_LOCAL 339
#define MAX_NICK_CHANGES 340
#define MAX_NICK_LENGTH 341
#define MAX_NICK_TIME 342
#define MAX_NUMBER 343
#define MAX_TARGETS 344
#define MAX_TOPIC_LENGTH 345
#define MAX_WATCH 346
#define MIN_IDLE 347
#define MIN_NONWILDCARD 348
#define MIN_NONWILDCARD_SIMPLE 349
#define MODULE 350
#define MODULES 351
#define MOTD 352
#define NAME 353
#define NEED_IDENT 354
#define NEED_PASSWORD 355
#define NETWORK_DESC 356
#define NETWORK_NAME 357
#define NICK 358
#define NO_OPER_FLOOD 359
#define NO_TILDE 360
#define NUMBER 361
#define NUMBER_PER_CIDR 362
#define NUMBER_PER_IP 363
#define OPER_ONLY_UMODES 364
#define OPER_UMODES 365
#define OPERATOR 366
#define OPERS_BYPASS_CALLERID 367
#define PACE_WAIT 368
#define PACE_WAIT_SIMPLE 369
#define PASSWORD 370
#define PATH 371
#define PING_COOKIE 372
#define PING_TIME 373
#define PORT 374
#define QSTRING 375
#define RANDOM_IDLE 376
#define REASON 377
#define REDIRPORT 378
#define REDIRSERV 379
#define REHASH 380
#define REMOTE 381
#define REMOTEBAN 382
#define RESV 383
#define RESV_EXEMPT 384
#define RSA_PRIVATE_KEY_FILE 385
#define RSA_PUBLIC_KEY_FILE 386
#define FLATTEN_LINKS_DELAY 298
#define FLATTEN_LINKS_FILE 299
#define GECOS 300
#define GENERAL 301
#define HIDDEN 302
#define HIDDEN_NAME 303
#define HIDE_CHANS 304
#define HIDE_IDLE 305
#define HIDE_IDLE_FROM_OPERS 306
#define HIDE_SERVER_IPS 307
#define HIDE_SERVERS 308
#define HIDE_SERVICES 309
#define HOST 310
#define HUB 311
#define HUB_MASK 312
#define IGNORE_BOGUS_TS 313
#define INVISIBLE_ON_CONNECT 314
#define INVITE_CLIENT_COUNT 315
#define INVITE_CLIENT_TIME 316
#define IP 317
#define IRCD_AUTH 318
#define IRCD_FLAGS 319
#define IRCD_SID 320
#define JOIN 321
#define KILL 322
#define KILL_CHASE_TIME_LIMIT 323
#define KLINE 324
#define KLINE_EXEMPT 325
#define KLINE_MIN_CIDR 326
#define KLINE_MIN_CIDR6 327
#define KNOCK_CLIENT_COUNT 328
#define KNOCK_CLIENT_TIME 329
#define KNOCK_DELAY_CHANNEL 330
#define LEAF_MASK 331
#define LISTEN 332
#define MASK 333
#define MAX_ACCEPT 334
#define MAX_BANS 335
#define MAX_CHANNELS 336
#define MAX_GLOBAL 337
#define MAX_IDENT 338
#define MAX_IDLE 339
#define MAX_LOCAL 340
#define MAX_NICK_CHANGES 341
#define MAX_NICK_LENGTH 342
#define MAX_NICK_TIME 343
#define MAX_NUMBER 344
#define MAX_TARGETS 345
#define MAX_TOPIC_LENGTH 346
#define MAX_WATCH 347
#define MIN_IDLE 348
#define MIN_NONWILDCARD 349
#define MIN_NONWILDCARD_SIMPLE 350
#define MODULE 351
#define MODULES 352
#define MOTD 353
#define NAME 354
#define NEED_IDENT 355
#define NEED_PASSWORD 356
#define NETWORK_DESC 357
#define NETWORK_NAME 358
#define NICK 359
#define NO_OPER_FLOOD 360
#define NO_TILDE 361
#define NUMBER 362
#define NUMBER_PER_CIDR 363
#define NUMBER_PER_IP 364
#define OPER_ONLY_UMODES 365
#define OPER_UMODES 366
#define OPERATOR 367
#define OPERS_BYPASS_CALLERID 368
#define PACE_WAIT 369
#define PACE_WAIT_SIMPLE 370
#define PASSWORD 371
#define PATH 372
#define PING_COOKIE 373
#define PING_TIME 374
#define PORT 375
#define QSTRING 376
#define RANDOM_IDLE 377
#define REASON 378
#define REDIRPORT 379
#define REDIRSERV 380
#define REHASH 381
#define REMOTE 382
#define REMOTEBAN 383
#define RESV 384
#define RESV_EXEMPT 385
#define RSA_PRIVATE_KEY_FILE 386
#define SECONDS 387
#define MINUTES 388
#define HOURS 389

Large diffs are not rendered by default.

@@ -51,7 +51,7 @@ event_add(struct event *ev, void *data)

ev->data = data;
ev->next = CurrentTime + ev->when;
ev->enabled = 1;
ev->active = 1;

DLINK_FOREACH(node, event_list.head)
{
@@ -83,11 +83,11 @@ event_addish(struct event *ev, void *data)
void
event_delete(struct event *ev)
{
if (!ev->enabled)
if (!ev->active)
return;

dlinkDelete(&ev->node, &event_list);
ev->enabled = 0;
ev->active = 0;
}

void
@@ -197,7 +197,7 @@ close_standard_fds(void)
close(i);

if (open("/dev/null", O_RDWR) < 0)
exit(-1); /* we're hosed if we can't even open /dev/null */
exit(EXIT_FAILURE); /* we're hosed if we can't even open /dev/null */
}
}

@@ -56,10 +56,6 @@ dlink_list atable[ATABLE_SIZE];
* Side effects: None
* Comments: Called from parse_netmask
*/
/* Fixed so ::/0 (any IPv6 address) is valid
Also a bug in DigitParse above.
-Gozem 2002-07-19 gozem@linux.nu
*/
static int
try_parse_v6_netmask(const char *text, struct irc_ssaddr *addr, int *b)
{
@@ -92,10 +88,13 @@ try_parse_v6_netmask(const char *text, struct irc_ssaddr *addr, int *b)
}
else
{
/* If there were less than 4 hex digits, e.g. :ABC: shift right
* so we don't interpret it as ABC0 -A1kmm */
/*
* If there were less than 4 hex digits, e.g. :ABC: shift right
* so we don't interpret it as ABC0 -A1kmm
*/
d[dp] = d[dp] >> 4 * nyble;
nyble = 4;

if (++dp >= 8)
return HM_HOST;
}
@@ -77,13 +77,13 @@ ipcache_hash_address(const struct irc_ssaddr *addr)
* count set to 0.
*/
struct ip_entry *
ipcache_find_or_add_address(struct irc_ssaddr *addr)
ipcache_find_or_add_address(const struct irc_ssaddr *addr)
{
dlink_node *node = NULL;
struct ip_entry *iptr = NULL;
const uint32_t hash_index = ipcache_hash_address(addr);
struct sockaddr_in *v4 = (struct sockaddr_in *)addr, *ptr_v4;
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr, *ptr_v6;
const struct sockaddr_in *v4 = (const struct sockaddr_in *)addr, *ptr_v4;
const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr, *ptr_v6;

DLINK_FOREACH(node, ip_hash_table[hash_index].head)
{
@@ -94,13 +94,13 @@ ipcache_find_or_add_address(struct irc_ssaddr *addr)

if (addr->ss.ss_family == AF_INET6)
{
ptr_v6 = (struct sockaddr_in6 *)&iptr->ip;
ptr_v6 = (const struct sockaddr_in6 *)&iptr->ip;
if (!memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr)))
return iptr; /* Found entry already in hash, return it. */
}
else
{
ptr_v4 = (struct sockaddr_in *)&iptr->ip;
ptr_v4 = (const struct sockaddr_in *)&iptr->ip;
if (!memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)))
return iptr; /* Found entry already in hash, return it. */
}
@@ -124,12 +124,12 @@ ipcache_find_or_add_address(struct irc_ssaddr *addr)
* the struct ip_entry is returned to the ip_entry_heap
*/
void
ipcache_remove_address(struct irc_ssaddr *addr)
ipcache_remove_address(const struct irc_ssaddr *addr)
{
dlink_node *node = NULL;
const uint32_t hash_index = ipcache_hash_address(addr);
struct sockaddr_in *v4 = (struct sockaddr_in *)addr, *ptr_v4;
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr, *ptr_v6;
const struct sockaddr_in *v4 = (const struct sockaddr_in *)addr, *ptr_v4;
const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr, *ptr_v6;

DLINK_FOREACH(node, ip_hash_table[hash_index].head)
{
@@ -140,13 +140,13 @@ ipcache_remove_address(struct irc_ssaddr *addr)

if (addr->ss.ss_family == AF_INET6)
{
ptr_v6 = (struct sockaddr_in6 *)&iptr->ip;
ptr_v6 = (const struct sockaddr_in6 *)&iptr->ip;
if (memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr)))
continue;
}
else
{
ptr_v4 = (struct sockaddr_in *)&iptr->ip;
ptr_v4 = (const struct sockaddr_in *)&iptr->ip;
if (memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)))
continue;
}
@@ -201,7 +201,7 @@ ipcache_remove_expired_entries(void *unused)
* used in the hash.
*/
void
ipcache_get_stats(unsigned int *const number_ips_stored, uint64_t *const mem_ips_stored)
ipcache_get_stats(unsigned int *const number_ips_stored, size_t *const mem_ips_stored)
{
for (unsigned int i = 0; i < IP_HASH_SIZE; ++i)
*number_ips_stored += dlink_list_length(&ip_hash_table[i]);
@@ -70,13 +70,13 @@ strip_tabs(char *dest, const char *src, size_t len)
}

/*
* strtoken - walk through a string of tokens, using a set of separators
* strtok_r - walk through a string of tokens, using a set of separators
* argv 9/90
*
*/
#ifndef HAVE_STRTOK_R
char *
strtoken(char **save, char *str, const char *fs)
strtok_r(char *str, const char *fs, char **save)
{
char *pos = *save; /* keep last position across calls */
char *tmp = NULL;
@@ -80,6 +80,32 @@ const char *pidFileName = PPATH;
unsigned int dorehash;
unsigned int doremotd;

static int printVersion;

static struct lgetopt myopts[] =
{
{ "configfile", &ConfigGeneral.configfile,
STRING, "File to use for ircd.conf" },
{ "klinefile", &ConfigGeneral.klinefile,
STRING, "File to use for kline database" },
{ "dlinefile", &ConfigGeneral.dlinefile,
STRING, "File to use for dline database" },
{ "xlinefile", &ConfigGeneral.xlinefile,
STRING, "File to use for xline database" },
{ "resvfile", &ConfigGeneral.resvfile,
STRING, "File to use for resv database" },
{ "logfile", &logFileName,
STRING, "File to use for ircd.log" },
{ "pidfile", &pidFileName,
STRING, "File to use for process ID" },
{ "foreground", &server_state.foreground,
YESNO, "Run in foreground (don't detach)" },
{ "version", &printVersion,
YESNO, "Print version and exit" },
{ "help", NULL, USAGE, "Print this text" },
{ NULL, NULL, STRING, NULL },
};

static struct event event_cleanup_tklines =
{
.name = "cleanup_tklines",
@@ -115,63 +141,6 @@ struct event event_write_links_file =
};


/*
* print_startup - print startup information
*/
static void
print_startup(int pid)
{
printf("ircd: version %s(%s)\n", ircd_version, serno);
printf("ircd: pid %d\n", pid);
printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
: "foreground", ConfigGeneral.dpath);
}

static void
make_daemon(void)
{
int pid;

if ((pid = fork()) < 0)
{
perror("fork");
exit(EXIT_FAILURE);
}
else if (pid > 0)
{
print_startup(pid);
exit(EXIT_SUCCESS);
}

setsid();
}

static int printVersion;

static struct lgetopt myopts[] =
{
{ "configfile", &ConfigGeneral.configfile,
STRING, "File to use for ircd.conf" },
{ "klinefile", &ConfigGeneral.klinefile,
STRING, "File to use for kline database" },
{ "dlinefile", &ConfigGeneral.dlinefile,
STRING, "File to use for dline database" },
{ "xlinefile", &ConfigGeneral.xlinefile,
STRING, "File to use for xline database" },
{ "resvfile", &ConfigGeneral.resvfile,
STRING, "File to use for resv database" },
{ "logfile", &logFileName,
STRING, "File to use for ircd.log" },
{ "pidfile", &pidFileName,
STRING, "File to use for process ID" },
{ "foreground", &server_state.foreground,
YESNO, "Run in foreground (don't detach)" },
{ "version", &printVersion,
YESNO, "Print version and exit" },
{ "help", NULL, USAGE, "Print this text" },
{ NULL, NULL, STRING, NULL },
};

void
set_time(void)
{
@@ -220,7 +189,7 @@ io_loop(void)
exit_aborted_clients();
free_exited_clients();

/* Check to see whether we have to rehash the configuration .. */
/* Check to see whether we have to rehash the configuration. */
if (dorehash)
{
conf_rehash(1);
@@ -328,7 +297,7 @@ check_pidfile(const char *filename)
{
/* log(L_ERROR, "Server is already running"); */
printf("ircd: daemon is already running\n");
exit(-1);
exit(EXIT_FAILURE);
}
}

@@ -431,6 +400,37 @@ ssl_init(void)
#endif /* HAVE_LIBCRYPTO */
}

/*
* print_startup - print startup information
*/
static void
print_startup(int pid)
{
printf("ircd: version %s(%s)\n", ircd_version, serno);
printf("ircd: pid %d\n", pid);
printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
: "foreground", ConfigGeneral.dpath);
}

static void
make_daemon(void)
{
int pid;

if ((pid = fork()) < 0)
{
perror("fork");
exit(EXIT_FAILURE);
}
else if (pid > 0)
{
print_startup(pid);
exit(EXIT_SUCCESS);
}

setsid();
}

int
main(int argc, char *argv[])
{
@@ -586,13 +586,11 @@ main(int argc, char *argv[])

event_addish(&event_save_all_databases, NULL);

if (ConfigServerHide.links_delay)
if (ConfigServerHide.flatten_links_delay && event_write_links_file.active == 0)
{
event_write_links_file.when = ConfigServerHide.links_delay;
event_addish(&event_write_links_file, NULL);
event_write_links_file.when = ConfigServerHide.flatten_links_delay;
event_add(&event_write_links_file, NULL);
}
else
ConfigServerHide.links_disabled = 1;

ilog(LOG_TYPE_IRCD, "Server Ready");
io_loop();
@@ -28,7 +28,6 @@
#include "ircd_defs.h"
#include "irc_string.h"
#include "memory.h"
#include "log.h"
#include "restart.h"


@@ -107,6 +106,5 @@ outofmemory(void)
if (was_here++)
abort();

ilog(LOG_TYPE_IRCD, "Out of memory: restarting server...");
server_die("Out of Memory", SERVER_RESTART);
server_die("out of memory", SERVER_RESTART);
}
@@ -96,6 +96,37 @@ date_ctime(time_t lclock)
return buf;
}

const char *
time_dissect(time_t time)
{
static char buf[64];
unsigned int days = 0, hours = 0, minutes = 0, seconds = 0;

while (time >= 60 * 60 * 24)
{
time -= 60 * 60 * 24;
++days;
}

while (time >= 60 * 60)
{
time -= 60 * 60;
++hours;
}

while (time >= 60)
{
time -= 60;
++minutes;
}

seconds = time;

snprintf(buf, sizeof(buf), "%u day%s, %02u:%02u:%02u",
days, days == 1 ? "" : "s", hours, minutes, seconds);
return buf;
}

#ifdef HAVE_LIBCRYPTO
const char *
ssl_get_cipher(const SSL *ssl)
@@ -189,7 +189,7 @@ modules_init(void)
{
ilog(LOG_TYPE_IRCD, "Couldn't initialize the libltdl run time dynamic"
" link library. Exiting.");
exit(0);
exit(EXIT_FAILURE);
}
}

@@ -57,35 +57,35 @@ static struct
static struct Motd *
motd_create(const char *mask, const char *path)
{
struct Motd *tmp = MyCalloc(sizeof(struct Motd));
struct Motd *motd = MyCalloc(sizeof(struct Motd));

if (EmptyString(mask))
tmp->type = MOTD_UNIVERSAL;
motd->type = MOTD_UNIVERSAL;
else if (class_find(mask, 1))
tmp->type = MOTD_CLASS;
motd->type = MOTD_CLASS;
else
{
switch (parse_netmask(mask, &tmp->address, &tmp->addrbits))
switch (parse_netmask(mask, &motd->address, &motd->addrbits))
{
case HM_IPV4:
tmp->type = MOTD_IPMASKV4;
motd->type = MOTD_IPMASKV4;
break;
case HM_IPV6:
tmp->type = MOTD_IPMASKV6;
motd->type = MOTD_IPMASKV6;
break;
default: /* HM_HOST */
tmp->type = MOTD_HOSTMASK;
motd->type = MOTD_HOSTMASK;
break;
}
}

if (mask)
tmp->mask = xstrdup(mask);
motd->mask = xstrdup(mask);

tmp->path = xstrdup(path);
tmp->maxcount = MOTD_MAXLINES;
motd->path = xstrdup(path);
motd->maxcount = MOTD_MAXLINES;

return tmp;
return motd;
}

/*! brief\ This function reads a motd out of a file (if needed) and caches it.
@@ -269,25 +269,25 @@ motd_lookup(const struct Client *client_p)

/*! \brief Send the content of a MotdCache to a user.
* If \a cache is NULL, simply send ERR_NOMOTD to the client.
* \param source_p Client to send MOTD to.
* \param client_p Client to send MOTD to.
* \param cache MOTD body to send to client.
*/
static void
motd_forward(struct Client *source_p, const struct MotdCache *cache)
motd_forward(struct Client *client_p, const struct MotdCache *cache)
{
if (!cache) /* No motd to send */
{
sendto_one_numeric(source_p, &me, ERR_NOMOTD);
sendto_one_numeric(client_p, &me, ERR_NOMOTD);
return;
}

/* Send the motd */
sendto_one_numeric(source_p, &me, RPL_MOTDSTART, me.name);
sendto_one_numeric(client_p, &me, RPL_MOTDSTART, me.name);

for (unsigned int i = 0; i < cache->count; ++i)
sendto_one_numeric(source_p, &me, RPL_MOTD, cache->motd[i]);
sendto_one_numeric(client_p, &me, RPL_MOTD, cache->motd[i]);

sendto_one_numeric(source_p, &me, RPL_ENDOFMOTD);
sendto_one_numeric(client_p, &me, RPL_ENDOFMOTD);
}

/*! \brief Find the MOTD for a client and send it.
@@ -305,23 +305,23 @@ motd_send(struct Client *client_p)
* If general::short_motd is true and a matching MOTD exists for the
* user, direct the client to type /MOTD to read it. Otherwise, call
* motd_forward() for the user.
* \param source_p Client that has just connected.
* \param client_p Client that has just connected.
*/
void
motd_signon(struct Client *source_p)
motd_signon(struct Client *client_p)
{
const struct MotdCache *cache = motd_cache(motd_lookup(source_p));
const struct MotdCache *cache = motd_cache(motd_lookup(client_p));

if (!ConfigGeneral.short_motd || !cache)
motd_forward(source_p, cache);
motd_forward(client_p, cache);
else
{
sendto_one_notice(source_p, &me, ":*** Notice -- motd was last changed at %s",
sendto_one_notice(client_p, &me, ":*** Notice -- motd was last changed at %s",
date_iso8601(cache->modtime));
sendto_one_notice(source_p, &me, ":*** Notice -- Please read the motd if you haven't read it");
sendto_one_numeric(source_p, &me, RPL_MOTDSTART, me.name);
sendto_one_numeric(source_p, &me, RPL_MOTD, "*** This is the short motd ***");
sendto_one_numeric(source_p, &me, RPL_ENDOFMOTD);
sendto_one_notice(client_p, &me, ":*** Notice -- Please read the motd if you haven't read it");
sendto_one_numeric(client_p, &me, RPL_MOTDSTART, me.name);
sendto_one_numeric(client_p, &me, RPL_MOTD, "*** This is the short motd ***");
sendto_one_numeric(client_p, &me, RPL_ENDOFMOTD);
}
}

@@ -400,27 +400,27 @@ motd_clear(void)
}

/*! \brief Report list of non-default MOTDs.
* \param source_p Client requesting statistics.
* \param client_p Client requesting statistics.
*/
void
motd_report(struct Client *source_p, int parc, char *parv[])
motd_report(struct Client *client_p, int parc, char *parv[])
{
const dlink_node *node = NULL;

DLINK_FOREACH(node, MotdList.other.head)
{
const struct Motd *motd = node->data;

sendto_one_numeric(source_p, &me, RPL_STATSTLINE,
sendto_one_numeric(client_p, &me, RPL_STATSTLINE,
motd->mask, motd->path);
}
}

/*! \brief Report MOTD memory usage to a client.
* \param source_p Client requesting memory usage.
* \param client_p Client requesting memory usage.
*/
void
motd_memory_count(struct Client *source_p)
motd_memory_count(struct Client *client_p)
{
const dlink_node *node = NULL;
unsigned int mt = 0; /* Motd count */
@@ -459,7 +459,7 @@ motd_memory_count(struct Client *source_p)
mtcm += sizeof(struct MotdCache) + (MOTD_LINESIZE * (cache->count - 1));
}

sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
sendto_one_numeric(client_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"z :Motds %u(%zu) Cache %u(%zu)",
mt, mtm, mtc, mtcm);
}
@@ -61,7 +61,7 @@ static const char *const replies[] =
/* 225 */ [RPL_STATSDLINE] = "%c %s :%s",
/* 226 */ [RPL_STATSALINE] = "%s",
/* 241 */ [RPL_STATSLLINE] = "%c %s * %s %u %s",
/* 242 */ [RPL_STATSUPTIME] = ":Server Up %d days, %d:%02d:%02d",
/* 242 */ [RPL_STATSUPTIME] = ":Server Up %s",
/* 243 */ [RPL_STATSOLINE] = "%c %s@%s * %s %s %s",
/* 244 */ [RPL_STATSHLINE] = "%c %s * %s %u %s",
/* 245 */ [RPL_STATSTLINE] = "T %s %s",
@@ -137,7 +137,6 @@ static const char *const replies[] =
/* 379 */ [RPL_WHOISMODES] = "%s :is using modes %s",
/* 381 */ [RPL_YOUREOPER] = ":You have entered... the Twilight Zone!",
/* 382 */ [RPL_REHASHING] = "%s :Rehashing",
/* 386 */ [RPL_RSACHALLENGE] = ":%s",
/* 391 */ [RPL_TIME] = "%s :%s",
/* 396 */ [RPL_VISIBLEHOST] = "%s :is now your visible host",
/* 401 */ [ERR_NOSUCHNICK] = "%s :No such nick/channel",
@@ -114,7 +114,7 @@ create_resv(const char *name, const char *reason, const dlink_list *list)
}

int
resv_find_exempt(const struct Client *who, const struct MaskItem *conf)
resv_find_exempt(const struct Client *client_p, const struct MaskItem *conf)
{
const dlink_node *node = NULL;

@@ -124,25 +124,25 @@ resv_find_exempt(const struct Client *who, const struct MaskItem *conf)

if (exptr->country_id)
{
if (exptr->country_id == who->connection->country_id)
if (exptr->country_id == client_p->connection->country_id)
return 1;
}
else if (!match(exptr->name, who->name) && !match(exptr->user, who->username))
else if (!match(exptr->name, client_p->name) && !match(exptr->user, client_p->username))
{
switch (exptr->type)
{
case HM_HOST:
if (!match(exptr->host, who->host) || !match(exptr->host, who->sockhost))
if (!match(exptr->host, client_p->host) || !match(exptr->host, client_p->sockhost))
return 1;
break;
case HM_IPV4:
if (who->connection->aftype == AF_INET)
if (match_ipv4(&who->connection->ip, &exptr->addr, exptr->bits))
if (client_p->connection->aftype == AF_INET)
if (match_ipv4(&client_p->connection->ip, &exptr->addr, exptr->bits))
return 1;
break;
case HM_IPV6:
if (who->connection->aftype == AF_INET6)
if (match_ipv6(&who->connection->ip, &exptr->addr, exptr->bits))
if (client_p->connection->aftype == AF_INET6)
if (match_ipv6(&client_p->connection->ip, &exptr->addr, exptr->bits))
return 1;
break;
default:
@@ -65,46 +65,4 @@ binary_to_hex(const unsigned char *bin, char *hex, unsigned int length)

*hex = '\0';
}

int
get_randomness(unsigned char *buf, int length)
{
return RAND_bytes(buf, length);
}

int
generate_challenge(char **r_challenge, char **r_response, RSA *rsa)
{
unsigned char secret[32], *tmp = NULL;
unsigned long length = 0;
int ret = -1;

if (!rsa)
return -1;

if (!get_randomness(secret, 32))
{
report_crypto_errors();
return -1;
}

*r_response = MyCalloc(65);
binary_to_hex(secret, *r_response, 32);

length = RSA_size(rsa);
tmp = MyCalloc(length);
ret = RSA_public_encrypt(32, secret, tmp, rsa, RSA_PKCS1_PADDING);

*r_challenge = MyCalloc((length << 1) + 1);
binary_to_hex(tmp, *r_challenge, length);
MyFree(tmp);

if (ret < 0)
{
report_crypto_errors();
return -1;
}

return 0;
}
#endif
@@ -57,9 +57,9 @@ init_netio(void)

if ((fd = open("/dev/poll", O_RDWR)) < 0)
{
ilog(LOG_TYPE_IRCD, "init_netio: Couldn't open /dev/poll - %d: %s",
errno, strerror(errno));
exit(115); /* Whee! */
ilog(LOG_TYPE_IRCD, "init_netio: couldn't open /dev/poll: %s",
strerror(errno));
exit(EXIT_FAILURE); /* Whee! */
}

fd_open(&dpfd, fd, 0, "/dev/poll file descriptor");
@@ -155,9 +155,8 @@ comm_select(void)

if (num < 0)
{
#ifdef HAVE_USLEEP
usleep(50000); /* avoid 99% CPU in comm_select */
#endif
const struct timespec req = { .tv_sec = 0, .tv_nsec = 50000000 };
nanosleep(&req, NULL); /* Avoid 99% CPU in comm_select */
return;
}

@@ -49,9 +49,9 @@ init_netio(void)

if ((fd = epoll_create(hard_fdlimit)) < 0)
{
ilog(LOG_TYPE_IRCD, "init_netio: Couldn't open epoll fd - %d: %s",
errno, strerror(errno));
exit(115); /* Whee! */
ilog(LOG_TYPE_IRCD, "init_netio: couldn't open epoll fd: %s",
strerror(errno));
exit(EXIT_FAILURE); /* Whee! */
}

fd_open(&efd, fd, 0, "epoll file descriptor");
@@ -134,9 +134,8 @@ comm_select(void)

if (num < 0)
{
#ifdef HAVE_USLEEP
usleep(50000); /* avoid 99% CPU in comm_select */
#endif
const struct timespec req = { .tv_sec = 0, .tv_nsec = 50000000 };
nanosleep(&req, NULL); /* Avoid 99% CPU in comm_select */
return;
}

@@ -52,8 +52,8 @@ init_netio(void)

if ((fd = kqueue()) < 0)
{
ilog(LOG_TYPE_IRCD, "init_netio: Couldn't open kqueue fd!");
exit(115); /* Whee! */
ilog(LOG_TYPE_IRCD, "init_netio: couldn't open kqueue fd: %s", strerror(errno));
exit(EXIT_FAILURE); /* Whee! */
}

fd_open(&kqfd, fd, 0, "kqueue() file descriptor");
@@ -157,9 +157,8 @@ comm_select(void)

if (num < 0)
{
#ifdef HAVE_USLEEP
usleep(50000); /* avoid 99% CPU in comm_select */
#endif
const struct timespec req = { .tv_sec = 0, .tv_nsec = 50000000 };
nanosleep(&req, NULL); /* Avoid 99% CPU in comm_select */
return;
}

@@ -156,9 +156,8 @@ comm_select(void)

if (num < 0)
{
#ifdef HAVE_USLEEP
usleep(50000); /* avoid 99% CPU in comm_select */
#endif
const struct timespec req = { .tv_sec = 0, .tv_nsec = 50000000 };
nanosleep(&req, NULL); /* Avoid 99% CPU in comm_select */
return;
}

@@ -69,9 +69,16 @@ write_links_file(void *unused)
dlink_node *node = NULL, *node_next = NULL;
char buff[IRCD_BUFSIZE] = "";

if ((file = fopen(LIPATH, "w")) == NULL)
if (EmptyString(ConfigServerHide.flatten_links_file))
return;

if ((file = fopen(ConfigServerHide.flatten_links_file, "w")) == NULL)
{
ilog(LOG_TYPE_IRCD, "Couldn't open \"%s\": %s", ConfigServerHide.flatten_links_file,
strerror(errno));
return;
}

DLINK_FOREACH_SAFE(node, node_next, flatten_links.head)
{
dlinkDelete(node, &flatten_links);
@@ -118,8 +125,15 @@ read_links_file(void)
char *p = NULL;
char buff[IRCD_BUFSIZE] = "";

if ((file = fopen(LIPATH, "r")) == NULL)
if (EmptyString(ConfigServerHide.flatten_links_file))
return;

if ((file = fopen(ConfigServerHide.flatten_links_file, "r")) == NULL)
{
ilog(LOG_TYPE_IRCD, "Couldn't open \"%s\": %s", ConfigServerHide.flatten_links_file,
strerror(errno));
return;
}

while (fgets(buff, sizeof(buff), file))
{
@@ -242,7 +256,6 @@ try_connections(void *unused)
{
dlink_node *node = NULL;

/* TODO: change this to set active flag to 0 when added to event! --Habeeb */
if (GlobalSetOptions.autoconn == 0)
return;

@@ -252,13 +265,12 @@ try_connections(void *unused)

assert(conf->type == CONF_SERVER);

/* Also when already connecting! (update holdtimes) --SRB
*/
/* Also when already connecting! (update holdtimes) --SRB */
if (!conf->port || !IsConfAllowAutoConn(conf))
continue;


/* Skip this entry if the use of it is still on hold until
/*
* Skip this entry if the use of it is still on hold until
* future. Otherwise handle this entry (and set it on hold
* until next time). Will reset only hold times, if already
* made one successfull connection... [this algorithm is
@@ -353,8 +365,6 @@ check_server(const char *name, struct Client *client_p)

error = -3;

/* XXX: Fix me for IPv6 */
/* XXX sockhost is the IPv4 ip as a string */
if (!match(conf->host, client_p->host) ||
!match(conf->host, client_p->sockhost))
{
@@ -592,8 +602,9 @@ serv_connect(struct MaskItem *conf, struct Client *by)
return 0;
}

/* Make sure this server isn't already connected
* Note: conf should ALWAYS be a valid C: line
/*
* Make sure this server isn't already connected.
* Note: conf should ALWAYS be a valid connect {} block
*/
if ((client_p = hash_find_server(conf->name)))
{
@@ -619,7 +630,7 @@ serv_connect(struct MaskItem *conf, struct Client *by)
/* We already converted the ip once, so lets use it - stu */
strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost));

/* create a socket for the server connection */
/* Create a socket for the server connection */
if (comm_open(&client_p->connection->fd, conf->addr.ss.ss_family, SOCK_STREAM, 0, NULL) < 0)
{
/* Eek, failure to create the socket */
@@ -630,11 +641,12 @@ serv_connect(struct MaskItem *conf, struct Client *by)
return 0;
}

/* servernames are always guaranteed under HOSTLEN chars */
fd_note(&client_p->connection->fd, "Server: %s", conf->name);
/* Server names are always guaranteed under HOSTLEN chars */
fd_note(&client_p->connection->fd, "Server: %s", client_p->name);

/* Attach config entries to client here rather than in
* serv_connect_callback(). This to avoid null pointer references.
/*
* Attach config entries to client here rather than in serv_connect_callback().
* This to avoid null pointer references.
*/
if (!attach_connect_block(client_p, conf->name, conf->host))
{
@@ -649,9 +661,10 @@ serv_connect(struct MaskItem *conf, struct Client *by)
return 0;
}

/* at this point we have a connection in progress and C/N lines
* attached to the client, the socket info should be saved in the
* client and it should either be resolved or have a valid address.
/*
* At this point we have a connection in progress and a connect {} block
* attached to the client, the socket info should be saved in the client
* and it should either be resolved or have a valid address.
*
* The socket has been connected or connect is in progress.
*/
@@ -263,11 +263,7 @@ introduce_client(struct Client *source_p)
static void
user_welcome(struct Client *source_p)
{
#ifdef BUILD_DATE
static const char built_date[] = BUILD_DATE;
#else
static const char built_date[] = __DATE__ " at " __TIME__;
#endif

#ifdef HAVE_LIBCRYPTO
if (HasFlag(source_p, FLAGS_SSL))
@@ -777,7 +773,7 @@ user_set_hostmask(struct Client *target_p, const char *hostname, const int what)
userhost_add(target_p->username, target_p->host, !MyConnect(target_p));
AddFlag(target_p, FLAGS_USERHOST);

if (MyClient(target_p))
if (MyConnect(target_p))
{
sendto_one_numeric(target_p, &me, RPL_VISIBLEHOST, target_p->host);
clear_ban_cache_client(target_p);
@@ -836,50 +832,3 @@ user_set_hostmask(struct Client *target_p, const char *hostname, const int what)
target_p->name, target_p->username,
target_p->host, target_p->away);
}

/*! \brief Blindly opers up given source_p, using conf info.
* All checks on passwords have already been done.
* \param source_p Pointer to given client to oper
*/
void
user_oper_up(struct Client *source_p)
{
const unsigned int old = source_p->umodes;
const struct MaskItem *const conf = source_p->connection->confs.head->data;

++Count.oper;
SetOper(source_p);

if (conf->modes)
AddUMode(source_p, conf->modes);
else if (ConfigGeneral.oper_umodes)
AddUMode(source_p, ConfigGeneral.oper_umodes);

if (!(old & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE))
++Count.invisi;
if ((old & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
--Count.invisi;

assert(dlinkFind(&oper_list, source_p) == NULL);
dlinkAdd(source_p, make_dlink_node(), &oper_list);

AddOFlag(source_p, conf->port);

if (HasOFlag(source_p, OPER_FLAG_ADMIN))
AddUMode(source_p, UMODE_ADMIN);

if (!EmptyString(conf->whois))
{
client_attach_svstag(source_p, RPL_WHOISOPERATOR, "+", conf->whois);
sendto_server(source_p, 0, 0, ":%s SVSTAG %s %lu %u + :%s",
me.id, source_p->id, (unsigned long)source_p->tsinfo,
RPL_WHOISOPERATOR, conf->whois);
}

sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "%s is now an operator",
get_oper_name(source_p));
sendto_server(NULL, 0, 0, ":%s GLOBOPS :%s is now an operator",
me.id, get_oper_name(source_p));
send_umode_out(source_p, old);
sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
}
@@ -65,7 +65,7 @@ watch_init(void)
/*! \brief Counts up memory used by watch list headers
*/
void
watch_count_memory(unsigned int *const count, uint64_t *const bytes)
watch_count_memory(unsigned int *const count, size_t *const bytes)
{
for (unsigned int i = 0; i < HASHSIZE; ++i)
(*count) += dlink_list_length(&watchTable[i]);
@@ -48,42 +48,42 @@ void
whowas_add_history(struct Client *client_p, const int online)
{
static unsigned int whowas_next = 0;
struct Whowas *const who = &WHOWAS[whowas_next];
struct Whowas *const whowas = &WHOWAS[whowas_next];

assert(IsClient(client_p));

if (++whowas_next == NICKNAMEHISTORYLENGTH)
whowas_next = 0;

if (who->hashv != -1)
if (whowas->hashv != -1)
{
if (who->online)
dlinkDelete(&who->cnode, &who->online->whowas);
if (whowas->online)
dlinkDelete(&whowas->cnode, &whowas->online->whowas);

dlinkDelete(&who->tnode, &WHOWASHASH[who->hashv]);
dlinkDelete(&whowas->tnode, &WHOWASHASH[whowas->hashv]);
}

who->hashv = strhash(client_p->name);
who->shide = IsHidden(client_p->servptr) != 0;
who->logoff = CurrentTime;
whowas->hashv = strhash(client_p->name);
whowas->shide = IsHidden(client_p->servptr) != 0;
whowas->logoff = CurrentTime;

strlcpy(who->account, client_p->account, sizeof(who->account));
strlcpy(who->name, client_p->name, sizeof(who->name));
strlcpy(who->username, client_p->username, sizeof(who->username));
strlcpy(who->hostname, client_p->host, sizeof(who->hostname));
strlcpy(who->sockhost, client_p->sockhost, sizeof(who->sockhost));
strlcpy(who->realname, client_p->info, sizeof(who->realname));
strlcpy(who->servername, client_p->servptr->name, sizeof(who->servername));
strlcpy(whowas->account, client_p->account, sizeof(whowas->account));
strlcpy(whowas->name, client_p->name, sizeof(whowas->name));
strlcpy(whowas->username, client_p->username, sizeof(whowas->username));
strlcpy(whowas->hostname, client_p->host, sizeof(whowas->hostname));
strlcpy(whowas->sockhost, client_p->sockhost, sizeof(whowas->sockhost));
strlcpy(whowas->realname, client_p->info, sizeof(whowas->realname));
strlcpy(whowas->servername, client_p->servptr->name, sizeof(whowas->servername));

if (online)
{
who->online = client_p;
dlinkAdd(who, &who->cnode, &client_p->whowas);
whowas->online = client_p;
dlinkAdd(whowas, &whowas->cnode, &client_p->whowas);
}
else
who->online = NULL;
whowas->online = NULL;

dlinkAdd(who, &who->tnode, &WHOWASHASH[who->hashv]);
dlinkAdd(whowas, &whowas->tnode, &WHOWASHASH[whowas->hashv]);
}

void
@@ -93,10 +93,10 @@ whowas_off_history(struct Client *client_p)

DLINK_FOREACH_SAFE(node, node_next, client_p->whowas.head)
{
struct Whowas *temp = node->data;
struct Whowas *whowas = node->data;

temp->online = NULL;
dlinkDelete(&temp->cnode, &client_p->whowas);
whowas->online = NULL;
dlinkDelete(&whowas->cnode, &client_p->whowas);
}
}

@@ -109,26 +109,26 @@ whowas_get_history(const char *nick, time_t timelimit)

DLINK_FOREACH(node, WHOWASHASH[strhash(nick)].head)
{
struct Whowas *temp = node->data;
struct Whowas *whowas = node->data;

if (temp->logoff < timelimit)
if (whowas->logoff < timelimit)
continue;
if (irccmp(nick, temp->name))
if (irccmp(nick, whowas->name))
continue;
return temp->online;
return whowas->online;
}

return NULL;
}

void
whowas_count_memory(unsigned int *const count, uint64_t *const bytes)
whowas_count_memory(unsigned int *const count, size_t *const bytes)
{
const struct Whowas *tmp = &WHOWAS[0];
const struct Whowas *whowas = &WHOWAS[0];

for (unsigned int i = 0; i < NICKNAMEHISTORYLENGTH; ++i, ++tmp)
for (unsigned int i = 0; i < NICKNAMEHISTORYLENGTH; ++i, ++whowas)
{
if (tmp->hashv != -1)
if (whowas->hashv != -1)
{
(*count)++;
(*bytes) += sizeof(struct Whowas);
@@ -1,10 +1,6 @@
AUTOMAKE_OPTIONS = foreign

bin_PROGRAMS = mkpasswd
if ENABLE_SSL
bin_PROGRAMS += respond
respond_SOURCES = respond.c
endif
mkpasswd_SOURCES = mkpasswd.c

install-exec-hook:
@@ -88,8 +88,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = mkpasswd$(EXEEXT) $(am__EXEEXT_1)
@ENABLE_SSL_TRUE@am__append_1 = respond
bin_PROGRAMS = mkpasswd$(EXEEXT)
subdir = tools
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \
@@ -117,7 +116,6 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@ENABLE_SSL_TRUE@am__EXEEXT_1 = respond$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_mkpasswd_OBJECTS = mkpasswd.$(OBJEXT)
@@ -127,10 +125,6 @@ AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
am__respond_SOURCES_DIST = respond.c
@ENABLE_SSL_TRUE@am_respond_OBJECTS = respond.$(OBJEXT)
respond_OBJECTS = $(am_respond_OBJECTS)
respond_LDADD = $(LDADD)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -165,8 +159,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(mkpasswd_SOURCES) $(respond_SOURCES)
DIST_SOURCES = $(mkpasswd_SOURCES) $(am__respond_SOURCES_DIST)
SOURCES = $(mkpasswd_SOURCES)
DIST_SOURCES = $(mkpasswd_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -336,7 +330,6 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
@ENABLE_SSL_TRUE@respond_SOURCES = respond.c
mkpasswd_SOURCES = mkpasswd.c
all: all-am

@@ -425,18 +418,13 @@ mkpasswd$(EXEEXT): $(mkpasswd_OBJECTS) $(mkpasswd_DEPENDENCIES) $(EXTRA_mkpasswd
@rm -f mkpasswd$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(mkpasswd_OBJECTS) $(mkpasswd_LDADD) $(LIBS)

respond$(EXEEXT): $(respond_OBJECTS) $(respond_DEPENDENCIES) $(EXTRA_respond_DEPENDENCIES)
@rm -f respond$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(respond_OBJECTS) $(respond_LDADD) $(LIBS)

mostlyclean-compile:
-rm -f *.$(OBJEXT)

distclean-compile:
-rm -f *.tab.c

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkpasswd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/respond.Po@am__quote@

.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -2,7 +2,4 @@ $Id$

A directory of support programs for ircd.

mkpasswd.c - makes password for operator {} blocks
respond.c - a tool to generate an RSA response to the challenge asked
by the server, and a tool to generate a keypair for the
C/R system
mkpasswd.c - makes password for operator {} blocks
@@ -2,47 +2,27 @@ $Id$

This is documentation for the mkpasswd.c included in ircd-hybrid.

This version of mkpasswd can create DES, Extended DES, Blowfish, MD5,
SHA-256 and SHA-512 passwords, with either randomly generated or user
provided salts.
This version of mkpasswd can create Blowfish, SHA-256 and SHA-512
passwords, with either randomly generated or user provided salts.

Options:
-6 - Create a SHA-512 password
-5 - Create a SHA-256 password
-m - Create an MD5 password
-6 - Create a SHA-512 password
-b - Create a Blowfish password
-d - Create a DES password
-e - Create an Extended DES password
-l - Specify the length of a random MD5 salt
-r - Specify a number of rounds for a Blowfish or Extended DES password
-R - Specify a raw salt passed directly to crypt()
-l - Specify the length of a random SHA-256/SHA-512 or Blowfish salt
-r - Specify a number of rounds for a Blowfish password
-p - Specify the plaintext password at the command line
-s - Specify the salt at the command line
-R - Specify a raw salt passed directly to crypt()
-h - Get help

If no parameter is given, it will create an MD5 password with a randomly
generated salt and prompting for the password (without echo).

A DES salt is a pair of alphanumeric characters ('.' and '/' are permitted
as well), such as 'a4' or 'Td'.

An MD5 salt consists of up to 16 (though most implementations limit you to
8) alphanumeric characters (plus '.' and '/'),
such as 'tGd' or 'J6d4dfG'.

Known bugs:
Blowfish (on OpenBSD) is not yet supported
The encryption algorithms supported depend on your system's crypt()
implementation.
The maximum length of an MD5 salt is limited to your system's crypt()
implementation, typically 8.
implementation.

Supported Platforms (Known and tested):
Linux glibc (SHA-256/SHA-512 since glibc 2.7, DES and MD5)
FreeBSD 3.x (DES (MD5 maybe))
FreeBSD 4.x (DES and MD5)
Solaris 2.5-2.6 (DES only)
OpenBSD 2.7 (don't link with -lcrypt) (DES and MD5, no Blowfish support)
Mac OS-X (Darwin) (don't link with -lcrypt) (DES only)
Linux glibc 2.7+ (SHA-256/SHA-512)
FreeBSD 10.2 (SHA-256/SHA-512, Blowfish)
OpenBSD 5.8 (Blowfish)

Other systems probably work, but they haven't been amply tested.

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.