aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-10-01 14:31:52 +0200
committerGravatar Christian Hesse <mail@eworm.de>2013-10-01 14:31:52 +0200
commit18006e4e31e0751e77d92e5780533d2ed070592f (patch)
treed4c6a8980c7349a9d6c91b78a872592b7c8d9c17
parente6da9b1b19f96625425f1f22e1fd898f0a8936b2 (diff)
downloadmkinitcpio-ykfde-18006e4e31e0751e77d92e5780533d2ed070592f.tar.gz
mkinitcpio-ykfde-18006e4e31e0751e77d92e5780533d2ed070592f.tar.zst
remove newline from response, answer password agent
-rw-r--r--bin/ykfde2
-rwxr-xr-xudev/ykfde8
2 files changed, 8 insertions, 2 deletions
diff --git a/bin/ykfde b/bin/ykfde
index 7d43b1b..d952e51 100644
--- a/bin/ykfde
+++ b/bin/ykfde
@@ -75,7 +75,7 @@ else
fi
# generate response and add key to LUKS device
-if ! ykchalresp -${SLOT} "${PASS}$(cat ${TMPDIR}/ykfde-challenge)" > "${TMPDIR}/ykfde-response"; then
+if ! ykchalresp -${SLOT} "${PASS}$(cat ${TMPDIR}/ykfde-challenge)" | tr -d '\n' > "${TMPDIR}/ykfde-response"; then
# ykchalresp should have shouted, so do not complain here
exit 1
fi
diff --git a/udev/ykfde b/udev/ykfde
index ce83117..e3fec3d 100755
--- a/udev/ykfde
+++ b/udev/ykfde
@@ -6,4 +6,10 @@ source /etc/ykfde.conf
# yet another add event. Ignore if the file exists.
[ -s /crypto_keyfile.bin ] && exit 0
-ykchalresp -${YKFDE_SLOT:-2} "$(cat /ykfde-challenge)" > /crypto_keyfile.bin 2>/dev/null
+# write the response to keyfile
+ykchalresp -${YKFDE_SLOT:-2} "$(cat /ykfde-challenge)" | tr -d '\n' > /crypto_keyfile.bin 2>/dev/null
+
+# if the systemd unit was faster try to answer password agent
+for REQUEST in $(grep -l '^Message=Please give passphrase for disk' /run/systemd/ask-password/ask.*); do
+ /usr/lib/systemd/systemd-reply-password 1 $(grep '^Socket=' ${REQUEST} | cut -d= -f2) < /crypto_keyfile.bin
+done