xbps_file_exec: don't fail if chroot(2) fails (due to EPERM).

This commit is contained in:
Juan RP 2012-11-17 11:44:14 +01:00
parent bc894aae1d
commit 0a082a82c3

View File

@ -50,17 +50,15 @@ pfcexec(struct xbps_handle *xhp, const char *file, const char **argv)
/* /*
* If rootdir != / and uid==0 and bin/sh exists, * If rootdir != / and uid==0 and bin/sh exists,
* change root directory and exec command. * change root directory and exec command.
*
* It's assumed that cwd is the target rootdir.
*/ */
if (strcmp(xhp->rootdir, "/")) { if (strcmp(xhp->rootdir, "/")) {
if (getuid() == 0 && access("bin/sh", X_OK) == 0) { if (geteuid() == 0 && access("bin/sh", X_OK) == 0) {
if (chroot(xhp->rootdir) == -1) if (chroot(xhp->rootdir) == 0) {
_exit(128);
if (chdir("/") == -1) if (chdir("/") == -1)
_exit(129); _exit(129);
} }
} }
}
(void)execv(file, __UNCONST(argv)); (void)execv(file, __UNCONST(argv));
_exit(127); _exit(127);
/* NOTREACHED */ /* NOTREACHED */