/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors.
+ * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "defines.h"
#include "conn.h"
+#include "class.h"
#include "conf-ssl.h"
#include "channel.h"
#include "conf.h"
static void Fill_Version PARAMS(( void ));
+static void Random_Init PARAMS(( void ));
+
static void Setup_FDStreams PARAMS(( int fd ));
static bool NGIRCd_Init PARAMS(( bool ));
NGIRCd_SignalRestart = false;
NGIRCd_SignalQuit = false;
+ Random_Init();
+
/* Initialize modules, part I */
Log_Init( ! NGIRCd_NoDaemon );
Conf_Init( );
Channel_Init( );
Client_Init( );
Conn_Init( );
+ Class_Init( );
if (!io_library_init(CONNECTION_POOL)) {
Log(LOG_ALERT, "Fatal: Cannot initialize IO routines: %s", strerror(errno));
Conn_Exit( );
Client_Exit( );
Channel_Exit( );
+ Class_Exit( );
Log_Exit( );
}
Pidfile_Delete( );
Show_Version( void )
{
puts( NGIRCd_Version );
- puts( "Copyright (c)2001-2011 Alexander Barton (<alex@barton.de>) and Contributors." );
+ puts( "Copyright (c)2001-2012 Alexander Barton (<alex@barton.de>) and Contributors." );
puts( "Homepage: <http://ngircd.barton.de/>\n" );
puts( "This is free software; see the source for copying conditions. There is NO" );
puts( "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." );
} /* NGIRCd_getNobodyID */
+static bool
+Random_Init_Kern(const char *file)
+{
+ unsigned int seed;
+ bool ret = false;
+ int fd = open(file, O_RDONLY);
+ if (fd >= 0) {
+ if (read(fd, &seed, sizeof(seed)) == sizeof(seed))
+ ret = true;
+ close(fd);
+ srand(seed);
+ }
+ return ret;
+}
+
+/**
+ * Initialize libc rand(3) number generator
+ */
+static void
+Random_Init(void)
+{
+ if (Random_Init_Kern("/dev/urandom"))
+ return;
+ if (Random_Init_Kern("/dev/random"))
+ return;
+ if (Random_Init_Kern("/dev/arandom"))
+ return;
+ srand(rand() ^ (unsigned)getpid() ^ (unsigned)time(NULL));
+}
+
+
/**
* Initialize ngIRCd daemon.
*
/* Detach stdin, stdout and stderr */
Setup_FDStreams(fd);
- if (fd > 2) {
+ if (fd > 2)
close(fd);
- fd = -1;
- }
}
pid = getpid();