Mercurial > dovecot > core-2.2
changeset 15577:3eeb5270963b
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.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 05 Jan 2013 00:50:04 +0200 |
parents | fc521e6378d5 |
children | 13e74bd5ac8c cf9d62fd0b14 |
files | src/auth/auth-request.c src/auth/auth-stream.c src/auth/auth-stream.h |
diffstat | 3 files changed, 22 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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++) {
--- 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);