1# $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 6if have_prog uname ; then 7 case `uname` in 8 AIX|CYGWIN*|OSF1) 9 echo "skipped (not supported on this platform)" 10 exit 0 11 ;; 12 esac 13fi 14 15if have_prog gdb ; then 16 : ok 17else 18 echo "skipped (gdb not found)" 19 exit 0 20fi 21 22if test -z "$SUDO" ; then 23 echo "skipped (SUDO not set)" 24 exit 0 25else 26 $SUDO chown 0 ${SSHAGENT} 27 $SUDO chgrp 0 ${SSHAGENT} 28 $SUDO chmod 2755 ${SSHAGENT} 29fi 30 31trace "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 44 egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace attach: Permission denied.|procfs:.*: Invalid argument.' >/dev/null ${OBJ}/gdb.out 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 53fi 54