123 lines
5.3 KiB
Diff
123 lines
5.3 KiB
Diff
From 3d352f522837ce8dc20ae130f79462e5a3cce347 Mon Sep 17 00:00:00 2001
|
|
From: Harald Hoyer <harald@redhat.com>
|
|
Date: Mon, 30 Jul 2012 14:34:55 +0200
|
|
Subject: [PATCH] crypt: add systemd crypt support
|
|
|
|
---
|
|
modules.d/90crypt/crypt-run-generator.sh | 10 +++++++
|
|
modules.d/90crypt/module-setup.sh | 13 ++++++++-
|
|
modules.d/90crypt/parse-crypt.sh | 46 ++++++++++++++++++++++----------
|
|
3 files changed, 54 insertions(+), 15 deletions(-)
|
|
create mode 100755 modules.d/90crypt/crypt-run-generator.sh
|
|
|
|
diff --git a/modules.d/90crypt/crypt-run-generator.sh b/modules.d/90crypt/crypt-run-generator.sh
|
|
new file mode 100755
|
|
index 0000000..d70443e
|
|
--- /dev/null
|
|
+++ b/modules.d/90crypt/crypt-run-generator.sh
|
|
@@ -0,0 +1,10 @@
|
|
+#!/bin/bash
|
|
+
|
|
+dev=$1
|
|
+luks=$2
|
|
+
|
|
+echo "$luks $dev" >> /etc/crypttab
|
|
+/lib/systemd/system-generators/systemd-cryptsetup-generator
|
|
+systemctl daemon-reload
|
|
+systemctl start cryptsetup.target
|
|
+exit 0
|
|
diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh
|
|
index 9b0bf64..b6d97af 100755
|
|
--- a/modules.d/90crypt/module-setup.sh
|
|
+++ b/modules.d/90crypt/module-setup.sh
|
|
@@ -49,5 +49,16 @@ install() {
|
|
inst_hook cleanup 30 "$moddir/crypt-cleanup.sh"
|
|
inst_simple /etc/crypttab
|
|
inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"
|
|
-}
|
|
|
|
+ dracut_install -o \
|
|
+ $systemdutildir/system-generators/systemd-cryptsetup-generator \
|
|
+ $systemdutildir/system-generators/systemd-cryptsetup-generator \
|
|
+ $systemdutildir/systemd-cryptsetup \
|
|
+ $systemdsystemunitdir/systemd-ask-password-console.path \
|
|
+ $systemdsystemunitdir/systemd-ask-password-console.service \
|
|
+ $systemdsystemunitdir/cryptsetup.target \
|
|
+ $systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \
|
|
+ systemd-ask-password systemd-tty-ask-password-agent
|
|
+ inst_hook initqueue/finished 01 "$moddir/finished-ask-password.sh"
|
|
+ inst_script "$moddir"/crypt-run-generator.sh /sbin/crypt-run-generator
|
|
+}
|
|
diff --git a/modules.d/90crypt/parse-crypt.sh b/modules.d/90crypt/parse-crypt.sh
|
|
index e20e6e0..8d1c8cd 100755
|
|
--- a/modules.d/90crypt/parse-crypt.sh
|
|
+++ b/modules.d/90crypt/parse-crypt.sh
|
|
@@ -2,8 +2,6 @@
|
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
|
-[ -n "$DRACUT_SYSTEMD" ] && exit 0
|
|
-
|
|
if ! getargbool 1 rd.luks -d -n rd_NO_LUKS; then
|
|
info "rd.luks=0: removing cryptoluks activation"
|
|
rm -f /etc/udev/rules.d/70-luks.rules
|
|
@@ -18,14 +16,26 @@ else
|
|
|
|
if [ -n "$LUKS" ]; then
|
|
for luksid in $LUKS; do
|
|
+
|
|
luksid=${luksid##luks-}
|
|
- {
|
|
- printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
|
|
- 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} %s"\n' $tout
|
|
- } >> /etc/udev/rules.d/70-luks.rules.new
|
|
+
|
|
+ if [ -z "$DRACUT_SYSTEMD" ]; then
|
|
+ {
|
|
+ printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
|
|
+ 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} %s"\n' $tout
|
|
+ } >> /etc/udev/rules.d/70-luks.rules.new
|
|
+ else
|
|
+ {
|
|
+ printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
|
|
+ printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
|
|
+ printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
|
|
+ printf -- '--name crypt-run-generator-%%k %s ' $(command -v crypt-run-generator)
|
|
+ printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n'
|
|
+ } >> /etc/udev/rules.d/70-luks.rules.new
|
|
+ fi
|
|
|
|
uuid=$luksid
|
|
while [ "$uuid" != "${uuid#*-}" ]; do uuid=${uuid%%-*}${uuid#*-}; done
|
|
@@ -38,11 +48,19 @@ else
|
|
} >> $hookdir/emergency/90-crypt.sh
|
|
done
|
|
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} %s"\n' $(command -v cryptroot-ask) $tout
|
|
- } >> /etc/udev/rules.d/70-luks.rules.new
|
|
+ if [ -z "$DRACUT_SYSTEMD" ]; then
|
|
+ {
|
|
+ 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} %s"\n' $(command -v cryptroot-ask) $tout
|
|
+ } >> /etc/udev/rules.d/70-luks.rules.new
|
|
+ else
|
|
+ {
|
|
+ printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' $(command -v initqueue)
|
|
+ printf -- '--unique --onetime --name crypt-run-generator-%%k '
|
|
+ printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID}"\n' $(command -v crypt-run-generator)
|
|
+ } >> /etc/udev/rules.d/70-luks.rules.new
|
|
+ fi
|
|
fi
|
|
|
|
echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules.new
|