From: Aki Tuomi Date: Fri, 25 Jul 2025 05:16:52 +0000 (+0300) Subject: [PATCH] auth: Use AUTH_CACHE_KEY_USER instead of per-database constants X-Git-Tag: archive/raspbian/1%2.4.1+dfsg1-6+rpi1+deb13u2^2^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8c5f4d416c50d75eb83c65941b0dd87b03151e07;p=dovecot.git [PATCH] auth: Use AUTH_CACHE_KEY_USER instead of per-database constants Fixes cache key issue where users would end up overwriting each other in cache due to cache key being essentially static string because we no longer support %u. Forgotten in 2e298e7ee98b6df61cf85117f000290d60a473b8 Gbp-Pq: Name auth__Use_AUTH_CACHE_KEY_USER_instead_of_per-database.patch --- diff --git a/src/auth/auth-settings.h b/src/auth/auth-settings.h index 1d420ec..90aba17 100644 --- a/src/auth/auth-settings.h +++ b/src/auth/auth-settings.h @@ -1,6 +1,8 @@ #ifndef AUTH_SETTINGS_H #define AUTH_SETTINGS_H +#define AUTH_CACHE_KEY_USER "%{user}" + struct master_service; struct master_service_settings_output; diff --git a/src/auth/passdb-bsdauth.c b/src/auth/passdb-bsdauth.c index 6829267..1b86da4 100644 --- a/src/auth/passdb-bsdauth.c +++ b/src/auth/passdb-bsdauth.c @@ -14,8 +14,6 @@ #include #include -#define BSDAUTH_CACHE_KEY "%u" - struct passdb_bsdauth_settings { pool_t pool; }; @@ -104,7 +102,7 @@ bsdauth_preinit(pool_t pool, struct event *event, &post_set, error_r) < 0) return -1; module->default_cache_key = auth_cache_parse_key_and_fields( - pool, BSDAUTH_CACHE_KEY, &post_set->fields, "bsdauth"); + pool, AUTH_CACHE_KEY_USER, &post_set->fields, "bsdauth"); settings_free(post_set); *module_r = module; diff --git a/src/auth/passdb-oauth2.c b/src/auth/passdb-oauth2.c index 96d902d..91fed06 100644 --- a/src/auth/passdb-oauth2.c +++ b/src/auth/passdb-oauth2.c @@ -53,7 +53,7 @@ oauth2_preinit(pool_t pool, struct event *event, struct passdb_module **module_r if (db_oauth2_init(event, TRUE, &module->db, error_r) < 0) return -1; module->module.default_pass_scheme = "PLAIN"; - module->module.default_cache_key = "%u"; + module->module.default_cache_key = AUTH_CACHE_KEY_USER; *module_r = &module->module; return 0; } diff --git a/src/auth/passdb-pam.c b/src/auth/passdb-pam.c index 2acbceb..fdf0f57 100644 --- a/src/auth/passdb-pam.c +++ b/src/auth/passdb-pam.c @@ -415,7 +415,8 @@ static int pam_preinit(pool_t pool, struct event *event, module = p_new(pool, struct pam_passdb_module, 1); module->module.default_cache_key = auth_cache_parse_key_and_fields(pool, - t_strdup_printf("%%u/%s", set->service_name), + t_strdup_printf("%"AUTH_CACHE_KEY_USER"\t%s", + set->service_name), &post_set->fields, "pam"); module->requests_left = set->max_requests; module->pam_setcred = set->setcred; diff --git a/src/auth/passdb-passwd.c b/src/auth/passdb-passwd.c index 1300315..22e2eae 100644 --- a/src/auth/passdb-passwd.c +++ b/src/auth/passdb-passwd.c @@ -10,7 +10,6 @@ #include "safe-memset.h" #include "ipwd.h" -#define PASSWD_CACHE_KEY "%u" #define PASSWD_PASS_SCHEME "CRYPT" #undef DEF @@ -142,7 +141,7 @@ static int passwd_preinit(pool_t pool, struct event *event, &post_set, error_r) < 0) return -1; module->default_cache_key = auth_cache_parse_key_and_fields(pool, - PASSWD_CACHE_KEY, + AUTH_CACHE_KEY_USER, &post_set->fields, "passwd"); settings_free(post_set); diff --git a/src/auth/userdb-passwd.c b/src/auth/userdb-passwd.c index 5241129..14cf90a 100644 --- a/src/auth/userdb-passwd.c +++ b/src/auth/userdb-passwd.c @@ -9,7 +9,6 @@ #include "ipwd.h" #include "time-util.h" -#define USER_CACHE_KEY "%u" #define PASSWD_SLOW_WARN_MSECS (10*1000) #define PASSWD_SLOW_MASTER_WARN_MSECS 50 #define PASSDB_SLOW_MASTER_WARN_COUNT_INTERVAL 100 @@ -225,7 +224,7 @@ static int passwd_preinit(pool_t pool, struct event *event ATTR_UNUSED, struct passwd_userdb_module *module = p_new(pool, struct passwd_userdb_module, 1); - module->module.default_cache_key = USER_CACHE_KEY; + module->module.default_cache_key = AUTH_CACHE_KEY_USER; *module_r = &module->module; return 0; }