]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Log a warning about plugin { ...=no } probably being treated as "yes"
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 10 Aug 2017 07:23:32 +0000 (10:23 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 10 Aug 2017 07:23:32 +0000 (10:23 +0300)
This is properly fixed in v2.3. This should be good enough for now.

src/config/config-parser-private.h
src/config/config-parser.c
src/config/old-set-parser.c

index d7e3ee1f7f5a9c49db6449f6fe82a612c9887b4d..03aee3c2ba538cd0e428037fd0647a50273e422e 100644 (file)
@@ -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,
index be0f6c7d6e4d20204bb51d9598314d3949fedcf1..b7c569339abc67a66fc04b10fcb0b53e91b0e9b3 100644 (file)
@@ -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)
index e6fd008e770a93ee27657626344c89ac4b736ae6..72a204db410e6da2c5aebb56a9d3e95dd8972731 100644 (file)
@@ -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;