-
Notifications
You must be signed in to change notification settings - Fork 13.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
Document that std::os::unix::process::CommandExt.uid() triggers setgroups(0,0) #39186
Comments
re-tagging as @rust-lang/libs ; would you like this to appear in the docs, or not? If so, we're happy to do it, but want to make sure to not over-specify. |
This seems like something we should document, yes. It's an unusual special-case that people should be aware of. This also interacts with #72160 . |
Ok, this is ready for a PR. I've labeled it accordingly. |
@joshtriplett hi! It may be a long time now but may I ask if this issue is still needed? Because I can't find the
Did I lookup the wrong function and structs? |
Rollup merge of rust-lang#121650 - GrigorenkoPV:cap_setgid, r=Amanieu change std::process to drop supplementary groups based on CAP_SETGID A trivial rebase of rust-lang#95982 Should fix rust-lang#39186 (from what I can tell) Original description: > Fixes rust-lang#88716 > > * Before this change, when a process was given a uid via `std::os::unix::process::CommandExt.uid`, there would be a `setgroups` call (when the process runs) to clear supplementary groups for the child **if the parent was root** (to remove potentially unwanted permissions). > * After this change, supplementary groups are cleared if we have permission to do so, that is, if we have the CAP_SETGID capability. > > This new behavior was agreed upon in rust-lang#88716 but there was a bit of uncertainty from `@Amanieu` here: [rust-lang#88716 (comment)](rust-lang#88716 (comment)) > > > I agree with this change, but is it really necessary to ignore an EPERM from setgroups? If you have permissions to change UID then you should also have permissions to change groups. I would feel more comfortable if we documented set_uid as requiring both UID and GID changing permissions. > > The way I've currently written it, we ignore an EPERM as that's what rust-lang#88716 originally suggested. I'm not at all an expert in any of this so I'd appreciate feedback on whether that was the right way to go.
While digging around for something else I have just discovered that setting the UID for a subprocess with
CommandExt.uid()
also causes a call tosetgroups(0,0)
in the child. This should be documented.(Related to #38527)
The text was updated successfully, but these errors were encountered: