]> granicus.if.org Git - pdns/commitdiff
Add back call to srandom() in common startup. srandom() is still used
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 14 Feb 2019 15:50:29 +0000 (16:50 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 14 Feb 2019 15:50:29 +0000 (16:50 +0100)
and needs seeding (even if the seeding itself is predicable)

pdns/common_startup.cc
pdns/unix_utility.cc
pdns/utility.hh

index f4959a6115c86a53cf55c7a81bfa464dc071393a..8f61cc4265b49d7b507fad7073a4cf57d48eaf06 100644 (file)
@@ -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"]);      
index b77d7a80809bb943cde6b74741287869af2b1a72..9c9af5283d2437a24af4c5714385bfae812a3a84 100644 (file)
@@ -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 )
index 2b0ea3c06a75251284dc7c27fdd915dd3d6ee4b1..7ba9b2fd353edc69d980a6e146f10c97316fff0c 100644 (file)
@@ -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 );