Blame SOURCES/0495-95ssh-client-attempt-to-copy-UserKnownHostsFile-to-k.patch

18971c
From 5ae8333947bb6a71232fbb99c626e08f177178e2 Mon Sep 17 00:00:00 2001
18971c
From: Tong Li <tonli@redhat.com>
18971c
Date: Wed, 30 Nov 2016 17:05:57 +0800
18971c
Subject: [PATCH] 95ssh-client: attempt to copy UserKnownHostsFile to kdump's
18971c
 initramfs
18971c
18971c
Bug related to this issue: https://bugzilla.redhat.com/show_bug.cgi?id=1360131
18971c
Now dracut only attempts to copy GlobalKnownHostsFile while generating kdump's
18971c
initramfs. This method will cause kdump's failure if users set customized
18971c
UserKnownHostsFile in /etc/ssh/ssh_config. This patch simply attempts to copy
18971c
those files too while going through /etc/ssh/ssh_config. Note that we need to
18971c
make sure ~/foo will be copied as /root/foo in kdump's initramfs.
18971c
18971c
Cherry-picked from: 32f5af2f5e20ee982745262c444c50b20bfb4c01
18971c
Resolves: #1360131
18971c
---
18971c
 modules.d/95ssh-client/module-setup.sh | 15 +++++++++++----
18971c
 1 file changed, 11 insertions(+), 4 deletions(-)
18971c
18971c
diff --git a/modules.d/95ssh-client/module-setup.sh b/modules.d/95ssh-client/module-setup.sh
18971c
index 6b441075..743de988 100755
18971c
--- a/modules.d/95ssh-client/module-setup.sh
18971c
+++ b/modules.d/95ssh-client/module-setup.sh
18971c
@@ -44,10 +44,17 @@ inst_sshenv()
18971c
     if [[ -f /etc/ssh/ssh_config ]]; then
18971c
         inst_simple /etc/ssh/ssh_config
18971c
         sed -i -e 's/\(^[[:space:]]*\)ProxyCommand/\1# ProxyCommand/' ${initdir}/etc/ssh/ssh_config
18971c
-        while read key val; do
18971c
-            [[ $key != "GlobalKnownHostsFile" ]] && continue
18971c
-            inst_simple "$val"
18971c
-            break
18971c
+        while read key val || [ -n "$key" ]; do
18971c
+            if [[ $key == "GlobalKnownHostsFile" ]]; then
18971c
+                inst_simple "$val"
18971c
+            # Copy customized UserKnowHostsFile
18971c
+            elif [[ $key == "UserKnownHostsFile" ]]; then
18971c
+                # Make sure that ~/foo will be copied as /root/foo in kdump's initramfs
18971c
+                if str_starts "$val" "~/"; then
18971c
+                    val="/root/${val#"~/"}"
18971c
+                fi
18971c
+                inst_simple "$val"
18971c
+            fi
18971c
         done < /etc/ssh/ssh_config
18971c
     fi
18971c