mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
Merge pull request #64268 from jameysharp/nscd-dynamicuser
nixos/nscd: DynamicUser and other cleanups
This commit is contained in:
commit
a0ba42e3f4
2 changed files with 9 additions and 40 deletions
|
@ -7,46 +7,28 @@
|
||||||
# is not aware of the path in which the nss modules live. As a workaround, we
|
# is not aware of the path in which the nss modules live. As a workaround, we
|
||||||
# have `enable-cache yes` with an explicit ttl of 0
|
# have `enable-cache yes` with an explicit ttl of 0
|
||||||
server-user nscd
|
server-user nscd
|
||||||
threads 1
|
|
||||||
paranoia no
|
|
||||||
debug-level 0
|
|
||||||
|
|
||||||
enable-cache passwd yes
|
enable-cache passwd yes
|
||||||
positive-time-to-live passwd 0
|
positive-time-to-live passwd 0
|
||||||
negative-time-to-live passwd 0
|
negative-time-to-live passwd 0
|
||||||
suggested-size passwd 211
|
|
||||||
check-files passwd yes
|
|
||||||
persistent passwd no
|
|
||||||
shared passwd yes
|
shared passwd yes
|
||||||
|
|
||||||
enable-cache group yes
|
enable-cache group yes
|
||||||
positive-time-to-live group 0
|
positive-time-to-live group 0
|
||||||
negative-time-to-live group 0
|
negative-time-to-live group 0
|
||||||
suggested-size group 211
|
|
||||||
check-files group yes
|
|
||||||
persistent group no
|
|
||||||
shared group yes
|
shared group yes
|
||||||
|
|
||||||
enable-cache netgroup yes
|
enable-cache netgroup yes
|
||||||
positive-time-to-live netgroup 0
|
positive-time-to-live netgroup 0
|
||||||
negative-time-to-live netgroup 0
|
negative-time-to-live netgroup 0
|
||||||
suggested-size netgroup 211
|
|
||||||
check-files netgroup yes
|
|
||||||
persistent netgroup no
|
|
||||||
shared netgroup yes
|
shared netgroup yes
|
||||||
|
|
||||||
enable-cache hosts yes
|
enable-cache hosts yes
|
||||||
positive-time-to-live hosts 600
|
positive-time-to-live hosts 600
|
||||||
negative-time-to-live hosts 0
|
negative-time-to-live hosts 0
|
||||||
suggested-size hosts 211
|
|
||||||
check-files hosts yes
|
|
||||||
persistent hosts no
|
|
||||||
shared hosts yes
|
shared hosts yes
|
||||||
|
|
||||||
enable-cache services yes
|
enable-cache services yes
|
||||||
positive-time-to-live services 0
|
positive-time-to-live services 0
|
||||||
negative-time-to-live services 0
|
negative-time-to-live services 0
|
||||||
suggested-size services 211
|
|
||||||
check-files services yes
|
|
||||||
persistent services no
|
|
||||||
shared services yes
|
shared services yes
|
||||||
|
|
|
@ -39,11 +39,6 @@ in
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
environment.etc."nscd.conf".text = cfg.config;
|
environment.etc."nscd.conf".text = cfg.config;
|
||||||
|
|
||||||
users.users.nscd =
|
|
||||||
{ isSystemUser = true;
|
|
||||||
description = "Name service cache daemon user";
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.nscd =
|
systemd.services.nscd =
|
||||||
{ description = "Name Service Cache Daemon";
|
{ description = "Name Service Cache Daemon";
|
||||||
|
|
||||||
|
@ -51,22 +46,23 @@ in
|
||||||
|
|
||||||
environment = { LD_LIBRARY_PATH = nssModulesPath; };
|
environment = { LD_LIBRARY_PATH = nssModulesPath; };
|
||||||
|
|
||||||
preStart =
|
|
||||||
''
|
|
||||||
mkdir -m 0755 -p /run/nscd
|
|
||||||
rm -f /run/nscd/nscd.pid
|
|
||||||
mkdir -m 0755 -p /var/db/nscd
|
|
||||||
'';
|
|
||||||
|
|
||||||
restartTriggers = [
|
restartTriggers = [
|
||||||
config.environment.etc.hosts.source
|
config.environment.etc.hosts.source
|
||||||
config.environment.etc."nsswitch.conf".source
|
config.environment.etc."nsswitch.conf".source
|
||||||
config.environment.etc."nscd.conf".source
|
config.environment.etc."nscd.conf".source
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# We use DynamicUser because in default configurations nscd doesn't
|
||||||
|
# create any files that need to survive restarts. However, in some
|
||||||
|
# configurations, nscd needs to be started as root; it will drop
|
||||||
|
# privileges after all the NSS modules have read their configuration
|
||||||
|
# files. So prefix the ExecStart command with "!" to prevent systemd
|
||||||
|
# from dropping privileges early. See ExecStart in systemd.service(5).
|
||||||
serviceConfig =
|
serviceConfig =
|
||||||
{ ExecStart = "@${pkgs.glibc.bin}/sbin/nscd nscd";
|
{ ExecStart = "!@${pkgs.glibc.bin}/sbin/nscd nscd";
|
||||||
Type = "forking";
|
Type = "forking";
|
||||||
|
DynamicUser = true;
|
||||||
|
RuntimeDirectory = "nscd";
|
||||||
PIDFile = "/run/nscd/nscd.pid";
|
PIDFile = "/run/nscd/nscd.pid";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
ExecReload =
|
ExecReload =
|
||||||
|
@ -75,15 +71,6 @@ in
|
||||||
"${pkgs.glibc.bin}/sbin/nscd --invalidate hosts"
|
"${pkgs.glibc.bin}/sbin/nscd --invalidate hosts"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Urgggggh... Nscd forks before opening its socket and writing
|
|
||||||
# its pid. So wait until it's ready.
|
|
||||||
postStart =
|
|
||||||
''
|
|
||||||
while ! ${pkgs.glibc.bin}/sbin/nscd -g > /dev/null; do
|
|
||||||
sleep 0.2
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue