use chdir() before calling chroot()

This commit is contained in:
Michael Scherer
2013-07-29 11:05:16 +02:00
committed by bubulle
parent 9be164101d
commit 4e65be1211
2 changed files with 15 additions and 0 deletions

View File

@ -106,6 +106,14 @@ static void change_root (const char* newroot)
Prog, newroot, strerror (errno));
exit (E_BAD_ARG);
}
if (chdir (newroot) != 0) {
fprintf(stderr,
_("%s: cannot chdir to chroot directory %s: %s\n"),
Prog, newroot, strerror (errno));
exit (E_BAD_ARG);
}
if (chroot (newroot) != 0) {
fprintf(stderr,
_("%s: unable to chroot to directory %s: %s\n"),