From: Otto Moerbeek Date: Thu, 14 Feb 2019 15:50:29 +0000 (+0100) Subject: Add back call to srandom() in common startup. srandom() is still used X-Git-Tag: dnsdist-1.4.0-alpha1~54^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8342eb4f20423a06f56b29f48f9dd2ea440ca77a;p=thirdparty%2Fpdns.git Add back call to srandom() in common startup. srandom() is still used and needs seeding (even if the seeding itself is predicable) --- diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index f4959a6115..8f61cc4265 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 b77d7a8080..9c9af5283d 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 2b0ea3c06a..7ba9b2fd35 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 );