blob: 3a40e7af824e01f8bdb94bc84890661ee1037e8b [file] [log] [blame]
Damien Miller8b9cde72003-01-22 17:53:16 +11001# $OpenBSD: agent-timeout.sh,v 1.1 2002/06/06 00:38:40 markus Exp $
2# Placed in the Public Domain.
3
4tid="agent timeout test"
5
Darren Tuckerdc7e6562003-09-13 09:46:03 +10006SSHAGENT_TIMEOUT=10
Damien Miller8b9cde72003-01-22 17:53:16 +11007
8trace "start agent"
9eval `${SSHAGENT} -s` > /dev/null
10r=$?
11if [ $r -ne 0 ]; then
12 fail "could not start ssh-agent: exit code $r"
13else
14 trace "add keys with timeout"
15 for t in rsa rsa1; do
Tim Rice55439472003-09-09 08:27:40 -070016 ${SSHADD} -t ${SSHAGENT_TIMEOUT} $OBJ/$t > /dev/null 2>&1
Damien Miller8b9cde72003-01-22 17:53:16 +110017 if [ $? -ne 0 ]; then
18 fail "ssh-add did succeed exit code 0"
19 fi
20 done
21 n=`${SSHADD} -l 2> /dev/null | wc -l`
22 trace "agent has $n keys"
23 if [ $n -ne 2 ]; then
24 fail "ssh-add -l did not return 2 keys: $n"
25 fi
Tim Rice55439472003-09-09 08:27:40 -070026 trace "sleeping 2*${SSHAGENT_TIMEOUT} seconds"
27 sleep ${SSHAGENT_TIMEOUT}
28 sleep ${SSHAGENT_TIMEOUT}
Darren Tucker58f89bc2003-09-04 15:07:59 +100029 ${SSHADD} -l 2> /dev/null | grep 'The agent has no identities.' >/dev/null
Damien Miller8b9cde72003-01-22 17:53:16 +110030 if [ $? -ne 0 ]; then
31 fail "ssh-add -l still returns keys after timeout"
32 fi
33
34 trace "kill agent"
35 ${SSHAGENT} -k > /dev/null
36fi