-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feature request: subuid and subgid #7
Comments
I think this is best solved by statically generating these files e.g. via systemd-tmpfiles. I don't want to touch the rust binary for this. |
This snippet works for me: environment.etc = let
mkSubUid = user: ''
${user.name}:100000:65536
'';
mkSubGid = user: ''
${user.group}:100000:65536
'';
users = lib.filter (u: u.isNormalUser) (lib.attrValues config.users.users);
in lib.mkIf config.services.userborn.enable {
"subuid".text = lib.concatMapStrings mkSubUid users;
"subgid".text = lib.concatMapStrings mkSubGid users;
}; |
@nikstur Actually, these IDs are stored in different places, including container configurations. It means that they have the same properties as proper UIDs and GIDs: they should be permanent and should not be reused. They also must not overlap1, so solution from @Sporif is not correct. Generating them in Nix is quite tricky and can only be correct with a bunch of assumptions. I got away with it on the infrastructure I manage like this: environment.etc = let
autosubs = lib.pipe config.users.users [
lib.attrValues
(lib.filter (u: u.uid != null && u.isNormalUser))
(lib.concatMapStrings (u: "${toString u.uid}:${toString (100000 + u.uid * 65536)}:65536\n"))
];
in {
"subuid".text = autosubs;
"subuid".mode = "0444";
"subgid".text = autosubs;
"subgid".mode = "0444";
}; But this has many assumptions that don't generally apply:
I feel like just like with UIDs and GIDs, Footnotes
|
This won't work for
|
From reading the rootless containers docs, the easiest way (and the one they seem to recommend) is to just pre-generate these maps for all possible UIDs & GIDs: https://rootlesscontaine.rs/getting-started/common/subuid/ They provide a python snippet for this pre-calculation.
Afaik this would solve all problems elegantly. If system users also need subuids, we can just start form uid 1. I don't see how another way of doing it would be more correct or secure. I don't see a reason why you wouldn't want to give a subuid range to a certain UID. It feels like this was placed in the Perl script simply because there already was a script and it was easiest to do it there. |
It would be great if userborn supports generating
/etc/subuid
and/etc/subgid
.Rootless podman requires these files to work properly:
Nixpkgs module provides the following options for subuid and subgid. These options will be processed by
update-users-groups.pl
by default.users.users.<name>.autoSubUidGidRange
users.users.<name>.subUidRanges
users.users.<name>.subGidRanges
The text was updated successfully, but these errors were encountered: