diff options
author | Andrew Bartlett <abartlet@samba.org> | 2020-05-23 21:24:07 +1200 |
---|---|---|
committer | Gary Lockyer <gary@samba.org> | 2020-05-27 20:55:26 +0000 |
commit | d279cf7bede639314cb2b9ba52d44218dc2fc353 (patch) | |
tree | 63c8d65fcaddd767760fe7e63c5d3fb28a4cffd4 /lib | |
parent | 7754a557d493f0c2af9420c8fa99fb8c2d9ac70c (diff) | |
download | samba-d279cf7bede639314cb2b9ba52d44218dc2fc353.tar.gz |
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 <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/util.c | 10 |
1 files changed, 10 insertions, 0 deletions
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 <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; } |