Sandbox script: change handling of TMPDIR#4589
Merged
rjbou merged 6 commits intoocaml:masterfrom Mar 10, 2021
Merged
Conversation
Collaborator
|
which one is to merge, #4561 or this one ? |
Member
Author
|
Hm, they're probably the same, the merge took too long so I forgot I had already filed it 🤡 |
The previous behaviour was to bind-mount $TMPDIR to /tmp within the sandbox, and re-set TMPDIR accordingly ; however, this meant that absolute paths within TMPDIR could be incompatible between the outside and the inside of the sandbox. This became a visible problem with dune 2.8, which redefines TMPDIR to a subdirectory (e.g. `/tmp/buildXXXX.dune`). If you happen to be running tests with an OPAMROOT within $TMPDIR, your opam root will no longer be accessible, and packages that run opam commands from within the sandbox (which is discouraged, but well...) will break. In our tests, run through dune, OPAMROOT gets created in `/tmp/buildXXXX.dune/OPAM`, then packages get installed within a sandbox, this is relocated to `/tmp/OPAM` but `OPAMROOT` and `OPAM_SWITCH_PREFIX` remained set to below `/tmp/buildXXXX.dune`, and things broke.
this made PWD always rw accessible on remove actions, and was possibly dangerous
Closed
kit-ty-kate
added a commit
that referenced
this pull request
Jun 18, 2021
I'm not sure what was the reason behind having /tmp rw on macos but read-only on linux. In opam 2.0 it seem to have been the invert at first (rw on linux and ro on macos) however it was synchronized to rw in both in 2.0.8 in see #374. In opam 2.1~rc a linux-only change was done which made it ro: #4589, but it was never ported to macos.
kit-ty-kate
added a commit
that referenced
this pull request
Jul 27, 2021
I'm not sure what was the reason behind having /tmp rw on macos but read-only on linux. In opam 2.0 it seem to have been the invert at first (rw on linux and ro on macos) however it was synchronized to rw in both in 2.0.8 in see #374. In opam 2.1~rc a linux-only change was done which made it ro: #4589, but it was never ported to macos.
rjbou
pushed a commit
to rjbou/opam
that referenced
this pull request
Sep 2, 2021
I'm not sure what was the reason behind having /tmp rw on macos but read-only on linux. In opam 2.0 it seem to have been the invert at first (rw on linux and ro on macos) however it was synchronized to rw in both in 2.0.8 in see ocaml#374. In opam 2.1~rc a linux-only change was done which made it ro: ocaml#4589, but it was never ported to macos.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(also: port improvements from bwrap to sandbox_exec, and fix a few
bugs, in particular for detection of the sandbox and newer dune)
The
bwrapscript now bind-mounts the existing$TMPDIRread-only,allowing proper communication from outside the sandbox to the inside;
and re-creates a tmpfs someplace else, re-defining
TMPDIR.It might break scripts that accessed
/tmpdirectly (instead ofTMPDIR) though, since it won't be writeable from within the sandbox.The previous behaviour was to bind-mount $TMPDIR to /tmp within the
sandbox, and re-set TMPDIR accordingly ; however, this meant that absolute
paths within TMPDIR could be incompatible between the outside and the
inside of the sandbox.
This became a visible problem with dune 2.8, which redefines TMPDIR to a
subdirectory (e.g.
/tmp/buildXXXX.dune). If you happen to be runningtests with an OPAMROOT within $TMPDIR, your opam root will no longer be
accessible, and packages that run opam commands from within the sandbox
(which is discouraged, but well...) will break.
In our tests, run through dune, OPAMROOT gets created in
/tmp/buildXXXX.dune/OPAM, then packages get installed within a sandbox,this is relocated to
/tmp/OPAMbutOPAMROOTandOPAM_SWITCH_PREFIXremained set to below
/tmp/buildXXXX.dune, and things broke.