From 09e66dc936cf2d99bcc44d60d6851aafa9ede46a Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: Wed, 19 Jun 2024 15:38:36 +0200 Subject: [PATCH] spec file: do not create /etc/ssh/ssh_config.orig if unchanged The upgrade removes the line HostKeyAlgorithms ssh-rsa,ssh-dss if present in /etc/ssh/ssh_config and creates a backup in /etc/ssh/ssh_config.orig, even if no change was applied. Create the backup file only if the file was changed. Fixes: https://pagure.io/freeipa/issue/9610 Signed-off-by: Florence Blanc-Renaud Reviewed-By: Michal Polovka --- freeipa.spec.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/freeipa.spec.in b/freeipa.spec.in index 6803de752bc122bf6e1eafd610d399cde994cad5..1e1a0c04728972c6c53beb47dafb25d7898ab0ea 100755 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -1320,7 +1320,9 @@ if [ $1 -gt 1 ] ; then chmod 0600 /var/log/ipaupgrade.log SSH_CLIENT_SYSTEM_CONF="/etc/ssh/ssh_config" if [ -f "$SSH_CLIENT_SYSTEM_CONF" ]; then - sed -E --in-place=.orig 's/^(HostKeyAlgorithms ssh-rsa,ssh-dss)$/# disabled by ipa-client update\n# \1/' "$SSH_CLIENT_SYSTEM_CONF" + if grep -E -q '^HostKeyAlgorithms ssh-rsa,ssh-dss' $SSH_CLIENT_SYSTEM_CONF 2>/dev/null; then + sed -E --in-place=.orig 's/^(HostKeyAlgorithms ssh-rsa,ssh-dss)$/# disabled by ipa-client update\n# \1/' "$SSH_CLIENT_SYSTEM_CONF" + fi # https://pagure.io/freeipa/issue/9536 # replace sss_ssh_knownhostsproxy with sss_ssh_knownhosts if [ -f '/usr/bin/sss_ssh_knownhosts' ]; then -- 2.45.2