summaryrefslogtreecommitdiff
path: root/dnstap
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2019-02-06 12:31:02 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2019-02-06 12:31:02 +0000
commit9c9d011eed674ddd7e4a0a148691887afb9e75cd (patch)
treecd45bceeed24e66e5b2838e8589d2c111cf691c6 /dnstap
parent089d83fbd0b24f957b753d440f188ddadaabf4ff (diff)
downloadsrc-test2-9c9d011eed674ddd7e4a0a148691887afb9e75cd.tar.gz
src-test2-9c9d011eed674ddd7e4a0a148691887afb9e75cd.zip
Notes
Diffstat (limited to 'dnstap')
-rw-r--r--dnstap/dnstap.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/dnstap/dnstap.c b/dnstap/dnstap.c
index 5d0420f6fbba..aabf8eec9071 100644
--- a/dnstap/dnstap.c
+++ b/dnstap/dnstap.c
@@ -39,6 +39,10 @@
#include "config.h"
#include <string.h>
#include <sys/time.h>
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#include <errno.h>
#include "sldns/sbuffer.h"
#include "util/config_file.h"
#include "util/net_help.h"
@@ -118,6 +122,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 +150,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)