]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Fixed caching to support %{passdb} and %{userdb}
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 26 Jul 2016 17:53:56 +0000 (13:53 -0400)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 4 Aug 2016 15:07:30 +0000 (18:07 +0300)
src/auth/auth-cache.c
src/auth/test-auth-cache.c

index 7608ac8d0e0142c84b070f442de2eb189d1f7074..58f3dd5d2bea38a77681316fca3ceb9e75614833 100644 (file)
@@ -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 *
index 5764f861a3b8ac2152d8d3a95d99b12ee8041a7e..14f4740194f8de19d68cbfc21d26382205eda09b 100644 (file)
@@ -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)