From 07d5608bb237e9b3fe86a2aeaa429392230faebf Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Tue, 3 May 2016 14:41:04 +0000 Subject: [PATCH] upstream commit support doas Upstream-Regress-ID: 8d5572b27ea810394eeda432d8b4e9e1064a7c38 --- regress/agent-getpeereid.sh | 25 ++++++++++++++++++------- 1 file 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 @@ -# $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" @@ -13,10 +13,16 @@ else echo "skipped (not supported on this platform)" exit 0 fi -if [ -z "$SUDO" ]; then - echo "skipped: need SUDO to switch to uid $UNPRIV" - exit 0 -fi +case "x$SUDO" in + xsudo) sudo=1;; + xdoas) ;; + x) + echo "need SUDO to switch to uid $UNPRIV" + exit 0 ;; + *) + echo "unsupported $SUDO - "doas" and "sudo" are allowed" + exit 0 ;; +esac trace "start agent" eval `${SSHAGENT} -s -a ${ASOCK}` > /dev/null @@ -31,8 +37,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"