- (djm) Release 4.6p1
[openssh-git.git] / regress / agent-getpeereid.sh
blobe5fcedda78ef07130d1b159a5f3b529e8e4ac354
1 # $OpenBSD: agent-getpeereid.sh,v 1.3 2006/07/06 12:01:53 grunk Exp $
2 # Placed in the Public Domain.
4 tid="disallow agent attach from other uid"
6 UNPRIV=nobody
7 ASOCK=${OBJ}/agent
8 SSH_AUTH_SOCK=/nonexistant
10 if grep "#undef.*HAVE_GETPEEREID" ${BUILDDIR}/config.h >/dev/null 2>&1
11 then
12 echo "skipped (not supported on this platform)"
13 exit 0
15 if [ -z "$SUDO" ]; then
16 echo "skipped: need SUDO to switch to uid $UNPRIV"
17 exit 0
21 trace "start agent"
22 eval `${SSHAGENT} -s -a ${ASOCK}` > /dev/null
23 r=$?
24 if [ $r -ne 0 ]; then
25 fail "could not start ssh-agent: exit code $r"
26 else
27 chmod 644 ${SSH_AUTH_SOCK}
29 ssh-add -l > /dev/null 2>&1
30 r=$?
31 if [ $r -ne 1 ]; then
32 fail "ssh-add failed with $r != 1"
35 < /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l > /dev/null 2>&1
36 r=$?
37 if [ $r -lt 2 ]; then
38 fail "ssh-add did not fail for ${UNPRIV}: $r < 2"
41 trace "kill agent"
42 ${SSHAGENT} -k > /dev/null
45 rm -f ${OBJ}/agent