From: Timo Sirainen Date: Mon, 29 Sep 2025 11:09:42 +0000 (+0300) Subject: config: Assume dovecot_config_version=0.0.0 is the same as the latest version X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3612c5ed51acb43c8142713c64cad6cc4234d4d6;p=thirdparty%2Fdovecot%2Fcore.git config: Assume dovecot_config_version=0.0.0 is the same as the latest version It's used for git builds. --- diff --git a/src/config/config-parser.c b/src/config/config-parser.c index 373cd13657..ba19506801 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -2959,6 +2959,17 @@ static bool config_version_find(const char *version, const char **error_r) return TRUE; } +static bool +dovecot_config_version_equals(struct config_parser_context *ctx, const char *value) +{ + if (strcmp(ctx->dovecot_config_version, value) == 0) + return TRUE; + if (strcmp(ctx->dovecot_config_version, CONFIG_VERSION_MAX) == 0 && + strcmp(value, CONFIG_VERSION_GIT) == 0) + return TRUE; + return FALSE; +} + static bool config_parser_get_version(struct config_parser_context *ctx, const struct config_line *line) { @@ -2971,7 +2982,7 @@ static bool config_parser_get_version(struct config_parser_context *ctx, if (strcmp(line->key, "dovecot_config_version") == 0) { if (ctx->dovecot_config_version == NULL) ; - else if (strcmp(ctx->dovecot_config_version, line->value) != 0) { + else if (!dovecot_config_version_equals(ctx, line->value)) { ctx->error = "dovecot_config_version value can't be changed once set"; return TRUE; } else { @@ -2991,6 +3002,9 @@ static bool config_parser_get_version(struct config_parser_context *ctx, else if (!config_version_find(line->value, &error)) { ctx->error = p_strdup_printf(ctx->pool, "Invalid dovecot_config_version: %s", error); + } else if (strcmp(line->value, CONFIG_VERSION_GIT) == 0) { + /* git build - this is the same as the latest version. */ + ctx->dovecot_config_version = CONFIG_VERSION_MAX; } else { ctx->dovecot_config_version = p_strdup(ctx->pool, line->value); } diff --git a/src/config/config-parser.h b/src/config/config-parser.h index 1c203ac2be..7a99c25a45 100644 --- a/src/config/config-parser.h +++ b/src/config/config-parser.h @@ -7,6 +7,9 @@ #define CONFIG_MODULE_DIR MODULEDIR"/settings" +#define CONFIG_VERSION_GIT "0.0.0" +#define CONFIG_VERSION_MAX "9999.9999.9999" + #define CONFIG_PARSER_CHANGE_GROUP 1 /* change_counter used for default settings created internally */ #define CONFIG_PARSER_CHANGE_DEFAULTS 2 diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 59706a4ee9..d84a317b26 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -1329,7 +1329,15 @@ int main(int argc, char *argv[]) printf("# %u default setting changes since version %s\n", count, version); } - printf("dovecot_config_version = %s\n", version); + if (strcmp(version, CONFIG_VERSION_MAX) != 0) + printf("dovecot_config_version = %s\n", version); + else { + /* GIT version was changed to MAX for easier + comparisons internally. However, output it + back as the original GIT version. */ + printf("dovecot_config_version = %s\n", + CONFIG_VERSION_GIT); + } } if (!config_path_specified) check_wrong_config(config_path);