summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordtucker <dtucker@openbsd.org>2020-06-19 05:07:09 +0000
committerdtucker <dtucker@openbsd.org>2020-06-19 05:07:09 +0000
commitf829cfcae3832cce4e4028fbac89a416c4143cf5 (patch)
tree6ada0d01a25bdf751be5525cf7e973b70191e71b
parentrun sshsig unit tests (diff)
downloadwireguard-openbsd-f829cfcae3832cce4e4028fbac89a416c4143cf5.tar.xz
wireguard-openbsd-f829cfcae3832cce4e4028fbac89a416c4143cf5.zip
Test that ssh-agent exits when running as as subprocess of a specified
command (ie "ssh-agent command"). Would have caught bz#3181.
-rw-r--r--regress/usr.bin/ssh/Makefile3
-rw-r--r--regress/usr.bin/ssh/agent-subprocess.sh22
2 files changed, 24 insertions, 1 deletions
diff --git a/regress/usr.bin/ssh/Makefile b/regress/usr.bin/ssh/Makefile
index 10639453d62..4c62cd51a72 100644
--- a/regress/usr.bin/ssh/Makefile
+++ b/regress/usr.bin/ssh/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.108 2020/04/20 04:44:47 djm Exp $
+# $OpenBSD: Makefile,v 1.109 2020/06/19 05:07:09 dtucker Exp $
.ifndef SKIP_UNIT
SUBDIR= unittests
@@ -32,6 +32,7 @@ LTESTS= connect \
agent-getpeereid \
agent-timeout \
agent-ptrace \
+ agent-subprocess \
keyscan \
keygen-change \
keygen-convert \
diff --git a/regress/usr.bin/ssh/agent-subprocess.sh b/regress/usr.bin/ssh/agent-subprocess.sh
new file mode 100644
index 00000000000..2f36d70ccca
--- /dev/null
+++ b/regress/usr.bin/ssh/agent-subprocess.sh
@@ -0,0 +1,22 @@
+# $OpenBSD: agent-subprocess.sh,v 1.1 2020/06/19 05:07:09 dtucker Exp $
+# Placed in the Public Domain.
+
+tid="agent subprocess"
+
+trace "ensure agent exits when run as subprocess"
+${SSHAGENT} sh -c "echo \$SSH_AGENT_PID >$OBJ/pidfile; sleep 1"
+
+pid=`cat $OBJ/pidfile`
+
+# Currently ssh-agent polls every 10s so we need to wait at least that long.
+n=12
+while kill -0 $pid >/dev/null 2>&1 && test "$n" -gt "0"; do
+ n=$(($n - 1))
+ sleep 1
+done
+
+if test "$n" -eq "0"; then
+ fail "agent still running"
+fi
+
+rm -f $OBJ/pidfile