]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: keep the state of log-dns-queries in a global.
authorMiod Vallat <miod.vallat@powerdns.com>
Wed, 13 May 2026 07:49:26 +0000 (09:49 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 26 May 2026 11:56:01 +0000 (13:56 +0200)
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
modules/remotebackend/test-remotebackend.cc
pdns/auth-main.cc
pdns/auth-main.hh
pdns/ixfrdist.cc
pdns/pdnsutil.cc
pdns/tcpreceiver.cc
pdns/testrunner.cc

index 3231b67ed94aa986cb68c0866e1626d4e681cfce..12c79c6340329ee8d423aecddee33205a24484c8 100644 (file)
@@ -45,6 +45,7 @@
 #include "test-remotebackend-keys.hh"
 
 bool g_slogStructured{false};
+bool g_logDNSQueries{false};
 
 extern std::unique_ptr<DNSBackend> backendUnderTest;
 
index 5c9aa7c2a2960d485dd973a78d595d021bf4d163..c5e59f934da0116dae6a1bce55681a87daeab2a1 100644 (file)
@@ -105,6 +105,7 @@ const char* funnytext = "*******************************************************
 
 bool g_anyToTcp;
 bool g_8bitDNS;
+bool g_logDNSQueries;
 #ifdef HAVE_LUA_RECORDS
 bool g_doLuaRecord;
 int g_luaRecordExecLimit;
@@ -594,7 +595,6 @@ static void qthread(unsigned int num)
 
     int diff{};
     int start{};
-    bool logDNSQueries = ::arg().mustDo("log-dns-queries");
     shared_ptr<UDPNameserver> NS; // NOLINT(readability-identifier-length)
     std::string buffer;
     ComboAddress accountremote;
@@ -652,7 +652,7 @@ static void qthread(unsigned int num)
 
         S.ringAccount("queries", question.qdomain, question.qtype);
         S.ringAccount("remotes", question.getInnerRemote());
-        if (logDNSQueries) {
+        if (g_logDNSQueries) {
           if (g_slogStructured) {
             if (question.d_ednsRawPacketSizeLimit > 0 && question.getMaxReplyLen() != (unsigned int)question.d_ednsRawPacketSizeLimit) {
               slog->info(Logr::Notice, "Query received", "remote", Logging::Loggable(question.getRemoteString()), "query", Logging::Loggable(question.qdomain), "type", Logging::Loggable(question.qtype), "dnssec", Logging::Loggable(question.d_dnssecOk), "max reply length", Logging::Loggable(question.getMaxReplyLen()), "raw packet size limit", Logging::Loggable(question.d_ednsRawPacketSizeLimit));
@@ -678,7 +678,7 @@ static void qthread(unsigned int num)
           }
           bool haveSomething = PC.get(question, cached, view); // does the PacketCache recognize this question?
           if (haveSomething) {
-            if (logDNSQueries) {
+            if (g_logDNSQueries) {
               SLOG(g_log << ": packetcache HIT" << endl,
                    slog->info(Logr::Notice, "packetcache HIT"));
             }
@@ -706,7 +706,7 @@ static void qthread(unsigned int num)
         }
 
         if (distributor->isOverloaded()) {
-          if (logDNSQueries) {
+          if (g_logDNSQueries) {
             SLOG(g_log << ": Dropped query, backends are overloaded" << endl,
                  slog->info(Logr::Notice, "Dropped query, backends are overloaded"));
           }
@@ -714,7 +714,7 @@ static void qthread(unsigned int num)
           continue;
         }
 
-        if (logDNSQueries) {
+        if (g_logDNSQueries) {
           if (PC.enabled()) {
             SLOG(g_log << ": packetcache MISS" << endl,
                  slog->info(Logr::Notice, "packetcache MISS"));
@@ -772,6 +772,7 @@ static void mainthread()
 
   g_anyToTcp = ::arg().mustDo("any-to-tcp");
   g_8bitDNS = ::arg().mustDo("8bit-dns");
+  g_logDNSQueries = ::arg().mustDo("log-dns-queries");
 #ifdef HAVE_LUA_RECORDS
   g_doLuaRecord = ::arg().mustDo("enable-lua-records");
   g_LuaRecordSharedState = (::arg()["enable-lua-records"] == "shared");
index 1dad9dc3050a7ffeb6aa03e4422e2651d7245bc6..45fcd34c4b3382489556b89d0827d3d34634fef7 100644 (file)
@@ -46,6 +46,7 @@ extern CommunicatorClass Communicator;
 void carbonDumpThread(Logr::log_t slog); // Implemented in auth-carbon.cc. Avoids having an auth-carbon.hh declaring exactly one function.
 extern bool g_anyToTcp;
 extern bool g_8bitDNS;
+extern bool g_logDNSQueries;
 extern NetmaskGroup g_proxyProtocolACL;
 extern size_t g_proxyProtocolMaximumSize;
 #ifdef HAVE_LUA_RECORDS
index 4066aba3132574d078a163afe4cb7125e942d881..9eab14178dd9c1557ab71ec9d8f4c5970c542284 100644 (file)
@@ -70,6 +70,7 @@ AuthPacketCache PC;
 // NOLINTNEXTLINE(readability-identifier-length)
 AuthQueryCache QC;
 AuthZoneCache g_zoneCache;
+bool g_logDNSQueries{false};
 
 ArgvMap &arg()
 {
index f18293f2c0929cc12079d5865e7fdb9f567188a0..fcf0b7b03d6404c2a1bed2c3140eeabee0429720 100644 (file)
@@ -63,6 +63,7 @@ namespace po = boost::program_options;
 po::variables_map g_vm;
 
 bool g_slogStructured{false};
+bool g_logDNSQueries{false};
 static Logger::Urgency s_logUrgency;
 
 string g_programname="pdns";
index d42bf4d227ce3335da3fc2f6f01653e421e554a8..d9aaf3c7c3be70ec82ed95e259c6f99fe77031ab 100644 (file)
@@ -264,7 +264,6 @@ void TCPNameserver::doConnection(int fd, Logr::log_t slog)
 
     DLOG(SLOG(g_log<<"TCP Connection accepted on fd "<<fd<<endl,
               slog->info(Logr::Debug, "TCP Connection accepted", "fd", Logging::Loggable(fd))));
-    bool logDNSQueries= ::arg().mustDo("log-dns-queries");
     if (g_proxyProtocolACL.match(remote)) {
       unsigned int remainingTime = 0;
       PacketBuffer proxyData;
@@ -398,7 +397,7 @@ void TCPNameserver::doConnection(int fd, Logr::log_t slog)
       std::unique_ptr<DNSPacket> reply;
       auto cached = make_unique<DNSPacket>(slog, false);
       std::shared_ptr<Logr::Logger> slogger;
-      if(logDNSQueries)  {
+      if(g_logDNSQueries)  {
         if (g_slogStructured) {
           slogger = slog->withValues("remote", Logging::Loggable(packet->getRemoteString()), "query", Logging::Loggable(packet->qdomain), "type", Logging::Loggable(packet->qtype), "dnssecok", Logging::Loggable(packet->d_dnssecOk), "bufsize", Logging::Loggable(packet->getMaxReplyLen()));
        }
@@ -416,7 +415,7 @@ void TCPNameserver::doConnection(int fd, Logr::log_t slog)
             view = g_zoneCache.getViewFromNetwork(&netmask);
           }
           if (PC.get(*packet, *cached, view)) { // short circuit - does the PacketCache recognize this question?
-            if(logDNSQueries) {
+            if(g_logDNSQueries) {
               SLOG(g_log<<": packetcache HIT"<<endl,
                    slogger->info(Logr::Notice, "Received TCP query", "packetcache", Logging::Loggable("hit")));
             }
@@ -430,12 +429,12 @@ void TCPNameserver::doConnection(int fd, Logr::log_t slog)
             continue;
           }
         }
-        if(logDNSQueries) {
+        if(g_logDNSQueries) {
           SLOG(g_log<<": packetcache MISS"<<endl,
                slogger->info(Logr::Notice, "Received TCP query", "packetcache", Logging::Loggable("miss")));
         }
       } else {
-        if (logDNSQueries) {
+        if (g_logDNSQueries) {
           SLOG(g_log<<endl,
                slogger->info(Logr::Notice, "Received TCP query"));
         }
index 4fd2dbabd4a11e435200291ae3d063e6dfdd8afc..b23e599f2ec3a77576f2cfdc58055758e3e65df5 100644 (file)
@@ -19,6 +19,7 @@ AuthQueryCache QC;
 AuthZoneCache g_zoneCache;
 uint16_t g_maxNSEC3Iterations{0};
 bool g_slogStructured{false};
+bool g_logDNSQueries{false};
 
 ArgvMap& arg()
 {