]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
feat(crypt): remove empty /etc/crypttab to allow creating it later
authorJo Zzsi <jozzsicsataban@gmail.com>
Thu, 26 Dec 2024 13:51:53 +0000 (08:51 -0500)
committerLaszlo <laszlo.gombos@gmail.com>
Thu, 26 Dec 2024 15:15:46 +0000 (10:15 -0500)
crypt module should not install an empty /etc/crypttab in hostonly mode.

Some distributions ship with an /etc/crypttab without entries (just
with comments). In those distributions installing /etc/crypttab
as part of --install command line option in hostonly mode would not
work as expected.

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1057
modules.d/90crypt/module-setup.sh

index dd297e5a34b382e8c940600be3fce73aaf253ebf..5d9356b47b662a6664681501d31ff0defbd2ff58 100755 (executable)
@@ -136,7 +136,13 @@ install() {
                 done
             fi
         done < "$dracutsysrootdir"/etc/crypttab > "$initdir"/etc/crypttab
-        mark_hostonly /etc/crypttab
+
+        # Remove empty /etc/crypttab to allow creating it later
+        if [ -s "$initdir"/etc/crypttab ]; then
+            mark_hostonly /etc/crypttab
+        else
+            rm -rf "$initdir"/etc/crypttab
+        fi
     fi
 
     inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"