mirror of
https://github.com/NixOS/nix
synced 2025-06-28 05:21:16 +02:00
* When not running as root, call the setuid helper to change the
ownership of the build result after the build.
This commit is contained in:
parent
6a07ff1ec0
commit
a0a43c3206
2 changed files with 13 additions and 7 deletions
|
@ -1398,7 +1398,7 @@ void DerivationGoal::startBuilder()
|
|||
safe. Also note that setuid() when run as root sets
|
||||
the real, effective and saved UIDs. */
|
||||
if (buildUser.enabled()) {
|
||||
printMsg(lvlInfo, format("switching to uid `%1%'") % buildUser.getUID());
|
||||
printMsg(lvlInfo, format("switching to user `%1%'") % buildUser.getUser());
|
||||
|
||||
if (amPrivileged()) {
|
||||
|
||||
|
@ -1544,6 +1544,12 @@ void DerivationGoal::computeClosure()
|
|||
throw Error(format("suspicious ownership or permission on `%1%'; rejecting this build output") % path);
|
||||
#endif
|
||||
|
||||
if (buildUser.enabled() && !amPrivileged())
|
||||
/* Call the setuid helper to change ownership from the
|
||||
build user to our uid. If we *are* root, then
|
||||
canonicalisePathMetaData() will take care of this. */
|
||||
getOwnership(path);
|
||||
|
||||
/* Get rid of all weird permissions. */
|
||||
canonicalisePathMetaData(path);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue