blob: d5892ed03098f4b9279840107bc7cbbddc84bc42 [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 Tuckerb17035f2004-08-29 20:33:07 +10008 AIX|CYGWIN*|OSF1)
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 Tucker90a58fd2007-03-03 09:42:23 +110044 egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace.*Permission denied.|procfs:.*: Invalid argument.' >/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