upstream commit

support doas

Upstream-Regress-ID: 8d5572b27ea810394eeda432d8b4e9e1064a7c38
This commit is contained in:
djm@openbsd.org 2016-05-03 14:41:04 +00:00 committed by Damien Miller
parent 01cabf10ad
commit 07d5608bb2
1 changed files with 18 additions and 7 deletions

View File

@ -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"