3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/modules/security
aszlig 7286be7e81 nixos/systemd-confinement: Allow shipped unit file
In issue #157787 @martined wrote:

  Trying to use confinement on packages providing their systemd units
  with systemd.packages, for example mpd, fails with the following
  error:

  system-units> ln: failed to create symbolic link
  '/nix/store/...-system-units/mpd.service': File exists

  This is because systemd-confinement and mpd both provide a mpd.service
  file through systemd.packages. (mpd got updated that way recently to
  use upstream's service file)

To address this, we now place the unit file containing the bind-mounted
paths of the Nix closure into a drop-in directory instead of using the
name of a unit file directly.

This does come with the implication that the options set in the drop-in
directory won't apply if the main unit file is missing. In practice
however this should not happen for two reasons:

  * The systemd-confinement module already sets additional options via
    systemd.services and thus we should get a main unit file
  * In the unlikely event that we don't get a main unit file regardless
    of the previous point, the unit would be a no-op even if the options
    of the drop-in directory would apply

Another thing to consider is the order in which those options are
merged, since systemd loads the files from the drop-in directory in
alphabetical order. So given that we have confinement.conf and
overrides.conf, the confinement options are loaded before the NixOS
overrides.

Since we're only setting the BindReadOnlyPaths option, the order isn't
that important since all those paths are merged anyway and we still
don't lose the ability to reset the option since overrides.conf comes
afterwards.

Fixes: https://github.com/NixOS/nixpkgs/issues/157787
Signed-off-by: aszlig <aszlig@nix.build>
2022-03-02 11:42:44 -08:00
..
acme nixos/acme: ensure web servers using certs can access them 2022-01-08 15:05:34 -05:00
apparmor
wrappers treewide: remove obsolete kernel version checks 2022-02-19 21:09:19 +00:00
apparmor.nix
audit.nix
auditd.nix
ca.nix
chromium-suid-sandbox.nix
dhparams.nix treewide: set defaultText for options using simple path defaults 2021-12-09 01:12:13 +01:00
doas.nix
duosec.nix
google_oslogin.nix google-compute-config: update config 2022-02-05 23:33:10 +03:00
lock-kernel-modules.nix
misc.nix nixos/nix-daemon: use structural settings 2022-01-26 21:04:50 -05:00
oath.nix
pam.nix google-compute-config: update config 2022-02-05 23:33:10 +03:00
pam_mount.nix
pam_usb.nix
polkit.nix
rngd.nix
rtkit.nix
sudo.nix
systemd-confinement.nix nixos/systemd-confinement: Allow shipped unit file 2022-03-02 11:42:44 -08:00
tpm2.nix