Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 1 | # $OpenBSD: agent-ptrace.sh,v 1.1 2002/12/09 15:38:30 markus Exp $ |
| 2 | # Placed in the Public Domain. |
| 3 | |
| 4 | tid="disallow agent ptrace attach" |
| 5 | |
Tim Rice | 23ee359 | 2003-09-11 22:32:17 -0700 | [diff] [blame] | 6 | if have_prog uname ; then |
Darren Tucker | 5569759 | 2003-09-04 13:55:25 +1000 | [diff] [blame] | 7 | case `uname` in |
Darren Tucker | b17035f | 2004-08-29 20:33:07 +1000 | [diff] [blame] | 8 | AIX|CYGWIN*|OSF1) |
Darren Tucker | 77d07e9 | 2003-09-04 22:06:16 +1000 | [diff] [blame] | 9 | echo "skipped (not supported on this platform)" |
Darren Tucker | 5569759 | 2003-09-04 13:55:25 +1000 | [diff] [blame] | 10 | exit 0 |
| 11 | ;; |
| 12 | esac |
| 13 | fi |
| 14 | |
Tim Rice | b7efb63 | 2003-09-12 11:20:32 -0700 | [diff] [blame] | 15 | if have_prog gdb ; then |
| 16 | : ok |
| 17 | else |
Darren Tucker | 5569759 | 2003-09-04 13:55:25 +1000 | [diff] [blame] | 18 | echo "skipped (gdb not found)" |
| 19 | exit 0 |
| 20 | fi |
| 21 | |
Darren Tucker | ea4c670 | 2003-10-21 22:27:08 +1000 | [diff] [blame] | 22 | if test -z "$SUDO" ; then |
| 23 | echo "skipped (SUDO not set)" |
| 24 | exit 0 |
| 25 | else |
Darren Tucker | be8a771 | 2003-11-03 22:52:52 +1100 | [diff] [blame] | 26 | $SUDO chown 0 ${SSHAGENT} |
| 27 | $SUDO chgrp 0 ${SSHAGENT} |
Darren Tucker | 2bdacad | 2003-10-21 23:12:37 +1000 | [diff] [blame] | 28 | $SUDO chmod 2755 ${SSHAGENT} |
Darren Tucker | ea4c670 | 2003-10-21 22:27:08 +1000 | [diff] [blame] | 29 | fi |
| 30 | |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 31 | trace "start agent" |
| 32 | eval `${SSHAGENT} -s` > /dev/null |
| 33 | r=$? |
| 34 | if [ $r -ne 0 ]; then |
| 35 | fail "could not start ssh-agent: exit code $r" |
| 36 | else |
| 37 | # ls -l ${SSH_AUTH_SOCK} |
| 38 | gdb ${SSHAGENT} ${SSH_AGENT_PID} > ${OBJ}/gdb.out 2>&1 << EOF |
| 39 | quit |
| 40 | EOF |
| 41 | if [ $? -ne 0 ]; then |
| 42 | fail "gdb failed: exit code $?" |
| 43 | fi |
Darren Tucker | 90a58fd | 2007-03-03 09:42:23 +1100 | [diff] [blame^] | 44 | egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace.*Permission denied.|procfs:.*: Invalid argument.' >/dev/null ${OBJ}/gdb.out |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 45 | 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 |
| 53 | fi |