upstream: Count the number of key types instead of assuming there

are only two.

OpenBSD-Regress-ID: 0998702c41235782cf0beee396ec49b5056eaed9
This commit is contained in:
dtucker@openbsd.org 2019-01-28 00:08:26 +00:00 committed by Darren Tucker
parent 1d05b4adcb
commit ffdde469ed
1 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: agent-timeout.sh,v 1.3 2015/03/03 22:35:19 markus Exp $ # $OpenBSD: agent-timeout.sh,v 1.4 2019/01/28 00:08:26 dtucker Exp $
# Placed in the Public Domain. # Placed in the Public Domain.
tid="agent timeout test" tid="agent timeout test"
@ -12,16 +12,18 @@ if [ $r -ne 0 ]; then
fail "could not start ssh-agent: exit code $r" fail "could not start ssh-agent: exit code $r"
else else
trace "add keys with timeout" trace "add keys with timeout"
keys=0
for t in ${SSH_KEYTYPES}; do for t in ${SSH_KEYTYPES}; do
${SSHADD} -t ${SSHAGENT_TIMEOUT} $OBJ/$t > /dev/null 2>&1 ${SSHADD} -t ${SSHAGENT_TIMEOUT} $OBJ/$t > /dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
fail "ssh-add did succeed exit code 0" fail "ssh-add did succeed exit code 0"
fi fi
keys=$((${keys} + 1))
done done
n=`${SSHADD} -l 2> /dev/null | wc -l` n=`${SSHADD} -l 2> /dev/null | wc -l`
trace "agent has $n keys" trace "agent has $n keys"
if [ $n -ne 2 ]; then if [ $n -ne $keys ]; then
fail "ssh-add -l did not return 2 keys: $n" fail "ssh-add -l did not return $keys keys: $n"
fi fi
trace "sleeping 2*${SSHAGENT_TIMEOUT} seconds" trace "sleeping 2*${SSHAGENT_TIMEOUT} seconds"
sleep ${SSHAGENT_TIMEOUT} sleep ${SSHAGENT_TIMEOUT}