summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/ssh/agent-getpeereid.sh20
1 files changed, 14 insertions, 6 deletions
diff --git a/regress/usr.bin/ssh/agent-getpeereid.sh b/regress/usr.bin/ssh/agent-getpeereid.sh
index 8e803cf5d77..fa8cec7ec7f 100644
--- a/regress/usr.bin/ssh/agent-getpeereid.sh
+++ b/regress/usr.bin/ssh/agent-getpeereid.sh
@@ -1,4 +1,4 @@
-# $OpenBSD: agent-getpeereid.sh,v 1.5 2013/05/17 10:33:09 dtucker Exp $
+# $OpenBSD: agent-getpeereid.sh,v 1.6 2016/05/03 14:41:04 djm Exp $
# Placed in the Public Domain.
tid="disallow agent attach from other uid"
@@ -7,9 +7,12 @@ UNPRIV=nobody
ASOCK=${OBJ}/agent
SSH_AUTH_SOCK=/nonexistent
-if [ -z "$SUDO" ]; then
- fatal "need SUDO to switch to uid $UNPRIV, test won't work without"
-fi
+case "x$SUDO" in
+ xsudo) sudo=1;;
+ xdoas) ;;
+ x) fatal "need SUDO to switch to uid $UNPRIV, test won't work without";;
+ *) fatal 'unsupported $SUDO - "doas" and "sudo" are allowed' ;;
+esac
trace "start agent"
eval `${SSHAGENT} -s -a ${ASOCK}` > /dev/null
@@ -24,8 +27,13 @@ else
if [ $r -ne 1 ]; then
fail "ssh-add failed with $r != 1"
fi
-
- < /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l 2>/dev/null
+ if test -z "$sudo" ; then
+ # doas
+ ${SUDO} -n -u ${UNPRIV} ssh-add -l 2>/dev/null
+ else
+ # sudo
+ < /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l 2>/dev/null
+ fi
r=$?
if [ $r -lt 2 ]; then
fail "ssh-add did not fail for ${UNPRIV}: $r < 2"