2019-11-26 23:43:10 +00:00
|
|
|
# $OpenBSD: agent-timeout.sh,v 1.6 2019/11/26 23:43:10 djm Exp $
|
2003-01-22 06:53:16 +00:00
|
|
|
# Placed in the Public Domain.
|
|
|
|
|
|
|
|
tid="agent timeout test"
|
|
|
|
|
2003-09-12 23:46:03 +00:00
|
|
|
SSHAGENT_TIMEOUT=10
|
2003-01-22 06:53:16 +00:00
|
|
|
|
|
|
|
trace "start agent"
|
2019-11-26 23:43:10 +00:00
|
|
|
eval `${SSHAGENT} -s ${EXTRA_AGENT_ARGS}` > /dev/null
|
2003-01-22 06:53:16 +00:00
|
|
|
r=$?
|
|
|
|
if [ $r -ne 0 ]; then
|
|
|
|
fail "could not start ssh-agent: exit code $r"
|
|
|
|
else
|
|
|
|
trace "add keys with timeout"
|
2019-01-28 00:08:26 +00:00
|
|
|
keys=0
|
2015-03-03 22:35:19 +00:00
|
|
|
for t in ${SSH_KEYTYPES}; do
|
2019-09-03 08:37:06 +00:00
|
|
|
${SSHADD} -kt ${SSHAGENT_TIMEOUT} $OBJ/$t > /dev/null 2>&1
|
2003-01-22 06:53:16 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
fail "ssh-add did succeed exit code 0"
|
|
|
|
fi
|
2019-01-28 00:08:26 +00:00
|
|
|
keys=$((${keys} + 1))
|
2003-01-22 06:53:16 +00:00
|
|
|
done
|
|
|
|
n=`${SSHADD} -l 2> /dev/null | wc -l`
|
|
|
|
trace "agent has $n keys"
|
2019-01-28 00:08:26 +00:00
|
|
|
if [ $n -ne $keys ]; then
|
|
|
|
fail "ssh-add -l did not return $keys keys: $n"
|
2003-01-22 06:53:16 +00:00
|
|
|
fi
|
2003-09-09 15:27:40 +00:00
|
|
|
trace "sleeping 2*${SSHAGENT_TIMEOUT} seconds"
|
|
|
|
sleep ${SSHAGENT_TIMEOUT}
|
|
|
|
sleep ${SSHAGENT_TIMEOUT}
|
2003-09-04 05:07:59 +00:00
|
|
|
${SSHADD} -l 2> /dev/null | grep 'The agent has no identities.' >/dev/null
|
2003-01-22 06:53:16 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
fail "ssh-add -l still returns keys after timeout"
|
|
|
|
fi
|
|
|
|
|
|
|
|
trace "kill agent"
|
|
|
|
${SSHAGENT} -k > /dev/null
|
|
|
|
fi
|