]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
settings: If file has var-expand template in path, expand before opening it
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 2 Jan 2025 08:16:33 +0000 (10:16 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:02 +0000 (10:40 +0200)
src/lib-settings/settings-parser.c

index c5e8941b0e19667579d91925f9a3cec6aa6b6925..b52d699fddd06b3b06608d98abb53c8026b8ed84 100644 (file)
@@ -6,6 +6,7 @@
 #include "str.h"
 #include "str-parse.h"
 #include "read-full.h"
+#include "var-expand.h"
 #include "settings-parser.h"
 
 #include <sys/stat.h>
@@ -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