lttng-crash: support recursive traces
[lttng-tools.git] / src / common / runas.c
index 9029f8f74d7802416a97a5f22a0650da9378ce68..471bb22046c3d3bf9f44dbf24c176f089a3e3c2e 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>
@@ -34,6 +35,7 @@
 #include <common/utils.h>
 #include <common/compat/mman.h>
 #include <common/compat/clone.h>
+#include <common/compat/getenv.h>
 
 #include "runas.h"
 
@@ -77,6 +79,20 @@ struct run_as_open_data {
        mode_t mode;
 };
 
+#ifdef VALGRIND
+static
+int use_clone(void)
+{
+       return 0;
+}
+#else
+static
+int use_clone(void)
+{
+       return !lttng_secure_getenv("LTTNG_DEBUG_NOCLONE");
+}
+#endif
+
 /*
  * Create recursively directory using the FULL path.
  */
@@ -271,7 +287,7 @@ int run_as_noclone(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
 static
 int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
 {
-       if (!getenv("LTTNG_DEBUG_NOCLONE")) {
+       if (use_clone()) {
                int ret;
 
                DBG("Using run_as_clone");
This page took 0.023313 seconds and 4 git commands to generate.