mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
nixos: Fix timesyncd test for systemd >= 257.1
Version 257.1 of systemd changed[1] the PrivateTmp setting for the systemd-timesyncd service from "yes" to "disconnected", which broke our systemd-timesyncd test. The reason for this is because the systemd-tmpfiles-setup.service is *only*[2] added as a dependency of systemd-timesyncd.service if PrivateTmp is set to "yes" but not when it is set to "disconnected" (which would make sense given that the tmpfiles.d mechanism was originally designed for temporary files). Commit339a866b7c
switched the activation script to using systemd-tmpfiles, but the commit in question doesn't provide an explanation why this was necessary in this particular case. However the pull request[3] lists an ongoing effort to get rid of Perl and in the future get also rid of BASH for activation. The reasons for doing this are outlined in the document[4]: > The simple presence of interpreters on a system pose a security risk. > An attacker that gains access to a system can abuse them to execute > arbitrary commands. Mitre lists this as technique T1059. The most > radical yet simple solution to mitigate this exploit is to remove all > interpreters from a system (Mitre M1042). This radical solution is > only really feasible and/or interesting for appliances (i.e. > non-interactive) systems. Especially for high-security solutions this > mitigtation is interesting. I personally don't think this is a very compelling reason, at least for our activation scripts, since an attacker could simply drop an executable binary. Nevertheless, getting rid of additional dependencies on eg. Perl or BASH is something worth pursuing to trim down moving parts. To address this, I decided to implement this as a normal systemd service unit, since we need to guarantee that it's started before systemd-timesyncd.service and with a dedicated unit we can ensure explicit ordering. This has the advantage that we don't interfere with the effort of getting rid of Perl/BASH for activation/boot and also don't risk running into race conditions (again) because it's very unlikely that systemd will change/deprecate explicit unit ordering in the near future. [1]:1f6e192848
[2]:30675a6ee9/src/core/unit.c (L1274)
[3]: https://github.com/NixOS/nixpkgs/pull/263203 [4]: https://pad.lassul.us/nixos-perlless-activation Signed-off-by: aszlig <aszlig@nix.build>
This commit is contained in:
parent
3bad4054ad
commit
e35a65a2f8
1 changed files with 12 additions and 7 deletions
|
@ -26,13 +26,18 @@ import ./make-test-python.nix (
|
|||
# create the path that should be migrated by our activation script when
|
||||
# upgrading to a newer nixos version
|
||||
system.stateVersion = "19.03";
|
||||
systemd.tmpfiles.settings.systemd-timesyncd-test = {
|
||||
"/var/lib/systemd/timesync".R = { };
|
||||
"/var/lib/systemd/timesync".L.argument = "/var/lib/private/systemd/timesync";
|
||||
"/var/lib/private/systemd/timesync".d = {
|
||||
user = "systemd-timesync";
|
||||
group = "systemd-timesync";
|
||||
};
|
||||
systemd.services.old-timesync-state-dir = {
|
||||
requiredBy = [ "sysinit.target" ];
|
||||
before = [ "systemd-timesyncd.service" ];
|
||||
after = [ "local-fs.target" ];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
rm -rf /var/lib/systemd/timesync
|
||||
mkdir -p /var/lib/systemd /var/lib/private/systemd/timesync
|
||||
ln -s /var/lib/private/systemd/timesync /var/lib/systemd/timesync
|
||||
chown systemd-timesync: /var/lib/private/systemd/timesync
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue