]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Modify journal availability test.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 1 Jun 2022 08:46:19 +0000 (10:46 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 1 Jun 2022 08:51:52 +0000 (10:51 +0200)
To both test for NOTIFY_SOCKET (to see if we're runnign underst systemd)
and availbility of the journal socket (to see if systemd-journal is
active)

pdns/recursordist/rec-main.cc

index 9282c8927860260c2367cc7b366f636b4233fa35..dfd16a7617b9161a7fc67e1f9155c3b75db4bd3e 100644 (file)
@@ -2762,11 +2762,13 @@ int main(int argc, char** argv)
 
 #ifdef HAVE_SYSTEMD
     if (getenv("NOTIFY_SOCKET") != nullptr) {
-      g_slog = Logging::Logger::create(loggerSDBackend);
+      if (int fd = sd_journal_stream_fd("pdns-recusor", LOG_DEBUG, 0); fd >= 0) {
+        g_slog = Logging::Logger::create(loggerSDBackend);
+        close(fd);
+      }
     }
-    else
 #endif
-    {
+    if (g_slog == nullptr) {
       g_slog = Logging::Logger::create(loggerBackend);
     }
     // Missing: a mechanism to call setVerbosity(x)