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

78 lines
2.3 KiB
Diff
Raw Normal View History

2009-01-13 19:26:24 +00:00
--- cyrus-imapd-2.3.13/lib/libcyr_cfg.h.authid_normalize 2008-07-30 18:03:39.000000000 +0200
+++ cyrus-imapd-2.3.13/lib/libcyr_cfg.h 2009-01-13 11:41:59.000000000 +0100
@@ -112,6 +112,8 @@ enum cyrus_opt {
CYRUSOPT_SQL_PASSWD,
/* Secure SQL connection (OFF) */
CYRUSOPT_SQL_USESSL,
2009-01-13 19:26:24 +00:00
+ /* Lowercase uid and strip leading and trailing blanks (OFF) */
+ CYRUSOPT_NORMALIZEUID,
CYRUSOPT_LAST
2009-01-13 19:26:24 +00:00
--- cyrus-imapd-2.3.13/lib/auth_unix.c.authid_normalize 2009-01-13 11:38:08.000000000 +0100
+++ cyrus-imapd-2.3.13/lib/auth_unix.c 2009-01-13 11:38:08.000000000 +0100
@@ -155,10 +155,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;
}
2009-01-13 19:26:24 +00:00
--- cyrus-imapd-2.3.13/lib/imapoptions.authid_normalize 2009-01-13 11:38:08.000000000 +0100
+++ cyrus-imapd-2.3.13/lib/imapoptions 2009-01-13 11:38:08.000000000 +0100
@@ -1182,6 +1182,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
2009-01-13 19:26:24 +00:00
--- cyrus-imapd-2.3.13/lib/libcyr_cfg.c.authid_normalize 2008-07-30 18:03:38.000000000 +0200
+++ cyrus-imapd-2.3.13/lib/libcyr_cfg.c 2009-01-13 11:38:08.000000000 +0100
@@ -150,6 +150,11 @@
CFGVAL(long, 0),
CYRUS_OPT_SWITCH },
+ { CYRUSOPT_NORMALIZEUID,
+ CFGVAL(long, 1),
+ CYRUS_OPT_SWITCH },
+
+
{ CYRUSOPT_LAST, { NULL }, CYRUS_OPT_NOTOPT }
};