diff options
author | Lafiel <lafiel@elven.pw> | 2023-03-16 16:59:05 +0300 |
---|---|---|
committer | lewo <lewo@abesis.fr> | 2023-05-23 20:41:36 +0000 |
commit | d8131ffc61553df6137b382eec380689596cae3d (patch) | |
tree | 516162e13d0aa4d506075104b4f9bc61a4f58e14 | |
parent | bd99079363d36d762d3862a4df6f026692560cba (diff) |
dovecot: split passdb and userdb
-rw-r--r-- | mail-server/dovecot.nix | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/mail-server/dovecot.nix b/mail-server/dovecot.nix index b1c4e59..01563e0 100644 --- a/mail-server/dovecot.nix +++ b/mail-server/dovecot.nix @@ -22,7 +22,8 @@ let cfg = config.mailserver; passwdDir = "/run/dovecot2"; - passwdFile = "${passwdDir}/passwd"; + passdbFile = "${passwdDir}/passdb"; + userdbFile = "${passwdDir}/userdb"; bool2int = x: if x then "1" else "0"; @@ -74,16 +75,23 @@ let fi done - cat <<EOF > ${passwdFile} + cat <<EOF > ${passdbFile} ${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: - "${name}:${"$(head -n 1 ${passwordFiles."${name}"})"}:${builtins.toString cfg.vmailUID}:${builtins.toString cfg.vmailUID}::${cfg.mailDirectory}:/run/current-system/sw/bin/nologin:" + "${name}:${"$(head -n 1 ${passwordFiles."${name}"})"}::::::" + ) cfg.loginAccounts)} + EOF + + cat <<EOF > ${userdbFile} + ${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: + "${name}:::::::" + (if lib.isString value.quota then "userdb_quota_rule=*:storage=${value.quota}" else "") ) cfg.loginAccounts)} EOF - chmod 600 ${passwdFile} + chmod 600 ${passdbFile} + chmod 600 ${userdbFile} ''; junkMailboxes = builtins.attrNames (lib.filterAttrs (n: v: v ? "specialUse" && v.specialUse == "Junk") cfg.mailboxes); @@ -212,12 +220,13 @@ in passdb { driver = passwd-file - args = ${passwdFile} + args = ${passdbFile} } userdb { driver = passwd-file - args = ${passwdFile} + args = ${userdbFile} + default_fields = uid=${builtins.toString cfg.vmailUID} gid=${builtins.toString cfg.vmailUID} home=${cfg.mailDirectory} } service auth { |