]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: set -o nounset for scripts
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 4 Jun 2024 13:25:03 +0000 (15:25 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 6 Jun 2024 08:02:23 +0000 (10:02 +0200)
Those scripts are written with the expectation that all input variables are set
and will not behave correctly if something is ommitted. In particular, the
non-chrooted scripts (mkosi.clean, mkosi.sync) might wreak havoc if called
without the full environment.

mkosi.images/system/mkosi.clean
mkosi.images/system/mkosi.postinst.chroot
mkosi.images/system/mkosi.sanitizers.chroot
mkosi.images/system/mkosi.sync

index cb716c41f714b3b41e98d55472ec267cc41b2ca6..64810b795712e13d805e51063a15176d9b2d0273 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/bash
 set -e
+set -o nounset
 
 rm -f "$OUTPUTDIR"/*.{rpm,deb,pkg.tar}
index 397884b72027d89d5ec076bb704db54da2e922b2..acb4e631e9c62a592c2cce904277d6a71845904b 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/bash
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -e
+set -o nounset
 
 if command -v authselect >/dev/null; then
     # authselect 1.5.0 renamed the minimal profile to the local profile without keeping backwards compat so
index 854a419933b68acd547ead9f23812c659bcae0cb..524e3dadb19b5881f615408e6fabad9916a57455 100755 (executable)
@@ -1,8 +1,9 @@
 #!/bin/bash
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -e
+set -o nounset
 
-if [[ -z "$SANITIZERS" ]]; then
+if [[ -z "${SANITIZERS:-}" ]]; then
     exit 0
 fi
 
@@ -18,7 +19,7 @@ EOF
 # ASAN and syscall filters aren't compatible with each other.
 find /usr /etc -name '*.service' -type f -exec sed -i 's/^\(MemoryDeny\|SystemCall\)/# \1/' {} +
 
-# `systemd-hwdb update` takes > 50s when built with sanitizers so let's not run it by default.
+# 'systemd-hwdb update' takes > 50s when built with sanitizers so let's not run it by default.
 systemctl mask systemd-hwdb-update.service
 
 ASAN_RT_PATH="$(grep libasan.so < <(ldd /usr/lib/systemd/systemd) | cut -d ' ' -f 3)"
index a4f0ab94ec185fe379837659fddee544bbf2e9b6..6856af7c6b013a441221f194b03942332d7db9de 100755 (executable)
@@ -1,8 +1,9 @@
 #!/bin/bash
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -e
+set -o nounset
 
-if ((NO_SYNC)); then
+if ((${NO_SYNC:-0})); then
     exit 0
 fi