Yevheniy Demchenko writes:
It seems, that asterisks (and possibly other special symbols) in mail addresses should be escaped before passing them to ldap.Proposed patch attached. Tested briefly. May need somewhat better memory handling.
Thanks for the patch, but I see that according to RFC 2254, only "*", "(", and ")" characters need escaping, furthermore, escaped characters are hex-encoded. Also, I prefer a different style. Please try to test the attached patch instead.
Furthermore, regarding your other patch, unfortunately it forces the usage of objectClass=CourierMailAccount, and would break all existing installations that use a different schema.
Index: courier/ldapaliasd.c
===================================================================
RCS file: /cvsroot/courier/courier/courier/courier/ldapaliasd.c,v
retrieving revision 1.28
diff -U3 -r1.28 ldapaliasd.c
--- courier/ldapaliasd.c 12 Nov 2006 15:33:23 -0000 1.28
+++ courier/ldapaliasd.c 17 Dec 2009 00:19:28 -0000
@@ -262,8 +262,66 @@
return result;
}
+static void escape_specials(const char *str,
+ char *bufptr,
+ size_t *sizeptr)
+{
+ static const char specials[]="*()\\";
+
+ while (*str)
+ {
+ char buf[10];
+ char *p;
+
+ if (strchr(specials, *str))
+ {
+ sprintf(buf, "\\%02x", (int)(unsigned char)*str);
+ }
+ else
+ {
+ buf[0]=*str;
+ buf[1]=0;
+ }
+
+ for (p=buf; *p; p++)
+ {
+ if (bufptr)
+ *bufptr++=*p;
+ if (sizeptr)
+ ++*sizeptr;
+ }
+ ++str;
+ }
+
+ if (bufptr)
+ *bufptr=0;
+}
+
+static int search_maildrop2(const char *mail, const char *source, FILE *outfp);
+
static int search_maildrop(const char *mail, const char *source, FILE *outfp)
{
+ char *escaped;
+ size_t escaped_cnt=1;
+ int rc;
+
+ escape_specials(mail, NULL, &escaped_cnt);
+ escaped=malloc(escaped_cnt);
+ if (!escaped)
+ {
+ syslog(LOG_DAEMON|LOG_CRIT, "malloc failed: %m");
+ return(0);
+ }
+
+ escape_specials(mail, escaped, NULL);
+
+ rc=search_maildrop2(escaped, source, outfp);
+ free(escaped);
+ return rc;
+}
+
+static int search_maildrop2(const char *mail, const char *source, FILE *outfp)
+{
char *filter;
char *p;
LDAPMessage *result;
pgpUnk1N6FhfM.pgp
Description: PGP signature
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ courier-users mailing list [email protected] Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users
