diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-06-12T15·43+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-06-12T15·43+0200 |
commit | 25230a17a9d0c22f97ed80b1a8f50566a4ff548d (patch) | |
tree | f5b3fd125c3dc22bc7053c0f74140915b209f321 /src/libmain/shared.cc | |
parent | 847f19a5f7a558252bbde9b4c70efa5f7fac1f4f (diff) |
On macOS, don't use /var/folders for TMPDIR
This broke "nix-store --serve".
Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r-- | src/libmain/shared.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index d6c1c0c9cb49..915e79550144 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 } |