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.
This commit is contained in:
Emanuele Torre 2020-06-20 05:20:50 +02:00 committed by Andreas Kling
parent 22aa4cbf92
commit 8e24a17d0d
2 changed files with 4 additions and 0 deletions

View file

@ -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

View file

@ -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