- Fix dnstap socket and the chroot not applied properly to the dnstap

socket path.
This commit is contained in:
W.C.A. Wijngaards 2020-10-09 08:57:23 +02:00
parent a87f05be7b
commit 795a33c6e5
3 changed files with 14 additions and 8 deletions

View file

@ -134,15 +134,13 @@ dt_create(struct config_file* cfg)
if(cfg->dnstap && cfg->dnstap_socket_path && cfg->dnstap_socket_path[0] && if(cfg->dnstap && cfg->dnstap_socket_path && cfg->dnstap_socket_path[0] &&
(cfg->dnstap_ip==NULL || cfg->dnstap_ip[0]==0)) { (cfg->dnstap_ip==NULL || cfg->dnstap_ip[0]==0)) {
char* p = fname_after_chroot(cfg->dnstap_socket_path, cfg, 1); char* p = cfg->dnstap_socket_path;
if(!p) { if(cfg->chrootdir && cfg->chrootdir[0] && strncmp(p,
log_err("malloc failure"); cfg->chrootdir, strlen(cfg->chrootdir)) == 0)
return NULL; p += strlen(cfg->chrootdir);
}
verbose(VERB_OPS, "attempting to connect to dnstap socket %s", verbose(VERB_OPS, "attempting to connect to dnstap socket %s",
p); p);
check_socket_file(p); check_socket_file(p);
free(p);
} }
env = (struct dt_env *) calloc(1, sizeof(struct dt_env)); env = (struct dt_env *) calloc(1, sizeof(struct dt_env));

View 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; dtio->is_bidirectional = cfg->dnstap_bidirectional;
if(dtio->upstream_is_unix) { if(dtio->upstream_is_unix) {
char* nm;
if(!cfg->dnstap_socket_path || if(!cfg->dnstap_socket_path ||
cfg->dnstap_socket_path[0]==0) { cfg->dnstap_socket_path[0]==0) {
log_err("dnstap setup: no dnstap-socket-path for " log_err("dnstap setup: no dnstap-socket-path for "
"socket connect"); "socket connect");
return 0; 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); free(dtio->socket_path);
dtio->socket_path = fname_after_chroot(cfg->dnstap_socket_path, dtio->socket_path = strdup(nm);
cfg, 1);
if(!dtio->socket_path) { if(!dtio->socket_path) {
log_err("dnstap setup: malloc failure"); log_err("dnstap setup: malloc failure");
return 0; return 0;

View 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 8 October 2020: Wouter
- Tag for 1.12.0 release. - Tag for 1.12.0 release.
- Current repo is version 1.12.1 in development. - Current repo is version 1.12.1 in development.