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 | |
Damien Miller | 6d6fcd1 | 2013-12-08 15:53:28 +1100 | [diff] [blame^] | 22 | if $OBJ/setuid-allowed ${SSHAGENT} ; then |
| 23 | : ok |
| 24 | else |
| 25 | echo "skipped (${SSHAGENT} is mounted on a no-setuid filesystem)" |
| 26 | exit 0 |
| 27 | fi |
| 28 | |
Darren Tucker | ea4c670 | 2003-10-21 22:27:08 +1000 | [diff] [blame] | 29 | if test -z "$SUDO" ; then |
| 30 | echo "skipped (SUDO not set)" |
| 31 | exit 0 |
| 32 | else |
Darren Tucker | be8a771 | 2003-11-03 22:52:52 +1100 | [diff] [blame] | 33 | $SUDO chown 0 ${SSHAGENT} |
| 34 | $SUDO chgrp 0 ${SSHAGENT} |
Darren Tucker | 2bdacad | 2003-10-21 23:12:37 +1000 | [diff] [blame] | 35 | $SUDO chmod 2755 ${SSHAGENT} |
Darren Tucker | ea4c670 | 2003-10-21 22:27:08 +1000 | [diff] [blame] | 36 | fi |
| 37 | |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 38 | trace "start agent" |
| 39 | eval `${SSHAGENT} -s` > /dev/null |
| 40 | r=$? |
| 41 | if [ $r -ne 0 ]; then |
| 42 | fail "could not start ssh-agent: exit code $r" |
| 43 | else |
| 44 | # ls -l ${SSH_AUTH_SOCK} |
| 45 | gdb ${SSHAGENT} ${SSH_AGENT_PID} > ${OBJ}/gdb.out 2>&1 << EOF |
| 46 | quit |
| 47 | EOF |
| 48 | if [ $? -ne 0 ]; then |
| 49 | fail "gdb failed: exit code $?" |
| 50 | fi |
Damien Miller | fd3669e | 2011-01-17 11:20:18 +1100 | [diff] [blame] | 51 | egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace.*Permission denied.|procfs:.*: Invalid argument.|Unable to access task ' >/dev/null ${OBJ}/gdb.out |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 52 | r=$? |
| 53 | rm -f ${OBJ}/gdb.out |
| 54 | if [ $r -ne 0 ]; then |
| 55 | fail "ptrace succeeded?: exit code $r" |
| 56 | fi |
| 57 | |
| 58 | trace "kill agent" |
| 59 | ${SSHAGENT} -k > /dev/null |
| 60 | fi |