File kdump-do-not-touch-dracut-vars-if-not-kdumprd.patch of Package kdump.17334

From: Petr Tesarik <ptesarik@suse.com>
Date: Wed, 2 May 2018 13:25:27 +0200
Subject: Do not touch dracut variables when generating a non-kdump initrd
References: bsc#1091304
Upstream: merged
Git-commit: a61577cfd7e92486b9fe708056e4c13e202fc21f

The kdump module's check() function is called for all dracut
invocations, i.e. even if the kdump module is not included.
Unfortunately, the check() routine modifies enough of dracut's
internal state to request bogus kdump mount points. This is
desirable for a kdump initrd but may render the system unbootable
otherwise.

Check explicitly that we're building a kdump-enabled initrd before
doing anything else.

Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
 init/module-setup.sh |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

--- a/init/module-setup.sh
+++ b/init/module-setup.sh
@@ -3,6 +3,21 @@
 
 . /lib/kdump/setup-kdump.functions
 
+kdump_needed() {
+    # Building a kdump initrd?
+    if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
+        return 0
+    fi
+
+    # Is FADUMP active?
+    if [ "$KDUMP_FADUMP" = "yes" ]; then
+        return 0
+    fi
+
+    # Do not include kdump by default
+    return 1
+}
+
 kdump_check_net() {
     kdump_neednet=
     for protocol in "${kdump_Protocol[@]}" ; do
@@ -98,6 +113,8 @@ check() {
     # Get configuration
     kdump_get_config || return 1
 
+    kdump_needed || return 1
+
     # add mount points
     if ! [[ $mount_needs ]] ; then
         kdump_get_mountpoints || return 1
@@ -112,7 +129,7 @@ check() {
 
     kdump_check_net
 
-    return 255
+    return 0
 }
 
 depends() {
openSUSE Build Service is sponsored by