Make -D mode work when the Yama LSM is enabled
* strace.c [HAVE_PRCTL]: Include sys/prctl.h.
(startup_child) [HAVE_PRCTL && PR_SET_PTRACER && PR_SET_PTRACER_ANY]:
In -D mode, allow tracing the process that is going to become the
tracee.
diff --git a/strace.c b/strace.c
index 84a443c..7c85123 100644
--- a/strace.c
+++ b/strace.c
@@ -39,6 +39,9 @@
#include <grp.h>
#include <dirent.h>
#include <sys/utsname.h>
+#ifdef HAVE_PRCTL
+# include <sys/prctl.h>
+#endif
#if defined(IA64)
# include <asm/ptrace_offsets.h>
#endif
@@ -1134,6 +1137,11 @@
*/
params_for_tracee.pathname = NOMMU_SYSTEM ? strdup(pathname) : pathname;
+#if defined HAVE_PRCTL && defined PR_SET_PTRACER && defined PR_SET_PTRACER_ANY
+ if (daemonized_tracer)
+ prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
+#endif
+
strace_child = pid = fork();
if (pid < 0) {
perror_msg_and_die("fork");