]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict-ldap: dict_ldap_map_settings - Rename pattern to parsed_pattern
authorMarco Bettini <marco.bettini@open-xchange.com>
Thu, 3 Oct 2024 13:42:47 +0000 (13:42 +0000)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:01 +0000 (10:40 +0200)
src/lib-dict-backend/dict-ldap-settings.c
src/lib-dict-backend/dict-ldap-settings.h
src/lib-dict-backend/dict-ldap.c

index 51529c072b99d55906145dfb02cd6d22ae76d199..2eb2209a28615d576ca8e81f4346cc21b21fb21c 100644 (file)
@@ -43,7 +43,7 @@ struct setting_parser_ctx {
 #define DEF_UINT(name) DEF_STRUCT_UINT(name ,dict_ldap_map_settings)
 
 static const struct setting_def dict_ldap_map_setting_defs[] = {
-       DEF_STR(pattern),
+       DEF_STR(parsed_pattern),
        DEF_STR(filter),
        DEF_STR(username_attribute),
        DEF_STR(value_attribute),
@@ -88,11 +88,11 @@ static const char *dict_ldap_attributes_map(struct setting_parser_ctx *ctx)
 
        /* go through the variables in the pattern, replace them with plain
           '$' character and add its ldap attribute */
-       pattern = t_str_new(strlen(ctx->cur_map.pattern) + 1);
+       pattern = t_str_new(strlen(ctx->cur_map.parsed_pattern) + 1);
        attributes = array_get_modifiable(&ctx->cur_attributes, &count);
 
        p_array_init(&ctx->cur_map.parsed_pattern_keys, ctx->pool, count);
-       for (p = ctx->cur_map.pattern; *p != '\0';) {
+       for (p = ctx->cur_map.parsed_pattern; *p != '\0';) {
                if (*p != '$') {
                        str_append_c(pattern, *p);
                        p++;
@@ -126,13 +126,13 @@ static const char *dict_ldap_attributes_map(struct setting_parser_ctx *ctx)
                }
        }
 
-       ctx->cur_map.pattern = p_strdup(ctx->pool, str_c(pattern));
+       ctx->cur_map.parsed_pattern = p_strdup(ctx->pool, str_c(pattern));
        return NULL;
 }
 
 static const char *dict_ldap_map_finish(struct setting_parser_ctx *ctx)
 {
-       if (ctx->cur_map.pattern == NULL)
+       if (ctx->cur_map.parsed_pattern == NULL)
                return "Missing setting: pattern";
        if (ctx->cur_map.filter == NULL)
                ctx->cur_map.filter = dict_ldap_empty_filter;
@@ -163,7 +163,7 @@ static const char *dict_ldap_map_finish(struct setting_parser_ctx *ctx)
        if (!array_is_created(&ctx->cur_map.parsed_pattern_keys)) {
                /* no attributes besides value. allocate the array anyway. */
                p_array_init(&ctx->cur_map.parsed_pattern_keys, ctx->pool, 1);
-               if (strchr(ctx->cur_map.pattern, '$') != NULL)
+               if (strchr(ctx->cur_map.parsed_pattern, '$') != NULL)
                        return "Missing attributes for pattern variables";
        }
        array_push_back(&ctx->set->parsed_maps, &ctx->cur_map);
index e75bb1bc2d95c69703b84b3d8deee3d6f78672aa..5f78fcee4ed736cf48e8fa1ae77a6df41a32aa70 100644 (file)
@@ -2,9 +2,6 @@
 #define DICT_LDAP_SETTINGS_H
 
 struct dict_ldap_map_settings {
-       /* pattern is in simplified form: all variables are stored as simple
-          '$' character. fields array is sorted by the variable index. */
-       const char *pattern;
        const char *filter;
        const char *username_attribute;
        const char *value_attribute;
@@ -15,6 +12,9 @@ struct dict_ldap_map_settings {
        /* parsed */
        ARRAY_TYPE(const_string) parsed_pattern_keys;
        int parsed_scope;
+
+       /* the variables are in the same order as parsed_pattern_keys. */
+       const char *parsed_pattern;
 };
 
 struct dict_ldap_settings {
index 25b644d2a33c8df363495bb01e9d8cee083296ab..c051ec138ea066032e6c251ad60a7f954f665796 100644 (file)
@@ -65,7 +65,7 @@ dict_ldap_map_match(const struct dict_ldap_map_settings *map, const char *path,
        size_t len;
 
        array_clear(values);
-       pat = map->pattern;
+       pat = map->parsed_pattern;
        while (*pat != '\0' && *path != '\0') {
                if (*pat == '$') {
                        /* variable */