summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2016-02-09 12:57:42 +0300
committerNikolay Amiantov <ab@fmap.me>2016-02-10 02:05:53 +0300
commit2202bb9cf541543917e6fa6201994fc6d3aee413 (patch)
treee2cd847929d7e45aef9770c5c7678f6ef0dd829e /nixos
parent5396a01b6c638cada3d5c81e03e14ffcbf982a1f (diff)
downloadnixpkgs-2202bb9cf541543917e6fa6201994fc6d3aee413.tar
nixpkgs-2202bb9cf541543917e6fa6201994fc6d3aee413.tar.gz
nixpkgs-2202bb9cf541543917e6fa6201994fc6d3aee413.tar.bz2
nixpkgs-2202bb9cf541543917e6fa6201994fc6d3aee413.tar.lz
nixpkgs-2202bb9cf541543917e6fa6201994fc6d3aee413.tar.xz
nixpkgs-2202bb9cf541543917e6fa6201994fc6d3aee413.tar.zst
nixpkgs-2202bb9cf541543917e6fa6201994fc6d3aee413.zip
postsrsd: fix secret generation
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/mail/postsrsd.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/nixos/modules/services/mail/postsrsd.nix b/nixos/modules/services/mail/postsrsd.nix
index 36a0f8218d8..68a4c101206 100644
--- a/nixos/modules/services/mail/postsrsd.nix
+++ b/nixos/modules/services/mail/postsrsd.nix
@@ -95,7 +95,11 @@ in {
       preStart = ''
         if [ ! -e "${cfg.secretsFile}" ]; then
           echo "WARNING: secrets file not found, autogenerating!"
-          mkdir -p -m750 "$(dirname "${cfg.secretsFile}")"
+          DIR="$(dirname "${cfg.secretsFile}")"
+          if [ ! -d "$DIR" ]; then
+            mkdir -p -m750 "$DIR"
+            chown "${cfg.user}:${cfg.group}" "$DIR"
+          fi
           dd if=/dev/random bs=18 count=1 | base64 > "${cfg.secretsFile}"
           chmod 600 "${cfg.secretsFile}"
         fi