From 4942e7c359dc504c0cbbe8fb223f2cad7b7cefc0 Mon Sep 17 00:00:00 2001 From: Thary Date: Thu, 18 Sep 2025 18:46:34 +0300 Subject: [PATCH] fix(email-options): --- module.nix | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/module.nix b/module.nix index 46fd1a4..5dfe521 100644 --- a/module.nix +++ b/module.nix @@ -98,13 +98,13 @@ in # services.postfix.config = { # smtp_sasl_auth_enable = "yes"; # smtp_sasl_security_options = ""; - # smtp_sasl_password_maps = "texthash:/run/postfix/mastodon.cf"; - # virtual_mailbox_maps = [ "hash:/run/postfix/mastodon.cf" ]; + # smtp_sasl_password_maps = "texthash:/run/keys/mastodon/hashed_email_password"; + # virtual_mailbox_maps = [ "hash:/run/keys/mastodon/hashed_email_password" ]; # }; # mailserver.loginAccounts."noreply.mastodon@${sp.domain}" = { # mailserver.loginAccounts."mastodon@${sp.domain}" = { selfprivacy.emails."noreply.mastodon" = { - hashedPasswordFile = "/run/postfix/mastodon.cf"; + hashedPasswordFile = "/run/keys/mastodon/hashed_email_password"; systemdTargets = [ "mastodon-email-password-setup.service" ]; sendOnly = false; # TODO }; @@ -117,19 +117,18 @@ in Type = "oneshot"; ExecStart = pkgs.writeShellScript "gen-mastodon-email-password" '' export password=$(head -c 32 /dev/urandom | base64 | sed 's/[+=\\/A-Z]//g') + mkdir /run/keys/mastodon/ || true # Create /run/keys/mastodon if it doesn't exist rm -f /run/keys/mastodon/email_password || true - mkdir /run/keys/mastodon/ || true # Create /run/keys/mastodon if it doesn't exist echo $password > /run/keys/mastodon/email_password chmod 400 /run/keys/mastodon/email_password chown ${config.services.mastodon.user}:${config.services.mastodon.group} /run/keys/mastodon/email_password - rm -f /run/postfix/mastodon.cf || true - mkdir /run/postfix/ || true # Create /run/postfix if it doesn't exist + rm -f /run/keys/mastodon/hashed_email_password || true export hashedPassword=$(${lib.getExe pkgs.mkpasswd} -sm bcrypt "$password") - echo "$hashedPassword" > /run/postfix/mastodon.cf - chmod 440 /run/postfix/mastodon.cf - chown ${config.services.postfix.user}:${config.services.postfix.group} /run/postfix/mastodon.cf + echo "$hashedPassword" > /run/keys/mastodon/hashed_email_password + chmod 440 /run/keys/mastodon/hashed_email_password + chown ${config.services.postfix.user}:${config.services.postfix.group} /run/keys/mastodon/hashed_email_password ''; }; };