diff options
-rwxr-xr-x | Meta/build-image-extlinux.sh | 14 | ||||
-rwxr-xr-x | Meta/build-image-grub.sh | 14 | ||||
-rwxr-xr-x | Meta/build-image-limine.sh | 14 | ||||
-rwxr-xr-x | Meta/build-image-qemu.sh | 15 | ||||
-rwxr-xr-x | Meta/build-native-partition.sh | 15 |
5 files changed, 65 insertions, 7 deletions
diff --git a/Meta/build-image-extlinux.sh b/Meta/build-image-extlinux.sh index 176a36e6f8..f52e29b168 100755 --- a/Meta/build-image-extlinux.sh +++ b/Meta/build-image-extlinux.sh @@ -8,7 +8,19 @@ die() { } if [ "$(id -u)" != 0 ]; then - exec sudo -E -- "$0" "$@" || die "this script needs to run as root" + set +e + ${SUDO} -E -- sh -c "\"$0\" $* || exit 42" + case $? in + 1) + die "this script needs to run as root" + ;; + 42) + exit 1 + ;; + *) + exit 0 + ;; + esac else : "${SUDO_UID:=0}" "${SUDO_GID:=0}" fi diff --git a/Meta/build-image-grub.sh b/Meta/build-image-grub.sh index dffc940fdb..c0b8ecc2bd 100755 --- a/Meta/build-image-grub.sh +++ b/Meta/build-image-grub.sh @@ -8,7 +8,19 @@ die() { } if [ "$(id -u)" != 0 ]; then - exec sudo -E -- "$0" "$@" || die "this script needs to run as root" + set +e + ${SUDO} -E -- sh -c "\"$0\" $* || exit 42" + case $? in + 1) + die "this script needs to run as root" + ;; + 42) + exit 1 + ;; + *) + exit 0 + ;; + esac else : "${SUDO_UID:=0}" "${SUDO_GID:=0}" fi diff --git a/Meta/build-image-limine.sh b/Meta/build-image-limine.sh index 0760ed7772..c84330323a 100755 --- a/Meta/build-image-limine.sh +++ b/Meta/build-image-limine.sh @@ -17,7 +17,19 @@ if [ ! -d "limine" ]; then fi if [ "$(id -u)" != 0 ]; then - exec sudo -E -- "$0" "$@" || die "this script needs to run as root" + set +e + ${SUDO} -E -- sh -c "\"$0\" $* || exit 42" + case $? in + 1) + die "this script needs to run as root" + ;; + 42) + exit 1 + ;; + *) + exit 0 + ;; + esac else : "${SUDO_UID:=0}" "${SUDO_GID:=0}" fi diff --git a/Meta/build-image-qemu.sh b/Meta/build-image-qemu.sh index 114e555db1..832bf683ba 100755 --- a/Meta/build-image-qemu.sh +++ b/Meta/build-image-qemu.sh @@ -31,8 +31,19 @@ if [ "$(id -u)" != 0 ]; then if [ -x "$FUSE2FS_PATH" ] && $FUSE2FS_PATH --help 2>&1 |grep fakeroot > /dev/null; then USE_FUSE2FS=1 else - ${SUDO} -E -- "$0" "$@" || die "this script needs to run as root" - exit 0 + set +e + ${SUDO} -E -- sh -c "\"$0\" $* || exit 42" + case $? in + 1) + die "this script needs to run as root" + ;; + 42) + exit 1 + ;; + *) + exit 0 + ;; + esac fi else : "${SUDO_UID:=0}" "${SUDO_GID:=0}" diff --git a/Meta/build-native-partition.sh b/Meta/build-native-partition.sh index 71ddf11c17..89ea47f6ec 100755 --- a/Meta/build-native-partition.sh +++ b/Meta/build-native-partition.sh @@ -16,8 +16,19 @@ cleanup() { } if [ "$(id -u)" != 0 ]; then - sudo -E -- "$0" "$@" || die "this script needs to run as root" - exit 0 + set +e + ${SUDO} -E -- sh -c "\"$0\" $* || exit 42" + case $? in + 1) + die "this script needs to run as root" + ;; + 42) + exit 1 + ;; + *) + exit 0 + ;; + esac else : "${SUDO_UID:=0}" "${SUDO_GID:=0}" fi |