-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Best effort supplementary groups #8342
Best effort supplementary groups #8342
Conversation
There is no obvious good solution for this that has occured to anyone.
Co-authored-by: Guillaume Girol <[email protected]>
This gets in the way of the tests running in parallel.
src/libstore/globals.hh
Outdated
R"( | ||
Whether to drop supplementary groups when building with sandboxing. | ||
This is normally a good idea if we are root and have the capability to | ||
do so. |
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.
When is it not? I think we should warn about negative groups (if that's the right name for it); groups that when you're a member, you have fewer capabilities rather than more.
It would guess for it to be rare that the daemon would start as root but have a negative group, but I don't think we are free to assume just assume that and be quiet about it here.
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.
@roberth The problem is I don't think Unix has any clue what groups are "covariant", "contravariant", or "invariant": it depends on how they are used, and none of the LWM stuff on this mention any attempt to annotate the intent of the group on the group itself.
Unix is thus stuck with the pessimistic assumption that all groups are invariant, and only privilaged users can take them on or drop them alike.
It's extremely mediocre :/
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.
I would love to yell ask nicely on the LKML about all this:
- Why no way to annotate that info on the group, backwards compatibly?!
- Why do all the groups of a user need to be mapped into the user namespace in the first place?!
- Why does creating a mount namespace require a user namespace in the first place?!
But I think these are yak shaves not yet fitting in anyone's budget :).
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.
We could document our opinion, "open letter" style.
contravariant
That corresponds to my "negative". Not sure which is better. Something "anti-..." could fit and be more explicit. Needs more thought or more reading, or anything will do.
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.
Yeah I think postive/negative is better than co-/contrainvariant :), but then there is "invariant" too, and what does that map to? "Neutral" sounds more innocuous, like "bivariant" to me.
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.
Going back to the original question, I am actually fine with Nix assuming all groups are "positive", and always trying to drop groups. Non-positive ones are gross to me and I have little interest in trying to support them.
The real question question is if that operation fails, is it a fatal error or not? That is what feels to me like like a question that ultimately needs to be in the user's not Nix's hand.
(To simply unblock myself writing tests, and also for backwards compat since Nix didn't try to do the operation as non-root before, I made the option on whether to attempt the option. I have issue to instead make the setting about what to do if the operation fails with EPERM or whatever. Non-root could attempt the operation anyways, after all, it's possible to have the CAP_SETGID
without being root so it might in fact succeed.)
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-06-22-nix-team-meeting-minutes-65/29643/1 |
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.
@benradf's changes look good to me in this PR. The only issue is now the test is being skipped.
Co-authored-by: Valentin Gagarin <[email protected]>
Co-authored-by: Valentin Gagarin <[email protected]>
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 unset NIX_STORE_DIR
changes look good. I see that the supplementary-groups
test is no longer being skipped on CI.
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.
Thanks, that's looking great now:+1:
The motivation for this is basically explained in the contribution guide, as guidance on how to design features like this going forward. In short, I think it is confusing for operations acting on the default profile to *always* do something different based on whether the user is regular or root. Instead, this makes there be flags which are (from the vantage point of today) "do the root default" vs "do the regular user" default. This make the situation teachable: we can point to the flags, and the conditional default, as *exactly* what varies between the root and non-root cases. And by manually specifying enough flags, we can ensure those defaults are overridden and Nix will indeed do the same thing (or fail trying). This is similar to the logic behind the supplementary group setting (NixOS#8342), which I also discuss in this new section of the contribution guide as a second example.
The motivation for this is basically explained in the contribution guide, as guidance on how to design features like this going forward. In short, I think it is confusing for operations acting on the default profile to *always* do something different based on whether the user is regular or root. Instead, this makes there be flags which are (from the vantage point of today) "do the root default" vs "do the regular user" default. This make the situation teachable: we can point to the flags, and the conditional default, as *exactly* what varies between the root and non-root cases. And by manually specifying enough flags, we can ensure those defaults are overridden and Nix will indeed do the same thing (or fail trying). This is similar to the logic behind the supplementary group setting (NixOS#8342), which I also discuss in this new section of the contribution guide as a second example. Instead of creating the default dirs in `getDefaultProfile` (which is a bit odd if the symlink points elsewhere), create the profile dir for the chosen profile in `createGeneration`. That seems more appropriate and keeps the test added in e997512 (where the profiles are deleted but the symlink isn't) working.
The motivation for this is basically explained in the contribution guide, as guidance on how to design features like this going forward. In short, I think it is confusing for operations acting on the default profile to *always* do something different based on whether the user is regular or root. Instead, this makes there be flags which are (from the vantage point of today) "do the root default" vs "do the regular user" default. This make the situation teachable: we can point to the flags, and the conditional default, as *exactly* what varies between the root and non-root cases. And by manually specifying enough flags, we can ensure those defaults are overridden and Nix will indeed do the same thing (or fail trying). This is similar to the logic behind the supplementary group setting (NixOS#8342), which I also discuss in this new section of the contribution guide as a second example. Instead of creating the default dirs in `getDefaultProfile` (which is a bit odd if the symlink points elsewhere), create the profile dir for the chosen profile in `createGeneration`. That seems more appropriate and keeps the test added in e997512 (where the profiles are deleted but the symlink isn't) working.
The motivation for this is basically explained in the contribution guide, as guidance on how to design features like this going forward. In short, I think it is confusing for operations acting on the default profile to *always* do something different based on whether the user is regular or root. Instead, this makes there be flags which are (from the vantage point of today) "do the root default" vs "do the regular user" default. This make the situation teachable: we can point to the flags, and the conditional default, as *exactly* what varies between the root and non-root cases. And by manually specifying enough flags, we can ensure those defaults are overridden and Nix will indeed do the same thing (or fail trying). This is similar to the logic behind the supplementary group setting (NixOS#8342), which I also discuss in this new section of the contribution guide as a second example. Instead of creating the default dirs in `getDefaultProfile` (which is a bit odd if the symlink points elsewhere), create the profile dir for the chosen profile in `createGeneration`. That seems more appropriate and keeps the test added in e997512 (where the profiles are deleted but the symlink isn't) working.
The motivation for this is basically explained in the contribution guide, as guidance on how to design features like this going forward. In short, I think it is confusing for operations acting on the default profile to *always* do something different based on whether the user is regular or root. Instead, this makes there be flags which are (from the vantage point of today) "do the root default" vs "do the regular user" default. This make the situation teachable: we can point to the flags, and the conditional default, as *exactly* what varies between the root and non-root cases. And by manually specifying enough flags, we can ensure those defaults are overridden and Nix will indeed do the same thing (or fail trying). This is similar to the logic behind the supplementary group setting (NixOS#8342), which I also discuss in this new section of the contribution guide as a second example. Instead of creating the default dirs in `getDefaultProfile` (which is a bit odd if the symlink points elsewhere), create the profile dir for the chosen profile in `createGeneration`. That seems more appropriate and keeps the test added in e997512 (where the profiles are deleted but the symlink isn't) working.
The motivation for this is basically explained in the contribution guide, as guidance on how to design features like this going forward. In short, I think it is confusing for operations acting on the default profile to *always* do something different based on whether the user is regular or root. Instead, this makes there be flags which are (from the vantage point of today) "do the root default" vs "do the regular user" default. This make the situation teachable: we can point to the flags, and the conditional default, as *exactly* what varies between the root and non-root cases. And by manually specifying enough flags, we can ensure those defaults are overridden and Nix will indeed do the same thing (or fail trying). This is similar to the logic behind the supplementary group setting (NixOS#8342), which I also discuss in this new section of the contribution guide as a second example. Instead of creating the default dirs in `getDefaultProfile` (which is a bit odd if the symlink points elsewhere), create the profile dir for the chosen profile in `createGeneration`. That seems more appropriate and keeps the test added in e997512 (where the profiles are deleted but the symlink isn't) working.
The motivation for this is basically explained in the contribution guide, as guidance on how to design features like this going forward. In short, I think it is confusing for operations acting on the default profile to *always* do something different based on whether the user is regular or root. Instead, this makes there be flags which are (from the vantage point of today) "do the root default" vs "do the regular user" default. This make the situation teachable: we can point to the flags, and the conditional default, as *exactly* what varies between the root and non-root cases. And by manually specifying enough flags, we can ensure those defaults are overridden and Nix will indeed do the same thing (or fail trying). This is similar to the logic behind the supplementary group setting (NixOS#8342), which I also discuss in this new section of the contribution guide as a second example. Instead of creating the default dirs in `getDefaultProfile` (which is a bit odd if the symlink points elsewhere), create the profile dir for the chosen profile in `createGeneration`. That seems more appropriate and keeps the test added in e997512 (where the profiles are deleted but the symlink isn't) working.
The motivation for this is basically explained in the contribution guide, as guidance on how to design features like this going forward. In short, I think it is confusing for operations acting on the default profile to *always* do something different based on whether the user is regular or root. Instead, this makes there be flags which are (from the vantage point of today) "do the root default" vs "do the regular user" default. This make the situation teachable: we can point to the flags, and the conditional default, as *exactly* what varies between the root and non-root cases. And by manually specifying enough flags, we can ensure those defaults are overridden and Nix will indeed do the same thing (or fail trying). This is similar to the logic behind the supplementary group setting (NixOS#8342), which I also discuss in this new section of the contribution guide as a second example. Instead of creating the default dirs in `getDefaultProfile` (which is a bit odd if the symlink points elsewhere), create the profile dir for the chosen profile in `createGeneration`. That seems more appropriate and keeps the test added in e997512 (where the profiles are deleted but the symlink isn't) working.
The motivation for this is basically explained in the contribution guide, as guidance on how to design features like this going forward. In short, I think it is confusing for operations acting on the default profile to *always* do something different based on whether the user is regular or root. Instead, this makes there be flags which are (from the vantage point of today) "do the root default" vs "do the regular user" default. This make the situation teachable: we can point to the flags, and the conditional default, as *exactly* what varies between the root and non-root cases. And by manually specifying enough flags, we can ensure those defaults are overridden and Nix will indeed do the same thing (or fail trying). This is similar to the logic behind the supplementary group setting (NixOS#8342), which I also discuss in this new section of the contribution guide as a second example. Instead of creating the default dirs in `getDefaultProfile` (which is a bit odd if the symlink points elsewhere), create the profile dir for the chosen profile in `createGeneration`. That seems more appropriate and keeps the test added in e997512 (where the profiles are deleted but the symlink isn't) working.
Motivation
There is no obvious good solution for this that has occurred to anyone.
Provide a way to hack around trying to drop supplementary groups when root.
Context
Currently,
will fail when the outside user is not root, because one doesn't actually have the permission to call
setgroups
. This provides a work-around to skip that step.Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*
Priorities
Add 👍 to pull requests you find important.