]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings: Expand %variables for SETTINGS_OVERRIDE_TYPE_DEFAULT settings
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 9 Dec 2023 23:30:34 +0000 (01:30 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:10 +0000 (12:34 +0200)
src/lib-settings/settings.c

index 1b21b05a85033d6dc9583a37fb53fd541ea9bde4..c7c22f8900f7a0179d1569baecdc899a81fc397b 100644 (file)
@@ -1510,6 +1510,25 @@ settings_instance_override(struct settings_apply_ctx *ctx,
                if (set->pool == ctx->temp_pool)
                        settings_override_free(set);
 
+               if (set->type == SETTINGS_OVERRIDE_TYPE_DEFAULT &&
+                   (ctx->flags & SETTINGS_GET_FLAG_NO_EXPAND) == 0) {
+                       /* Expand %variables only for default settings.
+                          These defaults are usually handled already by the
+                          config process, but we get here with -O parameter
+                          or with SETTINGS_OVERRIDE_TYPE_2ND_DEFAULT. */
+                       const char *error;
+                       str_truncate(ctx->str, 0);
+                       if (var_expand_with_arrays(ctx->str, value, ctx->tables,
+                                                  ctx->func_tables,
+                                                  ctx->func_contexts,
+                                                  &error) <= 0 &&
+                           (ctx->flags & SETTINGS_GET_FLAG_FAKE_EXPAND) == 0) {
+                               i_panic("BUG: Failed to expand default setting %s=%s variables: %s",
+                                       key, value, error);
+                       }
+                       value = str_c(ctx->str);
+               }
+
                if (value != set->value)
                        value = p_strdup(&ctx->mpool->pool, value);
                else {