2003-01-22 14:53:16 +08:00
|
|
|
# $OpenBSD: agent-ptrace.sh,v 1.1 2002/12/09 15:38:30 markus Exp $
|
|
|
|
# Placed in the Public Domain.
|
|
|
|
|
|
|
|
tid="disallow agent ptrace attach"
|
|
|
|
|
2003-09-12 13:32:17 +08:00
|
|
|
if have_prog uname ; then
|
2003-09-04 11:55:25 +08:00
|
|
|
case `uname` in
|
2004-08-29 18:33:07 +08:00
|
|
|
AIX|CYGWIN*|OSF1)
|
2003-09-04 20:06:16 +08:00
|
|
|
echo "skipped (not supported on this platform)"
|
2003-09-04 11:55:25 +08:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2003-09-13 02:20:32 +08:00
|
|
|
if have_prog gdb ; then
|
|
|
|
: ok
|
|
|
|
else
|
2003-09-04 11:55:25 +08:00
|
|
|
echo "skipped (gdb not found)"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2003-10-21 20:27:08 +08:00
|
|
|
if test -z "$SUDO" ; then
|
|
|
|
echo "skipped (SUDO not set)"
|
|
|
|
exit 0
|
|
|
|
else
|
2003-11-03 19:52:52 +08:00
|
|
|
$SUDO chown 0 ${SSHAGENT}
|
|
|
|
$SUDO chgrp 0 ${SSHAGENT}
|
2003-10-21 21:12:37 +08:00
|
|
|
$SUDO chmod 2755 ${SSHAGENT}
|
2003-10-21 20:27:08 +08:00
|
|
|
fi
|
|
|
|
|
2003-01-22 14:53:16 +08:00
|
|
|
trace "start agent"
|
|
|
|
eval `${SSHAGENT} -s` > /dev/null
|
|
|
|
r=$?
|
|
|
|
if [ $r -ne 0 ]; then
|
|
|
|
fail "could not start ssh-agent: exit code $r"
|
|
|
|
else
|
|
|
|
# ls -l ${SSH_AUTH_SOCK}
|
|
|
|
gdb ${SSHAGENT} ${SSH_AGENT_PID} > ${OBJ}/gdb.out 2>&1 << EOF
|
|
|
|
quit
|
|
|
|
EOF
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
fail "gdb failed: exit code $?"
|
|
|
|
fi
|
2005-03-03 13:49:56 +08:00
|
|
|
egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace attach: Permission denied.|procfs:.*: Invalid argument.' >/dev/null ${OBJ}/gdb.out
|
2003-01-22 14:53:16 +08:00
|
|
|
r=$?
|
|
|
|
rm -f ${OBJ}/gdb.out
|
|
|
|
if [ $r -ne 0 ]; then
|
|
|
|
fail "ptrace succeeded?: exit code $r"
|
|
|
|
fi
|
|
|
|
|
|
|
|
trace "kill agent"
|
|
|
|
${SSHAGENT} -k > /dev/null
|
|
|
|
fi
|