Home | History | Annotate | Download | only in regress
      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 
      6 if 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
     13 fi
     14 
     15 if have_prog gdb ; then
     16 	: ok
     17 else
     18 	echo "skipped (gdb not found)"
     19 	exit 0
     20 fi
     21 
     22 if test -z "$SUDO" ; then
     23 	echo "skipped (SUDO not set)"
     24 	exit 0
     25 else
     26 	$SUDO chown 0 ${SSHAGENT}
     27 	$SUDO chgrp 0 ${SSHAGENT}
     28 	$SUDO chmod 2755 ${SSHAGENT}
     29 fi
     30 
     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
     44 	egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace.*Permission denied.|procfs:.*: Invalid argument.|Unable to access task ' >/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
     53 fi
     54