Hi,
I just took the time to update the dash-patch from 20010305 to the
20010501 ldap patch. Remember: it's not my code, but the current
dash-trick patch on the http://www.lifewithqmail.org/ldap site for the
20010501 ldap patch is not correct. Hopefully this one is. So if
anybody's using this one, let the list know the results :)
Franky
--- ../qmail-1.03-patch20010501-orig/qmail-lspawn.c Sat Jun 2 18:00:12 2001
+++ qmail-lspawn.c Sat Jun 2 17:48:50 2001
@@ -351,6 +351,9 @@
int reply;
int at;
int i;
+#ifdef DASH_EXT
+ int dash;
+#endif
int force_forward;
char *r;
stralloc filter = {0};
@@ -401,38 +404,78 @@
ret = ldap_lookup(&search, attrs, &info, extra);
if ( ret != 0 && qldap_errno == LDAP_NOSUCH ) {
- /* this handles the "catch all" extension */
+ /* extensions: catchall and dash-trick */
at = 0;
r = mail->s;
i = mail->len;
for (at = i - 1; r[at] != '@' && at >= 0 ; at--) ;
/* handels also mailwith 2 @ */
- /* build the search string for the email address */
- if (!stralloc_copys(&filter,"(" ) ) _exit(QLX_NOMEM);
- /* optional objectclass */
- if (qldap_objectclass.len) {
- if (!stralloc_cats(&filter,"&(")) _exit(QLX_NOMEM);
- if (!stralloc_cats(&filter,LDAP_OBJECTCLASS)) _exit(QLX_NOMEM);
+#ifdef DASH_EXT
+ dash=0;
+ for (dash = at-1; dash > 0 && ret != 0 && qldap_errno == LDAP_NOSUCH; dash--) {
+ if ( r[dash-1] == '-' ) {
+ /* dash ext */
+ /* build the search string for the email address */
+ if (!stralloc_copys(&filter,"(" ) ) _exit(QLX_NOMEM);
+ /* optional objectclass */
+ if (qldap_objectclass.len) {
+ if (!stralloc_cats(&filter,"&(")) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,LDAP_OBJECTCLASS)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,"=")) _exit(QLX_NOMEM);
+ if (!stralloc_cat(&filter,&qldap_objectclass)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,")(")) _exit(QLX_NOMEM);
+ } /* end */
+ if (!stralloc_cats(&filter,"|(")) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,LDAP_MAIL)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,"=")) _exit(QLX_NOMEM);
+ if (!stralloc_catb(&filter,r,dash-1)) _exit(QLX_NOMEM);
+ if (!stralloc_catb(&filter,r+at, i-at)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,")(")) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,LDAP_MAILALTERNATE)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,"=")) _exit(QLX_NOMEM);
+ if (!stralloc_catb(&filter,r,dash-1)) _exit(QLX_NOMEM);
+ if (!stralloc_catb(&filter,r+at, i-at)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,"))")) _exit(QLX_NOMEM);
+ if (!stralloc_0(&filter)) _exit(QLX_NOMEM);
+
+ debug(16, "retry with filter '%s'\n", filter.s);
+ /* do the search */
+ ret = ldap_lookup(&search, attrs, &info, extra);
+ }
+ }
+
+ if (ret != 0 && qldap_errno == LDAP_NOSUCH) {
+#endif
+ /* catchall */
+ /* build the search string for the email address */
+ if (!stralloc_copys(&filter,"(" ) ) _exit(QLX_NOMEM);
+ /* optional objectclass */
+ if (qldap_objectclass.len) {
+ if (!stralloc_cats(&filter,"&(")) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,LDAP_OBJECTCLASS)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,"=")) _exit(QLX_NOMEM);
+ if (!stralloc_cat(&filter,&qldap_objectclass)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,")(")) _exit(QLX_NOMEM);
+ } /* end */
+ if (!stralloc_cats(&filter,"|(")) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,LDAP_MAIL)) _exit(QLX_NOMEM);
if (!stralloc_cats(&filter,"=")) _exit(QLX_NOMEM);
- if (!stralloc_cat(&filter,&qldap_objectclass)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,LDAP_CATCH_ALL)) _exit(QLX_NOMEM);
+ if (!stralloc_catb(&filter,r+at, i-at)) _exit(QLX_NOMEM);
if (!stralloc_cats(&filter,")(")) _exit(QLX_NOMEM);
- } /* end */
- if (!stralloc_cats(&filter,"|(")) _exit(QLX_NOMEM);
- if (!stralloc_cats(&filter,LDAP_MAIL)) _exit(QLX_NOMEM);
- if (!stralloc_cats(&filter,"=")) _exit(QLX_NOMEM);
- if (!stralloc_cats(&filter,LDAP_CATCH_ALL)) _exit(QLX_NOMEM);
- if (!stralloc_catb(&filter,r+at, i-at)) _exit(QLX_NOMEM);
- if (!stralloc_cats(&filter,")(")) _exit(QLX_NOMEM);
- if (!stralloc_cats(&filter,LDAP_MAILALTERNATE)) _exit(QLX_NOMEM);
- if (!stralloc_cats(&filter,"=")) _exit(QLX_NOMEM);
- if (!stralloc_cats(&filter,LDAP_CATCH_ALL)) _exit(QLX_NOMEM);
- if (!stralloc_catb(&filter,r+at, i-at)) _exit(QLX_NOMEM);
- if (!stralloc_cats(&filter,"))")) _exit(QLX_NOMEM);
- if (!stralloc_0(&filter)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,LDAP_MAILALTERNATE)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,"=")) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,LDAP_CATCH_ALL)) _exit(QLX_NOMEM);
+ if (!stralloc_catb(&filter,r+at, i-at)) _exit(QLX_NOMEM);
+ if (!stralloc_cats(&filter,"))")) _exit(QLX_NOMEM);
+ if (!stralloc_0(&filter)) _exit(QLX_NOMEM);
- debug(16, "retry with filter '%s'\n", filter.s);
- /* do the search for the catchall address */
- ret = ldap_lookup(&search, attrs, &info, extra);
+ debug(16, "retry with filter '%s'\n", filter.s);
+ /* do the search for the catchall address */
+ ret = ldap_lookup(&search, attrs, &info, extra);
+#ifdef DASH_EXT
+ }
+#endif
}
alloc_free(filter.s); filter.s = 0;
@@ -526,11 +569,24 @@
}
if (!stralloc_0(&nughde)) _exit(QLX_NOMEM);
- /* At the moment we ignore the dash-field and the extension field *
- * so we fill up the nughde structure with '\0' */
-
- if (!stralloc_0(&nughde)) _exit(QLX_NOMEM);
- if (!stralloc_0(&nughde)) _exit(QLX_NOMEM);
+#ifdef DASH_EXT
+ /* Here we fill the nughde structure with the dash-field the extension field */
+ if ((dash > 0) && (dash < (at-1))) {
+ if (!stralloc_cats(&nughde,"-")) _exit(QLX_NOMEM);
+ if (!stralloc_0(&nughde)) _exit(QLX_NOMEM);
+ if (!stralloc_catb(&nughde,r+dash+1,at-dash-1)) _exit(QLX_NOMEM);
+ if (!stralloc_0(&nughde)) _exit(QLX_NOMEM);
+
+ } else {
+#endif
+ /* we ignore the dash-field and the extension field *
+ * so we fill up the nughde structure with '\0' */
+ if (!stralloc_0(&nughde)) _exit(QLX_NOMEM);
+ if (!stralloc_0(&nughde)) _exit(QLX_NOMEM);
+
+#ifdef DASH_EXT
+ }
+#endif
/* get the quota for the user of that maildir mbox */
if ( extra[0].vals != 0 ) {