dovecot-1.0: Auth cache didn't work for usernames that got trans...

dovecot at dovecot.org dovecot at dovecot.org
Fri Nov 2 17:09:53 EET 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/004c228f60f3
changeset: 5443:004c228f60f3
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Nov 02 17:09:45 2007 +0200
description:
Auth cache didn't work for usernames that got translated internally.

diffstat:

3 files changed, 10 insertions(+), 3 deletions(-)
src/auth/auth-cache.c   |    6 +++---
src/auth/auth-request.c |    4 ++++
src/auth/auth-request.h |    3 +++

diffs (46 lines):

diff -r 1521674513a3 -r 004c228f60f3 src/auth/auth-cache.c
--- a/src/auth/auth-cache.c	Mon Oct 29 22:25:24 2007 +0200
+++ b/src/auth/auth-cache.c	Fri Nov 02 17:09:45 2007 +0200
@@ -196,12 +196,12 @@ void auth_cache_insert(struct auth_cache
 	size_t data_size, alloc_size, value_len = strlen(value);
 	char *current_username;
 
-	/* store into cache using the original username, except if we're doing
+	/* store into cache using the translated username, except if we're doing
 	   a master user login */
 	current_username = request->user;
-	if (request->original_username != NULL &&
+	if (request->translated_username != NULL &&
 	    request->requested_login_user == NULL)
-		request->user = t_strdup_noconst(request->original_username);
+		request->user = t_strdup_noconst(request->translated_username);
 
 	/* %! is prepended automatically. it contains the db ID number. */
 	str = t_str_new(256);
diff -r 1521674513a3 -r 004c228f60f3 src/auth/auth-request.c
--- a/src/auth/auth-request.c	Mon Oct 29 22:25:24 2007 +0200
+++ b/src/auth/auth-request.c	Fri Nov 02 17:09:45 2007 +0200
@@ -753,6 +753,10 @@ bool auth_request_set_username(struct au
 			"Invalid username: %s", str_sanitize(username, 128));
 		return FALSE;
 	}
+	if (request->translated_username == NULL) {
+		/* similar to original_username, but after translations */
+		request->translated_username = request->user;
+	}
 
 	if (login_username != NULL) {
 		if (!auth_request_set_login_username(request,
diff -r 1521674513a3 -r 004c228f60f3 src/auth/auth-request.h
--- a/src/auth/auth-request.h	Mon Oct 29 22:25:24 2007 +0200
+++ b/src/auth/auth-request.h	Fri Nov 02 17:09:45 2007 +0200
@@ -36,6 +36,9 @@ struct auth_request {
 	   client. this is needed at least with DIGEST-MD5 for password
 	   verification */
 	const char *original_username;
+	/* the username after doing all internal translations, but before
+	   being changed by a db lookup */
+	const char *translated_username;
 	char *mech_password; /* set if verify_plain() is called */
 	char *passdb_password; /* set after password lookup if successful */
         /* extra_fields are returned in authentication reply. Fields prefixed


More information about the dovecot-cvs mailing list