From: sergey.kitov Date: Fri, 20 Oct 2023 13:16:34 +0000 (+0300) Subject: auth: Change auth_realms to BOOLLIST. X-Git-Tag: 2.4.0~569 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad00b4f8a35449f32ae9e3a2a9237b8290f04f04;p=thirdparty%2Fdovecot%2Fcore.git auth: Change auth_realms to BOOLLIST. --- diff --git a/src/auth/auth-settings.c b/src/auth/auth-settings.c index 92db96689b..228fb0c388 100644 --- a/src/auth/auth-settings.c +++ b/src/auth/auth-settings.c @@ -336,7 +336,7 @@ const struct setting_parser_info auth_static_setting_parser_info = { static const struct setting_define auth_setting_defines[] = { DEF(BOOLLIST, mechanisms), - DEF(STR, realms), + DEF(BOOLLIST, realms), DEF(STR, default_domain), DEF(SIZE, cache_size), DEF(TIME, cache_ttl), @@ -404,7 +404,7 @@ static const struct setting_define auth_setting_defines[] = { }; static const struct auth_settings auth_default_settings = { - .realms = "", + .realms = ARRAY_INIT, .default_domain = "", .cache_size = 0, .cache_ttl = 60*60, @@ -630,8 +630,6 @@ static bool auth_settings_ext_check(struct event *event, void *_set, for (; *p != '\0' && p[1] != '\0'; p += 2) set->username_translation_map[(int)(uint8_t)*p] = p[1]; } - set->realms_arr = - (const char *const *)p_strsplit_spaces(pool, set->realms, " "); if (*set->policy_server_url != '\0') { if (*set->policy_hash_nonce == '\0') { diff --git a/src/auth/auth-settings.h b/src/auth/auth-settings.h index 7185684cae..ab7898e4de 100644 --- a/src/auth/auth-settings.h +++ b/src/auth/auth-settings.h @@ -66,7 +66,7 @@ struct auth_userdb_settings { struct auth_settings { pool_t pool; ARRAY_TYPE(const_string) mechanisms; - const char *realms; + ARRAY_TYPE(const_string) realms; const char *default_domain; uoff_t cache_size; unsigned int cache_ttl; @@ -120,7 +120,6 @@ struct auth_settings { ARRAY(const struct auth_userdb_settings *) parsed_userdbs; char username_chars_map[256]; char username_translation_map[256]; - const char *const *realms_arr; const struct ip_addr *proxy_self_ips; }; diff --git a/src/auth/mech-digest-md5.c b/src/auth/mech-digest-md5.c index d310f41538..35c8faa035 100644 --- a/src/auth/mech-digest-md5.c +++ b/src/auth/mech-digest-md5.c @@ -13,6 +13,7 @@ #include "str-sanitize.h" #include "mech.h" #include "passdb.h" +#include "settings-parser.h" /* Linear whitespace */ #define IS_LWS(c) ((c) == ' ' || (c) == '\t') @@ -51,12 +52,12 @@ static string_t *get_digest_challenge(struct digest_auth_request *request) request->nonce = p_strdup(request->pool, buf.data); str = t_str_new(256); - if (*set->realms_arr == NULL) { + if (array_is_empty(&set->realms)) { /* If no realms are given, at least Cyrus SASL client defaults to destination host name */ str_append(str, "realm=\"\","); } else { - for (tmp = set->realms_arr; *tmp != NULL; tmp++) + for (tmp = settings_boollist_get(&set->realms); *tmp != NULL; tmp++) str_printfa(str, "realm=\"%s\",", *tmp); }