From: Timo Sirainen Date: Mon, 29 Sep 2025 11:09:42 +0000 (+0300) Subject: [PATCH 09/12] config: Assume dovecot_config_version=0.0.0 is the same as the latest... X-Git-Tag: archive/raspbian/1%2.4.1+dfsg1-6+rpi1+deb13u7^2~32 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=38de2782588e5dd46ea3b99f967db4e28652152e;p=dovecot.git [PATCH 09/12] config: Assume dovecot_config_version=0.0.0 is the same as the latest version It's used for git builds. Gbp-Pq: Name 0009-config-Assume-dovecot_config_version-0.0.0-is-the-sa.patch --- diff --git a/src/config/config-parser.c b/src/config/config-parser.c index b288353..7e9db59 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -2604,6 +2604,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) { @@ -2616,7 +2627,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 { @@ -2636,6 +2647,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 949aac1..f9d70f1 100644 --- a/src/config/config-parser.h +++ b/src/config/config-parser.h @@ -5,6 +5,9 @@ #define CONFIG_MODULE_DIR MODULEDIR"/settings" +#define CONFIG_VERSION_GIT "0.0.0" +#define CONFIG_VERSION_MAX "9999.9999.9999" + /* change_counter used for default settings created internally */ #define CONFIG_PARSER_CHANGE_DEFAULTS 1 /* change_counter used for settings changed by configuration file */ diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 17dafbf..825d845 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -1297,7 +1297,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);