From 8e24a17d0d7f6ebe5fe7b9e242ce8e696ceeacbf Mon Sep 17 00:00:00 2001 From: Emanuele Torre Date: Sat, 20 Jun 2020 05:20:50 +0200 Subject: [PATCH] Meta: default SUDO_UID and SUDO_GID to 0 in build-image-*.sh scripts In the GNU coreutils version of chown, ":" is a valid argument (the command will result in a no-op), but POSIX chown does not consider that valid. If the user who ran build-image-*.sh was root, SUDO_UID and SUDO_GID would not be set and, if the version of chown installed on the system did not allow passing just a ":" as argument, the script would fail. Let's default the value of SUDO_UID and SUDO_GID to 0 just in case. --- Meta/build-image-grub.sh | 2 ++ Meta/build-image-qemu.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Meta/build-image-grub.sh b/Meta/build-image-grub.sh index 6c1a428d24..fff4f64eb5 100755 --- a/Meta/build-image-grub.sh +++ b/Meta/build-image-grub.sh @@ -9,6 +9,8 @@ die() { if [ "$(id -u)" != 0 ]; then exec sudo -E -- "$0" "$@" || die "this script needs to run as root" +else + : "${SUDO_UID:=0}" "${SUDO_GID:=0}" fi grub=$(command -v grub-install 2>/dev/null) || true diff --git a/Meta/build-image-qemu.sh b/Meta/build-image-qemu.sh index 578a56c4b1..86d6d271d6 100755 --- a/Meta/build-image-qemu.sh +++ b/Meta/build-image-qemu.sh @@ -9,6 +9,8 @@ die() { if [ "$(id -u)" != 0 ]; then exec sudo -E -- "$0" "$@" || die "this script needs to run as root" +else + : "${SUDO_UID:=0}" "${SUDO_GID:=0}" fi if [ "$(uname -s)" = "Darwin" ]; then