Date: Tue May 16 13:23:49 2017 +0200 From: Petr Tesarik Subject: Add KDUMP_SSH_IDENTITY config option References: FATE#321583 Git-commit: 3e7e5f020024eed5c6d944e0ff9554772cbdb896 Git-commit: d7e6f45461bf0f899cfedf564d985cf5cd41f331 Git-commit: f0a43757c99635ece304fc9c011c0b82acd86f64 Upstream: v0.8.17 Make the SSH private file configurable. Signed-off-by: Petr Tesarik --- doc/man/kdump.5.txt.in | 10 ++++++++++ init/setup-kdump.functions | 39 ++++++++++++++++++++++++++++----------- kdumptool/define_opt.h | 1 + 3 files changed, 39 insertions(+), 11 deletions(-) --- a/doc/man/kdump.5.txt.in +++ b/doc/man/kdump.5.txt.in @@ -643,7 +643,17 @@ Example (broken into lines for readabili Default: "" +KDUMP_SSH_IDENTITY +~~~~~~~~~~~~~~~~~~ +List of SSH identity files for public key authentication. If empty, kdump +will try all standard OpenSSH identities for the 'root' user (rsa, dsa, +ecdsa, ed25519, in this order). The path to every identity file is relative +to +~root/.ssh+, or an absolute path can be given. + +Example: "/root/.ssh/id_kdump_rsa" + +Default: "" URL FORMAT ---------- --- a/init/setup-kdump.functions +++ b/init/setup-kdump.functions @@ -935,6 +935,29 @@ function kdump_modify_multipath() } # }}} # +# Copy SSH identity file(s) and update the target config file +# Parameters: +# 1) dest: root of the temporary area +function kdump_copy_ssh_ident() # {{{ +{ + local sshdir="$1/kdump/.ssh" + local ssh_conf="$sshdir/config" + local f + + shift + for f in "$@"; do + test "${f:0:1}" = "/" || f=~root/".ssh/$f" + test -f "$f" || continue + + cp "$f" "$sshdir/" + test -f "${f}.pub" && cp "${f}.pub" "$sshdir/" + test -f "${f}-cert.pub" && cp "${f}-cert.pub" "$sshdir/" + f=$( basename $f ) + echo "IdentityFile /kdump/.ssh/${f}" >> "$ssh_conf" + done +} # }}} + +# # Copy SSH keys and create a config file in the target # Parameters: # 1) dest: root of the temporary area @@ -952,17 +975,11 @@ function kdump_init_ssh() # {{{ echo "StrictHostKeyChecking yes" >> "$ssh_conf" echo "UserKnownHostsFile /kdump/.ssh/known_hosts" >> "$ssh_conf" - local type - for type in rsa dsa ecdsa ed25519 - do - if [ -f /root/.ssh/id_${type} -a -f /root/.ssh/id_${type}.pub ] ; then - cp /root/.ssh/id_${type}{,.pub} "${dest}/kdump/.ssh/" - if [ -f /root/.ssh/id_${type}-cert.pub ] ; then - cp /root/.ssh/id_${type}-cert.pub "${dest}/kdump/.ssh/" - fi - echo "IdentityFile /kdump/.ssh/id_${type}" >> "$ssh_conf" - fi - done + if [ -n "$KDUMP_SSH_IDENTITY" ] ; then + kdump_copy_ssh_ident "$dest" $KDUMP_SSH_IDENTITY + else + kdump_copy_ssh_ident "$dest" id_{rsa,dsa,ecdsa,ed25519} + fi } # }}} # --- a/kdumptool/define_opt.h +++ b/kdumptool/define_opt.h @@ -41,3 +41,4 @@ DEFINE_OPT(KDUMP_SMTP_PASSWORD, String, DEFINE_OPT(KDUMP_NOTIFICATION_TO, String, "", DUMP) DEFINE_OPT(KDUMP_NOTIFICATION_CC, String, "", DUMP) DEFINE_OPT(KDUMP_HOST_KEY, String, "", DUMP) +DEFINE_OPT(KDUMP_SSH_IDENTITY, String, "", MKINITRD)