Blame 0093-crypt-crypt-run-generator.sh-do-not-add-already-exis.patch

Harald Hoyer 811c04
From 3f7e5358e520b3d55c709a675d46c8080070276d Mon Sep 17 00:00:00 2001
Harald Hoyer 811c04
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 811c04
Date: Mon, 30 Jul 2012 18:35:30 +0200
Harald Hoyer 811c04
Subject: [PATCH] crypt/crypt-run-generator.sh: do not add already existing
Harald Hoyer 811c04
 luks
Harald Hoyer 811c04
Harald Hoyer 811c04
---
Harald Hoyer 811c04
 modules.d/90crypt/crypt-run-generator.sh |  9 ++++++++-
Harald Hoyer 811c04
 test/TEST-10-RAID/create-root.sh         |  3 ++-
Harald Hoyer 811c04
 test/TEST-10-RAID/test.sh                |  9 +++++++--
Harald Hoyer 811c04
 test/TEST-12-RAID-DEG/create-root.sh     |  3 ++-
Harald Hoyer 811c04
 test/TEST-12-RAID-DEG/test.sh            |  6 ++++++
Harald Hoyer 811c04
 test/TEST-13-ENC-RAID-LVM/test.sh        | 14 +++++++++++---
Harald Hoyer 811c04
 test/TEST-30-ISCSI/create-root.sh        |  3 ---
Harald Hoyer 811c04
 test/TEST-40-NBD/create-root.sh          | 16 +++++++++-------
Harald Hoyer 811c04
 test/TEST-40-NBD/test.sh                 |  8 ++++++--
Harald Hoyer 811c04
 9 files changed, 51 insertions(+), 20 deletions(-)
Harald Hoyer 811c04
Harald Hoyer 811c04
diff --git a/modules.d/90crypt/crypt-run-generator.sh b/modules.d/90crypt/crypt-run-generator.sh
Harald Hoyer 811c04
index d70443e..cb3aedc 100755
Harald Hoyer 811c04
--- a/modules.d/90crypt/crypt-run-generator.sh
Harald Hoyer 811c04
+++ b/modules.d/90crypt/crypt-run-generator.sh
Harald Hoyer 811c04
@@ -1,8 +1,15 @@
Harald Hoyer 811c04
-#!/bin/bash
Harald Hoyer 811c04
+#!/bin/sh
Harald Hoyer 811c04
+
Harald Hoyer 811c04
+. /lib/dracut-lib.sh
Harald Hoyer 811c04
 
Harald Hoyer 811c04
 dev=$1
Harald Hoyer 811c04
 luks=$2
Harald Hoyer 811c04
 
Harald Hoyer 811c04
+while read l rest; do
Harald Hoyer 811c04
+    strstr "${l##luks-}" "${luks##luks-}" && exit 0
Harald Hoyer 811c04
+done < /etc/crypttab
Harald Hoyer 811c04
+
Harald Hoyer 811c04
+
Harald Hoyer 811c04
 echo "$luks $dev" >> /etc/crypttab
Harald Hoyer 811c04
 /lib/systemd/system-generators/systemd-cryptsetup-generator
Harald Hoyer 811c04
 systemctl daemon-reload
Harald Hoyer 811c04
diff --git a/test/TEST-10-RAID/create-root.sh b/test/TEST-10-RAID/create-root.sh
Harald Hoyer 811c04
index 3dd86cb..cd67819 100755
Harald Hoyer 811c04
--- a/test/TEST-10-RAID/create-root.sh
Harald Hoyer 811c04
+++ b/test/TEST-10-RAID/create-root.sh
Harald Hoyer 811c04
@@ -34,5 +34,6 @@ lvm lvchange -a n /dev/dracut/root
Harald Hoyer 811c04
 udevadm settle
Harald Hoyer 811c04
 cryptsetup luksClose /dev/mapper/dracut_crypt_test
Harald Hoyer 811c04
 udevadm settle
Harald Hoyer 811c04
-echo "dracut-root-block-created" >/dev/sda1
Harald Hoyer 811c04
+eval $(udevadm info --query=env --name=/dev/md0|while read line; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
Harald Hoyer 811c04
+{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } >/dev/sda1
Harald Hoyer 811c04
 poweroff -f
Harald Hoyer 811c04
diff --git a/test/TEST-10-RAID/test.sh b/test/TEST-10-RAID/test.sh
Harald Hoyer 811c04
index d2b1921..45bb62e 100755
Harald Hoyer 811c04
--- a/test/TEST-10-RAID/test.sh
Harald Hoyer 811c04
+++ b/test/TEST-10-RAID/test.sh
Harald Hoyer 811c04
@@ -4,14 +4,14 @@ TEST_DESCRIPTION="root filesystem on an encrypted LVM PV on a RAID-5"
Harald Hoyer 811c04
 KVERSION=${KVERSION-$(uname -r)}
Harald Hoyer 811c04
 
Harald Hoyer 811c04
 # Uncomment this to debug failures
Harald Hoyer 811c04
-#DEBUGFAIL="rd.shell"
Harald Hoyer 811c04
+DEBUGFAIL="rd.shell rd.udev.log-priority=debug loglevel=70 systemd.log_target=kmsg"
Harald Hoyer 811c04
 test_run() {
Harald Hoyer 811c04
     DISKIMAGE=$TESTDIR/TEST-10-RAID-root.img
Harald Hoyer 811c04
     $testdir/run-qemu \
Harald Hoyer 811c04
 	-hda $DISKIMAGE \
Harald Hoyer 811c04
 	-m 256M -nographic \
Harald Hoyer 811c04
 	-net none -kernel /boot/vmlinuz-$KVERSION \
Harald Hoyer 811c04
-	-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $DEBUGFAIL" \
Harald Hoyer 811c04
+	-append "root=/dev/dracut/root rw rd.retry=10 console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
Harald Hoyer 811c04
 	-initrd $TESTDIR/initramfs.testing
Harald Hoyer 811c04
     grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
Harald Hoyer 811c04
 }
Harald Hoyer 811c04
@@ -70,6 +70,7 @@ test_setup() {
Harald Hoyer 811c04
 	-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
Harald Hoyer 811c04
 	-initrd $TESTDIR/initramfs.makeroot  || return 1
Harald Hoyer 811c04
     grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
Harald Hoyer 811c04
+    eval $(grep -a -m 1 ID_FS_UUID $DISKIMAGE)
Harald Hoyer 811c04
 
Harald Hoyer 811c04
     (
Harald Hoyer 811c04
 	export initdir=$TESTDIR/overlay
Harald Hoyer 811c04
@@ -77,8 +78,12 @@ test_setup() {
Harald Hoyer 811c04
 	dracut_install poweroff shutdown
Harald Hoyer 811c04
 	inst_hook emergency 000 ./hard-off.sh
Harald Hoyer 811c04
 	inst ./cryptroot-ask.sh /sbin/cryptroot-ask
Harald Hoyer 811c04
+        mkdir -p $initdir/etc
Harald Hoyer 811c04
+        echo "luks-$ID_FS_UUID /dev/md0 /etc/key" > $initdir/etc/crypttab
Harald Hoyer 811c04
+        echo -n "test" > $initdir/etc/key
Harald Hoyer 811c04
 	inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
Harald Hoyer 811c04
     )
Harald Hoyer 811c04
+
Harald Hoyer 811c04
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
Harald Hoyer 811c04
 	-o "plymouth network" \
Harald Hoyer 811c04
 	-a "debug" \
Harald Hoyer 811c04
diff --git a/test/TEST-12-RAID-DEG/create-root.sh b/test/TEST-12-RAID-DEG/create-root.sh
Harald Hoyer 811c04
index 84f5ad2..d5a8c0b 100755
Harald Hoyer 811c04
--- a/test/TEST-12-RAID-DEG/create-root.sh
Harald Hoyer 811c04
+++ b/test/TEST-12-RAID-DEG/create-root.sh
Harald Hoyer 811c04
@@ -41,4 +41,5 @@ udevadm settle
Harald Hoyer 811c04
 mdadm -W /dev/md0 || :
Harald Hoyer 811c04
 mdadm --detail --export /dev/md0 |grep MD_UUID > /tmp/mduuid
Harald Hoyer 811c04
 . /tmp/mduuid
Harald Hoyer 811c04
-{ echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID; } > /dev/sda1
Harald Hoyer 811c04
+eval $(udevadm info --query=env --name=/dev/md0|while read line; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
Harald Hoyer 811c04
+{ echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID;  echo "ID_FS_UUID=$ID_FS_UUID";} > /dev/sda1
Harald Hoyer 811c04
diff --git a/test/TEST-12-RAID-DEG/test.sh b/test/TEST-12-RAID-DEG/test.sh
Harald Hoyer 811c04
index 96c84f8..558e3b0 100755
Harald Hoyer 811c04
--- a/test/TEST-12-RAID-DEG/test.sh
Harald Hoyer 811c04
+++ b/test/TEST-12-RAID-DEG/test.sh
Harald Hoyer 811c04
@@ -103,8 +103,11 @@ test_setup() {
Harald Hoyer 811c04
 	-kernel "/boot/vmlinuz-$kernel" \
Harald Hoyer 811c04
 	-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
Harald Hoyer 811c04
 	-initrd $TESTDIR/initramfs.makeroot  || return 1
Harald Hoyer 811c04
+
Harald Hoyer 811c04
     grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
Harald Hoyer 811c04
     eval $(grep --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2)
Harald Hoyer 811c04
+    eval $(grep -a -m 1 ID_FS_UUID $TESTDIR/root.ext2)
Harald Hoyer 811c04
+
Harald Hoyer 811c04
     (
Harald Hoyer 811c04
 	export initdir=$TESTDIR/overlay
Harald Hoyer 811c04
 	. $basedir/dracut-functions.sh
Harald Hoyer 811c04
@@ -114,7 +117,10 @@ test_setup() {
Harald Hoyer 811c04
 	inst ./cryptroot-ask.sh /sbin/cryptroot-ask
Harald Hoyer 811c04
         mkdir -p $initdir/etc
Harald Hoyer 811c04
         echo "ARRAY /dev/md0 level=raid5 num-devices=3 UUID=$MD_UUID" > $initdir/etc/mdadm.conf
Harald Hoyer 811c04
+        echo "luks-$ID_FS_UUID /dev/md0 /etc/key" > $initdir/etc/crypttab
Harald Hoyer 811c04
+        echo -n test > $initdir/etc/key
Harald Hoyer 811c04
     )
Harald Hoyer 811c04
+
Harald Hoyer 811c04
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
Harald Hoyer 811c04
 	-o "plymouth network" \
Harald Hoyer 811c04
 	-a "debug" \
Harald Hoyer 811c04
diff --git a/test/TEST-13-ENC-RAID-LVM/test.sh b/test/TEST-13-ENC-RAID-LVM/test.sh
Harald Hoyer 811c04
index f0f7d34..dff3229 100755
Harald Hoyer 811c04
--- a/test/TEST-13-ENC-RAID-LVM/test.sh
Harald Hoyer 811c04
+++ b/test/TEST-13-ENC-RAID-LVM/test.sh
Harald Hoyer 811c04
@@ -17,7 +17,7 @@ test_run() {
Harald Hoyer 811c04
 	-hdb $TESTDIR/check-success.img \
Harald Hoyer 811c04
 	-m 256M -nographic \
Harald Hoyer 811c04
 	-net none -kernel /boot/vmlinuz-$KVERSION \
Harald Hoyer 811c04
-	-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $LUKSARGS $DEBUGFAIL" \
Harald Hoyer 811c04
+	-append "root=/dev/dracut/root rw quiet rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $LUKSARGS $DEBUGFAIL" \
Harald Hoyer 811c04
 	-initrd $TESTDIR/initramfs.testing
Harald Hoyer 811c04
     grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
Harald Hoyer 811c04
     echo "CLIENT TEST END: [OK]"
Harald Hoyer 811c04
@@ -30,7 +30,7 @@ test_run() {
Harald Hoyer 811c04
 	-hdb $TESTDIR/check-success.img \
Harald Hoyer 811c04
 	-m 256M -nographic \
Harald Hoyer 811c04
 	-net none -kernel /boot/vmlinuz-$KVERSION \
Harald Hoyer 811c04
-	-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $DEBUGFAIL" \
Harald Hoyer 811c04
+	-append "root=/dev/dracut/root rw quiet rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $DEBUGFAIL" \
Harald Hoyer 811c04
 	-initrd $TESTDIR/initramfs.testing
Harald Hoyer 811c04
     grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
Harald Hoyer 811c04
     echo "CLIENT TEST END: [OK]"
Harald Hoyer 811c04
@@ -43,7 +43,7 @@ test_run() {
Harald Hoyer 811c04
 	-hdb $TESTDIR/check-success.img \
Harald Hoyer 811c04
 	-m 256M -nographic \
Harald Hoyer 811c04
 	-net none -kernel /boot/vmlinuz-$KVERSION \
Harald Hoyer 811c04
-	-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $DEBUGFAIL rd.luks.uuid=failme" \
Harald Hoyer 811c04
+	-append "root=/dev/dracut/root rw quiet rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $DEBUGFAIL rd.luks.uuid=failme" \
Harald Hoyer 811c04
 	-initrd $TESTDIR/initramfs.testing
Harald Hoyer 811c04
     grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img && return 1
Harald Hoyer 811c04
     echo "CLIENT TEST END: [OK]"
Harald Hoyer 811c04
@@ -114,6 +114,14 @@ test_setup() {
Harald Hoyer 811c04
 	inst_hook emergency 000 ./hard-off.sh
Harald Hoyer 811c04
 	inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
Harald Hoyer 811c04
 	inst ./cryptroot-ask.sh /sbin/cryptroot-ask
Harald Hoyer 811c04
+        mkdir -p $initdir/etc
Harald Hoyer 811c04
+        i=2
Harald Hoyer 811c04
+        for uuid in $cryptoUUIDS; do
Harald Hoyer 811c04
+	    eval $uuid
Harald Hoyer 811c04
+	    printf 'luks-%s /dev/sda%s /etc/key\n' $ID_FS_UUID $i
Harald Hoyer 811c04
+            ((i+=1))
Harald Hoyer 811c04
+        done > $initdir/etc/crypttab
Harald Hoyer 811c04
+        echo -n test > $initdir/etc/key
Harald Hoyer 811c04
     )
Harald Hoyer 811c04
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
Harald Hoyer 811c04
 	-o "plymouth network" \
Harald Hoyer 811c04
diff --git a/test/TEST-30-ISCSI/create-root.sh b/test/TEST-30-ISCSI/create-root.sh
Harald Hoyer 811c04
index 6016320..8116a13 100755
Harald Hoyer 811c04
--- a/test/TEST-30-ISCSI/create-root.sh
Harald Hoyer 811c04
+++ b/test/TEST-30-ISCSI/create-root.sh
Harald Hoyer 811c04
@@ -23,6 +23,3 @@ umount /sysroot && \
Harald Hoyer 811c04
 lvm lvchange -a n /dev/dracut/root && \
Harald Hoyer 811c04
 echo "dracut-root-block-created" >/dev/sdb
Harald Hoyer 811c04
 poweroff -f
Harald Hoyer 811c04
-
Harald Hoyer 811c04
-#lvm lvchange -a n /dev/dracut/root && \
Harald Hoyer 811c04
-#cryptsetup luksClose /dev/mapper/dracut_crypt_test && \
Harald Hoyer 811c04
diff --git a/test/TEST-40-NBD/create-root.sh b/test/TEST-40-NBD/create-root.sh
Harald Hoyer 811c04
index 4bef5f1..5b902c3 100755
Harald Hoyer 811c04
--- a/test/TEST-40-NBD/create-root.sh
Harald Hoyer 811c04
+++ b/test/TEST-40-NBD/create-root.sh
Harald Hoyer 811c04
@@ -18,11 +18,13 @@ mke2fs -j /dev/dracut/root && \
Harald Hoyer 811c04
 mkdir -p /sysroot && \
Harald Hoyer 811c04
 mount /dev/dracut/root /sysroot && \
Harald Hoyer 811c04
 cp -a -t /sysroot /source/* && \
Harald Hoyer 811c04
-umount /sysroot && \
Harald Hoyer 811c04
-sleep 1 && \
Harald Hoyer 811c04
-lvm lvchange -a n /dev/dracut/root && \
Harald Hoyer 811c04
-sleep 1 && \
Harald Hoyer 811c04
-cryptsetup luksClose /dev/mapper/dracut_crypt_test && \
Harald Hoyer 811c04
-sleep 1 && \
Harald Hoyer 811c04
-echo "dracut-root-block-created" >/dev/sda
Harald Hoyer 811c04
+umount /sysroot
Harald Hoyer 811c04
+sleep 1
Harald Hoyer 811c04
+lvm lvchange -a n /dev/dracut/root
Harald Hoyer 811c04
+udevadm settle
Harald Hoyer 811c04
+cryptsetup luksClose /dev/mapper/dracut_crypt_test
Harald Hoyer 811c04
+udevadm settle
Harald Hoyer 811c04
+sleep 1
Harald Hoyer 811c04
+eval $(udevadm info --query=env --name=/dev/sdb|while read line; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
Harald Hoyer 811c04
+{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } >/dev/sda
Harald Hoyer 811c04
 poweroff -f
Harald Hoyer 811c04
diff --git a/test/TEST-40-NBD/test.sh b/test/TEST-40-NBD/test.sh
Harald Hoyer 811c04
index 99d930f..9881630 100755
Harald Hoyer 811c04
--- a/test/TEST-40-NBD/test.sh
Harald Hoyer 811c04
+++ b/test/TEST-40-NBD/test.sh
Harald Hoyer 811c04
@@ -52,7 +52,6 @@ client_test() {
Harald Hoyer 811c04
 	echo "Unable to make client sda image" 1>&2
Harald Hoyer 811c04
 	return 1
Harald Hoyer 811c04
     fi
Harald Hoyer 811c04
-
Harald Hoyer 811c04
     $testdir/run-qemu \
Harald Hoyer 811c04
         -hda $TESTDIR/flag.img \
Harald Hoyer 811c04
         -m 256M -nographic \
Harald Hoyer 811c04
@@ -234,6 +233,7 @@ make_encrypted_root() {
Harald Hoyer 811c04
 	-append "root=/dev/dracut/root rw quiet console=ttyS0,115200n81 selinux=0" \
Harald Hoyer 811c04
 	-initrd $TESTDIR/initramfs.makeroot  || return 1
Harald Hoyer 811c04
     grep -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1
Harald Hoyer 811c04
+    grep -a -m 1 ID_FS_UUID $TESTDIR/flag.img > $TESTDIR/luks.uuid
Harald Hoyer 811c04
 }
Harald Hoyer 811c04
 
Harald Hoyer 811c04
 make_client_root() {
Harald Hoyer 811c04
@@ -328,7 +328,11 @@ test_setup() {
Harald Hoyer 811c04
 	dracut_install poweroff shutdown
Harald Hoyer 811c04
 	inst_hook emergency 000 ./hard-off.sh
Harald Hoyer 811c04
 	inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
Harald Hoyer 811c04
-	inst ./cryptroot-ask.sh /sbin/cryptroot-ask
Harald Hoyer 811c04
+        inst ./cryptroot-ask.sh /sbin/cryptroot-ask
Harald Hoyer 811c04
+        . $TESTDIR/luks.uuid
Harald Hoyer 811c04
+        mkdir -p $initdir/etc
Harald Hoyer 811c04
+	echo "luks-$ID_FS_UUID /dev/nbd0 /etc/key" > $initdir/etc/crypttab
Harald Hoyer 811c04
+        echo -n test > $initdir/etc/key
Harald Hoyer 811c04
     )
Harald Hoyer 811c04
 
Harald Hoyer 811c04
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \