From: Andrew Bartlett Date: Sat, 23 May 2020 09:24:07 +0000 (+1200) Subject: lib/util: Allow gdb to be started by samba_start_debugger() under the default Ubuntu... X-Git-Tag: ldb-2.2.0~321 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d279cf7bede639314cb2b9ba52d44218dc2fc353;p=thirdparty%2Fsamba.git lib/util: Allow gdb to be started by samba_start_debugger() under the default Ubuntu restrictions Ubuntu (in particular) restricts ptrace by default for security reasons but the processe to be traced can allow tracing by a child process using prctl(). This matches what is done for panic action = Signed-off-by: Andrew Bartlett Reviewed-by: Gary Lockyer --- diff --git a/lib/util/util.c b/lib/util/util.c index 0d9ffe5cb7b..a90d48f6f1b 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -36,6 +36,10 @@ #include "samba_util.h" #include "lib/util/select.h" +#ifdef HAVE_SYS_PRCTL_H +#include +#endif + #undef malloc #undef strcasecmp #undef strncasecmp @@ -1282,6 +1286,12 @@ void anonymous_shared_free(void *ptr) void samba_start_debugger(void) { char *cmd = NULL; +#if defined(HAVE_PRCTL) && defined(PR_SET_PTRACER) + /* + * Make sure all children can attach a debugger. + */ + prctl(PR_SET_PTRACER, getpid(), 0, 0, 0); +#endif if (asprintf(&cmd, "xterm -e \"gdb --pid %u\"&", getpid()) == -1) { return; }