Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Init sandbox check #4370

Merged
merged 2 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Possibly scripts breaking changes are prefixed with ✘.
New option/command/subcommand are prefixed with ◈.

## Version
* Bump version to '2.1.0~beta3' [@altgr]
* Bump version to '2.1.0~beta3' [#4351 @AltGr]

## Global CLI
*

## Init
*
* Fix sandbox check with not yet set opam environment variables [#4370 @rjbou - fix #4368]

## Config Upgrade
*
Expand Down
5 changes: 4 additions & 1 deletion src/client/opamAuxCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,11 @@ let check_and_revert_sandboxing root config =
| cmd::_ ->
let test_cmd = [ "sh"; "-c"; "echo SUCCESS >/tmp/t && cat /tmp/t" ] in
let working_or_noop =
let env =
Array.append [| "OPAM_SWITCH_PREFIX=/dev/null" |] (Unix.environment ())
in
try
OpamSystem.read_command_output ~allow_stdin:false (cmd @ test_cmd)
OpamSystem.read_command_output ~env ~allow_stdin:false (cmd @ test_cmd)
= ["SUCCESS"]
with e ->
(OpamConsole.error "Sandboxing is not working on your platform%s:\n%s"
Expand Down
3 changes: 3 additions & 0 deletions src/state/shellscripts/bwrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ add_dune_cache_mount() {
add_mount rw "$u_dune_cache" "$dune_cache"
}

# When using opam variable that must be defined at action time, add them also
# at init check in OpamAuxCommands.check_and_revert_sandboxing (like
# OPAM_SWITCH_PREFIX).
# This case-switch should remain identical between the different sandbox implems
COMMAND="$1"; shift
case "$COMMAND" in
Expand Down
3 changes: 3 additions & 0 deletions src/state/shellscripts/sandbox_exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ add_dune_cache_mount() {
add_mounts rw "$DUNE_CACHE"
}

# When using opam variable that must be defined at action time, add them also
# at init check in OpamAuxCommands.check_and_revert_sandboxing (like
# OPAM_SWITCH_PREFIX).
# This case-switch should remain identical between the different sandbox implems
COMMAND="$1"; shift
case "$COMMAND" in
Expand Down