From: Timo Sirainen Date: Thu, 10 Aug 2017 07:23:32 +0000 (+0300) Subject: config: Log a warning about plugin { ...=no } probably being treated as "yes" X-Git-Tag: 2.2.32.rc1~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5085e52a03e91f320e43a103bc4ee8969b2c0da;p=thirdparty%2Fdovecot%2Fcore.git config: Log a warning about plugin { ...=no } probably being treated as "yes" This is properly fixed in v2.3. This should be good enough for now. --- diff --git a/src/config/config-parser-private.h b/src/config/config-parser-private.h index d7e3ee1f7f..03aee3c2ba 100644 --- a/src/config/config-parser-private.h +++ b/src/config/config-parser-private.h @@ -9,6 +9,7 @@ enum config_line_type { CONFIG_LINE_TYPE_CONTINUE, CONFIG_LINE_TYPE_ERROR, CONFIG_LINE_TYPE_KEYVALUE, + CONFIG_LINE_TYPE_KEYVALUE_QUOTED, CONFIG_LINE_TYPE_KEYFILE, CONFIG_LINE_TYPE_KEYVARIABLE, CONFIG_LINE_TYPE_SECTION_BEGIN, diff --git a/src/config/config-parser.c b/src/config/config-parser.c index be0f6c7d6e..b7c569339a 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -679,10 +679,12 @@ config_parse_line(struct config_parser_context *ctx, ((*line == '"' && line[len-1] == '"') || (*line == '\'' && line[len-1] == '\''))) { line[len-1] = '\0'; - line = str_unescape(line+1); + *value_r = str_unescape(line+1); + return CONFIG_LINE_TYPE_KEYVALUE_QUOTED; + } else { + *value_r = line; + return CONFIG_LINE_TYPE_KEYVALUE; } - *value_r = line; - return CONFIG_LINE_TYPE_KEYVALUE; } if (strcmp(key, "}") == 0 && *line == '\0') @@ -807,6 +809,7 @@ static int config_write_value(struct config_parser_context *ctx, switch (type) { case CONFIG_LINE_TYPE_KEYVALUE: + case CONFIG_LINE_TYPE_KEYVALUE_QUOTED: str_append(str, value); break; case CONFIG_LINE_TYPE_KEYFILE: @@ -868,10 +871,22 @@ static int config_write_value(struct config_parser_context *ctx, } static void -config_parser_check_warnings(struct config_parser_context *ctx, const char *key) +config_parser_check_warnings(struct config_parser_context *ctx, + enum config_line_type type, + const char *key, const char *value) { const char *path, *first_pos; + if (strncmp(str_c(ctx->str), "plugin/", 7) == 0 && + strcasecmp(value, "no") == 0 && + type == CONFIG_LINE_TYPE_KEYVALUE) { + i_warning("%s line %u: plugin { %s=%s } is most likely handled as 'yes' - " + "remove the setting completely to disable it. " + "If this is intentional, add quotes around the value: %s=\"%s\"", + ctx->cur_input->path, ctx->cur_input->linenum, + key, value, key, value); + } + first_pos = hash_table_lookup(ctx->seen_settings, str_c(ctx->str)); if (ctx->cur_section->prev == NULL) { /* changing a root setting. if we've already seen it inside @@ -908,10 +923,11 @@ void config_parser_apply_line(struct config_parser_context *ctx, ctx->error = p_strdup(ctx->pool, value); break; case CONFIG_LINE_TYPE_KEYVALUE: + case CONFIG_LINE_TYPE_KEYVALUE_QUOTED: case CONFIG_LINE_TYPE_KEYFILE: case CONFIG_LINE_TYPE_KEYVARIABLE: str_append(ctx->str, key); - config_parser_check_warnings(ctx, key); + config_parser_check_warnings(ctx, type, key, value); str_append_c(ctx->str, '='); if (config_write_value(ctx, type, key, value) < 0) diff --git a/src/config/old-set-parser.c b/src/config/old-set-parser.c index e6fd008e77..72a204db41 100644 --- a/src/config/old-set-parser.c +++ b/src/config/old-set-parser.c @@ -587,6 +587,7 @@ bool old_settings_handle(struct config_parser_context *ctx, case CONFIG_LINE_TYPE_KEYVARIABLE: break; case CONFIG_LINE_TYPE_KEYVALUE: + case CONFIG_LINE_TYPE_KEYVALUE_QUOTED: if (ctx->pathlen == 0) { struct config_section_stack *old_section = ctx->cur_section;