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

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