summary refs log tree commit diff
path: root/nixos/modules/services/mail/nullmailer.nix
diff options
context:
space:
mode:
authorMichal Sojka <michal.sojka@cvut.cz>2022-09-01 15:25:02 +0200
committerMichal Sojka <michal.sojka@cvut.cz>2022-09-01 15:40:27 +0200
commit7e626703b0b892181cc1bc700d9b1cc88550243c (patch)
treefbfacc3dcfdbb7c1ce78e8fef6f2edd66b7ac893 /nixos/modules/services/mail/nullmailer.nix
parenta63021a330d8d33d862a8e29924b42d73037dd37 (diff)
downloadnixpkgs-7e626703b0b892181cc1bc700d9b1cc88550243c.tar
nixpkgs-7e626703b0b892181cc1bc700d9b1cc88550243c.tar.gz
nixpkgs-7e626703b0b892181cc1bc700d9b1cc88550243c.tar.bz2
nixpkgs-7e626703b0b892181cc1bc700d9b1cc88550243c.tar.lz
nixpkgs-7e626703b0b892181cc1bc700d9b1cc88550243c.tar.xz
nixpkgs-7e626703b0b892181cc1bc700d9b1cc88550243c.tar.zst
nixpkgs-7e626703b0b892181cc1bc700d9b1cc88550243c.zip
nixos/nullmailer: Always adjust ownership of spool directories
When switching between different NixOS configurations (with and
without nullmailer and other services), it can happen that the UID of
the nullmailer user changes. When it happens, the nullmailer service
happily starts, but the user cannot send any email, because the
sendmail wrapper doesn't have permission to write them to the queue.

This commit prevents that. Instead of creating the directories by the
nullmailer user, which doesn't have permissions to change ownership,
we now create them by the systemd-tmpfiles, which has sufficient
permissions to adjust ownership.
Diffstat (limited to 'nixos/modules/services/mail/nullmailer.nix')
-rw-r--r--nixos/modules/services/mail/nullmailer.nix4
1 files changed, 3 insertions, 1 deletions
diff --git a/nixos/modules/services/mail/nullmailer.nix b/nixos/modules/services/mail/nullmailer.nix
index 336c76c9850..7c72229efb2 100644
--- a/nixos/modules/services/mail/nullmailer.nix
+++ b/nixos/modules/services/mail/nullmailer.nix
@@ -212,6 +212,9 @@ with lib;
 
     systemd.tmpfiles.rules = [
       "d /var/spool/nullmailer - ${cfg.user} - - -"
+      "d /var/spool/nullmailer/failed 750 ${cfg.user} - - -"
+      "d /var/spool/nullmailer/queue 750 ${cfg.user} - - -"
+      "d /var/spool/nullmailer/tmp 750 ${cfg.user} - - -"
     ];
 
     systemd.services.nullmailer = {
@@ -220,7 +223,6 @@ with lib;
       after = [ "network.target" ];
 
       preStart = ''
-        mkdir -p /var/spool/nullmailer/{queue,tmp,failed}
         rm -f /var/spool/nullmailer/trigger && mkfifo -m 660 /var/spool/nullmailer/trigger
       '';