blob: bd79d7cb80f560eafc5051a58ee32348314f2ebe [file] [log] [blame]
Damien Miller8b9cde72003-01-22 17:53:16 +11001# $OpenBSD: agent-ptrace.sh,v 1.1 2002/12/09 15:38:30 markus Exp $
2# Placed in the Public Domain.
3
4tid="disallow agent ptrace attach"
5
Tim Rice23ee3592003-09-11 22:32:17 -07006if have_prog uname ; then
Darren Tucker55697592003-09-04 13:55:25 +10007 case `uname` in
Darren Tucker203c40b2003-11-15 12:13:16 +11008 AIX|CYGWIN*)
Darren Tucker77d07e92003-09-04 22:06:16 +10009 echo "skipped (not supported on this platform)"
Darren Tucker55697592003-09-04 13:55:25 +100010 exit 0
11 ;;
12 esac
13fi
14
Tim Riceb7efb632003-09-12 11:20:32 -070015if have_prog gdb ; then
16 : ok
17else
Darren Tucker55697592003-09-04 13:55:25 +100018 echo "skipped (gdb not found)"
19 exit 0
20fi
21
Darren Tuckerea4c6702003-10-21 22:27:08 +100022if test -z "$SUDO" ; then
23 echo "skipped (SUDO not set)"
24 exit 0
25else
Darren Tuckerbe8a7712003-11-03 22:52:52 +110026 $SUDO chown 0 ${SSHAGENT}
27 $SUDO chgrp 0 ${SSHAGENT}
Darren Tucker2bdacad2003-10-21 23:12:37 +100028 $SUDO chmod 2755 ${SSHAGENT}
Darren Tuckerea4c6702003-10-21 22:27:08 +100029fi
30
Damien Miller8b9cde72003-01-22 17:53:16 +110031trace "start agent"
32eval `${SSHAGENT} -s` > /dev/null
33r=$?
34if [ $r -ne 0 ]; then
35 fail "could not start ssh-agent: exit code $r"
36else
37 # ls -l ${SSH_AUTH_SOCK}
38 gdb ${SSHAGENT} ${SSH_AGENT_PID} > ${OBJ}/gdb.out 2>&1 << EOF
39 quit
40EOF
41 if [ $? -ne 0 ]; then
42 fail "gdb failed: exit code $?"
43 fi
Darren Tucker203c40b2003-11-15 12:13:16 +110044 egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace attach: Permission denied.' >/dev/null ${OBJ}/gdb.out
Damien Miller8b9cde72003-01-22 17:53:16 +110045 r=$?
46 rm -f ${OBJ}/gdb.out
47 if [ $r -ne 0 ]; then
48 fail "ptrace succeeded?: exit code $r"
49 fi
50
51 trace "kill agent"
52 ${SSHAGENT} -k > /dev/null
53fi