]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: When reporting errors in variable-strings, skip over the "0" prefix.
authorTimo Sirainen <tss@iki.fi>
Tue, 8 Sep 2009 22:45:27 +0000 (18:45 -0400)
committerTimo Sirainen <tss@iki.fi>
Tue, 8 Sep 2009 22:45:27 +0000 (18:45 -0400)
--HG--
branch : HEAD

src/config/config-parser.c
src/config/config-request.c
src/lib-settings/settings-parser.c
src/lib-settings/settings-parser.h

index ebd005d1cdc8c9e468a372caa0b88255f76ceb7c..7dc2ae9779747036e7c54a3b4224fc9ccaa1967a 100644 (file)
@@ -261,6 +261,7 @@ config_filter_parser_check(struct parser_context *ctx,
                           const char **error_r)
 {
        for (; p->module_name != NULL; p++) {
+               settings_parse_var_skip(p->parser);
                if (!settings_parser_check(p->parser, ctx->pool, error_r))
                        return -1;
        }
index a3ce2f3d9ff66de1ccc108b36727da5b9e2f5dc8..2686a13ff67775780070cc369821690a6305cbba 100644 (file)
@@ -271,6 +271,7 @@ int config_request_handle(const struct config_filter *filter,
                                settings_parser_get_changes(parser->parser));
 
                if (check_settings) {
+                       settings_parse_var_skip(parser->parser);
                        if (!settings_parser_check(parser->parser, ctx.pool,
                                                   &error)) {
                                i_error("%s", error);
index 2da926d62539f40fa1d375eacf3a01af4f2938b2..93087b1547559e10dd9650385671c7e272735126 100644 (file)
@@ -743,6 +743,42 @@ void settings_parse_set_expanded(struct setting_parser_context *ctx,
        ctx->str_vars_are_expanded = is_expanded;
 }
 
+void settings_parse_set_key_expandeded(struct setting_parser_context *ctx,
+                                      pool_t pool, const char *key)
+{
+       const struct setting_define *def;
+       struct setting_link *link;
+       const char **val;
+
+       if (!settings_find_key(ctx, key, &def, &link))
+               return;
+
+       val = PTR_OFFSET(link->set_struct, def->offset);
+       if (def->type == SET_STR_VARS && *val != NULL) {
+               i_assert(**val == SETTING_STRVAR_UNEXPANDED[0] ||
+                        **val == SETTING_STRVAR_EXPANDED[0]);
+               *val = p_strconcat(pool, SETTING_STRVAR_EXPANDED,
+                                  *val + 1, NULL);
+       }
+}
+
+void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx,
+                                       pool_t pool, const char *const *keys)
+{
+       for (; *keys != NULL; keys++)
+               settings_parse_set_key_expandeded(ctx, pool, *keys);
+}
+
+void settings_parse_var_skip(struct setting_parser_context *ctx)
+{
+       unsigned int i;
+
+       for (i = 0; i < ctx->root_count; i++) {
+               settings_var_expand(ctx->roots[i].info,
+                                   ctx->roots[i].set_struct, NULL, NULL);
+       }
+}
+
 static void
 settings_var_expand_info(const struct setting_parser_info *info,
                         pool_t pool, void *set,
@@ -761,7 +797,11 @@ settings_var_expand_info(const struct setting_parser_info *info,
                        if (*val == NULL)
                                break;
 
-                       if (**val == SETTING_STRVAR_UNEXPANDED[0]) {
+                       if (table == NULL) {
+                               i_assert(**val == SETTING_STRVAR_EXPANDED[0] ||
+                                        **val == SETTING_STRVAR_UNEXPANDED[0]);
+                               *val += 1;
+                       } else if (**val == SETTING_STRVAR_UNEXPANDED[0]) {
                                str_truncate(str, 0);
                                var_expand(str, *val + 1, table);
                                *val = p_strdup(pool, str_c(str));
@@ -791,32 +831,6 @@ settings_var_expand_info(const struct setting_parser_info *info,
        }
 }
 
-void settings_parse_set_key_expandeded(struct setting_parser_context *ctx,
-                                      pool_t pool, const char *key)
-{
-       const struct setting_define *def;
-       struct setting_link *link;
-       const char **val;
-
-       if (!settings_find_key(ctx, key, &def, &link))
-               return;
-
-       val = PTR_OFFSET(link->set_struct, def->offset);
-       if (def->type == SET_STR_VARS && *val != NULL) {
-               i_assert(**val == SETTING_STRVAR_UNEXPANDED[0] ||
-                        **val == SETTING_STRVAR_EXPANDED[0]);
-               *val = p_strconcat(pool, SETTING_STRVAR_EXPANDED,
-                                  *val + 1, NULL);
-       }
-}
-
-void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx,
-                                       pool_t pool, const char *const *keys)
-{
-       for (; *keys != NULL; keys++)
-               settings_parse_set_key_expandeded(ctx, pool, *keys);
-}
-
 void settings_var_expand(const struct setting_parser_info *info,
                         void *set, pool_t pool,
                         const struct var_expand_table *table)
index 0587f7450ba2e9892affec0bda1eb0433601c0c2..19de436d9caa7b8faeb0ab973f3feb28850f9281 100644 (file)
@@ -135,6 +135,10 @@ void settings_parse_set_key_expandeded(struct setting_parser_context *ctx,
                                       pool_t pool, const char *key);
 void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx,
                                        pool_t pool, const char *const *keys);
+/* Update variable string pointers to skip over the '1' or '0'.
+   This is mainly useful when you want to run settings_parser_check() without
+   actually knowing what the variables are. */
+void settings_parse_var_skip(struct setting_parser_context *ctx);
 /* Expand all unexpanded variables using the given table. Update the string
    pointers so that they can be used without skipping over the '1'. */
 void settings_var_expand(const struct setting_parser_info *info,