From 26778964a43425d462357007f3e7096f39df4ac8 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 25 Feb 2013 23:00:20 +0100 Subject: [PATCH] When executing scripts don't chroot if XBPS_TARGET_ARCH is set. --- lib/external/fexec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/external/fexec.c b/lib/external/fexec.c index 5ef2a662..8fe84661 100644 --- a/lib/external/fexec.c +++ b/lib/external/fexec.c @@ -42,6 +42,7 @@ static int pfcexec(struct xbps_handle *xhp, const char *file, const char **argv) { pid_t child; + const char *tarch; int status; child = vfork(); @@ -51,8 +52,9 @@ pfcexec(struct xbps_handle *xhp, const char *file, const char **argv) * If rootdir != / and uid==0 and bin/sh exists, * change root directory and exec command. */ + tarch = getenv("XBPS_TARGET_ARCH"); if (strcmp(xhp->rootdir, "/")) { - if (geteuid() == 0 && access("bin/sh", X_OK) == 0) { + if (!tarch && geteuid() == 0 && access("bin/sh", X_OK) == 0) { if (chroot(xhp->rootdir) == 0) { if (chdir("/") == -1) _exit(129);