diff -ru cyrus-sasl-2.1.18/saslauthd/auth_rimap.c cyrus-sasl-2.1.18_crm/saslauthd/auth_rimap.c --- cyrus-sasl-2.1.18/saslauthd/auth_rimap.c 2004-03-08 17:57:31.000000000 +0100 +++ cyrus-sasl-2.1.18_crm/saslauthd/auth_rimap.c 2004-07-13 15:07:39.000000000 +0200 @@ -83,6 +83,7 @@ /* PRIVATE DEPENDENCIES */ static const char *r_host = NULL; /* remote hostname (mech_option) */ static struct addrinfo *ai = NULL; /* remote authentication host */ +static char *realm_use = NULL; /* END PRIVATE DEPENDENCIES */ #define DEFAULT_REMOTE_SERVICE "imap" /* getservbyname() name for remote @@ -222,6 +223,7 @@ struct addrinfo hints; int err; char *c; /* scratch pointer */ + char *r; /* END VARIABLES */ if (mech_option == NULL) { @@ -250,6 +252,13 @@ c = DEFAULT_REMOTE_SERVICE; } + r = strchr(c, '/'); + + if (r != NULL) { + *r++ = '\0'; + realm_use = r; + } + if (ai) freeaddrinfo(ai); memset(&hints, 0, sizeof(hints)); @@ -314,6 +323,7 @@ int saved_errno; int niflags; /* END VARIABLES */ + char *tmp_login; /* temp login before quote */ /* sanity checks */ assert(login != NULL); @@ -395,7 +405,19 @@ /* build the LOGIN command */ - qlogin = qstring(login); /* quote login */ + if (realm_use != NULL) { + tmp_login = malloc(strlen(login) + strlen(realm) + 2); + strcpy(tmp_login, login); + strncat(tmp_login, realm_use, 1); + strcat(tmp_login, realm); + qlogin = qstring(tmp_login); /* quote login plus realm */ + free(tmp_login); + tmp_login = NULL; + } + else { + qlogin = qstring(login); /* quote login */ + } + qpass = qstring(password); /* quote password */ if (qlogin == NULL) { if (qpass != NULL) { diff -ru cyrus-sasl-2.1.18/saslauthd/saslauthd.8 cyrus-sasl-2.1.18_crm/saslauthd/saslauthd.8 --- cyrus-sasl-2.1.18/saslauthd/saslauthd.8 2004-03-09 17:58:06.000000000 +0100 +++ cyrus-sasl-2.1.18_crm/saslauthd/saslauthd.8 2004-07-13 14:55:36.000000000 +0200 @@ -127,6 +127,11 @@ by appending a slash and the port name or number to the hostname argument. + By default only the user part without the realm is used as login, if + user and realm should be used, a slash and a delimiter must be appended + to the host/service option. By using an '@' as delimiter a ripped apart + email address can be reconstructed. Example: localhost/imap/@ + The -O flag and argument are mandatory when using the rimap mechanism.