Skip to content

Commit 59ede6e

Browse files
committed
extract: chroot search for env binary
1 parent 367f024 commit 59ede6e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

scripts/extract_from_chroot.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ sudo mount --bind /sys "$VM_MOUNT_ROOT/sys"
2121
sudo mount --bind /proc "$VM_MOUNT_ROOT/proc"
2222
sudo mount --bind /dev "$VM_MOUNT_ROOT/dev"
2323

24+
for envCandidate in /bin/env /sbin/env /usr/bin/env /where/is/env; do
25+
[ -x "${VM_MOUNT_ROOT}${envCandidate}" ] && break || true
26+
done
2427
[[ $(type -t chroot_pre_hook) == 'function' ]] && chroot_pre_hook || true
25-
sudo chroot "$VM_MOUNT_ROOT" /bin/sh -c "/bin/env -i PATH=/bin sh -c '$command'"
28+
sudo chroot "$VM_MOUNT_ROOT" /bin/sh -c "$envCandidate -i PATH=/bin:/sbin:/usr/bin:/usr/sbin sh -c '$command'"
2629

2730
sudo umount -l "$VM_MOUNT_ROOT/dev"
2831
sudo umount -l "$VM_MOUNT_ROOT/proc"

0 commit comments

Comments
 (0)