]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/util: Allow gdb to be started by samba_start_debugger() under the default Ubuntu...
authorAndrew Bartlett <abartlet@samba.org>
Sat, 23 May 2020 09:24:07 +0000 (21:24 +1200)
committerGary Lockyer <gary@samba.org>
Wed, 27 May 2020 20:55:26 +0000 (20:55 +0000)
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 <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
lib/util/util.c

index 0d9ffe5cb7b61bb897ac686845ace2d893cc1117..a90d48f6f1b90ae85434b663879f2d620d201b4e 100644 (file)
 #include "samba_util.h"
 #include "lib/util/select.h"
 
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#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;
        }