From 58d28b741022d06d7050db66997fd5d527b99bc1 Mon Sep 17 00:00:00 2001 From: Ben Lipton Date: Thu, 11 Aug 2016 15:39:35 +0200 Subject: [PATCH] Silence sshd messages during install Fix for accidentally pushed commit c15ba1f9e8c7d236586d46271fce7c3950b509da During install we call sshd with no config file, sometimes leading to it complaining about missing files or bad config options. Since we're just looking for the return code to see if the options are correct, we can discard these error messages. Reviewed-By: Jan Cholasta --- freeipa.spec.in | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/freeipa.spec.in b/freeipa.spec.in index 78ab8ca58..ea580a20a 100644 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -1009,21 +1009,17 @@ if [ -f '/etc/ssh/sshd_config' -a $restore -ge 2 ]; then /^(AuthorizedKeysCommand(User|RunAs)|PubKeyAgentRunAs)[ \t]/ d ' /etc/ssh/sshd_config >/etc/ssh/sshd_config.ipanew - # Prevent complaints about missing host keys by using the configured ones - tmp_config=$(mktemp sshd_config.XXXXXX) - sed -n '/^HostKey[ \t]/ p' /etc/ssh/sshd_config > $tmp_config - - if /usr/sbin/sshd -t -f $tmp_config -o 'AuthorizedKeysCommand=/usr/bin/sss_ssh_authorizedkeys' -o 'AuthorizedKeysCommandUser=nobody'; then + if /usr/sbin/sshd -t -f /dev/null -o 'AuthorizedKeysCommand=/usr/bin/sss_ssh_authorizedkeys' -o 'AuthorizedKeysCommandUser=nobody' 2>/dev/null; then sed -ri ' s/^PubKeyAgent (.+) %u$/AuthorizedKeysCommand \1/ s/^AuthorizedKeysCommand .*$/\0\nAuthorizedKeysCommandUser nobody/ ' /etc/ssh/sshd_config.ipanew - elif /usr/sbin/sshd -t -f $tmp_config -o 'AuthorizedKeysCommand=/usr/bin/sss_ssh_authorizedkeys' -o 'AuthorizedKeysCommandRunAs=nobody'; then + elif /usr/sbin/sshd -t -f /dev/null -o 'AuthorizedKeysCommand=/usr/bin/sss_ssh_authorizedkeys' -o 'AuthorizedKeysCommandRunAs=nobody' 2>/dev/null; then sed -ri ' s/^PubKeyAgent (.+) %u$/AuthorizedKeysCommand \1/ s/^AuthorizedKeysCommand .*$/\0\nAuthorizedKeysCommandRunAs nobody/ ' /etc/ssh/sshd_config.ipanew - elif /usr/sbin/sshd -t -f $tmp_config -o 'PubKeyAgent=/usr/bin/sss_ssh_authorizedkeys %u' -o 'PubKeyAgentRunAs=nobody'; then + elif /usr/sbin/sshd -t -f /dev/null -o 'PubKeyAgent=/usr/bin/sss_ssh_authorizedkeys %u' -o 'PubKeyAgentRunAs=nobody' 2>/dev/null; then sed -ri ' s/^AuthorizedKeysCommand (.+)$/PubKeyAgent \1 %u/ s/^PubKeyAgent .*$/\0\nPubKeyAgentRunAs nobody/