Mercurial > dovecot > core-2.2
changeset 5131:172fb23d3c8f HEAD
If user is changed with "user=x" in extra_fields, cache the entry with the
original username instead of with the changed username.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 15 Feb 2007 13:06:35 +0200 |
parents | 142726697f29 |
children | c4fab2513f50 |
files | src/auth/auth-cache.c src/auth/auth-cache.h src/auth/auth-request.c |
diffstat | 3 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/auth-cache.c Thu Feb 15 12:48:08 2007 +0200 +++ b/src/auth/auth-cache.c Thu Feb 15 13:06:35 2007 +0200 @@ -188,13 +188,20 @@ return node->data + strlen(node->data) + 1; } -void auth_cache_insert(struct auth_cache *cache, - const struct auth_request *request, +void auth_cache_insert(struct auth_cache *cache, struct auth_request *request, const char *key, const char *value, bool last_success) { string_t *str; struct auth_cache_node *node; 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 + a master user login */ + current_username = request->user; + if (request->original_username != NULL && + request->requested_login_user == NULL) + request->user = t_strdup_noconst(request->original_username); /* %! is prepended automatically. it contains the db ID number. */ str = t_str_new(256); @@ -203,6 +210,8 @@ auth_request_get_var_expand_table(request, auth_request_str_escape)); + request->user = current_username; + data_size = str_len(str) + 1 + value_len + 1; alloc_size = sizeof(struct auth_cache_node) - sizeof(node->data) + data_size;
--- a/src/auth/auth-cache.h Thu Feb 15 12:48:08 2007 +0200 +++ b/src/auth/auth-cache.h Thu Feb 15 13:06:35 2007 +0200 @@ -37,8 +37,7 @@ const char *key, struct auth_cache_node **node_r, bool *expired_r); /* Insert key => value into cache. */ -void auth_cache_insert(struct auth_cache *cache, - const struct auth_request *request, +void auth_cache_insert(struct auth_cache *cache, struct auth_request *request, const char *key, const char *value, bool last_success); /* Remove key from cache */
--- a/src/auth/auth-request.c Thu Feb 15 12:48:08 2007 +0200 +++ b/src/auth/auth-request.c Thu Feb 15 13:06:35 2007 +0200 @@ -933,6 +933,12 @@ if (strcmp(name, "user") == 0) { /* update username to be exactly as it's in database */ if (strcmp(request->user, value) != 0) { + /* remember the original username for cache */ + if (request->original_username == NULL) { + request->original_username = + p_strdup(request->pool, request->user); + } + auth_request_log_debug(request, "auth", "username changed %s -> %s", request->user, value);