From 25230a17a9d0c22f97ed80b1a8f50566a4ff548d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 12 Jun 2017 17:43:19 +0200 Subject: [PATCH] On macOS, don't use /var/folders for TMPDIR This broke "nix-store --serve". --- src/libmain/shared.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index d6c1c0c9c..915e79550 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -138,6 +138,14 @@ void initNix() struct timeval tv; gettimeofday(&tv, 0); srandom(tv.tv_usec); + + /* On macOS, don't use the per-session TMPDIR (as set e.g. by + sshd). This breaks build users because they don't have access + to the TMPDIR, in particular in ‘nix-store --serve’. */ +#if __APPLE__ + if (getuid() == 0 && hasPrefix(getEnv("TMPDIR"), "/var/folders/")) + unsetenv("TMPDIR"); +#endif }