]> granicus.if.org Git - pdns/commitdiff
Utility::random() and srandom() is not used anymore.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 12 Feb 2019 13:06:52 +0000 (14:06 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 12 Feb 2019 13:52:18 +0000 (14:52 +0100)
modules/randombackend/randombackend.cc
pdns/common_startup.cc
pdns/unix_utility.cc
pdns/utility.hh

index 6cec85188deaabd01dded97d2090a87f69ce88f3..525beb897ba1c7a2c80eb64a602eaba1b4cc3294 100644 (file)
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
-#include "pdns/utility.hh"
 #include "pdns/dnsbackend.hh"
 #include "pdns/dns.hh"
 #include "pdns/dnsbackend.hh"
 #include "pdns/dnspacket.hh"
+#include "pdns/dns_random.hh"
 #include "pdns/pdnsexception.hh"
 #include "pdns/logger.hh"
 #include "pdns/version.hh"
@@ -59,7 +59,7 @@ public:
     } else if (qdomain == d_ourname) {
       if(type.getCode() == QType::A || type.getCode() == QType::ANY) {
         ostringstream os;
-        os<<Utility::random()%256<<"."<<Utility::random()%256<<"."<<Utility::random()%256<<"."<<Utility::random()%256;
+        os<<dns_random(256)<<"."<<dns_random(256)<<"."<<dns_random(256)<<"."<<dns_random(256);
         d_answer=os.str(); // our random ip address
       } else {
         d_answer="";
index ccdfbe8b25b429e9e29cc7e7e1e45e6d14ce7836..f4959a6115c86a53cf55c7a81bfa464dc071393a 100644 (file)
@@ -496,9 +496,7 @@ static void triggerLoadOfLibraries()
 
 void mainthread()
 {
-   Utility::srandom(time(0) ^ getpid());
-
-   int newgid=0;      
+   int newgid=0;
    if(!::arg()["setgid"].empty()) 
      newgid=Utility::makeGidNumeric(::arg()["setgid"]);      
    int newuid=0;      
index f06d90cb602df11353bd0350a2ebd3772600a68b..b77d7a80809bb943cde6b74741287869af2b1a72 100644 (file)
@@ -213,19 +213,6 @@ int Utility::makeUidNumeric(const string &username)
 }
 
 
-// Returns a random number.
-long int Utility::random( void )
-{
-  return rand();
-}
-
-// 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 2672a1826135fc973ff5b6f47882adae199a04e8..2b0ea3c06a75251284dc7c27fdd915dd3d6ee4b1 100644 (file)
@@ -128,11 +128,6 @@ public:
 
   //! Writes a vector.
   static int writev( Utility::sock_t socket, const iovec *vector, size_t count );
-  //! Returns a random number.
-  static long int random( void );
-
-  //! Sets the random seed.
-  static void srandom( unsigned int seed );
 
   //! Drops the program's group privileges.
   static void dropGroupPrivs( int uid, int gid );