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