Blame SOURCES/cyrus-imapd-2.3.1-authid_normalize.patch

62c494
diff -up cyrus-imapd-2.4.14/lib/auth_unix.c.authid_normalize cyrus-imapd-2.4.14/lib/auth_unix.c
62c494
--- cyrus-imapd-2.4.14/lib/auth_unix.c.authid_normalize	2012-03-12 12:47:51.000000000 +0100
62c494
+++ cyrus-imapd-2.4.14/lib/auth_unix.c	2012-03-14 10:49:50.679822894 +0100
62c494
@@ -156,10 +156,12 @@ const char *identifier;
62c494
 size_t len;
62c494
 {
62c494
     static char retbuf[81];
62c494
+    char backup[81];
62c494
     struct group *grp;
62c494
     char sawalpha;
62c494
     char *p;
62c494
     int username_tolower = 0;
62c494
+    int ic,rbc;
62c494
 
62c494
     if(!len) len = strlen(identifier);
62c494
     if(len >= sizeof(retbuf)) return NULL;
62c494
@@ -211,6 +213,22 @@ size_t len;
62c494
     /* now we don't */
62c494
     /* if (!sawalpha) return NULL;  */
62c494
 
62c494
+    if( (libcyrus_config_getswitch(CYRUSOPT_NORMALIZEUID) == 1) ) {
62c494
+        strcpy(backup,retbuf);
62c494
+       /* remove leading blanks */
62c494
+       for(ic=0; isblank(backup[ic]); ic++);
62c494
+       for(rbc=0; backup[ic]; ic++) {
62c494
+            retbuf[rbc] = ( isalpha(backup[ic]) ?
62c494
+                 tolower(backup[ic]) : backup[ic] );
62c494
+            rbc++;
62c494
+       }
62c494
+       retbuf[rbc] = '\0';
62c494
+       /* remove trailing blanks */
62c494
+       for(--rbc; isblank(retbuf[rbc]); rbc--) {
62c494
+            retbuf[rbc] = '\0';
62c494
+       }
62c494
+    }
62c494
+
62c494
     return retbuf;
62c494
 }
62c494
 
62c494
diff -up cyrus-imapd-2.4.14/lib/imapoptions.authid_normalize cyrus-imapd-2.4.14/lib/imapoptions
62c494
--- cyrus-imapd-2.4.14/lib/imapoptions.authid_normalize	2012-03-12 12:47:51.000000000 +0100
62c494
+++ cyrus-imapd-2.4.14/lib/imapoptions	2012-03-14 11:01:11.020256349 +0100
62c494
@@ -844,6 +844,11 @@ Blank lines and lines beginning with ``#
62c494
 /* Set the length of the NNTP server's inactivity autologout timer,    
62c494
    in minutes.  The minimum value is 3, the default. */
62c494
 
62c494
+{ "normalizeuid", 0, SWITCH }
62c494
+/* Lowercase uid and strip leading and trailing blanks. It is recommended
62c494
+   to set this to yes, especially if OpenLDAP is used as authentication
62c494
+   source. */
62c494
+
62c494
 { "notifysocket", "{configdirectory}/socket/notify", STRING }
62c494
 /* Unix domain socket that the mail notification daemon listens on. */
62c494
 
62c494
diff -up cyrus-imapd-2.4.14/lib/libcyr_cfg.c.authid_normalize cyrus-imapd-2.4.14/lib/libcyr_cfg.c
62c494
--- cyrus-imapd-2.4.14/lib/libcyr_cfg.c.authid_normalize	2012-03-12 12:47:51.000000000 +0100
62c494
+++ cyrus-imapd-2.4.14/lib/libcyr_cfg.c	2012-03-14 10:49:50.681822910 +0100
62c494
@@ -158,6 +158,10 @@ struct cyrusopt_s cyrus_options[] = {
62c494
       CFGVAL(long, 1),
62c494
       CYRUS_OPT_SWITCH },
62c494
 
62c494
+    { CYRUSOPT_NORMALIZEUID,
62c494
+      CFGVAL(long, 1),
62c494
+      CYRUS_OPT_SWITCH },
62c494
+
62c494
     { CYRUSOPT_LAST, { NULL }, CYRUS_OPT_NOTOPT }
62c494
 };
62c494
 
62c494
diff -up cyrus-imapd-2.4.14/lib/libcyr_cfg.h.authid_normalize cyrus-imapd-2.4.14/lib/libcyr_cfg.h
62c494
--- cyrus-imapd-2.4.14/lib/libcyr_cfg.h.authid_normalize	2012-03-12 12:47:51.000000000 +0100
62c494
+++ cyrus-imapd-2.4.14/lib/libcyr_cfg.h	2012-03-14 10:49:50.681822910 +0100
62c494
@@ -116,6 +116,8 @@ enum cyrus_opt {
62c494
     CYRUSOPT_SQL_USESSL,
62c494
     /* Checkpoint after every recovery (OFF) */
62c494
     CYRUSOPT_SKIPLIST_ALWAYS_CHECKPOINT,
62c494
+    /* Lowercase uid and strip leading and trailing blanks (OFF) */
62c494
+    CYRUSOPT_NORMALIZEUID,
62c494
 
62c494
     CYRUSOPT_LAST
62c494