]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Rename config_module_parser.error to delayed_error
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 26 Apr 2023 11:45:28 +0000 (14:45 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:21:55 +0000 (14:21 +0200)
src/config/config-parser.c
src/config/config-parser.h
src/config/config-request.c

index eea6f2b58fbf095c131377a0745ac68245103a5e..69f63cb0cf6d343dd22d4d161384f14830303c44 100644 (file)
@@ -164,10 +164,13 @@ config_apply_error(struct config_parser_context *ctx, const char *key)
        enum setting_type type;
        bool found = FALSE;
 
+       /* Couldn't get value for the setting, but we're delaying error
+          handling. Mark all settings parsers containing this key as failed.
+          See config-parser.h for details. */
        for (l = ctx->cur_section->parsers; l->root != NULL; l++) {
                if (settings_parse_get_value(l->parser, key, &type) != NULL) {
-                       if (l->error == NULL)
-                               l->error = ctx->error;
+                       if (l->delayed_error == NULL)
+                               l->delayed_error = ctx->error;
                        ctx->error = NULL;
                        found = TRUE;
                }
@@ -400,8 +403,11 @@ config_filter_parser_check(struct config_parser_context *ctx,
                                pool_unref(&tmp_pool);
                                return -1;
                        }
-                       if (p->error == NULL)
-                               p->error = p_strdup(ctx->pool, error);
+                       /* Settings checking failed, but we're delaying the
+                          error until the settings struct is used by the
+                          client side. See config-parser.h */
+                       if (p->delayed_error == NULL)
+                               p->delayed_error = p_strdup(ctx->pool, error);
                }
        }
        pool_unref(&tmp_pool);
index f0da95e060e02e4f6979693e8ef5b8f35b156a0c..593974c217e993ccf587e4e23b637891b51fa985 100644 (file)
@@ -17,7 +17,13 @@ struct config_module_parser {
        const struct setting_parser_info *root;
        struct setting_parser_context *parser;
        void *settings;
-       const char *error;
+       /* Set if CONFIG_PARSE_FLAG_DELAY_ERRORS is enabled. The error won't
+          cause an immediate config parsing failure. Instead, the error string
+          is forwarded to the config client process, which errors out only if
+          the settings struct is attempted to be used. This allows for example
+          doveadm to be called non-root and not fail even if it can't access
+          ssl_key file. */
+       const char *delayed_error;
 };
 ARRAY_DEFINE_TYPE(config_module_parsers, struct config_module_parser *);
 
index 348063a4ca251634d5e3fe345508932fa1570f22..be8dd263cacbcde1feef80465f9448c66e7c556f 100644 (file)
@@ -512,8 +512,8 @@ int config_export_parser(struct config_export_context *ctx,
        const struct config_module_parser *parser = &ctx->parsers[parser_idx];
        int ret = 0;
 
-       if (parser->error != NULL) {
-               *error_r = parser->error;
+       if (parser->delayed_error != NULL) {
+               *error_r = parser->delayed_error;
                return -1;
        }