about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorh7x4 <h7x4@nani.wtf>2024-06-18 10:32:49 +0200
committerGitHub <noreply@github.com>2024-06-18 10:32:49 +0200
commitf5263306d85dbbfbb3d45dd4e6b3ee9067ded881 (patch)
treed20288dee42256b8aca24804c4afa0c8eae992a9 /nixos/modules
parentdbc9841e4563d0dfb8085b2045929129a2a5b49a (diff)
parente9570410a1a9d0f5fea3fe06486d65acfb0f0866 (diff)
Merge pull request #304340 from Stunkymonkey/postsrsd-chmod-install
nixos/postsrsd: prefer 'install' over 'chmod/chown'
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/mail/postsrsd.nix9
1 files changed, 2 insertions, 7 deletions
diff --git a/nixos/modules/services/mail/postsrsd.nix b/nixos/modules/services/mail/postsrsd.nix
index 2ebc675ab10af..92f01dd4101e8 100644
--- a/nixos/modules/services/mail/postsrsd.nix
+++ b/nixos/modules/services/mail/postsrsd.nix
@@ -120,14 +120,9 @@ in {
         if [ ! -e "${cfg.secretsFile}" ]; then
           echo "WARNING: secrets file not found, autogenerating!"
           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}"
+          install -m 750 -o ${cfg.user} -g ${cfg.group} -d "$DIR"
+          install -m 600 -o ${cfg.user} -g ${cfg.group} <(dd if=/dev/random bs=18 count=1 | base64) "${cfg.secretsFile}"
         fi
-        chown "${cfg.user}:${cfg.group}" "${cfg.secretsFile}"
       '';
     };