]> granicus.if.org Git - strace/commitdiff
Make -D mode work when the Yama LSM is enabled
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 13 May 2013 18:43:28 +0000 (18:43 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 14 May 2013 22:29:18 +0000 (22:29 +0000)
* 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.

strace.c

index 84a443c07ff6c5a0fce8d96937feda9a5f363784..7c851234ab7a5e6d2f06ec8e22472bd892e3ce27 100644 (file)
--- 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 @@ startup_child(char **argv)
         */
        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");