On 08/09/17 at 04:33pm, Ziyue Yang wrote:
This commit makes kdump's module-setup.sh modify known_hosts
file installed to dracut, adding 'kdump-' interface prefix to
items interface name like 'eth*'. This ensures that the ssh
target is known while dumping.
Signed-off-by: Ziyue Yang <ziyang(a)redhat.com>
---
dracut-module-setup.sh | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index ae13337..2fe7c94 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -707,12 +707,34 @@ kdump_install_random_seed() {
bs=$poolsize count=1 2> /dev/null
}
+# Install kdump-specialized known_hosts, which is needed
+# to provide correct network interface name while ssh dumping
+kdump_install_ssh_known_hosts() {
+ local _origin_known_hosts=/root/.ssh/known_hosts
+ local _tmp_known_hosts=$initdir/tmp/kdump_known_hosts
+ while read -r known_host;
+ do
+ echo $known_host
+ if [[ $known_host == *":"* ]]; then
should extract the first field first then check is_ipv6 address
BTW, since this is used several times, it is better to create a
function like is_ipv6_link_local_addr()
+ local _host_prefix=${known_host%\%*}
+ local _host_postfix=${known_host##*\%}
+ if [[ $_host_postfix == "eth"* ]]; then
+ echo "$_host_prefix%kdump-$_host_postfix"
+ fi
+ fi
+ done < $_origin_known_hosts > $_tmp_known_hosts
+ # replace origin known_hosts
+ cp $_tmp_known_hosts $initdir/$_origin_known_hosts
+ rm -f $_tmp_known_hosts
+}
+
dracut ssh-client module installs known_hosts, so we should not do it
again. It would be better to check and replace the already installed file in
$initdir/ instead.
This can be called in kdump_setup_ifname() function so that is is
more readable.
install() {
kdump_install_conf
remove_sysctl_conf
if is_ssh_dump_target; then
kdump_install_random_seed
+ kdump_install_ssh_known_hosts
fi
dracut_install -o /etc/adjtime /etc/localtime
inst "$moddir/monitor_dd_progress"
"/kdumpscripts/monitor_dd_progress"
--
2.9.3
_______________________________________________
kexec mailing list -- kexec(a)lists.fedoraproject.org
To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
Thanks
Dave