From: Timo Sirainen Date: Wed, 26 Apr 2023 11:45:28 +0000 (+0300) Subject: config: Rename config_module_parser.error to delayed_error X-Git-Tag: 2.4.0~2109 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a4a40b682e42635fcf1749fbd1d2a7a83023068d;p=thirdparty%2Fdovecot%2Fcore.git config: Rename config_module_parser.error to delayed_error --- diff --git a/src/config/config-parser.c b/src/config/config-parser.c index eea6f2b58f..69f63cb0cf 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -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); diff --git a/src/config/config-parser.h b/src/config/config-parser.h index f0da95e060..593974c217 100644 --- a/src/config/config-parser.h +++ b/src/config/config-parser.h @@ -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 *); diff --git a/src/config/config-request.c b/src/config/config-request.c index 348063a4ca..be8dd263ca 100644 --- a/src/config/config-request.c +++ b/src/config/config-request.c @@ -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; }