1# $OpenBSD: agent-ptrace.sh,v 1.2 2014/02/27 21:21:25 djm Exp $ 2# Placed in the Public Domain. 3 4tid="disallow agent ptrace attach" 5 6trace "start agent" 7eval `${SSHAGENT} -s` > /dev/null 8r=$? 9if [ $r -ne 0 ]; then 10 fail "could not start ssh-agent: exit code $r" 11else 12 # ls -l ${SSH_AUTH_SOCK} 13 gdb ${SSHAGENT} ${SSH_AGENT_PID} > ${OBJ}/gdb.out 2>&1 << EOF 14 quit 15EOF 16 r=$? 17 if [ $r -ne 0 ]; then 18 fail "gdb failed: exit code $r" 19 fi 20 grep -q 'ptrace: Operation not permitted.' ${OBJ}/gdb.out 21 r=$? 22 rm -f ${OBJ}/gdb.out 23 if [ $r -ne 0 ]; then 24 fail "ptrace succeeded?: exit code $r" 25 fi 26 27 trace "kill agent" 28 ${SSHAGENT} -k > /dev/null 29fi 30