Blob Blame History Raw
diff -up cyrus-imapd-2.4.14/lib/auth_unix.c.authid_normalize cyrus-imapd-2.4.14/lib/auth_unix.c
--- cyrus-imapd-2.4.14/lib/auth_unix.c.authid_normalize	2012-03-12 12:47:51.000000000 +0100
+++ cyrus-imapd-2.4.14/lib/auth_unix.c	2012-03-14 10:49:50.679822894 +0100
@@ -156,10 +156,12 @@ const char *identifier;
 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;
@@ -211,6 +213,22 @@ size_t len;
     /* 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 -up cyrus-imapd-2.4.14/lib/imapoptions.authid_normalize cyrus-imapd-2.4.14/lib/imapoptions
--- cyrus-imapd-2.4.14/lib/imapoptions.authid_normalize	2012-03-12 12:47:51.000000000 +0100
+++ cyrus-imapd-2.4.14/lib/imapoptions	2012-03-14 11:01:11.020256349 +0100
@@ -844,6 +844,11 @@ Blank lines and lines beginning with ``#
 /* Set the length of the NNTP server's inactivity autologout timer,    
    in minutes.  The minimum value is 3, the default. */
 
+{ "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. */
+
 { "notifysocket", "{configdirectory}/socket/notify", STRING }
 /* Unix domain socket that the mail notification daemon listens on. */
 
diff -up cyrus-imapd-2.4.14/lib/libcyr_cfg.c.authid_normalize cyrus-imapd-2.4.14/lib/libcyr_cfg.c
--- cyrus-imapd-2.4.14/lib/libcyr_cfg.c.authid_normalize	2012-03-12 12:47:51.000000000 +0100
+++ cyrus-imapd-2.4.14/lib/libcyr_cfg.c	2012-03-14 10:49:50.681822910 +0100
@@ -158,6 +158,10 @@ struct cyrusopt_s cyrus_options[] = {
       CFGVAL(long, 1),
       CYRUS_OPT_SWITCH },
 
+    { CYRUSOPT_NORMALIZEUID,
+      CFGVAL(long, 1),
+      CYRUS_OPT_SWITCH },
+
     { CYRUSOPT_LAST, { NULL }, CYRUS_OPT_NOTOPT }
 };
 
diff -up cyrus-imapd-2.4.14/lib/libcyr_cfg.h.authid_normalize cyrus-imapd-2.4.14/lib/libcyr_cfg.h
--- cyrus-imapd-2.4.14/lib/libcyr_cfg.h.authid_normalize	2012-03-12 12:47:51.000000000 +0100
+++ cyrus-imapd-2.4.14/lib/libcyr_cfg.h	2012-03-14 10:49:50.681822910 +0100
@@ -116,6 +116,8 @@ enum cyrus_opt {
     CYRUSOPT_SQL_USESSL,
     /* Checkpoint after every recovery (OFF) */
     CYRUSOPT_SKIPLIST_ALWAYS_CHECKPOINT,
+    /* Lowercase uid and strip leading and trailing blanks (OFF) */
+    CYRUSOPT_NORMALIZEUID,
 
     CYRUSOPT_LAST