File kdump-nsswitch.conf-filtering.patch of Package kdump.21349

From: Lance Wang <lzwang@suse.com>
Date: Mon, 4 Dec 2017 16:14:06 +0800
Subject: Copy /etc/hosts and /etc/nsswitch.conf in setup-kdump.functions
References: bsc#1048178,bsc#1002617
Upstream: merged
Git-commit: c5b2ce7c303d19f3615607d9867a06ce0f0d7ae2

Only filter field hosts from /etc/nsswitch.conf to avoid ssh login failure.
It is better to copy files in kdump dracut module than via the cmdline
to dracut.
---
 init/mkdumprd              |    3 ---
 init/setup-kdump.functions |    2 ++
 2 files changed, 2 insertions(+), 3 deletions(-)

--- a/init/mkdumprd
+++ b/init/mkdumprd
@@ -142,9 +142,6 @@ function run_dracut()
     # Make resolved variables visible to the dracut module
     kdump_export_targets
 
-    # Include additional files in the kdump initial ram disk
-    DRACUT_ARGS="$DRACUT_ARGS --install '/etc/hosts /etc/nsswitch.conf'"
-
     DRACUT_ARGS="$DRACUT_ARGS --add 'kdump' $INITRD $KERNELVERSION"
     echo "Regenerating kdump initrd ..." >&2
     eval "bash -$- $DRACUT $DRACUT_ARGS"
--- a/init/setup-kdump.functions
+++ b/init/setup-kdump.functions
@@ -859,6 +859,8 @@ function kdump_modify_config()						   #
             KDUMP_SAVEDIR="${KDUMP_SAVEDIR}file://${kdump_Realpath[i]}"
 	elif [ "$protocol" != "srcfile" ] ; then
             KDUMP_SAVEDIR="${KDUMP_SAVEDIR}${kdump_URL[i]}"
+            cp /etc/hosts "${dest}/etc"
+            grep '^hosts:' /etc/nsswitch.conf > "${dest}/etc/nsswitch.conf"
 	fi
 
 	#
openSUSE Build Service is sponsored by