xbps_file_exec: if chroot(2) returns EPERM, don't error out and try chdir(2).

This makes possible to install a base system with fakeroot (of course
some things won't probably work fully).
This commit is contained in:
Juan RP 2011-02-25 11:17:13 +01:00
parent 9759a62e3f
commit ce24ff488c

View File

@ -64,11 +64,16 @@ pfcexec(const char *path, const char *file, const char **argv)
} else if (path && !do_chroot) {
if (chdir(path) == -1)
_exit(127);
} else if (!path && do_chroot) {
if (chroot(".") == -1)
_exit(127);
if (chdir("/") == -1)
_exit(127);
} else if (path == NULL && do_chroot) {
if (chroot(".") == -1) {
if (errno != EPERM)
_exit(127);
if (chdir(path) == -1)
_exit(127);
} else {
if (chdir("/") == -1)
_exit(127);
}
}
(void)execv(file, __UNCONST(argv));