markus@openbsd.org | dad2b18 | 2015-03-03 22:35:19 +0000 | [diff] [blame] | 1 | # $OpenBSD: agent-timeout.sh,v 1.3 2015/03/03 22:35:19 markus Exp $ |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 2 | # Placed in the Public Domain. |
| 3 | |
| 4 | tid="agent timeout test" |
| 5 | |
Darren Tucker | dc7e656 | 2003-09-13 09:46:03 +1000 | [diff] [blame] | 6 | SSHAGENT_TIMEOUT=10 |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 7 | |
| 8 | trace "start agent" |
| 9 | eval `${SSHAGENT} -s` > /dev/null |
| 10 | r=$? |
| 11 | if [ $r -ne 0 ]; then |
| 12 | fail "could not start ssh-agent: exit code $r" |
| 13 | else |
| 14 | trace "add keys with timeout" |
markus@openbsd.org | dad2b18 | 2015-03-03 22:35:19 +0000 | [diff] [blame] | 15 | for t in ${SSH_KEYTYPES}; do |
Tim Rice | 5543947 | 2003-09-09 08:27:40 -0700 | [diff] [blame] | 16 | ${SSHADD} -t ${SSHAGENT_TIMEOUT} $OBJ/$t > /dev/null 2>&1 |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 17 | 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 Rice | 5543947 | 2003-09-09 08:27:40 -0700 | [diff] [blame] | 26 | trace "sleeping 2*${SSHAGENT_TIMEOUT} seconds" |
| 27 | sleep ${SSHAGENT_TIMEOUT} |
| 28 | sleep ${SSHAGENT_TIMEOUT} |
Darren Tucker | 58f89bc | 2003-09-04 15:07:59 +1000 | [diff] [blame] | 29 | ${SSHADD} -l 2> /dev/null | grep 'The agent has no identities.' >/dev/null |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 30 | 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 |
| 36 | fi |