]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
hook up dns urandom for auth server too
authorBert Hubert <bert.hubert@netherlabs.nl>
Fri, 8 Aug 2008 13:54:36 +0000 (13:54 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Fri, 8 Aug 2008 13:54:36 +0000 (13:54 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1256 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/Makefile.am
pdns/common_startup.cc
pdns/misc.hh
pdns/pdns_recursor.cc
pdns/randomhelper.cc [new file with mode: 0644]
pdns/receiver.cc

index 451acee807155c0b41053e27f2ba9c9ac37533ed..1dc2203c25f5be8d6217e7f22bd2e7bdb8638c31 100644 (file)
@@ -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 \
index 826b55fd33db9037ac0693f8f59040072143992b..8cd7c453388dbd7ddbd3eabd435b343a3856c759 100644 (file)
@@ -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)
index 77ed7392a329a955711d1c6ee6a36c670ae1a229..471a745edba4bdf33c7e9fa0b43e07581e2114e2 100644 (file)
@@ -383,5 +383,5 @@ inline string toCanonic(const string& zone, const string& domain)
 }
 
 string stripDot(const string& dom);
-
+void seedRandom(const string& source);
 #endif
index fa11c5b9dbfb48420fdb7ab13da6910d5f42237b..7bdd242c9ac3838cde6b3975c3695fafc69dc6dc 100644 (file)
@@ -1655,7 +1655,7 @@ string doReloadLuaScript(vector<string>::const_iterator begin, vector<string>::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<<Logger::Warning<<"Reading random entropy from '"<<source<<"'"<<endl;
-
-  int fd=open(source.c_str(), O_RDONLY);
-  if(fd < 0) {
-    L<<Logger::Error<<"Unable to open source of random '"<<source<<"': "<<stringerror()<<endl;
-    exit(EXIT_FAILURE);
-  }
-  char seed[16];
-  int ret;
-  int pos=0;
-  while(pos!=sizeof(seed)) {
-    ret = read(fd, seed+pos, sizeof(seed)-pos);
-    if(ret < 0) { 
-      L<<Logger::Error<<"Unable to read random seed from "<<source<<": "<<stringerror()<<endl;
-      close(fd);
-      exit(EXIT_FAILURE);
-    }
-    if(!ret) {
-      L<<Logger::Error<<"Unable to read random seed from "<<source<<": end of file"<<endl;
-      close(fd);
-      exit(EXIT_FAILURE);
-    }
-    pos+=ret;
-  }
-  close(fd);
-  dns_random_init(seed);
-}
 
 int main(int argc, char **argv) 
 {
diff --git a/pdns/randomhelper.cc b/pdns/randomhelper.cc
new file mode 100644 (file)
index 0000000..89c1f66
--- /dev/null
@@ -0,0 +1,36 @@
+#include "misc.hh"
+#include "logger.hh"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "dns_random.hh"                     
+
+void seedRandom(const string& source)
+{
+  L<<Logger::Warning<<"Reading random entropy from '"<<source<<"'"<<endl;
+
+  int fd=open(source.c_str(), O_RDONLY);
+  if(fd < 0) {
+    L<<Logger::Error<<"Unable to open source of random '"<<source<<"': "<<stringerror()<<endl;
+    exit(EXIT_FAILURE);
+  }
+  char seed[16];
+  int ret;
+  int pos=0;
+  while(pos!=sizeof(seed)) {
+    ret = read(fd, seed+pos, sizeof(seed)-pos);
+    if(ret < 0) { 
+      L<<Logger::Error<<"Unable to read random seed from "<<source<<": "<<stringerror()<<endl;
+      close(fd);
+      exit(EXIT_FAILURE);
+    }
+    if(!ret) {
+      L<<Logger::Error<<"Unable to read random seed from "<<source<<": end of file"<<endl;
+      close(fd);
+      exit(EXIT_FAILURE);
+    }
+    pos+=ret;
+  }
+  close(fd);
+  dns_random_init(seed);
+}
index 33cd807b19b54b5555174aaf6a31a0cc0bd44419..0b775294338cd3120e7bbb1ea92ad21c574fee62 100644 (file)
@@ -458,6 +458,8 @@ int main(int argc, char **argv)
     
     // we really need to do work - either standalone or as an instance
     
+    seedRandom(::arg()["entropy-source"]);
+    
     loadModules();
     BackendMakers().launch(::arg()["launch"]); // vrooooom!