Purity checking should also accept $TMP, $TMPDIR and $TEMP, $TEMPDIR#97597
Purity checking should also accept $TMP, $TMPDIR and $TEMP, $TEMPDIR#97597vcunat merged 1 commit intoNixOS:stagingfrom
Conversation
2254685 to
8ab5d80
Compare
|
A quick thought: if we go for such a long positive list, wouldn't it be easier to just reject |
|
I agree with the more clean. If you have a specific list of acceptable paths, an exact whitelist seems like a better filter than an approximate blacklist to me. It is unfortunate that a temporary location is a bit messy, but [nix-shell:~]$ env | egrep 'T[^=]*MP[^=]*='
...
TMP=/run/user/1000
TMPDIR=/run/user/1000
TEMPDIR=/run/user/1000
TEMP=/run/user/1000In the original patch I just did |
vcunat
left a comment
There was a problem hiding this comment.
Seems good to me. The conflict is due to the previous version of this getting reverted.
I believe this can be merged to staging without further testing. This new version "breaks" only a subset of badPath invocations in comparison to the previous version which turned out not to be that bad (was in master and release-20.09 for some time).
this not only gives us a "hint" of test coverage, but also proves the fix from NixOS#97597 allows import of theano from within a sandboxed build
(modified cherry pick of commit 4a9dba6) some tricks are required to make this work because NixOS#93560 and NixOS#97597 didn't make it into this branch, but this example shows what is required to import theano from within a nix build environment on this branch.
Motivation for this change
@FRidh @jtojnar @matthewbauer @vcunat @pbogdan have to submit a new pull request for an update to #93560 as it was accepted (and hence closed) but later reverted.
The details again are, the
badPathroutine used by the various compiler paths to check purity is hard coded to reject any paths that lie outside of$NIX_STORE,$NIX_BUILD_TOP, and/tmp.In build environments, however,
/tmpis frequently overriden by settings the$TMP,$TMPDIR, and$TEMPenvironment variables, so I submitted a pull request #93560 to make the system use $TMP, if set, instead of/tmp.This broke packages that were hardcoded to use
/tmp(e.g.,mktemp /tmp/FOOXXXX). In retrospect, the patch was also somewhat lacking as it should technically should also have accept$TMPDIRand$TEMPin addition to$TMP. This is an updated pull request that accepts all of$NIX_STORE,$NIX_BUILD_TOP,/tmp,$TMP,$TMPDIR, and$TEMP.Being strictly more accepting than the previous one, this one should not causes any failures.
Things done
I have verified the above GNU helloworld (see above) compiles correctly in the above example once this change is made. This is actually quite extensive as change the
badPathroutine does result in a fairly significant rebuild of dependencies.sandboxinnix.confon non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)nix path-info -Sbefore and after)