summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-mail/cyrus-imapd/files/kolab/2.3.12_p2/uid.patch')
-rw-r--r--net-mail/cyrus-imapd/files/kolab/2.3.12_p2/uid.patch115
1 files changed, 115 insertions, 0 deletions
diff --git a/net-mail/cyrus-imapd/files/kolab/2.3.12_p2/uid.patch b/net-mail/cyrus-imapd/files/kolab/2.3.12_p2/uid.patch
new file mode 100644
index 0000000..a044463
--- /dev/null
+++ b/net-mail/cyrus-imapd/files/kolab/2.3.12_p2/uid.patch
@@ -0,0 +1,115 @@
+Allows login by uid rather than the mail address on the cyrus imapd server [Version: 2.3.9]
+
+diff -r d62bf3b0902d configure
+--- a/configure Thu Oct 25 08:30:57 2007 +0200
++++ b/configure Thu Oct 25 08:31:06 2007 +0200
+@@ -18119,7 +18119,7 @@ done
+ done
+
+ IMAP_COM_ERR_LIBS="${COM_ERR_LIBS}"
+-IMAP_LIBS="${LIB_SASL} ${LIBS}"
++IMAP_LIBS="${LIB_SASL} -lldap -llber ${LIBS}"
+
+
+
+diff -r d62bf3b0902d imap/global.c
+--- a/imap/global.c Thu Oct 25 08:30:57 2007 +0200
++++ b/imap/global.c Thu Oct 25 08:31:06 2007 +0200
+@@ -52,6 +52,9 @@
+ #include <netinet/in.h>
+ #include <sys/stat.h>
+
++#include <ldap.h>
++#include <lber.h>
++
+ #if HAVE_UNISTD_H
+ # include <unistd.h>
+ #endif
+@@ -362,6 +365,18 @@ char *canonify_userid(char *user, char *
+ char *domain = NULL;
+ int len = strlen(user);
+ char buf[81];
++ const char *uri;
++ const char *base;
++ const char *binddn;
++ const char *bindpw;
++ struct timeval timeout;
++ char filter[255];
++ LDAP *handle;
++ LDAPMessage *res;
++ LDAPMessage *entry;
++ char ** vals;
++
++ int rc;
+
+ /* check for domain */
+ if (config_virtdomains &&
+@@ -380,6 +395,47 @@ char *canonify_userid(char *user, char *
+ }
+
+ if (config_virtdomains) {
++ if (config_virtdomains == IMAP_ENUM_VIRTDOMAINS_LDAP) {
++ uri = config_getstring(IMAPOPT_LDAP_URI);
++ base = config_getstring(IMAPOPT_LDAP_BASE);
++ binddn = config_getstring(IMAPOPT_LDAP_BIND_DN);
++ bindpw = config_getstring(IMAPOPT_LDAP_PASSWORD);
++ timeout.tv_sec = config_getint(IMAPOPT_LDAP_TIME_LIMIT);
++ timeout.tv_usec = 0;
++ sprintf(filter, "(uid=%s)", user);
++ rc = ldap_initialize(&handle, uri);
++ if (rc != LDAP_SUCCESS) {
++ syslog(LOG_ERR, "ldap_initialize failed (%s)", uri);
++ } else {
++ rc = ldap_simple_bind_s(handle, binddn, bindpw);
++ if (rc != LDAP_SUCCESS) {
++ syslog(LOG_ERR, "ldap_simple_bind() failed %d (%s)", rc, ldap_err2string(rc));
++ } else {
++ rc = ldap_search_st(handle, base, LDAP_SCOPE_SUBTREE, filter, NULL, 0, &timeout, &res);
++ if (rc != LDAP_SUCCESS) {
++ syslog(LOG_ERR, "ldap_search_st failed %d (%s)", rc, ldap_err2string(rc));
++ } else {
++ if ( (entry = ldap_first_entry(handle, res)) != NULL ) {
++ // read mail attribute from entry
++ if ( (vals = ldap_get_values(handle, entry, "mail")) ) {
++ if (strchr(vals[0], '@')) {
++ static char buf[81]; /* same size as in auth_canonifyid */
++ strncpy( buf, vals[0], sizeof(buf) );
++ buf[80] = '\0'; /* make sure it's null-terminated */
++ ldap_value_free( vals );
++ ldap_msgfree( res );
++ ldap_unbind_s(handle); /* also frees handle */
++ return auth_canonifyid( buf, 0) ;
++ }
++ ldap_value_free( vals );
++ }
++ }
++ ldap_msgfree( res );
++ }
++ }
++ ldap_unbind_s(handle); /* also frees handle */
++ }
++ }
+ if (domain) {
+ if (config_defdomain && !strcasecmp(config_defdomain, domain+1)) {
+ *domain = '\0'; /* trim the default domain */
+@@ -392,7 +448,7 @@ char *canonify_userid(char *user, char *
+ user = buf;
+ }
+ }
+- else if (config_virtdomains != IMAP_ENUM_VIRTDOMAINS_USERID) {
++ else if (config_virtdomains != IMAP_ENUM_VIRTDOMAINS_USERID && config_virtdomains != IMAP_ENUM_VIRTDOMAINS_LDAP) {
+ socklen_t salen;
+ int error;
+ struct sockaddr_storage localaddr;
+diff -r d62bf3b0902d lib/imapoptions
+--- a/lib/imapoptions Thu Oct 25 08:30:57 2007 +0200
++++ b/lib/imapoptions Thu Oct 25 08:31:06 2007 +0200
+@@ -1034,7 +1034,7 @@ are listed with ``<none>''.
+ mailbox hierarchy. The default is to use the netnews separator
+ character '.'. */
+
+-{ "virtdomains", "off", ENUM("off", "userid", "on") }
++{ "virtdomains", "off", ENUM("off", "userid", "ldap", "on") }
+ /* Enable virtual domain support. If enabled, the user's domain will
+ be determined by splitting a fully qualified userid at the last '@'
+ or '%' symbol. If the userid is unqualified, and the virtdomains