summaryrefslogtreecommitdiff
path: root/regress/agent-getpeereid.sh
diff options
context:
space:
mode:
Diffstat (limited to 'regress/agent-getpeereid.sh')
-rw-r--r--regress/agent-getpeereid.sh25
1 files changed, 18 insertions, 7 deletions
diff --git a/regress/agent-getpeereid.sh b/regress/agent-getpeereid.sh
index d5ae2d6e2..24b71f458 100644
--- a/regress/agent-getpeereid.sh
+++ b/regress/agent-getpeereid.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: agent-getpeereid.sh,v 1.5 2013/05/17 10:33:09 dtucker Exp $ 1# $OpenBSD: agent-getpeereid.sh,v 1.6 2016/05/03 14:41:04 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="disallow agent attach from other uid" 4tid="disallow agent attach from other uid"
@@ -13,10 +13,16 @@ else
13 echo "skipped (not supported on this platform)" 13 echo "skipped (not supported on this platform)"
14 exit 0 14 exit 0
15fi 15fi
16if [ -z "$SUDO" ]; then 16case "x$SUDO" in
17 echo "skipped: need SUDO to switch to uid $UNPRIV" 17 xsudo) sudo=1;;
18 exit 0 18 xdoas) ;;
19fi 19 x)
20 echo "need SUDO to switch to uid $UNPRIV"
21 exit 0 ;;
22 *)
23 echo "unsupported $SUDO - "doas" and "sudo" are allowed"
24 exit 0 ;;
25esac
20 26
21trace "start agent" 27trace "start agent"
22eval `${SSHAGENT} -s -a ${ASOCK}` > /dev/null 28eval `${SSHAGENT} -s -a ${ASOCK}` > /dev/null
@@ -31,8 +37,13 @@ else
31 if [ $r -ne 1 ]; then 37 if [ $r -ne 1 ]; then
32 fail "ssh-add failed with $r != 1" 38 fail "ssh-add failed with $r != 1"
33 fi 39 fi
34 40 if test -z "$sudo" ; then
35 < /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l 2>/dev/null 41 # doas
42 ${SUDO} -n -u ${UNPRIV} ssh-add -l 2>/dev/null
43 else
44 # sudo
45 < /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l 2>/dev/null
46 fi
36 r=$? 47 r=$?
37 if [ $r -lt 2 ]; then 48 if [ $r -lt 2 ]; then
38 fail "ssh-add did not fail for ${UNPRIV}: $r < 2" 49 fail "ssh-add did not fail for ${UNPRIV}: $r < 2"