upstream: Log output of ssh-agent and ssh-add

This should  make debugging easier.

OpenBSD-Regress-ID: 5974b02651f428d7e1079b41304c498ca7e306c8
This commit is contained in:
dtucker@openbsd.org 2022-12-01 02:19:29 +00:00 committed by Darren Tucker
parent 4a1805d532
commit 7a8b40cf6a
No known key found for this signature in database
1 changed files with 7 additions and 4 deletions

View File

@ -6,6 +6,8 @@ tid="disallow agent attach from other uid"
UNPRIV=nobody
ASOCK=${OBJ}/agent
SSH_AUTH_SOCK=/nonexistent
>$OBJ/ssh-agent.log
>$OBJ/ssh-add.log
if config_defined HAVE_GETPEEREID HAVE_GETPEERUCRED HAVE_SO_PEERCRED ; then
:
@ -25,14 +27,14 @@ case "x$SUDO" in
esac
trace "start agent"
eval `${SSHAGENT} ${EXTRA_AGENT_ARGS} -s -a ${ASOCK}` > /dev/null
eval `${SSHAGENT} ${EXTRA_AGENT_ARGS} -s -a ${ASOCK}` >$OBJ/ssh-agent.log 2>&1
r=$?
if [ $r -ne 0 ]; then
fail "could not start ssh-agent: exit code $r"
else
chmod 644 ${SSH_AUTH_SOCK}
${SSHADD} -l > /dev/null 2>&1
${SSHADD} -vvv -l >>$OBJ/ssh-add.log 2>&1
r=$?
if [ $r -ne 1 ]; then
fail "ssh-add failed with $r != 1"
@ -42,15 +44,16 @@ else
${SUDO} -n -u ${UNPRIV} ${SSHADD} -l 2>/dev/null
else
# sudo
< /dev/null ${SUDO} -S -u ${UNPRIV} ${SSHADD} -l 2>/dev/null
< /dev/null ${SUDO} -S -u ${UNPRIV} ${SSHADD} -vvv -l >>$OBJ/ssh-add.log 2>&1
fi
r=$?
if [ $r -lt 2 ]; then
fail "ssh-add did not fail for ${UNPRIV}: $r < 2"
cat $OBJ/ssh-add.log
fi
trace "kill agent"
${SSHAGENT} -k > /dev/null
${SSHAGENT} -vvv -k >>$OBJ/ssh-agent.log 2>&1
fi
rm -f ${OBJ}/agent