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

darwin sandbox #3429

Merged
merged 4 commits into from
Mar 23, 2020
Merged

darwin sandbox #3429

merged 4 commits into from
Mar 23, 2020

Conversation

LnL7
Copy link
Member

@LnL7 LnL7 commented Mar 20, 2020

This should make the darwin sandbox functional by default, resolving the issues with dependency tracking of impurities like frameworks in favour of opening up the default sandbox a bit more.

LnL7 added 4 commits March 20, 2020 21:21
This is used to determine the dependency tree of impure libraries so nix
knows what paths to open in the sandbox.  With the less restrictive
defaults it isn't needed anymore.
Nix now runs builds with a pseudo-terminal to enable colored build
output.
Sadly 10.15 changed /bin/sh to a shim which executes bash, this means it
can't be used anymore without also opening up the sandbox to allow bash.

    Failed to exec /bin/bash as variant for /bin/sh (1: Operation not permitted).

/* chroot-like behavior from Apple's sandbox */
#if __APPLE__
sandboxPaths = tokenizeString<StringSet>("/System/Library/Frameworks /System/Library/PrivateFrameworks /bin/sh /bin/bash /private/tmp /private/var/tmp /usr/lib");
Copy link
Member Author

Choose a reason for hiding this comment

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

I would really prefer not to need bash here (#3223) but other than either disallowing /bin/sh completely or having nix depend on something like fuse bindfs I don't think we can work around it. 😕

Copy link
Member

Choose a reason for hiding this comment

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

I really wish there was some way to say "allow /bin/bash but only when executed by /bin/sh" 🤷‍♀️

@LnL7 LnL7 marked this pull request as ready for review March 20, 2020 21:46
@edolstra edolstra merged commit 5885e20 into NixOS:master Mar 23, 2020
@LnL7 LnL7 deleted the darwin-sandbox branch March 23, 2020 22:47

; This is used by /bin/sh on macOS 10.15 and later.
(allow file*
(literal "/private/var/select/sh"))
Copy link
Member

Choose a reason for hiding this comment

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

We actually want to explicitly disallow access to this, because this file is what’s used to control whether /bin/sh is bash or zsh. If we disallow access it will always resolve to bash. If we allow access then the user can configure it to be zsh instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thought I tested that and it failed, but looks like it's indeed only an error message.

$ sandbox-exec -f sandbox.sb /bin/sh -c "echo ok"
Error opening /private/var/select/sh: Operation not permitted
ok

Luckily it doesn't really matter and not having to spew out errors out by default is nice.

Failed to exec /bin/zsh as variant for /bin/sh (1: Operation not permitted). Falling back to /bin/bash.
ok

Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Apr 8, 2024
Fix NixOS#9769

As @abathur reports, it seems to be unused since NixOS#3429 in 2020.
Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Apr 8, 2024
Fix NixOS#9769

As Abathur reports, it seems to be unused since NixOS#3429 in 2020.
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.

3 participants