agent-getpeereid.sh revision 157016
13229Spst#	$OpenBSD: agent-getpeereid.sh,v 1.2 2005/11/14 21:25:56 grunk Exp $
211050Sbde#	Placed in the Public Domain.
33229Spst
43229Spsttid="disallow agent attach from other uid"
53229Spst
611050SbdeUNPRIV=nobody
73229SpstASOCK=${OBJ}/agent
83229SpstSSH_AUTH_SOCK=/nonexistant
93229Spst
103229Spstif grep "#undef.*HAVE_GETPEEREID" ${BUILDDIR}/config.h >/dev/null 2>&1
113229Spstthen
123229Spst	echo "skipped (not supported on this platform)"
13	exit 0
14fi
15
16trace "start agent"
17eval `${SSHAGENT} -s -a ${ASOCK}` > /dev/null
18r=$?
19if [ $r -ne 0 ]; then
20	fail "could not start ssh-agent: exit code $r"
21else
22	chmod 644 ${SSH_AUTH_SOCK}
23
24	ssh-add -l > /dev/null 2>&1
25	r=$?
26	if [ $r -ne 1 ]; then
27		fail "ssh-add failed with $r != 1"
28	fi
29
30	< /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l > /dev/null 2>&1
31	r=$?
32	if [ $r -lt 2 ]; then
33		fail "ssh-add did not fail for ${UNPRIV}: $r < 2"
34	fi
35
36	trace "kill agent"
37	${SSHAGENT} -k > /dev/null
38fi
39
40rm -f ${OBJ}/agent
41