]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Assume dovecot_config_version=0.0.0 is the same as the latest version
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 29 Sep 2025 11:09:42 +0000 (14:09 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 1 Oct 2025 06:23:12 +0000 (06:23 +0000)
It's used for git builds.

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

index 373cd13657c1700d9096382c85957b125db6d20f..ba1950680165494c8772bc7bdef8212b8f3e4708 100644 (file)
@@ -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);
        }
index 1c203ac2be218da197b16c702cd73c8bf4030f24..7a99c25a4521273f91f9b86ecd891efe4611ec32 100644 (file)
@@ -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
index 59706a4ee99d74a7db9a5fa747db190e96b70e63..d84a317b268cb4906603aa2614de7a03ee23194d 100644 (file)
@@ -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);