From: "Przemysław Rudy" <prudy1-h7QdYz1kt/Q@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 2/2] luks key on ext dev - wait for luks
Date: Tue, 07 Jun 2011 20:22:51 +0200 [thread overview]
Message-ID: <islq9r$vpc$1@dough.gmane.org> (raw)
This asks for the luks passphrase if key is not found for defined time (if defined with rd.luks.tout cmd line):
modules.d/90crypt/cryptroot-ask.sh | 21 ++++++++++++++++++---
modules.d/90crypt/parse-crypt.sh | 5 +++--
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/modules.d/90crypt/cryptroot-ask.sh b/modules.d/90crypt/cryptroot-ask.sh
index f8e1bd8..9b8f8c2 100755
--- a/modules.d/90crypt/cryptroot-ask.sh
+++ b/modules.d/90crypt/cryptroot-ask.sh
@@ -22,6 +22,9 @@ NEWROOT=${NEWROOT:-"/sysroot"}
# default luksname - luks-UUID
luksname=$2
+# fallback to passphrase
+ask_passphrase=1
+
# if device name is /dev/dm-X, convert to /dev/mapper/name
if [ "${1##/dev/dm-}" != "$1" ]; then
device="/dev/mapper/$(dmsetup info -c --noheadings -o name "$1")"
@@ -63,12 +66,21 @@ fi
info "luksOpen $device $luksname"
-if [ -n "$(getarg rd.luks.key)" ]; then
+while [ -n "$(getarg rd.luks.key)" ]; do
if tmp=$(getkey /tmp/luks.keys $device); then
keydev="${tmp%%:*}"
keypath="${tmp#*:}"
else
- info "No key found for $device. Will try later."
+ if [ $# -eq 3 ]; then
+ if [ $3 -eq 0 ]; then
+ info "No key found for $device. Fallback to passphrase mode."
+ break
+ fi
+ info "No key found for $device. Will try $3 time(s) more later."
+ set -- "$1" "$2" "$(($3 - 1))"
+ else
+ info "No key found for $device. Will try later."
+ fi
initqueue --unique --onetime --settled \
--name cryptroot-ask-$luksname \
$(command -v cryptroot-ask) "$@"
@@ -80,7 +92,10 @@ if [ -n "$(getarg rd.luks.key)" ]; then
readkey "$keypath" "$keydev" "$device" \
| cryptsetup -d - luksOpen "$device" "$luksname"
unset keypath keydev
-else
+ ask_passphrase=0
+ break
+done
+if [ $ask_passphrase -ne 0 ]; then
luks_open="$(command -v cryptsetup) luksOpen"
ask_for_password --ply-tries 5 \
--ply-cmd "$luks_open -T1 $device $luksname" \
diff --git a/modules.d/90crypt/parse-crypt.sh b/modules.d/90crypt/parse-crypt.sh
index 7ec232a..c76fb23 100755
--- a/modules.d/90crypt/parse-crypt.sh
+++ b/modules.d/90crypt/parse-crypt.sh
@@ -11,6 +11,7 @@ else
} > /etc/udev/rules.d/70-luks.rules.new
LUKS=$(getargs rd.luks.uuid rd_LUKS_UUID)
+ tout=$(getarg rd.luks.tout)
if [ -n "$LUKS" ]; then
for luksid in $LUKS; do
@@ -20,7 +21,7 @@ else
printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
printf -- '--name cryptroot-ask-%%k %s ' $(command -v cryptroot-ask)
- printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n'
+ printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $tout
} >> /etc/udev/rules.d/70-luks.rules.new
printf -- '[ -e /dev/disk/by-uuid/*%s* ]\n' $luksid \
@@ -34,7 +35,7 @@ else
{
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' $(command -v initqueue)
printf -- '--unique --onetime --name cryptroot-ask-%%k '
- printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID}"\n' $(command -v cryptroot-ask)
+ printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $(command -v cryptroot-ask) $tout
} >> /etc/udev/rules.d/70-luks.rules.new
fi
next reply other threads:[~2011-06-07 18:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-07 18:22 Przemysław Rudy [this message]
2011-08-18 15:57 ` [PATCH 2/2] luks key on ext dev - wait for luks Przemek Rudy
[not found] ` <loom.20110818T175530-594-eS7Uydv5nfjZ+VzJOa5vwg@public.gmane.org>
2011-08-18 16:06 ` Amadeusz Żołnowski
2011-08-21 8:26 ` [PATCH 2/2] crypt: changed cmdline arg name from rd.luks.tout to rd.luks.key.tout Amadeusz Żołnowski
[not found] ` <1313915200-13079-1-git-send-email-aidecoe-2qtfh70TtYba5EbDDlwbIw@public.gmane.org>
2011-08-21 8:31 ` Amadeusz Żołnowski
2011-08-25 18:20 ` Przemek Rudy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='islq9r$vpc$1@dough.gmane.org' \
--to=prudy1-h7qdyz1kt/q@public.gmane.org \
--cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox