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>
#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
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;
}