]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings: Add */key=value override filter that applies to all named list filters
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 28 Dec 2023 20:46:32 +0000 (15:46 -0500)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:10 +0000 (12:34 +0200)
Normally key=value overrides only the global settings, not settings inside
named list filters. Using */key makes it override everything.

src/lib-settings/settings.c

index 5c22f3bdc22450a1e6a174bc8d375c0869c0a998..6c86a410204128d905897958b32281ec75c1bc4f 100644 (file)
@@ -37,6 +37,8 @@ struct settings_override {
        /* TRUE once all the filter elements have been processed in "key",
           and it points to a non-filter suffix of the path. */
        bool filter_finished;
+       /* Always apply this override, regardless of any filters. */
+       bool always_match;
        /* Original key for the overridden setting, e.g.
           namespace/inbox/mailbox/Sent/mail_attribute/dict_driver */
        const char *orig_key;
@@ -1134,6 +1136,12 @@ settings_override_filter_match(struct settings_apply_ctx *ctx,
                           with all filters, which otherwise wouldn't be
                           visible to the settings override code. */
                        set_type = SET_FILTER_NAME;
+               } else if (strcmp(part, "*") == 0 && set->filter == NULL) {
+                       /* always match, also for any named list filters */
+                       set->filter_finished = TRUE;
+                       set->always_match = TRUE;
+                       set->key = p + 1;
+                       return 1;
                } else {
                        filter_finished = FALSE;
                        break;
@@ -1349,7 +1357,7 @@ settings_instance_override(struct settings_apply_ctx *ctx,
                /* If we're being called while applying filters, only apply
                   the overrides that have a matching filter. This preserves
                   the expected order in which settings are applied. */
-               if (event_filter != NULL &&
+               if (event_filter != NULL && !set->always_match &&
                    (set->filter_event == NULL ||
                     !event_filter_match(event_filter, set->filter_event,
                                         &failure_ctx)))