call getHostname
authorPieter Lexis <pieter.lexis@powerdns.com>
Mon, 9 Apr 2018 13:55:00 +0000 (15:55 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 30 May 2018 08:00:52 +0000 (10:00 +0200)
pdns/pdns_recursor.cc

index eb481d2f79bb42645c79470c79d38807272975e0..b198ae4d47fe3cd49f77fe1da1e48850b819afd6 100644 (file)
@@ -3195,10 +3195,10 @@ static int serviceMain(int argc, char*argv[])
     g_quiet=false;
     g_dnssecLOG=true;
   }
-  char myHostname[MAXHOSTNAMELEN];
-  if (gethostname(myHostname, sizeof(myHostname)-1) == 0){
-  } else {
-    g_log<<Logger::Warning<<"Unable to get the hostname, NSID and id.server values will be empty: "<<strerror(errno)<<endl;
+  string myHostname = getHostname();
+  if (myHostname == "UNKNOWN"){
+    g_log<<Logger::Warning<<"Unable to get the hostname, NSID and id.server values will be empty"<<endl;
+    myHostname = "";
   }
 
   SyncRes::s_minimumTTL = ::arg().asNum("minimum-ttl-override");