]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Change auth_realms to BOOLLIST.
authorsergey.kitov <sergey.kitov@open-xchange.com>
Fri, 20 Oct 2023 13:16:34 +0000 (16:16 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:39:59 +0000 (10:39 +0200)
src/auth/auth-settings.c
src/auth/auth-settings.h
src/auth/mech-digest-md5.c

index 92db96689b7ce732a2eff3711c75153fefb0c6ff..228fb0c3884a8767ac5f14a99a36ccd100eeabbc 100644 (file)
@@ -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') {
index 7185684cae8adef7515763cce70b4adc634b5386..ab7898e4de7b741cddc3239f76af9d7c55657b21 100644 (file)
@@ -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;
 };
 
index d310f4153887fd7ac52b05b22f2c3d108ea322ff..35c8faa0359077abd29fc66faaaa9e394e6345e1 100644 (file)
@@ -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);
        }