From b89841dce2d4995b00d3bed41d7f55dd323e4ff8 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 9 Apr 2025 14:11:42 +0300 Subject: [PATCH] [PATCH 12/12] config: doveconf -dF - Add dovecot_storage_version Gbp-Pq: Name 0012-config-doveconf-dF-Add-dovecot_storage_version.patch --- src/config/config-parser.c | 14 ++++++++++++++ src/config/config-parser.h | 3 +++ src/config/doveconf.c | 2 ++ 3 files changed, 19 insertions(+) diff --git a/src/config/config-parser.c b/src/config/config-parser.c index dbbe91e..f9920da 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -2958,6 +2958,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) : diff --git a/src/config/config-parser.h b/src/config/config-parser.h index f9d70f1..976aede 100644 --- a/src/config/config-parser.h +++ b/src/config/config-parser.h @@ -40,6 +40,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 diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 825d845..ddc055f 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -1234,6 +1234,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, -- 2.39.5