Skip to content

Commit

Permalink
Meta: default SUDO_UID and SUDO_GID to 0 in build-image-*.sh scripts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
emanuele6 authored and awesomekling committed Jun 21, 2020
1 parent 22aa4cb commit 8e24a17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Meta/build-image-grub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Meta/build-image-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8e24a17

Please sign in to comment.