From 8342eb4f20423a06f56b29f48f9dd2ea440ca77a Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 14 Feb 2019 16:50:29 +0100 Subject: [PATCH] Add back call to srandom() in common startup. srandom() is still used and needs seeding (even if the seeding itself is predicable) --- pdns/common_startup.cc | 2 ++ pdns/unix_utility.cc | 5 +++++ pdns/utility.hh | 3 +++ 3 files changed, 10 insertions(+) diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index f4959a611..8f61cc426 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -496,6 +496,8 @@ static void triggerLoadOfLibraries() void mainthread() { + Utility::srandom(time(0) ^ getpid()); + int newgid=0; if(!::arg()["setgid"].empty()) newgid=Utility::makeGidNumeric(::arg()["setgid"]); diff --git a/pdns/unix_utility.cc b/pdns/unix_utility.cc index b77d7a808..9c9af5283 100644 --- a/pdns/unix_utility.cc +++ b/pdns/unix_utility.cc @@ -212,6 +212,11 @@ int Utility::makeUidNumeric(const string &username) return newuid; } +// Sets the random seed. +void Utility::srandom( unsigned int seed ) +{ + ::srandom(seed); +} // Writes a vector. int Utility::writev(int socket, const iovec *vector, size_t count ) diff --git a/pdns/utility.hh b/pdns/utility.hh index 2b0ea3c06..7ba9b2fd3 100644 --- a/pdns/utility.hh +++ b/pdns/utility.hh @@ -129,6 +129,9 @@ public: //! Writes a vector. static int writev( Utility::sock_t socket, const iovec *vector, size_t count ); + //! Sets the random seed. + static void srandom( unsigned int seed ); + //! Drops the program's group privileges. static void dropGroupPrivs( int uid, int gid ); -- 2.40.0