Fixup for chroot

git-svn-id: file:///svn/unbound/trunk@3776 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2016-06-09 23:16:45 +00:00
parent 12f96dc321
commit 6ff2a2e407
2 changed files with 296 additions and 282 deletions

File diff suppressed because it is too large Load diff

View file

@ -527,9 +527,16 @@ server_directory: VAR_DIRECTORY STRING_ARG
cfg_parser->cfg->directory = $2;
/* change there right away for includes relative to this */
if($2[0]) {
if(chdir($2))
char* d = $2;
/* adjust directory if we have already chroot,
* like, we reread after sighup */
if(cfg_parser->chroot && cfg_parser->chroot[0] &&
strncmp(d, cfg_parser->chroot, strlen(
cfg_parser->chroot)) == 0)
d += strlen(cfg_parser->chroot);
if(chdir(d))
log_err("cannot chdir to directory: %s (%s)",
$2, strerror(errno));
d, strerror(errno));
}
}
;