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.
This commit is contained in:
Дмитрий Левин 2013-05-13 18:43:28 +00:00
parent 7a0fb38386
commit 882478a072

View File

@ -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");