-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 \
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@
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
#../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 \
::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)
}
string stripDot(const string& dom);
-
+void seedRandom(const string& source);
#endif
return "ok - loaded script from '"+fname+"'\n";
}
-void seedRandom(const string& source);
+
int serviceMain(int argc, char*argv[])
{
}
#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)
{
--- /dev/null
+#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);
+}
// we really need to do work - either standalone or as an instance
+ seedRandom(::arg()["entropy-source"]);
+
loadModules();
BackendMakers().launch(::arg()["launch"]); // vrooooom!