while(*incfile == ' ' || *incfile == '\t')
incfile++;
/* adjust for chroot on include file */
- incfile = fname_after_chroot(incfile, cfg, 1);
+ if(cfg->chrootdir && cfg->chrootdir[0] &&
+ strncmp(incfile, cfg->chrootdir,
+ strlen(cfg->chrootdir)) == 0)
+ incfile += strlen(cfg->chrootdir);
+ incfile = strdup(incfile);
if(!incfile) {
log_err("malloc failure");
return 0;
FILE* in;
if(!z || !z->zonefile || z->zonefile[0]==0)
return 1; /* no file, or "", nothing to read */
- zfilename = fname_after_chroot(z->zonefile, cfg, 1);
+
+ zfilename = z->zonefile;
+ if(cfg->chrootdir && cfg->chrootdir[0] && strncmp(zfilename,
+ cfg->chrootdir, strlen(cfg->chrootdir)) == 0)
+ zfilename += strlen(cfg->chrootdir);
if(verbosity >= VERB_ALGO) {
char nm[255+1];
dname_str(z->name, nm);
verbose(VERB_ALGO, "no zonefile %s for %s",
zfilename, n?n:"error");
free(n);
- free(zfilename);
return 1;
}
log_err("cannot open zonefile %s for %s: %s",
zfilename, n?n:"error", strerror(errno));
free(n);
- free(zfilename);
return 0;
}
log_err("error parsing zonefile %s for %s",
zfilename, n?n:"error");
free(n);
- free(zfilename);
fclose(in);
return 0;
}
- free(zfilename);
fclose(in);
return 1;
}
static void
xfr_write_after_update(struct auth_xfer* xfr, struct module_env* env)
{
+ struct config_file* cfg = env->cfg;
struct auth_zone* z;
char tmpfile[1024];
char* zfilename;
/* no write needed, no zonefile set */
return;
}
- zfilename = fname_after_chroot(z->zonefile, env->cfg, 1);
+ zfilename = z->zonefile;
+ if(cfg->chrootdir && cfg->chrootdir[0] && strncmp(zfilename,
+ cfg->chrootdir, strlen(cfg->chrootdir)) == 0)
+ zfilename += strlen(cfg->chrootdir);
/* write to tempfile first */
if((size_t)strlen(zfilename) + 16 > sizeof(tmpfile)) {
verbose(VERB_ALGO, "tmpfilename too long, cannot update "
" zonefile %s", zfilename);
lock_rw_unlock(&z->lock);
- free(zfilename);
return;
}
snprintf(tmpfile, sizeof(tmpfile), "%s.tmp%u", zfilename,
} else if(!auth_zone_write_file(z, tmpfile)) {
unlink(tmpfile);
lock_rw_unlock(&z->lock);
- free(zfilename);
return;
}
if(rename(tmpfile, zfilename) < 0) {
strerror(errno));
unlink(tmpfile);
lock_rw_unlock(&z->lock);
- free(zfilename);
return;
}
lock_rw_unlock(&z->lock);
- free(zfilename);
}
/** process chunk list and update zone in memory,