1 # $OpenBSD: agent-getpeereid.sh,v 1.4 2007/11/25 15:35:09 jmc Exp $
2 # Placed in the Public Domain.
4 tid
="disallow agent attach from other uid"
8 SSH_AUTH_SOCK
=/nonexistent
10 if grep "#undef.*HAVE_GETPEEREID" ${BUILDDIR}/config.h
>/dev
/null
2>&1 && \
11 grep "#undef.*HAVE_GETPEERUCRED" ${BUILDDIR}/config.h
>/dev
/null
&& \
12 grep "#undef.*HAVE_SO_PEERCRED" ${BUILDDIR}/config.h
>/dev
/null
14 echo "skipped (not supported on this platform)"
17 if [ -z "$SUDO" ]; then
18 echo "skipped: need SUDO to switch to uid $UNPRIV"
24 eval `${SSHAGENT} -s -a ${ASOCK}` > /dev
/null
27 fail
"could not start ssh-agent: exit code $r"
29 chmod 644 ${SSH_AUTH_SOCK}
31 ssh-add
-l > /dev
/null
2>&1
34 fail
"ssh-add failed with $r != 1"
37 < /dev
/null
${SUDO} -S -u ${UNPRIV} ssh-add
-l > /dev
/null
2>&1
40 fail
"ssh-add did not fail for ${UNPRIV}: $r < 2"
44 ${SSHAGENT} -k > /dev
/null