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