From cfb35c2f78d342fc4fc10cb48f0d045e7e57c92a Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Tue, 6 Sep 2022 15:52:51 +0200 Subject: [PATCH] auth: initialize zone cache after dropping privileges --- pdns/auth-main.cc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/pdns/auth-main.cc b/pdns/auth-main.cc index 96f20a4dfd..4c985d78c2 100644 --- a/pdns/auth-main.cc +++ b/pdns/auth-main.cc @@ -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(); // this fails when we are not root, throws exception g_udpReceivers.push_back(N); -- 2.47.2