]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: initialize zone cache after dropping privileges 11908/head
authorKees Monshouwer <mind04@monshouwer.org>
Tue, 6 Sep 2022 13:52:51 +0000 (15:52 +0200)
committermind04 <mind04@monshouwer.org>
Tue, 6 Sep 2022 14:10:19 +0000 (16:10 +0200)
pdns/auth-main.cc

index 96f20a4dfdfd2d119aa4c674ccad5c9ac35dc0e6..4c985d78c2a9d535a21c649504e52dc87f219996 100644 (file)
@@ -816,6 +816,23 @@ void mainthread()
 
   pdns::parseTrustedNotificationProxy(::arg()["trusted-notification-proxy"]);
 
+  UeberBackend::go();
+
+  // Setup the zone cache
+  g_zoneCache.setRefreshInterval(::arg().asNum("zone-cache-refresh-interval"));
+  try {
+    UeberBackend B;
+    B.updateZoneCache();
+  }
+  catch (PDNSException& e) {
+    g_log << Logger::Error << "PDNSException while filling the zone cache: " << e.reason << endl;
+    exit(1);
+  }
+  catch (std::exception& e) {
+    g_log << Logger::Error << "STL Exception while filling the zone cache: " << e.what() << endl;
+    exit(1);
+  }
+
   // NOW SAFE TO CREATE THREADS!
   dl->go();
 
@@ -1418,14 +1435,6 @@ int main(int argc, char** argv)
       }
     }
 
-    UeberBackend::go();
-
-    g_zoneCache.setRefreshInterval(::arg().asNum("zone-cache-refresh-interval"));
-    {
-      UeberBackend B;
-      B.updateZoneCache();
-    }
-
     N = std::make_shared<UDPNameserver>(); // this fails when we are not root, throws exception
     g_udpReceivers.push_back(N);