File 0303-crypt_parse-crypt.sh_hide_encrypted_devices_from_systemd_timeout_warnings.patch of Package dracut.892

From: NeilBrown <neilb@suse.de>
Subject: crypt/parse-crypt.sh: hide encrypted devices from systemd timeout warnings.
References: bnc#932735
Patch-Mainline: 
Git-commit: 4d9d767da2e5928552a9603d91382f8dc34cc26d
Git-repo: git.kernel.org/pub/scm/boot/dracut/dracut.git

Signed-off-by: Thomas Renninger <trenn@suse.de>

When systemd's crypttab generator parsed crypttab, it tells
systemd about several devices which may not appear until later
in the boot sequence, and which are not needed while dract is running.

This can particularly happen when an md array is encrypted,
and the array is newly degraded so that it doesn't appear until
dracut runs mdraid_start.sh.

This can result in systemd printing warning messages which are
inappropriate.

So tell systemd that the timeout for each of these is zero.

This is involves splitting some functionality out of wait_for_dev()

That function does two things:
 - creates 'finished' hooks so that dracut will wait for the device,
   and
 - sets the systemd timeout for the device to zero, so systemd doesn't
   wait.

We only want the second of these for most encrypted devices.
So split that out into a new function set_systemd_timeout_for_dev(),
and call it from parse-crypt.sh

Signed-off-by: NeilBrown <neilb@suse.de>

--
This version fixes the missing redirect from /etc/crypttab
NeilBrown

Index: dracut-037/modules.d/90crypt/parse-crypt.sh
===================================================================
--- dracut-037.orig/modules.d/90crypt/parse-crypt.sh	2015-06-03 18:44:03.786006303 +0200
+++ dracut-037/modules.d/90crypt/parse-crypt.sh	2015-06-03 18:44:20.974970795 +0200
@@ -16,6 +16,10 @@
     LUKS=$(getargs rd.luks.uuid -d rd_LUKS_UUID)
     tout=$(getarg rd.luks.key.tout)
 
+    while read _mapper _dev _rest ; do
+        set_systemd_timeout_for_dev $_dev
+    done < /etc/crypttab
+
     if [ -n "$LUKS" ]; then
         for luksid in $LUKS; do
 
Index: dracut-037/modules.d/99base/dracut-lib.sh
===================================================================
--- dracut-037.orig/modules.d/99base/dracut-lib.sh	2015-06-03 18:44:03.786006303 +0200
+++ dracut-037/modules.d/99base/dracut-lib.sh	2015-06-03 18:44:20.974970795 +0200
@@ -878,12 +878,10 @@
     printf -- "%s" "$dev"
 }
 
-# wait_for_dev <dev>
-#
-# Installs a initqueue-finished script,
-# which will cause the main loop only to exit,
-# if the device <dev> is recognized by the system.
-wait_for_dev()
+# set_systemd_timeout_for_dev <dev>
+# Set 'rd.timeout' as the systemd timeout for <dev>
+
+set_systemd_timeout_for_dev()
 {
     local _name
     local _needreload
@@ -898,17 +896,6 @@
     _timeout=$(getarg rd.timeout)
     _timeout=${_timeout:-0}
 
-    _name="$(str_replace "$1" '/' '\x2f')"
-
-    [ -e "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
-
-    printf '[ -e "%s" ]\n' $1 \
-        >> "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh"
-    {
-        printf '[ -e "%s" ] || ' $1
-        printf 'warn "\"%s\" does not exist"\n' $1
-    } >> "${PREFIX}$hookdir/emergency/80-${_name}.sh"
-
     if [ -n "$DRACUT_SYSTEMD" ]; then
         _name=$(dev_unit_name "$1")
         if ! [ -L ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device ]; then
@@ -931,6 +918,36 @@
         fi
     fi
 }
+# wait_for_dev <dev>
+#
+# Installs a initqueue-finished script,
+# which will cause the main loop only to exit,
+# if the device <dev> is recognized by the system.
+wait_for_dev()
+{
+    local _name
+    local _noreload
+
+    if [ "$1" = "-n" ]; then
+        _noreload=-n
+        shift
+    fi
+
+    _name="$(str_replace "$1" '/' '\x2f')"
+
+    type mark_hostonly >/dev/null 2>&1 && mark_hostonly "$hookdir/initqueue/finished/devexists-${_name}.sh"
+
+    [ -e "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
+
+    printf '[ -e "%s" ]\n' $1 \
+        >> "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh"
+    {
+        printf '[ -e "%s" ] || ' $1
+        printf 'warn "\"%s\" does not exist"\n' $1
+    } >> "${PREFIX}$hookdir/emergency/80-${_name}.sh"
+
+    set_systemd_timeout_for_dev $_noreload $1
+}
 
 cancel_wait_for_dev()
 {