nixos/users-groups: add warning when changing subuid ranges

This commit is contained in:
mikitsu 2025-04-13 20:12:36 +02:00 committed by Leona Maroni
parent 46600598f1
commit 374b2ed9f9
No known key found for this signature in database
GPG key ID: D5B08ADFC75E3605

View file

@ -362,6 +362,14 @@ foreach my $u (values %usersOut) {
if($u->{autoSubUidGidRange}) {
my $subordinate = allocSubUid($name);
if (defined $subUidMap->{$name} && $subUidMap->{$name} != $subordinate) {
print STDERR "warning: The subuids for '$name' changed, as they coincided with the subuids of a different user (see /etc/subuid). "
. "The range now starts with $subordinate instead of $subUidMap->{$name}. "
. "If the subuids were used (e.g. with rootless container managers like podman), please change the ownership of affected files accordingly. "
. "Alternatively, to keep the old overlapping ranges, add this to the system configuration: "
. "users.users.$name.subUidRanges = [{startUid = $subUidMap->{$name}; count = 65536;}]; "
. "users.users.$name.subGidRanges = [{startGid = $subUidMap->{$name}; count = 65536;}];\n";
}
$subUidMap->{$name} = $subordinate;
my $value = join(":", ($name, $subordinate, 65536));
push @subUids, $value;