export_ctx = config_export_init(
CONFIG_DUMP_SCOPE_SET_AND_DEFAULT_OVERRIDES,
0, ctx->dovecot_config_version,
+ config_filter_get_path_prefix(&filter->filter),
config_dump_full_stdout_callback, &dump_ctx);
} else {
export_ctx = config_export_init(
CONFIG_DUMP_SCOPE_SET_AND_DEFAULT_OVERRIDES,
0, ctx->dovecot_config_version,
+ config_filter_get_path_prefix(&filter->filter),
config_dump_full_callback, &dump_ctx);
}
config_export_set_module_parsers(export_ctx,
if (dest == CONFIG_DUMP_FULL_DEST_STDOUT) {
export_ctx = config_export_init(
CONFIG_DUMP_SCOPE_SET_AND_DEFAULT_OVERRIDES,
- flags, dovecot_config_version,
+ flags, dovecot_config_version, "",
config_dump_full_stdout_callback, &dump_ctx);
} else {
export_ctx = config_export_init(
CONFIG_DUMP_SCOPE_SET_AND_DEFAULT_OVERRIDES,
- flags, dovecot_config_version,
+ flags, dovecot_config_version, "",
config_dump_full_callback, &dump_ctx);
}
struct config_filter_parser *filter_parser =
#include "lib.h"
#include "array.h"
+#include "str.h"
#include "crc32.h"
#include "settings-parser.h"
#include "master-service-settings.h"
{
return config_filters_equal(filter, &empty_defaults_filter);
}
+
+static void
+config_filter_get_path_str(string_t **path, const struct config_filter *filter)
+{
+ if (filter->parent != NULL)
+ config_filter_get_path_str(path, filter->parent);
+ if (filter->filter_name != NULL) {
+ if (*path == NULL)
+ *path = t_str_new(128);
+ str_append(*path, filter->filter_name);
+ str_append_c(*path, '/');
+ }
+}
+
+const char *config_filter_get_path_prefix(const struct config_filter *filter)
+{
+ string_t *path = NULL;
+ config_filter_get_path_str(&path, filter);
+ return path == NULL ? "" : str_c(path);
+}
default_settings=TRUE. */
bool config_filter_is_empty_defaults(const struct config_filter *filter);
+/* Return path prefix of named [list] filters. */
+const char *config_filter_get_path_prefix(const struct config_filter *filter);
+
#endif
HASH_TABLE(const char *, const char *) keys;
enum config_dump_scope scope;
const char *dovecot_config_version;
+ const char *path_prefix;
config_request_callback_t *callback;
void *context;
if (module_parser->change_counters[define_idx] <= CONFIG_PARSER_CHANGE_DEFAULTS) {
/* Setting isn't explicitly set. We need to see
if its default has changed. */
+ const char *key_with_path = def->key;
+ if (ctx->path_prefix[0] != '\0') {
+ key_with_path = t_strconcat(
+ ctx->path_prefix, def->key, NULL);
+ }
if (old_settings_default(ctx->dovecot_config_version,
- def->key, &old_default)) {
+ def->key, key_with_path,
+ &old_default)) {
default_str = t_str_new(strlen(old_default));
str_append(default_str, old_default);
default_changed = TRUE;
struct config_export_context *
config_export_init(enum config_dump_scope scope,
enum config_dump_flags flags,
- const char *dovecot_config_version,
+ const char *dovecot_config_version, const char *path_prefix,
config_request_callback_t *callback, void *context)
{
struct config_export_context *ctx;
ctx->context = context;
ctx->scope = scope;
ctx->dovecot_config_version = p_strdup(pool, dovecot_config_version);
+ ctx->path_prefix = p_strdup(pool, path_prefix);
ctx->value = str_new(pool, 256);
if ((ctx->flags & CONFIG_DUMP_FLAG_DEDUPLICATE_KEYS) != 0)
hash_table_create(&ctx->keys, ctx->pool, 0, str_hash, strcmp);
struct config_export_context *
config_export_init(enum config_dump_scope scope,
enum config_dump_flags flags,
- const char *dovecot_config_version,
+ const char *dovecot_config_version, const char *path_prefix,
config_request_callback_t *callback, void *context)
ATTR_NULL(1, 5);
-#define config_export_init(scope, flags, version, callback, context) \
- config_export_init(scope, flags, version, \
+#define config_export_init(scope, flags, version, path_prefix, callback, context) \
+ config_export_init(scope, flags, version, path_prefix, \
(config_request_callback_t *)callback, \
TRUE ? context : CALLBACK_TYPECHECK(callback, \
void (*)(const struct config_export_setting *, typeof(context))))
flags = CONFIG_DUMP_FLAG_DEDUPLICATE_KEYS;
ctx->export_ctx = config_export_init(scope, flags,
- dovecot_config_version,
- config_request_get_strings, ctx);
+ dovecot_config_version,
+ config_filter_get_path_prefix(&filter_parser->filter),
+ config_request_get_strings, ctx);
config_export_set_module_parsers(ctx->export_ctx,
filter_parser->module_parsers);
return ctx;
}
bool old_settings_default(const char *dovecot_config_version,
- const char *key, const char **old_default_r)
+ const char *key, const char *key_with_path,
+ const char **old_default_r)
{
struct settings_history *history = settings_history_get();
const struct setting_history_default *def;
array_foreach(&history->defaults, def) {
if (version_cmp(def->version, dovecot_config_version) <= 0)
break;
- if (strcmp(def->key, key) == 0) {
+ if (strcmp(def->key, key) == 0 ||
+ strcmp(def->key, key_with_path) == 0) {
*old_default_r = def->old_value;
return TRUE;
}
void old_settings_handle(struct config_parser_context *ctx,
struct config_line *line);
bool old_settings_default(const char *dovecot_config_version,
- const char *key, const char **old_default_r);
+ const char *key, const char *key_with_path,
+ const char **old_default_r);
#endif