diff options
author | dtucker@openbsd.org <dtucker@openbsd.org> | 2020-06-19 05:07:09 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2020-06-19 16:06:53 +1000 |
commit | 5dba1fcabacaab46693338ec829b42a1293d1f52 (patch) | |
tree | 8e292787efa12bfe9b36298bb9c35e6c5568a453 | |
parent | 68e8294f6b04f9590ea227e63d3e129398a49e27 (diff) |
upstream: Test that ssh-agent exits when running as as subprocess
of a specified command (ie "ssh-agent command"). Would have caught bz#3181.
OpenBSD-Regress-ID: 895b4765ba5153eefaea3160a7fe08ac0b6db8b3
-rw-r--r-- | regress/Makefile | 3 | ||||
-rw-r--r-- | regress/agent-subprocess.sh | 22 |
2 files changed, 24 insertions, 1 deletions
diff --git a/regress/Makefile b/regress/Makefile index 62794d25f..db0268fc0 100644 --- a/regress/Makefile +++ b/regress/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.108 2020/04/20 04:44:47 djm Exp $ | 1 | # $OpenBSD: Makefile,v 1.109 2020/06/19 05:07:09 dtucker Exp $ |
2 | 2 | ||
3 | tests: prep file-tests t-exec unit | 3 | tests: prep file-tests t-exec unit |
4 | 4 | ||
@@ -41,6 +41,7 @@ LTESTS= connect \ | |||
41 | agent-getpeereid \ | 41 | agent-getpeereid \ |
42 | agent-timeout \ | 42 | agent-timeout \ |
43 | agent-ptrace \ | 43 | agent-ptrace \ |
44 | agent-subprocess \ | ||
44 | keyscan \ | 45 | keyscan \ |
45 | keygen-change \ | 46 | keygen-change \ |
46 | keygen-convert \ | 47 | keygen-convert \ |
diff --git a/regress/agent-subprocess.sh b/regress/agent-subprocess.sh new file mode 100644 index 000000000..2f36d70cc --- /dev/null +++ b/regress/agent-subprocess.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | # $OpenBSD: agent-subprocess.sh,v 1.1 2020/06/19 05:07:09 dtucker Exp $ | ||
2 | # Placed in the Public Domain. | ||
3 | |||
4 | tid="agent subprocess" | ||
5 | |||
6 | trace "ensure agent exits when run as subprocess" | ||
7 | ${SSHAGENT} sh -c "echo \$SSH_AGENT_PID >$OBJ/pidfile; sleep 1" | ||
8 | |||
9 | pid=`cat $OBJ/pidfile` | ||
10 | |||
11 | # Currently ssh-agent polls every 10s so we need to wait at least that long. | ||
12 | n=12 | ||
13 | while kill -0 $pid >/dev/null 2>&1 && test "$n" -gt "0"; do | ||
14 | n=$(($n - 1)) | ||
15 | sleep 1 | ||
16 | done | ||
17 | |||
18 | if test "$n" -eq "0"; then | ||
19 | fail "agent still running" | ||
20 | fi | ||
21 | |||
22 | rm -f $OBJ/pidfile | ||