From a28a204ace2d98152e055a05615b58967576bc9c Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Fri, 8 Aug 2008 13:54:36 +0000 Subject: [PATCH] hook up dns urandom for auth server too git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1256 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/Makefile.am | 10 ++++++---- pdns/common_startup.cc | 1 + pdns/misc.hh | 2 +- pdns/pdns_recursor.cc | 31 +------------------------------ pdns/randomhelper.cc | 36 ++++++++++++++++++++++++++++++++++++ pdns/receiver.cc | 2 ++ 6 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 pdns/randomhelper.cc diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 451acee807..1dc2203c25 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -1,4 +1,4 @@ -AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ +AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ # -I/usr/include/lua5.1 AM_CPPFLAGS=-Ibackends/bind @THREADFLAGS@ EXTRA_DIST = docs/Makefile docs/expand \ @@ -40,7 +40,8 @@ base64.cc sillyrecords.cc \ base64.hh zoneparser-tng.cc dnsrecords.cc dnswriter.cc \ rcpgenerator.cc dnsparser.cc dns_random.hh aes/aescpp.h \ aes/aescrypt.c aes/aes.h aes/aeskey.c aes/aes_modes.c aes/aesopt.h \ -aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc +aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc \ +randomhelper.cc # pdns_server_LDFLAGS= @moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@ @@ -120,7 +121,8 @@ mtasker.hh syncres.hh recursor_cache.cc recursor_cache.hh dnsparser.cc \ dnswriter.cc dnswriter.hh dnsrecords.cc dnsrecords.hh rcpgenerator.cc rcpgenerator.hh \ base64.cc base64.hh zoneparser-tng.cc zoneparser-tng.hh rec_channel.cc rec_channel.hh \ rec_channel_rec.cc selectmplexer.cc epollmplexer.cc sillyrecords.cc htimer.cc htimer.hh \ -aes/dns_random.cc aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c +aes/dns_random.cc aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c \ +lua-pdns-recursor.cc lua-pdns-recursor.hh randomhelper.cc if NEDMALLOC pdns_recursor_SOURCES += ext/nedmalloc/malloc.c @@ -128,7 +130,7 @@ endif #../modules/gmysqlbackend/smysql.cc -pdns_recursor_LDFLAGS= +pdns_recursor_LDFLAGS= # -llua5.1 pdns_recursor_LDADD= pdns_control_SOURCES=dynloader.cc dynmessenger.cc arguments.cc logger.cc statbag.cc \ diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 826b55fd33..8cd7c45338 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -125,6 +125,7 @@ void declareArguments() ::arg().set("setgid","If set, change group id to this gid for more security")=""; ::arg().set("max-cache-entries", "Maximum number of cache entries")="1000000"; + ::arg().set("entropy-source", "If set, read entropy from this file")="/dev/urandom"; } void declareStats(void) diff --git a/pdns/misc.hh b/pdns/misc.hh index 77ed7392a3..471a745edb 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -383,5 +383,5 @@ inline string toCanonic(const string& zone, const string& domain) } string stripDot(const string& dom); - +void seedRandom(const string& source); #endif diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index fa11c5b9db..7bdd242c9a 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1655,7 +1655,7 @@ string doReloadLuaScript(vector::const_iterator begin, vector::c return "ok - loaded script from '"+fname+"'\n"; } -void seedRandom(const string& source); + int serviceMain(int argc, char*argv[]) { @@ -1910,35 +1910,6 @@ void doWindowsServiceArguments(RecursorService& recursor) } #endif -void seedRandom(const string& source) -{ - L< +#include +#include +#include "dns_random.hh" + +void seedRandom(const string& source) +{ + L<