1 # $OpenBSD: agent-getpeereid.sh,v 1.6 2016/05/03 14:41:04 djm 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"
23 echo "unsupported $SUDO - "doas" and "sudo" are allowed"
28 eval `${SSHAGENT} -s -a ${ASOCK}` > /dev/null
31 fail "could not start ssh-agent: exit code $r"
33 chmod 644 ${SSH_AUTH_SOCK}
35 ssh-add -l > /dev/null 2>&1
38 fail "ssh-add failed with $r != 1"
40 if test -z "$sudo" ; then
42 ${SUDO} -n -u ${UNPRIV} ssh-add -l 2>/dev/null
45 < /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l 2>/dev/null
49 fail "ssh-add did not fail for ${UNPRIV}: $r < 2"
53 ${SSHAGENT} -k > /dev/null