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

On init, check and propose to disable sandboxing if tool present & not working (docker, chroot, WLS1, etc.) #4284

Merged
merged 5 commits into from
Aug 27, 2020

Conversation

rjbou
Copy link
Collaborator

@rjbou rjbou commented Jul 27, 2020

The check is done by calling the sandbox script with sandbox <action> sh -c "echo SUCCESS >/tmp/t && cat /tmp/t", and checking that stdout is SUCCESS.
Disabling is done by removing from global config sandboxing wrappers, default ones, defined in OpamInitDefaults.sandbox_wrappers.

src/client/opamClient.ml Outdated Show resolved Hide resolved
@rjbou rjbou added this to the 2.1.0~alpha3 milestone Jul 28, 2020
@rjbou rjbou linked an issue Jul 30, 2020 that may be closed by this pull request
@rjbou rjbou modified the milestones: 2.1.0~alpha3, 2.1.0~beta Aug 11, 2020
@rjbou
Copy link
Collaborator Author

rjbou commented Aug 20, 2020

ping @mato?

src/client/opamClient.ml Outdated Show resolved Hide resolved
Copy link
Member

@AltGr AltGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good, see comments for fields where I'd have liked it differently, but you may not have had better options.

@@ -752,6 +752,62 @@ let init_checks ?(hard_fail_exn=true) init_config =
if hard_fail && hard_fail_exn then OpamStd.Sys.exit_because `Configuration_error
else not (soft_fail || hard_fail)

(* Check sandboxing script call. If it errors or unattended output, disable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I would have chosen this module for this, since it's at the moment concerned with package-handling stuff and the switch state... but I don't have a much better proposition ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to OpamAuxCommand

OpamSysPoll.variables >>= Lazy.force)
in
match OpamFilter.commands env sdbx_wrappers with
| [] -> config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too bad we can't use the code of OpamAction here :/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added OpamEnv.hook_env

@rjbou rjbou requested a review from AltGr August 26, 2020 18:13
@AltGr AltGr merged commit f0e82e9 into ocaml:master Aug 27, 2020
AltGr added a commit to OCamlPro/opam that referenced this pull request Sep 2, 2020
See ocaml#4284

I was getting:
```
% OPAMROOT=/tmp/egex opam init
[NOTE] Will configure from built-in defaults.
[ERROR] Sandboxing is not working on your platform debian:
        "/tmp/egex/opam-init/hooks/sandbox.sh": command not found.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fail gracefully if bwrap sandbox is available but not functional
3 participants