From: Jo Zzsi Date: Thu, 26 Dec 2024 13:51:53 +0000 (-0500) Subject: feat(crypt): remove empty /etc/crypttab to allow creating it later X-Git-Tag: 106~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23ef35d;p=thirdparty%2Fdracut-ng.git feat(crypt): remove empty /etc/crypttab to allow creating it later 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 --- diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh index dd297e5a3..5d9356b47 100755 --- a/modules.d/90crypt/module-setup.sh +++ b/modules.d/90crypt/module-setup.sh @@ -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"