1 # $OpenBSD: agent-getpeereid.sh,v 1.10 2018/02/09 03:40:22 dtucker Exp $
2 # Placed in the Public Domain.
4 tid="disallow agent attach from other uid"
8 SSH_AUTH_SOCK=/nonexistent
10 if config_defined HAVE_GETPEEREID HAVE_GETPEERUCRED HAVE_SO_PEERCRED ; then
13 echo "skipped (not supported on this platform)"
20 echo "need SUDO to switch to uid $UNPRIV"
24 echo "unsupported $SUDO - "doas" and "sudo" are allowed"
29 eval `${SSHAGENT} -s -a ${ASOCK}` > /dev/null
32 fail "could not start ssh-agent: exit code $r"
34 chmod 644 ${SSH_AUTH_SOCK}
36 ${SSHADD} -l > /dev/null 2>&1
39 fail "ssh-add failed with $r != 1"
41 if test -z "$sudo" ; then
43 ${SUDO} -n -u ${UNPRIV} ${SSHADD} -l 2>/dev/null
46 < /dev/null ${SUDO} -S -u ${UNPRIV} ${SSHADD} -l 2>/dev/null
50 fail "ssh-add did not fail for ${UNPRIV}: $r < 2"
54 ${SSHAGENT} -k > /dev/null