git » kxd » commit 2e90543

cryptsetup: Copy /etc/kxc into initramfs only if it exists

author Alberto Bertogli
2024-08-10 16:25:41 UTC
committer Alberto Bertogli
2024-08-10 16:25:41 UTC
parent 26069a52958532d8ce481a26218556daf333fffa

cryptsetup: Copy /etc/kxc into initramfs only if it exists

Today, the initramfs hook that copies /etc/kxc does so unconditionally.

That fails if the directory doesn't exist, for example if kxc was
installed but not configured yet.

This patch fixes the issue by only doing the copy if the directory
exists.

Thanks to Leandro Lucarella for reporting this bug:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1063700

cryptsetup/initramfs-hooks/kxc +4 -2

diff --git a/cryptsetup/initramfs-hooks/kxc b/cryptsetup/initramfs-hooks/kxc
index ab78e6f..217bc0e 100755
--- a/cryptsetup/initramfs-hooks/kxc
+++ b/cryptsetup/initramfs-hooks/kxc
@@ -23,5 +23,7 @@ esac
 # it for us if it sees it being used as a keyscript.
 copy_exec /usr/bin/kxc /bin
 
-# Install the configuration into initramfs
-cp -a /etc/kxc/ ${DESTDIR}/etc
+# Install the configuration into initramfs (if it exists).
+if [ -d /etc/kxc/ ]; then
+	cp -a /etc/kxc/ ${DESTDIR}/etc
+fi