Blob Blame Raw
diff -Naur cyrus-imapd-2.3.1.orig/lib/auth_unix.c cyrus-imapd-2.3.1/lib/auth_unix.c
--- cyrus-imapd-2.3.1.orig/lib/auth_unix.c	Wed Feb 16 22:06:50 2005
+++ cyrus-imapd-2.3.1/lib/auth_unix.c	Wed Dec 21 13:50:05 2005
@@ -157,10 +157,12 @@
 size_t len;
 {
     static char retbuf[81];
+    char backup[81];
     struct group *grp;
     char sawalpha;
     char *p;
     int username_tolower = 0;
+    int ic,rbc;
 
     if(!len) len = strlen(identifier);
     if(len >= sizeof(retbuf)) return NULL;
@@ -210,6 +212,22 @@
     /* now we don't */
     /* if (!sawalpha) return NULL;  */
 
+    if( (libcyrus_config_getswitch(CYRUSOPT_NORMALIZEUID) == 1) ) {
+        strcpy(backup,retbuf);
+       /* remove leading blanks */
+       for(ic=0; isblank(backup[ic]); ic++);
+       for(rbc=0; backup[ic]; ic++) {
+            retbuf[rbc] = ( isalpha(backup[ic]) ?
+                 tolower(backup[ic]) : backup[ic] );
+            rbc++;
+       }
+       retbuf[rbc] = '\0';
+       /* remove trailing blanks */
+       for(--rbc; isblank(retbuf[rbc]); rbc--) {
+            retbuf[rbc] = '\0';
+       }
+    }
+
     return retbuf;
 }
 
diff -Naur cyrus-imapd-2.3.1.orig/lib/imapoptions cyrus-imapd-2.3.1/lib/imapoptions
--- cyrus-imapd-2.3.1.orig/lib/imapoptions	Tue Dec 13 20:36:11 2005
+++ cyrus-imapd-2.3.1/lib/imapoptions	Wed Dec 21 13:50:05 2005
@@ -990,6 +990,11 @@
    interface, otherwise the user is assumed to be in the default
    domain (if set). */
 
+{ "normalizeuid", 0, SWITCH }
+/* Lowercase uid and strip leading and trailing blanks. It is recommended
+   to set this to yes, especially if OpenLDAP is used as authentication
+   source. */
+
 /*
 .SH SEE ALSO
 .PP
diff -Naur cyrus-imapd-2.3.1.orig/lib/libcyr_cfg.c cyrus-imapd-2.3.1/lib/libcyr_cfg.c
--- cyrus-imapd-2.3.1.orig/lib/libcyr_cfg.c	Tue Dec 13 20:36:12 2005
+++ cyrus-imapd-2.3.1/lib/libcyr_cfg.c	Wed Dec 21 13:50:05 2005
@@ -127,6 +127,11 @@
       CFGVAL(const char *, "c"),
       CYRUS_OPT_STRING },
 
+    { CYRUSOPT_NORMALIZEUID,
+      CFGVAL(long, 1),
+      CYRUS_OPT_SWITCH },
+
+
     { CYRUSOPT_LAST, { NULL }, CYRUS_OPT_NOTOPT }
 };
 
diff -Naur cyrus-imapd-2.3.1.orig/lib/libcyr_cfg.h cyrus-imapd-2.3.1/lib/libcyr_cfg.h
--- cyrus-imapd-2.3.1.orig/lib/libcyr_cfg.h	Tue Dec 13 20:36:12 2005
+++ cyrus-imapd-2.3.1/lib/libcyr_cfg.h	Wed Dec 21 13:51:37 2005
@@ -101,6 +101,8 @@
     CYRUSOPT_BERKELEY_TXNS_MAX,
     /* RFC 2086 right which allows DELETE ("c") */
     CYRUSOPT_DELETERIGHT,
+    /* Lowercase uid and strip leading and trailing blanks (OFF) */
+    CYRUSOPT_NORMALIZEUID,
 
     CYRUSOPT_LAST