-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Functionality for pseudoterminals in linux sandbox #14072
Functionality for pseudoterminals in linux sandbox #14072
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This review is just general comments. I don't know enough about the sandbox to determine if this is a general purpose patch, or if we'll be back for a new design the second someone wants it for BSD or NIX. Also, it is not clear to me from the comments in #5373 that we should even do this.
"Explicitly enable the creation of pseudoterminals for sandboxed actions." | ||
+ " Some linux distributions require setting the group of the user to 'tty'" | ||
+ " inside the sandbox in order for pseudoterminals to function. If this is" | ||
+ " causing issues, this flag can be disabled to enable other groups to be used.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not look like there is any option to use other gid values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intended meaning is that setting the flag would override anything that would otherwise alter the gid within the user namespace, e.g. if --sandbox_fake_username
is set or if REQUIRES_FAKEROOT
evaluates to true. I could rephrase this if it's unclear.
src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java
Outdated
Show resolved
Hide resolved
We'll need to have someone who owns sandboxing review this. I added @philwo because of comments in the original bug. |
Thank you @crydell-ericsson! Ideally I'd like to avoid adding yet another flag... is there a way to automatically detect what the right thing to do is? Could we just always mount |
I think we should be able to always have
I'm not sure how this could be done in a way that would still let this functionality be used by an unprivileged user. From the man page of user_namespaces(7):
Ideally you would be able to make two gid mappings, one tty->tty mapping and one arbitrary mapping for the gid in the parent namespace. This would not be possible if we want to run bazel as an unprivileged user, since only a single mapping can be done without granting the CAP_SETGID capability to the process in the parent namespace. |
Just thought I'd check in on the progress of this pull request; is there any additional information needed for this? |
Thank you for the information, @crydell-ericsson. It's too bad that the best solution requires CAP_SETGID. 😞 I agree with your thoughts. @larsrc-google Shall we merge this as is? Looks clean to me and all changed behavior is behind a flag. |
82212be
to
d9c4266
Compare
4aef41d
to
ab9ae7f
Compare
@crydell-ericsson This PR is out of date, could you update it? |
As brought up in issue #5373 , the Linux sandbox does not allow processes that run inside it to open pseudoterminals. These changes enable this by addressing the two main underlying issues:
/dev/pts
can not be read-only if a new pseudoterminal is to be created. These changes makedev/pts
writable when remounting file systems during sandbox initialization.These changes introduce the
-P
flag tolinux-sandbox
in order to control whether or not the changes are applied, and the--sandbox-explicit-pseudoterminal
tobazel
in order to set this when calling bazel.