Tweaks to dovecot

This commit is contained in:
niten 2023-09-29 10:19:09 -07:00
parent 96aa481ad7
commit 2492a479db
3 changed files with 45 additions and 38 deletions

View File

@ -186,10 +186,16 @@ in {
tmpfiles.rules = [ tmpfiles.rules = [
"d ${cfg.state-directory} 0751 ${cfg.mail-user} ${cfg.mail-group} - -" "d ${cfg.state-directory} 0751 ${cfg.mail-user} ${cfg.mail-group} - -"
"d ${cfg.state-directory}/mail 0750 ${cfg.mail-user} ${cfg.mail-group} - -" "d ${cfg.state-directory}/mail 0750 ${cfg.mail-user} ${cfg.mail-group} - -"
"d ${cfg.state-directory}/sieves 0750 ${config.services.dovecot2.user} - - -" "d ${cfg.state-directory}/sieves 0750 ${config.services.dovecot2.user} ${config.services.dovecot2.group} - -"
]; ];
services.dovecot-sieve-generator = let services = {
prometheus-dovecot-exporter = {
requires = [ "dovecot2.service" ];
after = [ "dovecot2.service" ];
};
dovecot-sieve-generator = let
isRegularFile = _: type: type == "regular"; isRegularFile = _: type: type == "regular";
sieves = filterAttrs isRegularFile (builtins.readDir ./sieves); sieves = filterAttrs isRegularFile (builtins.readDir ./sieves);
headOrNull = lst: if lst == [ ] then null else head lst; headOrNull = lst: if lst == [ ] then null else head lst;
@ -205,11 +211,11 @@ in {
''; '';
in { in {
wantedBy = [ "dovecot2.service" ]; wantedBy = [ "dovecot2.service" ];
before = [ "dovecot2.service" ]; after = [ "dovecot2.service" ];
path = with pkgs; [ dovecot_pigeonhole ]; path = with pkgs; [ dovecot_pigeonhole ];
serviceConfig = { serviceConfig = {
User = config.services.dovecot2.user; User = config.services.dovecot2.user;
ReadWritePaths = [ sieveDirectory ]; ReadWritePaths = [ sieveDirectory "/run/dovecot2" ];
ExecStart = pkgs.writeShellScript "generate-sieves.sh" ExecStart = pkgs.writeShellScript "generate-sieves.sh"
(concatStringsSep "\n" (mapAttrsToList compileFile sieves)); (concatStringsSep "\n" (mapAttrsToList compileFile sieves));
PrivateDevices = true; PrivateDevices = true;
@ -226,6 +232,7 @@ in {
}; };
}; };
}; };
};
services = { services = {
prometheus.exporters.dovecot = { prometheus.exporters.dovecot = {

View File

@ -244,7 +244,7 @@ in {
relay-restrictions = [ relay-restrictions = [
"reject_unauth_destination" "reject_unauth_destination"
# "reject_unauth_pipelining" "reject_unauth_pipelining"
"reject_unknown_sender_domain" "reject_unknown_sender_domain"
"permit_mynetworks" "permit_mynetworks"
"permit_sasl_authenticated" "permit_sasl_authenticated"
@ -255,7 +255,7 @@ in {
"check_sender_access ${mappedFile "reject_recipients"}" "check_sender_access ${mappedFile "reject_recipients"}"
"reject_unknown_sender_domain" "reject_unknown_sender_domain"
"reject_unknown_recipient_domain" "reject_unknown_recipient_domain"
# "reject_unauth_pipelining" "reject_unauth_pipelining"
"reject_unauth_destination" "reject_unauth_destination"
"reject_invalid_hostname" "reject_invalid_hostname"
"reject_non_fqdn_hostname" "reject_non_fqdn_hostname"

View File

@ -9,7 +9,7 @@ if string "${mailbox}" "Trash" {
} }
if string "${mailbox}" "Junk" { if string "${mailbox}" "Junk" {
stop stop;
} }
if environment :matches "imap.user" "*" { if environment :matches "imap.user" "*" {