changeset 20540:4ea94770b30c

auth: Fixed caching to support %{passdb} and %{userdb}
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 26 Jul 2016 13:53:56 -0400
parents 97f1fdbfd385
children 0bdffed7f6ef
files src/auth/auth-cache.c src/auth/test-auth-cache.c
diffstat 2 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-cache.c	Tue Jul 26 13:52:44 2016 -0400
+++ b/src/auth/auth-cache.c	Tue Jul 26 13:53:56 2016 -0400
@@ -340,18 +340,13 @@
 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 *
--- a/src/auth/test-auth-cache.c	Tue Jul 26 13:52:44 2016 -0400
+++ b/src/auth/test-auth-cache.c	Tue Jul 26 13:53:56 2016 -0400
@@ -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 @@
 	{ '\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)