about summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authorGeorge Shammas <george@shamm.as>2023-09-16 07:47:52 -0400
committerGeorge Shammas <george@shamm.as>2023-09-16 08:22:45 -0400
commit142d83f90e2903c92a78c8f4fa84a87fe37a0409 (patch)
treeb99f79e21405bccc374cdb86bc59655a057492a1 /nixos/modules/services
parent47fc70dde97b3c378b47c5419cb6bb6cae252367 (diff)
downloadnixlib-142d83f90e2903c92a78c8f4fa84a87fe37a0409.tar
nixlib-142d83f90e2903c92a78c8f4fa84a87fe37a0409.tar.gz
nixlib-142d83f90e2903c92a78c8f4fa84a87fe37a0409.tar.bz2
nixlib-142d83f90e2903c92a78c8f4fa84a87fe37a0409.tar.lz
nixlib-142d83f90e2903c92a78c8f4fa84a87fe37a0409.tar.xz
nixlib-142d83f90e2903c92a78c8f4fa84a87fe37a0409.tar.zst
nixlib-142d83f90e2903c92a78c8f4fa84a87fe37a0409.zip
nixos/postfix: postalias should not use source file permissions
Our postfix-setup service ensures that the directory is only writable by root.

postalias by default drops permissions to the user of the source file. In the
case of NixOS that file is in the nix store and thus always owned by root and
everything works.

The problem is that when using a nixos-container with user namespaces (`-U`)
then the nix store is owned by nobody/nogroup, and postfix-setup.service will be
unable to create or modify `aliases.db`.

Since the file would otherwise be owned by root, we should tell postfix to not
assume the user and permissions of the `aliases` file by setting -o and -p

From postalias(1)

> -o Do not release root privileges when processing a non-root input file. By
> default, postalias(1) drops root privileges and runs as the source file owner
> instead.

> -p Do not inherit the file access permissions from the input file when
> creating a new file. Instead, create a new file with default access
> permissions (mode 0644).
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/mail/postfix.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/modules/services/mail/postfix.nix b/nixos/modules/services/mail/postfix.nix
index 23c47aaca7e2..bfc4b6ccbfee 100644
--- a/nixos/modules/services/mail/postfix.nix
+++ b/nixos/modules/services/mail/postfix.nix
@@ -747,7 +747,7 @@ in
 
             ${concatStringsSep "\n" (mapAttrsToList (to: from: ''
               ln -sf ${from} /var/lib/postfix/conf/${to}
-              ${pkgs.postfix}/bin/postalias /var/lib/postfix/conf/${to}
+              ${pkgs.postfix}/bin/postalias -o -p /var/lib/postfix/conf/${to}
             '') cfg.aliasFiles)}
             ${concatStringsSep "\n" (mapAttrsToList (to: from: ''
               ln -sf ${from} /var/lib/postfix/conf/${to}