[Dovecot] Dovecot, LDAP and something akin to Postfix' "table search order" from virtual deliver.

Pawel Sawicki pawel.sawicki at pawel-sawicki.com
Tue Mar 21 23:26:57 EET 2006


Pawel Sawicki wrote:

> Is there a way to mimic Postfix' "table search order" in Dovecot's LDAP 
> configuration of pass_filter/user_filter?

(...)

Well I think I've managed to prepare a rather simple patch:

---

$ cvs diff -u src/deliver.c
Index: src/deliver.c
===================================================================
RCS file: /home/cvs/dovecot-lda/src/deliver.c,v
retrieving revision 1.39
diff -u -r1.39 deliver.c
--- src/deliver.c       8 Feb 2006 11:39:29 -0000       1.39
+++ src/deliver.c       21 Mar 2006 21:05:55 -0000
@@ -477,7 +477,6 @@
                         return NULL;
                 }

-               script_path = home_expand(SIEVE_SCRIPT_PATH);
                 if (*script_path != '/' && *script_path != '\0') {
                         /* relative path. change to absolute. */
                         script_path = t_strconcat(getenv("HOME"), "/",
@@ -570,6 +569,23 @@
                         auth_socket = DEFAULT_AUTH_SOCKET_PATH;

                 ret = user_init(auth_socket, destination);
+
+               /*
+                * Try to check for Postfix-like catch-all virtual 
mailbox address.
+                * Contributed by Pawel Sawicki 
<pawel.sawicki at pawel-sawicki.com>.
+                */
+
+               if (ret != 0) {
+                       /* Find the first '@' character and rerun the 
check. */
+                       destination = (const char *) strchr(destination, 
'@');
+
+                       /* Rerun the check. */
+                       if (destination != NULL)
+                               ret = user_init(auth_socket, destination);
+               }
+
+               /* End of Postfix-like catch-all virtual mailbox address 
check. */
+
                 if (ret != 0)
                         return ret;

---

First of all - in this case only user_filter is important :)

All in all - the code does its job perfectly. There's one distadvantage 
though. For each unsuccesful lookup (the first one) it produces an entry 
in the error log (syslog). While it would require more work inside the 
dovecot itself I left it intact :)

The patch is is based on 1.39, not 1.40, but it touches no changes made 
in 1.40.

Moreover I think I've located an error when dovecot received sieve path 
from userdb (the first change in the patch). Regardless of the passed 
value it was overwritten - this is my guess at least. Can anyone please 
comment on that?

Best regards,
Pawel Sawicki


More information about the dovecot mailing list