]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
errno review wip
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 17 Jun 2019 09:12:07 +0000 (11:12 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 18 Jun 2019 13:44:53 +0000 (15:44 +0200)
12 files changed:
pdns/bpf-filter.cc
pdns/capabilities.cc
pdns/dns_random.cc
pdns/dnsdist-lua-actions.cc
pdns/dnsdist-lua-bindings.cc
pdns/iputils.cc
pdns/lock.hh
pdns/misc.cc
pdns/misc.hh
pdns/pdns_recursor.cc
pdns/rec_channel.cc
pdns/rec_channel_rec.cc

index e797a04c9b6e6802da70bb5e593426208d48715e..ed5ba4727e0b0e0d4e198419bbcacb245c65fb7c 100644 (file)
@@ -116,7 +116,7 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
         return res;
       }
     }
-    throw std::runtime_error("Error loading BPF program: (" + std::string(strerror(errno)) + "):\n" + std::string(log_buf));
+    throw std::runtime_error("Error loading BPF program: (" + stringerror() + "):\n" + std::string(log_buf));
   }
   return res;
 }
@@ -141,22 +141,22 @@ BPFFilter::BPFFilter(uint32_t maxV4Addresses, uint32_t maxV6Addresses, uint32_t
 {
   d_v4map.fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(uint32_t), sizeof(uint64_t), (int) maxV4Addresses);
   if (d_v4map.fd == -1) {
-    throw std::runtime_error("Error creating a BPF v4 map of size " + std::to_string(maxV4Addresses) + ": " + std::string(strerror(errno)));
+    throw std::runtime_error("Error creating a BPF v4 map of size " + std::to_string(maxV4Addresses) + ": " + stringerror());
   }
 
   d_v6map.fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(struct KeyV6), sizeof(uint64_t), (int) maxV6Addresses);
   if (d_v6map.fd == -1) {
-    throw std::runtime_error("Error creating a BPF v6 map of size " + std::to_string(maxV6Addresses) + ": " + std::string(strerror(errno)));
+    throw std::runtime_error("Error creating a BPF v6 map of size " + std::to_string(maxV6Addresses) + ": " + stringerror());
   }
 
   d_qnamemap.fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(struct QNameKey), sizeof(struct QNameValue), (int) maxQNames);
   if (d_qnamemap.fd == -1) {
-    throw std::runtime_error("Error creating a BPF qname map of size " + std::to_string(maxQNames) + ": " + std::string(strerror(errno)));
+    throw std::runtime_error("Error creating a BPF qname map of size " + std::to_string(maxQNames) + ": " + stringerror());
   }
 
   d_filtermap.fd = bpf_create_map(BPF_MAP_TYPE_PROG_ARRAY, sizeof(uint32_t), sizeof(uint32_t), 1);
   if (d_filtermap.fd == -1) {
-    throw std::runtime_error("Error creating a BPF program map of size 1: " + std::string(strerror(errno)));
+    throw std::runtime_error("Error creating a BPF program map of size 1: " + stringerror());
   }
 
   struct bpf_insn main_filter[] = {
@@ -169,7 +169,7 @@ BPFFilter::BPFFilter(uint32_t maxV4Addresses, uint32_t maxV6Addresses, uint32_t
                                   "GPL",
                                   0);
   if (d_mainfilter.fd == -1) {
-    throw std::runtime_error("Error loading BPF main filter: " + std::string(strerror(errno)));
+    throw std::runtime_error("Error loading BPF main filter: " + stringerror());
   }
 
   struct bpf_insn qname_filter[] = {
@@ -182,13 +182,13 @@ BPFFilter::BPFFilter(uint32_t maxV4Addresses, uint32_t maxV6Addresses, uint32_t
                                    "GPL",
                                    0);
   if (d_qnamefilter.fd == -1) {
-    throw std::runtime_error("Error loading BPF qname filter: " + std::string(strerror(errno)));
+    throw std::runtime_error("Error loading BPF qname filter: " + stringerror());
   }
 
   uint32_t key = 0;
   int res = bpf_update_elem(d_filtermap.fd, &key, &d_qnamefilter.fd, BPF_ANY);
   if (res != 0) {
-    throw std::runtime_error("Error updating BPF filters map: " + std::string(strerror(errno)));
+    throw std::runtime_error("Error updating BPF filters map: " + stringrerror());
   }
 }
 
@@ -197,7 +197,7 @@ void BPFFilter::addSocket(int sock)
   int res = setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &d_mainfilter.fd, sizeof(d_mainfilter.fd));
 
   if (res != 0) {
-    throw std::runtime_error("Error attaching BPF filter to this socket: " + std::string(strerror(errno)));
+    throw std::runtime_error("Error attaching BPF filter to this socket: " + stringerror());
   }
 }
 
@@ -206,7 +206,7 @@ void BPFFilter::removeSocket(int sock)
   int res = setsockopt(sock, SOL_SOCKET, SO_DETACH_BPF, &d_mainfilter.fd, sizeof(d_mainfilter.fd));
 
   if (res != 0) {
-    throw std::runtime_error("Error detaching BPF filter from this socket: " + std::string(strerror(errno)));
+    throw std::runtime_error("Error detaching BPF filter from this socket: " + stringerror());
   }
 }
 
@@ -255,7 +255,7 @@ void BPFFilter::block(const ComboAddress& addr)
   }
 
   if (res != 0) {
-    throw std::runtime_error("Error adding blocked address " + addr.toString() + ": " + std::string(strerror(errno)));
+    throw std::runtime_error("Error adding blocked address " + addr.toString() + ": " + stringerror());
   }
 }
 
@@ -285,7 +285,7 @@ void BPFFilter::unblock(const ComboAddress& addr)
   }
 
   if (res != 0) {
-    throw std::runtime_error("Error removing blocked address " + addr.toString() + ": " + std::string(strerror(errno)));
+    throw std::runtime_error("Error removing blocked address " + addr.toString() + ": " + stringerror());
   }
 }
 
index c269099a3121d17046924a47c1cb3fbb541d5da9..0abb742a3c38b5f34ff75a7583cc8bc85505c6fe 100644 (file)
@@ -40,7 +40,7 @@ void dropCapabilities()
 
      if (cap_set_proc(caps) != 0) {
        cap_free(caps);
-       throw std::runtime_error("Unable to drop capabilities: " + std::string(strerror(errno)));
+       throw std::runtime_error("Unable to drop capabilities: " + stringerror());
      }
 
      cap_free(caps);
index 48b910c8f4f85d7c2a561f664de3c52fc37dd922..79d0d4156d88224d66d1bc1c2d689c61bd99495b 100644 (file)
@@ -172,14 +172,14 @@ static void dns_random_setup(bool force=false)
   if (chosen_rng == RNG_URANDOM) {
     urandom_fd = open(rdev.c_str(), O_RDONLY);
     if (urandom_fd == -1)
-      throw std::runtime_error("Cannot open " + rdev + ": " + std::string(strerror(errno)));
+      throw std::runtime_error("Cannot open " + rdev + ": " + stringerror());
   }
 #if defined(HAVE_KISS_RNG)
   if (chosen_rng == RNG_KISS) {
     unsigned int seed;
     urandom_fd = open(rdev.c_str(), O_RDONLY);
     if (urandom_fd == -1)
-      throw std::runtime_error("Cannot open " + rdev + ": " + std::string(strerror(errno)));
+      throw std::runtime_error("Cannot open " + rdev + ": " + stringerror());
     if (read(urandom_fd, &seed, sizeof(seed)) < 0) {
       (void)close(urandom_fd);
       throw std::runtime_error("Cannot read random device");
@@ -264,7 +264,7 @@ uint32_t dns_random(uint32_t upper_bound) {
       uint32_t num = 0;
       do {
         if (getrandom(&num, sizeof(num), 0) != sizeof(num))
-          throw std::runtime_error("getrandom() failed: " + std::string(strerror(errno)));
+          throw std::runtime_error("getrandom() failed: " + stringerror());
       }
       while(num < min);
 
index 2943ad31899885cd2379db0a4037fc32f3568c79..849a2b8bab6106a408bbc1af944570bbe451928b 100644 (file)
@@ -561,7 +561,7 @@ public:
     else
       d_fp = fopen(str.c_str(), "w");
     if(!d_fp)
-      throw std::runtime_error("Unable to open file '"+str+"' for logging: "+std::string(strerror(errno)));
+      throw std::runtime_error("Unable to open file '"+str+"' for logging: "+stringerror());
     if(!buffered)
       setbuf(d_fp, 0);
   }
index d29081e100603277f9e85f57d2a0a9f2d1a8a4fd..93caad5912707c7dc42a9e415d59381543200d04 100644 (file)
@@ -355,7 +355,7 @@ void setupLuaBindings(bool client)
 
         int fd = open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660);
         if (fd < 0) {
-          g_outputBuffer = "Error opening dump file for writing: " + string(strerror(errno)) + "\n";
+          g_outputBuffer = "Error opening dump file for writing: " + stringerror() + "\n";
           return;
         }
 
index f58d0e31b2770cb2260ba261b1d4c2cb89580004..2010a6e5f9ca5a2ecf951ed2d0899487e5ce9650 100644 (file)
@@ -352,10 +352,11 @@ size_t sendMsgWithOptions(int fd, const char* buffer, size_t len, const ComboAdd
       return res;
     }
     else if (res == -1) {
-      if (errno == EINTR) {
+      int err = errno;
+      if (err == EINTR) {
         continue;
       }
-      else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) {
+      else if (err == EAGAIN || err == EWOULDBLOCK || err == EINPROGRESS || err == ENOTCONN) {
         /* EINPROGRESS might happen with non blocking socket,
            especially with TCP Fast Open */
         return sent;
index 3529ee3ae302bf699ae2ccb659afaaba8b667a21..895d346e06b46fe1a19019640c24884519acbf36 100644 (file)
@@ -68,8 +68,7 @@ public:
 
     int err;
     if((err = pthread_rwlock_wrlock(d_lock))) {
-      errno = err;
-      throw PDNSException("error acquiring rwlock wrlock: "+stringerror());
+      throw PDNSException("error acquiring rwlock wrlock: "+stringerror(err));
     }
   }
   ~WriteLock()
@@ -109,8 +108,7 @@ public:
     d_havelock=false;
     int err;
     if((err = pthread_rwlock_trywrlock(d_lock)) && err!=EBUSY) {
-      errno = err;
-      throw PDNSException("error acquiring rwlock tryrwlock: "+stringerror());
+      throw PDNSException("error acquiring rwlock tryrwlock: "+stringerror(err));
     }
     d_havelock=(err==0);
   }
@@ -158,8 +156,7 @@ public:
 
     int err;
     if((err = pthread_rwlock_tryrdlock(d_lock)) && err!=EBUSY) {
-      errno = err;
-      throw PDNSException("error acquiring rwlock tryrdlock: "+stringerror());
+      throw PDNSException("error acquiring rwlock tryrdlock: "+stringerror(err));
     }
     d_havelock=(err==0);
   }
@@ -201,8 +198,7 @@ public:
 
     int err;
     if((err = pthread_rwlock_rdlock(d_lock))) {
-      errno = err;
-      throw PDNSException("error acquiring rwlock readlock: "+stringerror());
+      throw PDNSException("error acquiring rwlock readlock: "+stringerror(err));
     }
   }
   ~ReadLock()
index 1f90bbcbd14c4ff8bf98c9d7d8729f712ed73bc7..027856dfc1969217f2b8c3f005e48abfeb89b500 100644 (file)
@@ -525,14 +525,14 @@ string bitFlip(const string &str)
   return ret;
 }
 
-string stringerror()
+string stringerror(int err)
 {
-  return strerror(errno);
+  return strerror(err);
 }
 
-string netstringerror()
+string stringerror()
 {
-  return stringerror();
+  return strerror(errno);
 }
 
 void cleanSlashes(string &str)
index ee255e9b90930a0d7972e1527529a805929386a4..7aeb70e31217c8e7a71645070234df98214ab0ac 100644 (file)
@@ -20,7 +20,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 #pragma once
-#include <errno.h>
 #include <inttypes.h>
 #include <cstring>
 #include <cstdio>
@@ -155,8 +154,8 @@ const string toLower(const string &upper);
 const string toLowerCanonic(const string &upper);
 bool IpToU32(const string &str, uint32_t *ip);
 string U32ToIP(uint32_t);
+string stringerror(int);
 string stringerror();
-string netstringerror();
 string itoa(int i);
 string uitoa(unsigned int i);
 string bitFlip(const string &str);
@@ -283,7 +282,7 @@ inline double getTime()
 
 inline void unixDie(const string &why)
 {
-  throw runtime_error(why+": "+strerror(errno));
+  throw runtime_error(why+": "+stringerror());
 }
 
 string makeHexDump(const string& str);
index 491ae26bd95d34a0c4e3a5c62b2130bd90c0e4cc..cd4ed89e8b4453ac023297abb74576d4adadec03 100644 (file)
@@ -513,8 +513,10 @@ static void setSocketBuffer(int fd, int optname, uint32_t size)
     return;
   }
 
-  if (setsockopt(fd, SOL_SOCKET, optname, (char*)&size, sizeof(size)) < 0 )
-    g_log<<Logger::Error<<"Unable to raise socket buffer size to "<<size<<": "<<strerror(errno)<<endl;
+  if (setsockopt(fd, SOL_SOCKET, optname, (char*)&size, sizeof(size)) < 0) {
+    int err = errno;
+    g_log << Logger::Error << "Unable to raise socket buffer size to " << size << ": " << strerror(err) << endl;
+  }
 }
 
 
@@ -732,8 +734,11 @@ static void writePid(void)
   ofstream of(s_pidfname.c_str(), std::ios_base::app);
   if(of)
     of<< Utility::getpid() <<endl;
-  else
-    g_log<<Logger::Error<<"Writing pid for "<<Utility::getpid()<<" to "<<s_pidfname<<" failed: "<<strerror(errno)<<endl;
+  else {
+    int err = errno;
+    g_log << Logger::Error << "Writing pid for " << Utility::getpid() << " to " << s_pidfname << " failed: "
+          << strerror(err) << endl;
+  }
 }
 
 TCPConnection::TCPConnection(int fd, const ComboAddress& addr) : data(2, 0), d_remote(addr), d_fd(fd)
@@ -1661,8 +1666,11 @@ static void startDoResolve(void *p)
       if(g_fromtosockets.count(dc->d_socket)) {
        addCMsgSrcAddr(&msgh, cbuf, &dc->d_local, 0);
       }
-      if(sendmsg(dc->d_socket, &msgh, 0) < 0 && g_logCommonErrors) 
-        g_log<<Logger::Warning<<"Sending UDP reply to client "<<dc->getRemote()<<" failed with: "<<strerror(errno)<<endl;
+      if(sendmsg(dc->d_socket, &msgh, 0) < 0 && g_logCommonErrors) {
+        int err = errno;
+        g_log << Logger::Warning << "Sending UDP reply to client " << dc->getRemote() << " failed with: "
+              << strerror(err) << endl;
+      }
 
       if(variableAnswer || sr.wasVariable()) {
         g_stats.variableResponses++;
@@ -1695,9 +1703,10 @@ static void startDoResolve(void *p)
 
       if(wret == 0)
         g_log<<Logger::Error<<"EOF writing TCP answer to "<<dc->getRemote()<<endl;
-      else if(wret < 0 )
-        g_log<<Logger::Error<<"Error writing TCP answer to "<<dc->getRemote()<<": "<< strerror(errno) <<endl;
-      else if((unsigned int)wret != 2 + packet.size())
+      else if(wret < 0 ) {
+        int err = errno;
+        g_log << Logger::Error << "Error writing TCP answer to " << dc->getRemote() << ": " << strerror(err) << endl;
+      } else if((unsigned int)wret != 2 + packet.size())
         g_log<<Logger::Error<<"Oops, partial answer sent to "<<dc->getRemote()<<" for "<<dc->d_mdp.d_qname<<" (size="<< (2 + packet.size()) <<", sent "<<wret<<")"<<endl;
       else
         hadError=false;
@@ -2320,9 +2329,12 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
       if(g_fromtosockets.count(fd)) {
        addCMsgSrcAddr(&msgh, cbuf, &destaddr, 0);
       }
-      if(sendmsg(fd, &msgh, 0) < 0 && g_logCommonErrors)
-        g_log<<Logger::Warning<<"Sending UDP reply to client "<<source.toStringWithPort()<<(source != fromaddr ? " (via "+fromaddr.toStringWithPort()+")" : "")<<" failed with: "<<strerror(errno)<<endl;
-
+      if(sendmsg(fd, &msgh, 0) < 0 && g_logCommonErrors) {
+        int err = errno;
+        g_log << Logger::Warning << "Sending UDP reply to client " << source.toStringWithPort()
+              << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << " failed with: "
+              << strerror(err) << endl;
+      }
       if(response.length() >= sizeof(struct dnsheader)) {
         struct dnsheader tmpdh;
         memcpy(&tmpdh, response.c_str(), sizeof(tmpdh));
@@ -2557,7 +2569,8 @@ static void makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set<int>& tcp
       exit(1);
     }
     if(sin.sin6.sin6_family == AF_INET6 && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &tmp, sizeof(tmp)) < 0) {
-      g_log<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(errno)<<endl;
+      int err = errno;
+      g_log<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(err)<<endl;
     }
 
 #ifdef TCP_DEFER_ACCEPT
@@ -2581,7 +2594,8 @@ static void makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set<int>& tcp
 #ifdef TCP_FASTOPEN
       int fastOpenQueueSize = ::arg().asNum("tcp-fast-open");
       if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &fastOpenQueueSize, sizeof fastOpenQueueSize) < 0) {
-        g_log<<Logger::Error<<"Failed to enable TCP Fast Open for listening socket: "<<strerror(errno)<<endl;
+        int err = errno;
+        g_log<<Logger::Error<<"Failed to enable TCP Fast Open for listening socket: "<<strerror(err)<<endl;
       }
 #else
       g_log<<Logger::Warning<<"TCP Fast Open configured but not supported for listening socket"<<endl;
@@ -2634,7 +2648,7 @@ static void makeUDPServerSockets(deferredAdd_t& deferredAdds)
 
     int fd=socket(sin.sin4.sin_family, SOCK_DGRAM, 0);
     if(fd < 0) {
-      throw PDNSException("Making a UDP server socket for resolver: "+netstringerror());
+      throw PDNSException("Making a UDP server socket for resolver: "+stringerror());
     }
     if (!setSocketTimestamps(fd))
       g_log<<Logger::Warning<<"Unable to enable timestamp reporting for socket"<<endl;
@@ -2649,7 +2663,8 @@ static void makeUDPServerSockets(deferredAdd_t& deferredAdds)
           g_fromtosockets.insert(fd);
 #endif
       if(sin.sin6.sin6_family == AF_INET6 && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)) < 0) {
-       g_log<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(errno)<<endl;
+        int err = errno;
+             g_log<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(err)<<endl;
       }
     }
     if( ::arg().mustDo("non-local-bind") )
@@ -2894,7 +2909,8 @@ static void makeThreadPipes()
 
     if (pipeBufferSize > 0) {
       if (!setPipeBufferSize(threadInfos.pipes.writeQueriesToThread, pipeBufferSize)) {
-        g_log<<Logger::Warning<<"Error resizing the buffer of the distribution pipe for thread "<<n<<" to "<<pipeBufferSize<<": "<<strerror(errno)<<endl;
+        int err = errno;
+        g_log<<Logger::Warning<<"Error resizing the buffer of the distribution pipe for thread "<<n<<" to "<<pipeBufferSize<<": "<<strerror(err)<<endl;
         auto existingSize = getPipeBufferSize(threadInfos.pipes.writeQueriesToThread);
         if (existingSize > 0) {
           g_log<<Logger::Warning<<"The current size of the distribution pipe's buffer for thread "<<n<<" is "<<existingSize<<endl;
@@ -4037,8 +4053,9 @@ static int serviceMain(int argc, char*argv[])
      }
 #endif
     if (chroot(::arg()["chroot"].c_str())<0 || chdir("/") < 0) {
-      g_log<<Logger::Error<<"Unable to chroot to '"+::arg()["chroot"]+"': "<<strerror (errno)<<", exiting"<<endl;
-      exit(1);
+       int err = errno;
+       g_log<<Logger::Error<<"Unable to chroot to '"+::arg()["chroot"]+"': "<<strerror (err)<<", exiting"<<endl;
+       exit(1);
     }
     else
       g_log<<Logger::Info<<"Chrooted to '"<<::arg()["chroot"]<<"'"<<endl;
index ccfd766cb8925b02d65212062431c6bbdd6a8047..0884afaa63cfeed350c879209f0d29fdd45ed6bd 100644 (file)
@@ -95,7 +95,7 @@ void RecursorControlChannel::connect(const string& path, const string& fname)
   setCloseOnExec(d_fd);
 
   if(d_fd < 0) 
-    throw PDNSException("Creating UNIX domain socket: "+string(strerror(errno)));
+    throw PDNSException("Creating UNIX domain socket: "+stringerror());
 
   try {
     int tmp=1;
@@ -149,7 +149,7 @@ void RecursorControlChannel::send(const std::string& msg, const std::string* rem
     throw PDNSException("Timeout sending message over control channel");
   }
   else if(ret < 0) {
-    throw PDNSException("Error sending message over control channel:" + string(strerror(errno)));
+    throw PDNSException("Error sending message over control channel:" + stringerror());
   }
 
   if(remote) {
@@ -161,10 +161,10 @@ void RecursorControlChannel::send(const std::string& msg, const std::string* rem
     remoteaddr.sun_path[sizeof(remoteaddr.sun_path)-1] = '\0';
 
     if(::sendto(d_fd, msg.c_str(), msg.length(), 0, (struct sockaddr*) &remoteaddr, sizeof(remoteaddr) ) < 0)
-      throw PDNSException("Unable to send message over control channel '"+string(remoteaddr.sun_path)+"': "+string(strerror(errno)));
+      throw PDNSException("Unable to send message over control channel '"+string(remoteaddr.sun_path)+"': "+stringerror());
   }
   else if(::send(d_fd, msg.c_str(), msg.length(), 0) < 0)
-    throw PDNSException("Unable to send message over control channel: "+string(strerror(errno)));
+    throw PDNSException("Unable to send message over control channel: "+stringerror());
 }
 
 string RecursorControlChannel::recv(std::string* remote, unsigned int timeout)
@@ -179,7 +179,7 @@ string RecursorControlChannel::recv(std::string* remote, unsigned int timeout)
     throw PDNSException("Timeout waiting for answer from control channel");
   
   if( ret < 0 || (len=::recvfrom(d_fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&remoteaddr, &addrlen)) < 0)
-    throw PDNSException("Unable to receive message over control channel: "+string(strerror(errno)));
+    throw PDNSException("Unable to receive message over control channel: "+stringerror());
 
   if(remote)
     *remote=remoteaddr.sun_path;
index c2f0139ca2b3adc1e880f833a183def7cf831eac..432b8a22e7c87c5d3487237edc01db2e9150d6ad 100644 (file)
@@ -242,7 +242,7 @@ static string doDumpNSSpeeds(T begin, T end)
 
   int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660);
   if(fd < 0)
-    return "Error opening dump file for writing: "+string(strerror(errno))+"\n";
+    return "Error opening dump file for writing: "+stringerror()+"\n";
   uint64_t total = 0;
   try {
     total = broadcastAccFunction<uint64_t>(boost::bind(pleaseDumpNSSpeeds, fd));
@@ -273,7 +273,7 @@ static string doDumpCache(T begin, T end)
 
   int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660);
   if(fd < 0) 
-    return "Error opening dump file for writing: "+string(strerror(errno))+"\n";
+    return "Error opening dump file for writing: "+stringerror()+"\n";
   uint64_t total = 0;
   try {
     total = broadcastAccFunction<uint64_t>(boost::bind(pleaseDump, fd));
@@ -295,7 +295,7 @@ static string doDumpEDNSStatus(T begin, T end)
 
   int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660);
   if(fd < 0) 
-    return "Error opening dump file for writing: "+string(strerror(errno))+"\n";
+    return "Error opening dump file for writing: "+stringerror()+"\n";
   uint64_t total = 0;
   try {
     total = broadcastAccFunction<uint64_t>(boost::bind(pleaseDumpEDNSMap, fd));
@@ -331,13 +331,13 @@ static string doDumpRPZ(T begin, T end)
   int fd = open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660);
 
   if(fd < 0) {
-    return "Error opening dump file for writing: "+string(strerror(errno))+"\n";
+    return "Error opening dump file for writing: "+stringerror()+"\n";
   }
 
   auto fp = std::unique_ptr<FILE, int(*)(FILE*)>(fdopen(fd, "w"), fclose);
   if (!fp) {
     close(fd);
-    return "Error converting file descriptor: "+string(strerror(errno))+"\n";
+    return "Error converting file descriptor: "+stringerror()+"\n";
   }
 
   zone->dump(fp.get());
@@ -356,7 +356,7 @@ static string doDumpThrottleMap(T begin, T end)
 
   int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660);
   if(fd < 0)
-    return "Error opening dump file for writing: "+string(strerror(errno))+"\n";
+    return "Error opening dump file for writing: "+stringerror()+"\n";
   uint64_t total = 0;
   try {
     total = broadcastAccFunction<uint64_t>(boost::bind(pleaseDumpThrottleMap, fd));