nixos/nscd: run with a dynamic user
nscd doesn't create any files outside of /run/nscd unless the nscd.conf
"persistent" option is used, which we don't do by default. Therefore it
doesn't matter what UID/GID we run this service as, so long as it isn't
shared with any other running processes.
/run/nscd does need to be owned by the same UID that the service is
running as, but systemd takes care of that for us thanks to the
RuntimeDirectory directive.
If someone wants to turn on the "persistent" option, they need to
manually configure users.users.nscd and systemd.tmpfiles.rules so that
/var/db/nscd is owned by the same user that nscd runs as.
In an all-defaults boot.isContainer configuration of NixOS, this removes
the only user which did not have a pre-assigned UID.
commitde251704d66331f61417b9eaa42c58270ea6c766
authorJamey Sharp <jamey@minilop.net>
dateWed 3 Jul 2019, 13:11 (7 years ago)
parent597563d
nixos/modules/services/system/nscd.conf−1
@@ -6,7 +6,6 @@
66# fallback to trying to handle the request by itself. Which won't work as glibc
77# is not aware of the path in which the nss modules live. As a workaround, we
88# have `enable-cache yes` with an explicit ttl of 0
9−server-user nscd
109threads 1
1110paranoia no
1211debug-level 0
nixos/modules/services/system/nscd.nix+2−5
@@ -39,11 +39,6 @@ in
3939 config = mkIf cfg.enable {
4040 environment.etc."nscd.conf".text = cfg.config;
4141
42− users.users.nscd =
43− { isSystemUser = true;
44− description = "Name service cache daemon user";
45− };
46−
4742 systemd.services.nscd =
4843 { description = "Name Service Cache Daemon";
4944
@@ -60,6 +55,8 @@ in
6055 serviceConfig =
6156 { ExecStart = "@${pkgs.glibc.bin}/sbin/nscd nscd";
6257 Type = "forking";
58+ User = "nscd";
59+ DynamicUser = true;
6360 RuntimeDirectory = "nscd";
6461 PIDFile = "/run/nscd/nscd.pid";
6562 Restart = "always";