From: Timo Sirainen Date: Tue, 26 Jul 2016 17:53:56 +0000 (-0400) Subject: auth: Fixed caching to support %{passdb} and %{userdb} X-Git-Tag: 2.2.26~461 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4156beb95d74d8a11ad66da1384146cbaf9a12f;p=thirdparty%2Fdovecot%2Fcore.git auth: Fixed caching to support %{passdb} and %{userdb} --- diff --git a/src/auth/auth-cache.c b/src/auth/auth-cache.c index 7608ac8d0e..58f3dd5d2b 100644 --- a/src/auth/auth-cache.c +++ b/src/auth/auth-cache.c @@ -340,18 +340,13 @@ static const char * auth_request_expand_cache_key(const struct auth_request *request, const char *key) { - string_t *str; - /* Uniquely identify the request's passdb/userdb with the P/U prefix and by "%!", which expands to the passdb/userdb ID number. */ key = t_strconcat(request->userdb_lookup ? "U" : "P", "%!", request->master_user == NULL ? "" : "+%{master_user}", "\t", key, NULL); - str = t_str_new(256); - var_expand(str, key, - auth_request_get_var_expand_table(request, auth_cache_escape)); - return str_c(str); + return t_auth_request_var_expand(key, request, auth_cache_escape); } const char * diff --git a/src/auth/test-auth-cache.c b/src/auth/test-auth-cache.c index 5764f861a3..14f4740194 100644 --- a/src/auth/test-auth-cache.c +++ b/src/auth/test-auth-cache.c @@ -1,6 +1,7 @@ /* Copyright (c) 2013-2016 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "str.h" #include "auth-request.h" #include "auth-cache.h" #include "test-common.h" @@ -17,11 +18,14 @@ const struct var_expand_table auth_request_var_expand_static_tab[] = { { '\0', NULL, NULL } }; -const struct var_expand_table * -auth_request_get_var_expand_table(const struct auth_request *auth_request ATTR_UNUSED, - auth_request_escape_func_t *escape_func ATTR_UNUSED) +const char * +t_auth_request_var_expand(const char *str, + const struct auth_request *auth_request ATTR_UNUSED, + auth_request_escape_func_t *escape_func ATTR_UNUSED) { - return auth_request_var_expand_static_tab; + string_t *dest = t_str_new(128); + var_expand(dest, str, auth_request_var_expand_static_tab); + return str_c(dest); } static void test_auth_cache_parse_key(void)