From: Timo Sirainen Date: Mon, 8 Jan 2024 03:58:18 +0000 (-0500) Subject: lib-settings, config: Remove SET_FILTER_HIERARCHY X-Git-Tag: 2.4.1~1084 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=391a4c0b833457a89be278074cc6cd37478a5589;p=thirdparty%2Fdovecot%2Fcore.git lib-settings, config: Remove SET_FILTER_HIERARCHY Now that lib-fs is configured with named list filters, there is no more need for this type of a hierarchical setting. --- diff --git a/src/config/config-dump-full.c b/src/config/config-dump-full.c index bd73cb5a57..5c84a15b2a 100644 --- a/src/config/config-dump-full.c +++ b/src/config/config-dump-full.c @@ -78,23 +78,10 @@ static int output_blob_size(struct ostream *output, uoff_t blob_size_offset) return 0; } -static void -config_filter_write_hierarchical(string_t *str, - const struct config_filter *filter) -{ - if (filter == NULL || !filter->filter_hierarchical) - return; - if (str_len(str) > 0) - str_append_c(str, '/'); - str_append(str, filter->filter_name); - config_filter_write_hierarchical(str, filter->parent); -} - static void config_dump_full_append_filter_query(string_t *str, const struct config_filter *filter, - bool leaf, bool parent_hierarchical, - bool write_named_filters) + bool leaf, bool write_named_filters) { if (filter->service != NULL) { if (filter->service[0] != '!') { @@ -141,20 +128,7 @@ config_dump_full_append_filter_query(string_t *str, } else if (filter->filter_name != NULL) { const char *filter_name = filter->filter_name; - if (!parent_hierarchical && - filter->filter_hierarchical && - filter->parent->filter_hierarchical) { - /* beginning of a hierarchical filter. */ - string_t *str = t_str_new(128); - config_filter_write_hierarchical(str, filter); - filter_name = str_c(str); - } else if (parent_hierarchical && - filter->filter_hierarchical) { - /* hierarchical filter was already written. */ - return; - } - - if (write_named_filters || filter->filter_hierarchical) { + if (write_named_filters) { str_printfa(str, SETTINGS_EVENT_FILTER_NAME"=\"%s\" AND ", wildcard_str_escape(filter_name)); } @@ -167,14 +141,11 @@ config_dump_full_append_filter(string_t *str, bool write_named_filters) { bool leaf = TRUE; - bool parent_hierarchical = FALSE; do { config_dump_full_append_filter_query(str, filter, leaf, - parent_hierarchical, write_named_filters); leaf = FALSE; - parent_hierarchical = filter->filter_hierarchical; filter = filter->parent; } while (filter != NULL); diff --git a/src/config/config-filter.h b/src/config/config-filter.h index bd0ed4609d..915b5e6b56 100644 --- a/src/config/config-filter.h +++ b/src/config/config-filter.h @@ -22,10 +22,6 @@ struct config_filter { const char *filter_name; /* named_list_filter key { .. } */ bool filter_name_array; - /* This filter is hierarchical. If a child event is also hierarchical, - their filter_names will be merged into one filter path when dumping - the config. */ - bool filter_hierarchical; /* TRUE if default settings are being accessed. These will be stored in separate filters so they can be ordered before global settings. */ diff --git a/src/config/config-parser.c b/src/config/config-parser.c index 13cced9209..98e9ae15a5 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -405,7 +405,6 @@ settings_value_check(struct config_parser_context *ctx, case SET_FILTER_ARRAY: break; case SET_FILTER_NAME: - case SET_FILTER_HIERARCHY: ctx->error = p_strdup_printf(ctx->pool, "Setting is a named filter, use '%s {'", def->key); return -1; @@ -428,7 +427,6 @@ config_is_filter_name(struct config_parser_context *ctx, const char *key, def = &all_infos[config_key->info_idx]->defines[config_key->define_idx]; if (def->type != SET_FILTER_NAME && - def->type != SET_FILTER_HIERARCHY && def->type != SET_FILTER_ARRAY) return FALSE; @@ -687,8 +685,7 @@ again: /* Verify that this is a filter_name/ prefix. If not, it should be a list/ */ if (l->info->defines[config_key->define_idx].type != SET_FILTER_NAME && - l->info->defines[config_key->define_idx].type != SET_FILTER_ARRAY && - l->info->defines[config_key->define_idx].type != SET_FILTER_HIERARCHY) + l->info->defines[config_key->define_idx].type != SET_FILTER_ARRAY) break; filter.filter_name = @@ -1007,16 +1004,13 @@ config_filter_add_new_filter(struct config_parser_context *ctx, else filter.remote_host = p_strdup(ctx->pool, value); } else if (config_is_filter_name(ctx, key, &filter_def)) { - if (filter_def->type == SET_FILTER_NAME || - filter_def->type == SET_FILTER_HIERARCHY) { + if (filter_def->type == SET_FILTER_NAME) { if (value[0] != '\0' || value_quoted) { ctx->error = p_strdup_printf(ctx->pool, "%s { } must not have a section name", key); return TRUE; } - if (filter_def->type == SET_FILTER_HIERARCHY) - filter.filter_hierarchical = TRUE; filter.filter_name = p_strdup(ctx->pool, key); } else { if (strcmp(key, "namespace") == 0 && diff --git a/src/config/config-request.c b/src/config/config-request.c index 28e86ecd19..e6e5549e81 100644 --- a/src/config/config-request.c +++ b/src/config/config-request.c @@ -312,7 +312,6 @@ settings_export(struct config_export_context *ctx, break; } case SET_FILTER_NAME: - case SET_FILTER_HIERARCHY: case SET_ALIAS: break; } diff --git a/src/lib-settings/settings-parser.c b/src/lib-settings/settings-parser.c index 44c7143ae1..133780ed7d 100644 --- a/src/lib-settings/settings-parser.c +++ b/src/lib-settings/settings-parser.c @@ -570,7 +570,6 @@ settings_parse(struct setting_parser_context *ctx, break; } case SET_FILTER_NAME: - case SET_FILTER_HIERARCHY: settings_parser_set_error(ctx, t_strdup_printf( "Setting is a named filter, use '%s {'", key)); return -1; @@ -589,8 +588,7 @@ settings_find_key(struct setting_parser_context *ctx, const char *key, /* try to find the exact key */ def = setting_define_find(ctx->info, key); - if (def != NULL && ((def->type != SET_FILTER_NAME && - def->type != SET_FILTER_HIERARCHY) || + if (def != NULL && (def->type != SET_FILTER_NAME || allow_filter_name)) { *def_r = def; return TRUE; diff --git a/src/lib-settings/settings-parser.h b/src/lib-settings/settings-parser.h index 2ac181565d..b2488fee53 100644 --- a/src/lib-settings/settings-parser.h +++ b/src/lib-settings/settings-parser.h @@ -34,7 +34,6 @@ enum setting_type { SET_BOOLLIST, /* of type ARRAY_TYPE(const_string) - guaranteed NULL-terminted */ SET_ALIAS, /* alias name for above setting definition */ SET_FILTER_NAME, - SET_FILTER_HIERARCHY, SET_FILTER_ARRAY, }; enum setting_flags { diff --git a/src/lib-settings/settings.c b/src/lib-settings/settings.c index 48bb594452..23e1dcc9e6 100644 --- a/src/lib-settings/settings.c +++ b/src/lib-settings/settings.c @@ -1174,28 +1174,6 @@ settings_override_filter_match(struct settings_apply_ctx *ctx, SETTINGS_EVENT_FILTER_NAME, last_filter_key); break; - case SET_FILTER_HIERARCHY: { - /* add the full repeated hierarchy here */ - const char *next; - - str_printfa(filter_string, SETTINGS_EVENT_FILTER_NAME"=\"%s", - wildcard_str_escape(part)); - while (str_begins(p + 1, part, &next) && - next[0] == SETTINGS_SEPARATOR) { - str_append_c(filter_string, '/'); - str_append(filter_string, - wildcard_str_escape(part)); - p = next; - } - str_append_c(filter_string, '"'); - - last_filter_key = t_strdup_until(set->key, p); - last_filter_value = NULL; - event_add_str(set->filter_event, - SETTINGS_EVENT_FILTER_NAME, - last_filter_key); - break; - } case SET_FILTER_ARRAY: { const char *value = p + 1; p = strchr(value, SETTINGS_SEPARATOR);