3
0
Fork 0
forked from mirrors/nixpkgs

nixos/users-groups: Fix eval on missing uid/gid.

This hopefully fixes a regression introduced by 08b214a.

In bf129a2, it was already fixed for normal uid/gid values and it got
reintroduced by sub-uid/gid-handling again, so I've refactored it a bit
into a filterNull function which takes care of also the filtering
introduced by bf129a2.

I have not tested this extensively, but master is already broken for
systems with `mutableUsers = true` and no uid values set.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-08-29 07:17:19 +02:00
parent fe287a2601
commit e0e65cbf8e
No known key found for this signature in database
GPG key ID: D0EBD0EC8C2DC961

View file

@ -309,19 +309,19 @@ let
u.description u.home u.shell
];
filterNull = a: filter (x: hasAttr a x && getAttr a x != null);
sortOn = a: sort (as1: as2: lessThan (getAttr a as1) (getAttr a as2));
groupFile = pkgs.writeText "group" (
concatStringsSep "\n" (map (g: mkGroupEntry g.name) (
let f = g: g.gid != null; in
sortOn "gid" (filter f (attrValues cfg.extraGroups))
sortOn "gid" (filterNull "gid" (attrValues cfg.extraGroups))
))
);
passwdFile = pkgs.writeText "passwd" (
concatStringsSep "\n" (map (u: mkPasswdEntry u.name) (
let f = u: u.createUser && (u.uid != null); in
sortOn "uid" (filter f (attrValues cfg.extraUsers))
sortOn "uid" (filterNull "uid" (attrValues cfg.extraUsers))
))
);
@ -330,14 +330,14 @@ let
user.subUidRanges);
subuidFile = concatStrings (map mkSubuidEntry (
sortOn "uid" (attrValues cfg.extraUsers)));
sortOn "uid" (filterNull "uid" (attrValues cfg.extraUsers))));
mkSubgidEntry = user: concatStrings (
map (range: "${user.name}:${toString range.startGid}:${toString range.count}\n")
user.subGidRanges);
subgidFile = concatStrings (map mkSubgidEntry (
sortOn "uid" (attrValues cfg.extraUsers)));
sortOn "uid" (filterNull "uid" (attrValues cfg.extraUsers))));
# If mutableUsers is true, this script adds all users/groups defined in
# users.extra{Users,Groups} to /etc/{passwd,group} iff there isn't any