dovecot: fix julm's sieve by setting home through mailHomeDirectory
authorJulien Moutinho <julm@sourcephile.fr>
Sat, 4 Apr 2020 00:42:39 +0000 (02:42 +0200)
committerJulien Moutinho <julm@sourcephile.fr>
Sat, 4 Apr 2020 00:42:39 +0000 (02:42 +0200)
servers/mermet/dovecot.nix
servers/mermet/dovecot/ldap.conf
servers/mermet/dovecot/sieve/global/list.sieve
servers/mermet/openldap/autogeree.net.nix
servers/mermet/openldap/posixAccount.nix
servers/mermet/openldap/sourcephile.fr.nix

index 54c9488246d460ec386574780e28c110a3adacff..2488e3cb65842ee44c50e925f222484d917d5cf9 100644 (file)
@@ -121,7 +121,6 @@ services.dovecot2 = {
     #ssl_verify_client_cert = yes
 
     listen = *
-    # If needed, may be overrided by userdb_mail
     mail_home = ${stateDir}/home/%d/%n
     # Read multiple mails in parallel, improves performance
     mail_prefetch_count = 20
index fd954948ba5cd8d556b855517bf63e415b908f80..82a58a6052fa0fea1bfba51f08e4fdb3337316f1 100644 (file)
@@ -23,19 +23,19 @@ auth_bind_userdn = uid=%n,ou=accounts,ou=posix,dc=%Dd
 #pass_filter = (&(objectClass=posixAccount)(uid=%n)(mailEnabled=TRUE))
 #pass_attrs = uidNumber=userdb_uid,\
 #             gidNumber=userdb_gid,\
+#             mailHomeDirectory=userdb_home,\
 #             mailStorageDirectory=userdb_mail,\
-#             =userdb_mail_access_groups=sourcephile,\
+#             mailGroupMember=userdb_mail_access_groups,\
 #             quotaBytes=userdb_quota_rule=*:bytes=%{ldap:quotaBytes},\
 #             =user=%n@%d
-#             #homeDirectory=userdb_home
 #default_pass_scheme = SSHA
 
 # dovecot userdb query
 # For dovecot-lda
 user_filter = (&(objectClass=posixAccount)(uid=%n)(mailEnabled=TRUE))
-user_attrs = mailStorageDirectory=mail,\
-             uidNumber=uid,\
+user_attrs = uidNumber=uid,\
              gidNumber=gid,\
+             mailHomeDirectory=home,\
              mailStorageDirectory=mail,\
              mailGroupMember=mail_access_groups,\
              quotaBytes=quota_rule=*:bytes=%{ldap:quotaBytes}
index 3cc7a51b7486c8a79c859f212be2babab3822a07..dc888aed1304f59933179332243ffc95c0addfc6 100644 (file)
@@ -1,17 +1,25 @@
 require [ "date", "fileinto", "mailbox", "variables" ];
 
-if currentdate :matches "year"  "*" { set "year"  "${1}"; }
+#if currentdate :matches "year"  "*" { set "year"  "${1}"; }
 #if currentdate :matches "month" "*" { set "month" "${1}"; }
 
-if exists "List-ID" {
-  if header :matches "List-ID" "*<*.*.*.*>*" {
+if exists "X-MC-User" {
+  if header :matches "From" "*<*@*.*>*" {
+    set "list"   "${2}";
+    set "domain" "${3}";
+  }
+  fileinto :create "Listes+${domain}+${list}";
+  stop;
+}
+elsif exists "List-Id" {
+  if header :matches "List-Id" "*<*.*.*.*>*" {
     set "list"   "${2}";
     set "domain" "${4}";
   }
-  elsif header :matches "List-ID" "*<*.*.*>*" {
+  elsif header :matches "List-Id" "*<*.*.*>*" {
     set "list"   "${2}";
     set "domain" "${3}";
   }
-  fileinto :create "Listes+${domain}+${list}+${year}";
+  fileinto :create "Listes+${domain}+${list}";
   stop;
 }
index f9fc94a7474883c73daa2cdf35a148f090e8bb87..07eec8aa36b4e3fef6f77a4dfc197d26549233c0 100644 (file)
@@ -96,10 +96,9 @@ services.openldap.databases."${domainSuffix}" = {
       gidNumber = groups.julm.gid;
       mailAlias = [ "julien.moutinho" ];
       userPassword = pass-chomp "members/julm/mail/hashedPassword";
+      mailHomeDirectory = "/home/${uid}/mail/${domain}";
       mailStorageDirectory =
-        let stateDir = "/var/lib/dovecot";
-            d=domain;
-        in
+        let stateDir = "/var/lib/dovecot"; in
         # I'm personnaly using "maildir:" instead of "sdbox:" to be able to use a local (neo)mutt on it,
         # bypassing IMAP because (neo)mutt support of IMAP is very bad
         # (can't even have a decent $folder_format (with %n or %m) working,
@@ -107,7 +106,7 @@ services.openldap.databases."${domainSuffix}" = {
         # WARNING: regarding the atomicity of backuping,
         # it's not a good idea to put the mails
         # and the index/control on different ZFS datasets like here.
-        "maildir:/home/${uid}/mail/${d}/mail:LAYOUT=maildir++:UTF-8:CONTROL=${stateDir}/control/${d}/${uid}:INDEX=${stateDir}/index/${d}/${uid}";
+        "maildir:/home/${uid}/mail/${domain}/mail:LAYOUT=maildir++:UTF-8:CONTROL=${stateDir}/control/${domain}/${uid}:INDEX=${stateDir}/index/${domain}/${uid}";
     }
   ];
 };
index 13d138f378775b57a3781bf5d6392d5770bbd64d..da16cdc932e9abdbf26ba24e417fc5fb72517f9a 100644 (file)
@@ -10,6 +10,7 @@ in
 , userPassword ? null # Use slappasswd -o module-load=pw-pbkdf2 -h "{PBKDF2-SHA256}"
 , mailAlias ? []
 , homeDirectory ? ""
+, mailHomeDirectory ? null
 , mailStorageDirectory ? null
 , loginShell ? "/run/current-system/sw/bin/bash"
 , mailEnabled ? true
@@ -35,6 +36,7 @@ in
   ++ [ "homeDirectory: ${homeDirectory}" ]
   ++ lib.optional (loginShell != null)  "loginShell: ${loginShell}"
   ++ lib.optional (userPassword != null) "userPassword: ${userPassword}"
+  ++ lib.optional (mailHomeDirectory != null) "mailHomeDirectory: ${mailHomeDirectory}"
   ++ lib.optional (mailStorageDirectory != null) "mailStorageDirectory: ${mailStorageDirectory}"
   ++ map (forward: "mailForwardingAddress: ${forward}") mailForwardingAddress
   ++ map (alias: "mailAlias: ${alias}@${domain}") mailAlias
index 686147493e7f0ef9f4a5a90fedfbd08b505e847d..ca943fef5b123f2d4538c45b9e9ed1090e0ac558 100644 (file)
@@ -111,10 +111,9 @@ services.openldap.databases."${domainSuffix}" = {
       gidNumber = groups.julm.gid;
       mailAlias = [ "julien.moutinho" ];
       userPassword = pass-chomp "members/julm/mail/hashedPassword";
+      mailHomeDirectory = "/home/${uid}/mail/${domain}";
       mailStorageDirectory =
-        let stateDir = "/var/lib/dovecot";
-            d=domain;
-        in
+        let stateDir = "/var/lib/dovecot"; in
         # I'm personnaly using "maildir:" instead of "sdbox:" to be able to use a local (neo)mutt on it,
         # bypassing IMAP because (neo)mutt support of IMAP is very bad
         # (can't even have a decent $folder_format (with %n or %m) working,
@@ -122,7 +121,7 @@ services.openldap.databases."${domainSuffix}" = {
         # WARNING: regarding the atomicity of backuping,
         # it's not a good idea to put the mails
         # and the index/control on different ZFS datasets like here.
-        "maildir:/home/${uid}/mail/${d}/mail:LAYOUT=maildir++:UTF-8:CONTROL=${stateDir}/control/${d}/${uid}:INDEX=${stateDir}/index/${d}/${uid}";
+        "maildir:/home/${uid}/mail/${domain}/mail:LAYOUT=maildir++:UTF-8:CONTROL=${stateDir}/control/${domain}/${uid}:INDEX=${stateDir}/index/${domain}/${uid}";
     }
   ];
 };