dovecot-2.2: auth: Fixed handling usernames with the same name a...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jan 5 01:14:36 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/3eeb5270963b
changeset: 15577:3eeb5270963b
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jan 05 00:50:04 2013 +0200
description:
auth: Fixed handling usernames with the same name as userdb extra fields.
This is a bit kludgy fix, but pretty much guaranteed not to break anything.
v2.2 has a cleaner fix, but it's a bit more invasive.

diffstat:

 src/auth/auth-request.c |   4 ++--
 src/auth/auth-stream.c  |  22 +++++++++++++++++++---
 src/auth/auth-stream.h  |   1 +
 3 files changed, 22 insertions(+), 5 deletions(-)

diffs (79 lines):

diff -r fc521e6378d5 -r 3eeb5270963b src/auth/auth-request.c
--- a/src/auth/auth-request.c	Sat Jan 05 00:12:54 2013 +0200
+++ b/src/auth/auth-request.c	Sat Jan 05 00:50:04 2013 +0200
@@ -863,7 +863,7 @@
 	}
 
 	*result_r = USERDB_RESULT_OK;
-	*reply_r = auth_stream_reply_init(request->pool);
+	*reply_r = auth_stream_reply_init_userdb(request->pool);
 	auth_stream_reply_import(*reply_r, value);
 	return TRUE;
 }
@@ -1342,7 +1342,7 @@
 {
 	struct userdb_module *module = request->userdb->userdb;
 
-	request->userdb_reply = auth_stream_reply_init(request->pool);
+	request->userdb_reply = auth_stream_reply_init_userdb(request->pool);
 	auth_stream_reply_add(request->userdb_reply, NULL, request->user);
 
 	userdb_template_export(module->default_fields_tmpl, request);
diff -r fc521e6378d5 -r 3eeb5270963b src/auth/auth-stream.c
--- a/src/auth/auth-stream.c	Sat Jan 05 00:12:54 2013 +0200
+++ b/src/auth/auth-stream.c	Sat Jan 05 00:50:04 2013 +0200
@@ -9,6 +9,7 @@
 
 struct auth_stream_reply {
 	string_t *str;
+	bool userdb;
 };
 
 struct auth_stream_reply *auth_stream_reply_init(pool_t pool)
@@ -20,6 +21,15 @@
 	return reply;
 }
 
+struct auth_stream_reply *auth_stream_reply_init_userdb(pool_t pool)
+{
+	struct auth_stream_reply *reply;
+
+	reply = auth_stream_reply_init(pool);
+	reply->userdb = TRUE;
+	return reply;
+}
+
 void auth_stream_reply_add(struct auth_stream_reply *reply,
 			   const char *key, const char *value)
 {
@@ -44,10 +54,16 @@
 auth_stream_reply_find_area(struct auth_stream_reply *reply, const char *key,
 			    unsigned int *idx_r, unsigned int *len_r)
 {
-	const char *str = str_c(reply->str);
-	unsigned int i, start, key_len = strlen(key);
+	const char *p, *str = str_c(reply->str);
+	unsigned int i = 0, start, key_len = strlen(key);
 
-	i = 0;
+	if (reply->userdb) {
+		p = strchr(str, '\t');
+		if (p == NULL)
+			return FALSE;
+		i = p-str+1;
+	}
+
 	while (str[i] != '\0') {
 		start = i;
 		for (; str[i] != '\0'; i++) {
diff -r fc521e6378d5 -r 3eeb5270963b src/auth/auth-stream.h
--- a/src/auth/auth-stream.h	Sat Jan 05 00:12:54 2013 +0200
+++ b/src/auth/auth-stream.h	Sat Jan 05 00:50:04 2013 +0200
@@ -4,6 +4,7 @@
 struct auth_request;
 
 struct auth_stream_reply *auth_stream_reply_init(pool_t pool);
+struct auth_stream_reply *auth_stream_reply_init_userdb(pool_t pool);
 void auth_stream_reply_add(struct auth_stream_reply *reply,
 			   const char *key, const char *value);
 void auth_stream_reply_reset(struct auth_stream_reply *reply);


More information about the dovecot-cvs mailing list