dovecot-2.0: auth: Fixed prefetch userdb interaction with passdb...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 7 20:53:54 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/48ac56ad4768
changeset: 11490:48ac56ad4768
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 07 18:53:42 2010 +0100
description:
auth: Fixed prefetch userdb interaction with passdb changing username.
If userdb_* fields were set before user was changed, prefetch returned
the unchanged username.

diffstat:

 src/auth/auth-request.c |  19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diffs (43 lines):

diff -r c73ddaa39ca4 -r 48ac56ad4768 src/auth/auth-request.c
--- a/src/auth/auth-request.c	Mon Jun 07 17:48:51 2010 +0100
+++ b/src/auth/auth-request.c	Mon Jun 07 18:53:42 2010 +0100
@@ -31,6 +31,7 @@
 
 static void get_log_prefix(string_t *str, struct auth_request *auth_request,
 			   const char *subsystem);
+static void auth_request_userdb_reply_update_user(struct auth_request *request);
 
 struct auth_request *
 auth_request_new(const struct mech_module *mech,
@@ -1096,6 +1097,10 @@
 				request->user, value);
 			request->user = p_strdup(request->pool, value);
 		}
+
+		if (request->userdb_reply != NULL)
+			auth_request_userdb_reply_update_user(request);
+
 		/* restore the original value so it gets saved correctly to
 		   cache. */
 		value = orig_value;
@@ -1172,6 +1177,20 @@
 	auth_stream_reply_add(request->userdb_reply, NULL, request->user);
 }
 
+static void auth_request_userdb_reply_update_user(struct auth_request *request)
+{
+	const char *str, *p;
+
+	str = t_strdup(auth_stream_reply_export(request->userdb_reply));
+
+	auth_stream_reply_reset(request->userdb_reply);
+	auth_stream_reply_add(request->userdb_reply, NULL, request->user);
+
+	p = strchr(str, '\t');
+	if (p != NULL)
+		auth_stream_reply_import(request->userdb_reply, p + 1);
+}
+
 static void
 auth_request_change_userdb_user(struct auth_request *request, const char *user)
 {


More information about the dovecot-cvs mailing list