From: Aki Tuomi Date: Thu, 2 Jan 2025 08:16:33 +0000 (+0200) Subject: settings: If file has var-expand template in path, expand before opening it X-Git-Tag: 2.4.0~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ded5640cc751b1c243e819e230c986a6cd44fa37;p=thirdparty%2Fdovecot%2Fcore.git settings: If file has var-expand template in path, expand before opening it --- diff --git a/src/lib-settings/settings-parser.c b/src/lib-settings/settings-parser.c index c5e8941b0e..b52d699fdd 100644 --- a/src/lib-settings/settings-parser.c +++ b/src/lib-settings/settings-parser.c @@ -6,6 +6,7 @@ #include "str.h" #include "str-parse.h" #include "read-full.h" +#include "var-expand.h" #include "settings-parser.h" #include @@ -685,6 +686,14 @@ settings_parse(struct setting_parser_context *ctx, *((const char **)ptr) = value; break; case SET_FILE: { + /* only expand first line, if there */ + const char *path = t_strcut(value, '\n'); + if (strstr(path, "%{") != NULL) { + if (t_var_expand(value, NULL, &value, &error) < 0) { + settings_parser_set_error(ctx, error); + return -1; + } + } /* Read the file directly to get the content */ if (get_file(ctx, dup_value, &value) < 0) { /* We may be running settings_check()s in doveconf at a