From 2d85a600590b23ca5ca1e182187d08f44808ef80 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 24 Feb 2012 11:39:52 -0500 Subject: [PATCH] Debugger support: introduce LTTNG_DEBUG_NOCLONE env. var. Signed-off-by: Mathieu Desnoyers --- doc/man/lttng-sessiond.8 | 3 +++ src/common/runas.c | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/man/lttng-sessiond.8 b/doc/man/lttng-sessiond.8 index 8a235f941..50a03b029 100644 --- a/doc/man/lttng-sessiond.8 +++ b/doc/man/lttng-sessiond.8 @@ -129,6 +129,9 @@ Allow to specifiy the 64-bit library path containing libconsumer.so. .IP "LTTNG_CONSUMERD64_LIBDIR" Allow to specifiy the 32-bit library path containing libconsumer.so. \fB--consumerd64-libdir\fP override this variable. +.IP "LTTNG_DEBUG_NOCLONE" +Debug-mode disabling use of clone/fork. Insecure, but required to allow +debuggers to work with sessiond on some operating systems. .SH "SEE ALSO" .PP diff --git a/src/common/runas.c b/src/common/runas.c index 7dee28abe..4742a792e 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -200,7 +200,7 @@ int child_run_as(void *_data) } static -int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid) +int run_as_clone(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid) { struct run_as_data run_as_data; int ret = 0; @@ -292,6 +292,29 @@ end: return retval.i; } +/* + * To be used on setups where gdb has issues debugging programs using + * clone/rfork. Note that this is for debuging ONLY, and should not be + * considered secure. + */ +static +int run_as_noclone(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid) +{ + return cmd(data); +} + +static +int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid) +{ + if (!getenv("LTTNG_DEBUG_NOCLONE")) { + DBG("Using run_as_clone"); + return run_as_clone(cmd, data, uid, gid); + } else { + DBG("Using run_as_noclone"); + return run_as_noclone(cmd, data, uid, gid); + } +} + int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid) { struct run_as_mkdir_data data; -- 2.34.1