1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/nixos/tests/ntpd.nix
Stefan Frijters 31942f20f4 nixos/ntpd: fix permissions error when creating drift file
This fixes "frequency file /var/lib/ntp/ntp.drift.TEMP: Permission denied".

Creating a directory via StateDirectory makes that directory /var/lib/ntp owned by root:root.
However, when running ntpd we change to user ntp (see ntpFlags), so the process cannot
actually use that directory.

Actually creating a home directory for the user at that location solves that problem.
2024-12-22 16:20:31 -06:00

28 lines
615 B
Nix

import ./make-test-python.nix (
{ lib, ... }:
{
name = "ntpd";
meta = {
maintainers = with lib.maintainers; [ pyrox0 ];
};
nodes.machine = {
services.ntp = {
enable = true;
};
};
testScript = ''
start_all()
machine.wait_for_unit('ntpd.service')
machine.wait_for_console_text('Listen normally on 10 eth*')
machine.succeed('systemctl is-active ntpd.service')
machine.succeed('ntpq -p')
# ntp user must be able to create drift files
machine.succeed('su -s /bin/sh -c "touch /var/lib/ntp/ntp.drift" ntp')
'';
}
)