]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix dnstap socket and the chroot not applied properly to the dnstap
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 9 Oct 2020 06:57:23 +0000 (08:57 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 9 Oct 2020 06:57:23 +0000 (08:57 +0200)
  socket path.

dnstap/dnstap.c
dnstap/dtstream.c
doc/Changelog

index 0c8c6c4d462acdecb3e83583d733c49e01bef755..b8a3216703c1d031e8ac3771ae58e44704dd44ce 100644 (file)
@@ -134,15 +134,13 @@ dt_create(struct config_file* cfg)
 
        if(cfg->dnstap && cfg->dnstap_socket_path && cfg->dnstap_socket_path[0] &&
                (cfg->dnstap_ip==NULL || cfg->dnstap_ip[0]==0)) {
-               char* p = fname_after_chroot(cfg->dnstap_socket_path, cfg, 1);
-               if(!p) {
-                       log_err("malloc failure");
-                       return NULL;
-               }
+               char* p = cfg->dnstap_socket_path;
+               if(cfg->chrootdir && cfg->chrootdir[0] && strncmp(p,
+                       cfg->chrootdir, strlen(cfg->chrootdir)) == 0)
+                       p += strlen(cfg->chrootdir);
                verbose(VERB_OPS, "attempting to connect to dnstap socket %s",
                        p);
                check_socket_file(p);
-               free(p);
        }
 
        env = (struct dt_env *) calloc(1, sizeof(struct dt_env));
index b0918c52cc637ab8e4332827f389afd4a4d530f9..f1ace3c340236e25f86b53eb7ad437c1175effec 100644 (file)
@@ -341,15 +341,19 @@ int dt_io_thread_apply_cfg(struct dt_io_thread* dtio, struct config_file *cfg)
        dtio->is_bidirectional = cfg->dnstap_bidirectional;
 
        if(dtio->upstream_is_unix) {
+               char* nm;
                if(!cfg->dnstap_socket_path ||
                        cfg->dnstap_socket_path[0]==0) {
                        log_err("dnstap setup: no dnstap-socket-path for "
                                "socket connect");
                        return 0;
                }
+               nm = cfg->dnstap_socket_path;
+               if(cfg->chrootdir && cfg->chrootdir[0] && strncmp(nm,
+                       cfg->chrootdir, strlen(cfg->chrootdir)) == 0)
+                       nm += strlen(cfg->chrootdir);
                free(dtio->socket_path);
-               dtio->socket_path = fname_after_chroot(cfg->dnstap_socket_path,
-                       cfg, 1);
+               dtio->socket_path = strdup(nm);
                if(!dtio->socket_path) {
                        log_err("dnstap setup: malloc failure");
                        return 0;
index c59352cfda6a9a25e88f0ebeb3debecddce6958c..035d040a932e086f4add45dd89e66b1a5e8b3b60 100644 (file)
@@ -1,3 +1,7 @@
+9 October 2020: Wouter
+       - Fix dnstap socket and the chroot not applied properly to the dnstap
+         socket path.
+
 8 October 2020: Wouter
        - Tag for 1.12.0 release.
        - Current repo is version 1.12.1 in development.