Przeglądaj źródła

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.
Emanuele Torre 5 lat temu
rodzic
commit
8e24a17d0d
2 zmienionych plików z 4 dodań i 0 usunięć
  1. 2 0
      Meta/build-image-grub.sh
  2. 2 0
      Meta/build-image-qemu.sh

+ 2 - 0
Meta/build-image-grub.sh

@@ -9,6 +9,8 @@ die() {
 
 
 if [ "$(id -u)" != 0 ]; then
 if [ "$(id -u)" != 0 ]; then
     exec sudo -E -- "$0" "$@" || die "this script needs to run as root"
     exec sudo -E -- "$0" "$@" || die "this script needs to run as root"
+else
+    : "${SUDO_UID:=0}" "${SUDO_GID:=0}"
 fi
 fi
 
 
 grub=$(command -v grub-install 2>/dev/null) || true
 grub=$(command -v grub-install 2>/dev/null) || true

+ 2 - 0
Meta/build-image-qemu.sh

@@ -9,6 +9,8 @@ die() {
 
 
 if [ "$(id -u)" != 0 ]; then
 if [ "$(id -u)" != 0 ]; then
     exec sudo -E -- "$0" "$@" || die "this script needs to run as root"
     exec sudo -E -- "$0" "$@" || die "this script needs to run as root"
+else
+    : "${SUDO_UID:=0}" "${SUDO_GID:=0}"
 fi
 fi
 
 
 if [ "$(uname -s)" = "Darwin" ]; then
 if [ "$(uname -s)" = "Darwin" ]; then