about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nix-setuid-helper/nix-setuid-helper.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nix-setuid-helper/nix-setuid-helper.cc b/src/nix-setuid-helper/nix-setuid-helper.cc
index 168cff40a3f6..ffb2abc1f164 100644
--- a/src/nix-setuid-helper/nix-setuid-helper.cc
+++ b/src/nix-setuid-helper/nix-setuid-helper.cc
@@ -128,8 +128,15 @@ static void runBuilder(uid_t uidNix, gid_t gidBuildUsers,
     for (int i = 0; i < argc; ++i)
         args.push_back(argv[i]);
     args.push_back(0);
+
+    environ = env;
+
+    /* Glibc clears TMPDIR in setuid programs (see
+       sysdeps/generic/unsecvars.h in the Glibc sources), so bring it
+       back. */
+    setenv("TMPDIR", getenv("NIX_BUILD_TOP"), 1);
     
-    if (execve(program.c_str(), (char * *) &args[0], env) == -1)
+    if (execv(program.c_str(), (char * *) &args[0]) == -1)
         throw SysError(format("cannot execute `%1%'") % program);
 }