2017-10-20 04:22:00 +02:00
|
|
|
# $OpenBSD: agent-ptrace.sh,v 1.3 2015/09/11 04:55:01 djm Exp $
|
2003-01-22 07:53:16 +01:00
|
|
|
# Placed in the Public Domain.
|
|
|
|
|
|
|
|
tid="disallow agent ptrace attach"
|
|
|
|
|
2003-09-12 07:32:17 +02:00
|
|
|
if have_prog uname ; then
|
2003-09-04 05:55:25 +02:00
|
|
|
case `uname` in
|
2004-08-29 12:33:07 +02:00
|
|
|
AIX|CYGWIN*|OSF1)
|
2003-09-04 14:06:16 +02:00
|
|
|
echo "skipped (not supported on this platform)"
|
2003-09-04 05:55:25 +02:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2015-09-11 06:55:01 +02:00
|
|
|
if [ "x$USER" = "xroot" ]; then
|
|
|
|
echo "Skipped: running as root"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2003-09-12 20:20:32 +02:00
|
|
|
if have_prog gdb ; then
|
|
|
|
: ok
|
|
|
|
else
|
2003-09-04 05:55:25 +02:00
|
|
|
echo "skipped (gdb not found)"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2013-12-08 05:53:28 +01:00
|
|
|
if $OBJ/setuid-allowed ${SSHAGENT} ; then
|
|
|
|
: ok
|
|
|
|
else
|
|
|
|
echo "skipped (${SSHAGENT} is mounted on a no-setuid filesystem)"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2003-10-21 14:27:08 +02:00
|
|
|
if test -z "$SUDO" ; then
|
|
|
|
echo "skipped (SUDO not set)"
|
|
|
|
exit 0
|
|
|
|
else
|
2003-11-03 12:52:52 +01:00
|
|
|
$SUDO chown 0 ${SSHAGENT}
|
|
|
|
$SUDO chgrp 0 ${SSHAGENT}
|
2003-10-21 15:12:37 +02:00
|
|
|
$SUDO chmod 2755 ${SSHAGENT}
|
2003-10-21 14:27:08 +02:00
|
|
|
fi
|
|
|
|
|
2003-01-22 07:53:16 +01: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
|
2014-01-28 19:26:25 +01:00
|
|
|
r=$?
|
|
|
|
if [ $r -ne 0 ]; then
|
|
|
|
fail "gdb failed: exit code $r"
|
2003-01-22 07:53:16 +01:00
|
|
|
fi
|
2011-01-17 01:20:18 +01:00
|
|
|
egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace.*Permission denied.|procfs:.*: Invalid argument.|Unable to access task ' >/dev/null ${OBJ}/gdb.out
|
2003-01-22 07:53:16 +01: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
|