]> dgit.raspbian.org Git - dovecot.git/commitdiff
[PATCH 09/12] config: Assume dovecot_config_version=0.0.0 is the same as the latest...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 29 Sep 2025 11:09:42 +0000 (14:09 +0300)
committerNoah Meyerhans <noahm@debian.org>
Wed, 16 Sep 2026 19:06:35 +0000 (15:06 -0400)
It's used for git builds.

Gbp-Pq: Name 0009-config-Assume-dovecot_config_version-0.0.0-is-the-sa.patch

src/config/config-parser.c
src/config/config-parser.h
src/config/doveconf.c

index b2883538aedcd500b2cd31b11f22f5968318f7e6..7e9db599f49a17761374c8ea4e3a0d0c16bca65c 100644 (file)
@@ -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);
        }
index 949aac100b5b175554f580e6a3b3a00172f689d7..f9d70f1be8b46538470d11c40ee0f479a6a879d7 100644 (file)
@@ -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 */
index 17dafbf00688d44802235416bf2259f1c4e6e819..825d84545c0223eaff829ca308ae0cd0260e1551 100644 (file)
@@ -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);