]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: doveconf -dF - Add dovecot_storage_version
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 9 Apr 2025 11:11:42 +0000 (14:11 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 12 May 2025 15:51:47 +0000 (15:51 +0000)
src/config/config-parser.c
src/config/config-parser.h
src/config/doveconf.c

index 42eb82bbb1c775282cd800bea4f616e2e095ffde..288d5923acef9ab523789ef581dbe75f8420cce8 100644 (file)
@@ -3077,6 +3077,20 @@ int config_parse_file(const char *path, enum config_parse_flags flags,
                hook_config_parser_begin(&ctx);
        } T_END;
 
+       if ((flags & CONFIG_PARSE_FLAG_DEFAULT_VERSION) != 0) {
+               /* Use default settings. Set dovecot_storage_version to the
+                  latest version, so it won't cause a failure.
+
+                  When building from git we don't know the latest version, so
+                  just use 9999. The version validity checks are disabled for
+                  git builds, so this should work. */
+               const char *version = version_is_valid(DOVECOT_VERSION) ?
+                       DOVECOT_VERSION : "9999";
+               if (config_apply_exact_line(&ctx, NULL, "dovecot_storage_version",
+                                           version) < 0)
+                       i_panic("Couldn't set default dovecot_storage_version: %s", ctx.error);
+       }
+
        internal.path = "Internal config_import";
        ctx.cur_input->input = config_import == NULL ?
                i_stream_create_from_data("", 0) :
index f7c5d08a280990214de9bb54b69a041c702dac3a..be0714e9185af1138d5357780509d4dfe06ed6d8 100644 (file)
@@ -37,6 +37,9 @@ enum config_parse_flags {
        CONFIG_PARSE_FLAG_MERGE_DEFAULT_FILTERS = BIT(9),
        /* Ignore unknown settings in the config file. */
        CONFIG_PARSE_FLAG_IGNORE_UNKNOWN = BIT(10),
+       /* Executing "doveconf -dF" - add default dovecot_storage_version
+          setting. */
+       CONFIG_PARSE_FLAG_DEFAULT_VERSION = BIT(11),
 };
 
 /* Used to track changed settings for a setting_parser_info. Initially only
index 64ed3a9951442d6e2a5419b9cf692e8f3a9a7d84..a87c68a1f466213d64780d14978178731d161485 100644 (file)
@@ -1261,6 +1261,8 @@ int main(int argc, char *argv[])
                flags |= CONFIG_PARSE_FLAG_DELAY_ERRORS;
        if (exec_args == NULL)
                flags |= CONFIG_PARSE_FLAG_EXTERNAL_HOOKS;
+       else if (dump_defaults)
+               flags |= CONFIG_PARSE_FLAG_DEFAULT_VERSION;
        T_BEGIN {
                ret = config_parse_file(dump_defaults ? NULL : config_path,
                        flags, have_dump_filter ? &dump_filter : NULL,