]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(squash-lib): harden against empty $initdir
authorPhilipp Rudo <prudo@redhat.com>
Mon, 26 Aug 2024 13:29:01 +0000 (15:29 +0200)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Wed, 28 Aug 2024 11:59:47 +0000 (07:59 -0400)
The postinstall phase of 99squash-lib has the potential to delete the
whole rootfs if $initdir is empty. This should(tm) never happen.
Nevertheless as the consequences are so devastating it is better to
double check.

Signed-off-by: Philipp Rudo <prudo@redhat.com>
modules.d/99squash-lib/module-setup.sh

index 6a0b6f851da857d65d0846b395b64598526ec320..be3d3dc0484ae33b6ec8eff280e7a0d979b5cc16 100755 (executable)
@@ -72,6 +72,14 @@ squash_install() {
 squash_installpost() {
     local _file _handler
 
+    # this shouldn't happen but...
+    # ...better safe than deleting your rootfs
+    if [[ -z $initdir ]]; then
+        #shellcheck disable=SC2016
+        dfatal '$initdir not set. Something went terribly wrong.'
+        exit 1
+    fi
+
     _handler=$(squash_get_handler)
     [[ -n $_handler ]] || return 1