]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- check that the dnstap socket file can be opened and exists, print
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 22 Oct 2018 10:17:38 +0000 (10:17 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 22 Oct 2018 10:17:38 +0000 (10:17 +0000)
  error if not.

git-svn-id: file:///svn/unbound/trunk@4943 be551aaa-1e26-0410-a405-d3ace91eadb9

dnstap/dnstap.c
doc/Changelog

index 5d0420f6fbba2305e8f5984fe6d77b248d57de36..631ccd7adac687d8ee5597d15dae640698d8dd30 100644 (file)
@@ -39,6 +39,8 @@
 #include "config.h"
 #include <string.h>
 #include <sys/time.h>
+#include <sys/stat.h>
+#include <errno.h>
 #include "sldns/sbuffer.h"
 #include "util/config_file.h"
 #include "util/net_help.h"
@@ -118,6 +120,18 @@ dt_msg_init(const struct dt_env *env,
        }
 }
 
+/* check that the socket file can be opened and exists, print error if not */
+static void
+check_socket_file(const char* socket_path)
+{
+       struct stat statbuf;
+       memset(&statbuf, 0, sizeof(statbuf));
+       if(stat(socket_path, &statbuf) < 0) {
+               log_warn("could not open dnstap-socket-path: %s, %s",
+                       socket_path, strerror(errno));
+       }
+}
+
 struct dt_env *
 dt_create(const char *socket_path, unsigned num_workers)
 {
@@ -134,6 +148,7 @@ dt_create(const char *socket_path, unsigned num_workers)
                socket_path);
        log_assert(socket_path != NULL);
        log_assert(num_workers > 0);
+       check_socket_file(socket_path);
 
        env = (struct dt_env *) calloc(1, sizeof(struct dt_env));
        if (!env)
index 3002473f1e9dd2835b895684e59f5233a5a0febf..0f2372b84ac002b77af863654d5ccd5d761fe978 100644 (file)
@@ -1,6 +1,8 @@
 22 October 2018: Wouter
        - Fix #4192: unbound-control-setup generates keys not readable by
          group.
+       - check that the dnstap socket file can be opened and exists, print
+         error if not.
 
 22 October 2018: Ralph
        - Change fast-server-num default to 3.