From 23ef35d3eddb49bd09df15a8f3f28244e1a4fa70 Mon Sep 17 00:00:00 2001 From: Jo Zzsi Date: Thu, 26 Dec 2024 08:51:53 -0500 Subject: [PATCH] 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 --- modules.d/90crypt/module-setup.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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" -- 2.47.3