Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/ntpd: fix permissions error when creating drift file #367064

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

SFrijters
Copy link
Member

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.

Fixes #366475 .

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

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.
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 21, 2024
@SFrijters
Copy link
Member Author

The error only occurs after a while, so keeping this as draft until I can confirm that the error is indeed fixed.

@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Dec 21, 2024
@SFrijters SFrijters marked this pull request as ready for review December 21, 2024 14:26
@nix-owners nix-owners bot requested a review from thoughtpolice December 21, 2024 14:28
Copy link
Contributor

@chewblacka chewblacka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me. Tested with nix-build nixos/tests/ntpd.nix and that produced a successful outcome:

(finished: must succeed: su -s /bin/sh -c "touch /var/lib/ntp/ntp.drift" ntp, in 0.19 seconds)
(finished: run the VM test script, in 26.40 seconds)
test script finished in 26.48s

@pyrox0
Copy link
Member

pyrox0 commented Dec 22, 2024

I had thought of a different way of solving this problem, but this works too!

@pyrox0 pyrox0 added 12.approvals: 1 This PR was reviewed and approved by one reputable person backport release-24.11 Backport PR automatically labels Dec 22, 2024
@chewblacka chewblacka added 12.approvals: 2 This PR was reviewed and approved by two reputable people and removed 12.approvals: 1 This PR was reviewed and approved by one reputable person labels Dec 22, 2024
@thoughtpolice thoughtpolice merged commit 31942f2 into NixOS:master Dec 22, 2024
44 checks passed
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Dec 22, 2024

Successfully created backport PR for release-24.11:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12.approvals: 2 This PR was reviewed and approved by two reputable people backport release-24.11 Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nixos/ntpd: permission denied error
4 participants