Use ptrace(PT_DENY_ATTACH, ..) on OS X.

This commit is contained in:
Darren Tucker 2016-11-01 08:12:33 +11:00
parent 315d2a4e67
commit 5ee3fb5aff
2 changed files with 9 additions and 0 deletions

View File

@ -405,6 +405,7 @@ AC_CHECK_HEADERS([ \
sys/poll.h \
sys/prctl.h \
sys/pstat.h \
sys/ptrace.h \
sys/select.h \
sys/stat.h \
sys/stream.h \

View File

@ -20,6 +20,9 @@
#if defined(HAVE_SYS_PRCTL_H)
#include <sys/prctl.h> /* For prctl() and PR_SET_DUMPABLE */
#endif
#ifdef HAVE_SYS_PTRACE_H
#include <sys/ptrace.h>
#endif
#ifdef HAVE_PRIV_H
#include <priv.h> /* For setpflags() and __PROC_PROTECT */
#endif
@ -40,4 +43,9 @@ platform_disable_tracing(int strict)
if (setpflags(__PROC_PROTECT, 1) != 0 && strict)
fatal("unable to make the process untraceable");
#endif
#ifdef PT_DENY_ATTACH
/* Mac OS X */
if (ptrace(PT_DENY_ATTACH, 0, 0, 0) == -1 && strict)
fatal("unable to set PT_DENY_ATTACH");
#endif
}