xbps_file_exec: don't fail if chroot(2) fails (due to EPERM).
This commit is contained in:
parent
bc894aae1d
commit
0a082a82c3
8
lib/external/fexec.c
vendored
8
lib/external/fexec.c
vendored
@ -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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user