]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
95ssh-client: attempt to copy UserKnownHostsFile to kdump's initramfs 184/head
authorTong Li <tonli@redhat.com>
Wed, 30 Nov 2016 09:05:57 +0000 (17:05 +0800)
committerTong Li <tonli@redhat.com>
Wed, 30 Nov 2016 09:05:57 +0000 (17:05 +0800)
Bug related to this issue: https://bugzilla.redhat.com/show_bug.cgi?id=1360131
Now dracut only attempts to copy GlobalKnownHostsFile while generating kdump's
initramfs. This method will cause kdump's failure if users set customized
UserKnownHostsFile in /etc/ssh/ssh_config. This patch simply attempts to copy
those files too while going through /etc/ssh/ssh_config. Note that we need to
make sure ~/foo will be copied as /root/foo in kdump's initramfs.

modules.d/95ssh-client/module-setup.sh

index 0a0e80cd9887a8dc9f96667d711031b948cac8b7..2a7e0ee374dff3af0b01bf53d07fa31985240485 100755 (executable)
@@ -45,9 +45,16 @@ inst_sshenv()
         inst_simple /etc/ssh/ssh_config
         sed -i -e 's/\(^[[:space:]]*\)ProxyCommand/\1# ProxyCommand/' ${initdir}/etc/ssh/ssh_config
         while read key val || [ -n "$key" ]; do
-            [[ $key != "GlobalKnownHostsFile" ]] && continue
-            inst_simple "$val"
-            break
+            if [[ $key == "GlobalKnownHostsFile" ]]; then
+                inst_simple "$val"
+            # Copy customized UserKnowHostsFile
+            elif [[ $key == "UserKnownHostsFile" ]]; then
+                # Make sure that ~/foo will be copied as /root/foo in kdump's initramfs
+                if str_starts "$val" "~/"; then
+                    val="/root/${val#"~/"}"
+                fi
+                inst_simple "$val"
+            fi
         done < /etc/ssh/ssh_config
     fi