Merge pull request #11366 from Mic92/homeless-shelter

Revert: Make $HOME=/proc/homeless-shelter instead of /homeless-shelter
This commit is contained in:
tomberek 2024-08-25 05:07:41 -04:00 committed by GitHub
commit a30eb6de1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 1 additions and 18 deletions

View file

@ -1,9 +0,0 @@
---
synopsis: On linux, set $HOME=/proc/homeless-shelter instead of /homeless-shelter
issues: [8313, 11295]
prs: [11300]
---
When building, $HOME is set to a non-existing directory. Previously it was always set to `/homeless-shelter`. Before a build, Nix verifies that it doesn't exist. In some scenarios (specifically when using the Linux sandbox with a single-user installation), it is possible to create the `/homeless-shelter` directory, and some tools will create it, resulting in a build error.
Now, on Linux, $HOME is set to `/proc/homeless-shelter`. This directory can never be created, since `/proc` is a virtual filesystem. This resolves the issue.

View file

@ -264,8 +264,7 @@ The [`builder`](#attr-builder) is executed as follows:
- `PATH` is set to `/path-not-set` to prevent shells from
initialising it to their built-in default value.
- `HOME` is set to `/proc/homeless-shelter` on Linux and `/homeless-shelter`
on OSX, to prevent programs from
- `HOME` is set to `/homeless-shelter` to prevent programs from
using `/etc/passwd` or the like to find the user's home
directory, which could cause impurity. Usually, when `HOME` is
set, it is used as the location of the home directory, even if

View file

@ -102,14 +102,7 @@ void handleDiffHook(
}
}
// We want $HOME to be un-creatable in the sandbox. On Linux,
// you can't create anything inside /proc since it's a virtual filesystem.
// On Darwin it seems that `/homeless-shelter` is good enough.
#if __linux__
const Path LocalDerivationGoal::homeDir = "/proc/homeless-shelter";
#else
const Path LocalDerivationGoal::homeDir = "/homeless-shelter";
#endif
LocalDerivationGoal::~LocalDerivationGoal()