dovecot-2.2: lib-settings: settings_parser_apply_changes() now d...
dovecot at dovecot.org
dovecot at dovecot.org
Sun May 20 03:26:29 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/bb8387e6b18f
changeset: 14365:bb8387e6b18f
user: Timo Sirainen <tss at iki.fi>
date: Wed Mar 21 18:58:37 2012 +0200
description:
lib-settings: settings_parser_apply_changes() now deduplicates SET_STRLIST arrays.
This fixes overriding strlist keys in config file filters, e.g.:
plugin {
foo = general
}
protocol lda {
plugin {
foo = lda-specific setting
}
}
diffstat:
src/lib-settings/settings-parser.c | 20 +++++++++++++++++---
src/lib-settings/settings-parser.h | 6 +++++-
2 files changed, 22 insertions(+), 4 deletions(-)
diffs (55 lines):
diff -r 3599790da3d7 -r bb8387e6b18f src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c Wed Mar 21 14:25:12 2012 +0200
+++ b/src/lib-settings/settings-parser.c Wed Mar 21 18:58:37 2012 +0200
@@ -1379,18 +1379,32 @@
case SET_STRLIST: {
const ARRAY_TYPE(const_string) *src_arr = src;
ARRAY_TYPE(const_string) *dest_arr = dest;
- const char *const *strings, *dup;
- unsigned int i, count;
+ const char *const *strings, *const *dest_strings, *dup;
+ unsigned int i, j, count, dest_count;
if (!array_is_created(src_arr))
break;
strings = array_get(src_arr, &count);
+ i_assert(count % 2 == 0);
if (!array_is_created(dest_arr))
p_array_init(dest_arr, pool, count);
- for (i = 0; i < count; i++) {
+ dest_count = array_count(dest_arr);
+ i_assert(dest_count % 2 == 0);
+ for (i = 0; i < count; i += 2) {
+ if (dest_count > 0) {
+ dest_strings = array_idx(dest_arr, 0);
+ for (j = 0; j < dest_count; j += 2) {
+ if (strcmp(strings[i], dest_strings[j]) == 0)
+ break;
+ }
+ if (j < dest_count)
+ continue;
+ }
dup = p_strdup(pool, strings[i]);
array_append(dest_arr, &dup, 1);
+ dup = p_strdup(pool, strings[i+1]);
+ array_append(dest_arr, &dup, 1);
}
break;
}
diff -r 3599790da3d7 -r bb8387e6b18f src/lib-settings/settings-parser.h
--- a/src/lib-settings/settings-parser.h Wed Mar 21 14:25:12 2012 +0200
+++ b/src/lib-settings/settings-parser.h Wed Mar 21 18:58:37 2012 +0200
@@ -208,7 +208,11 @@
/* Copy changed settings from src to dest. If conflict_key_r is not NULL and
both src and dest have changed the same setting, return -1 and set the
- key name. If it's NULL, the old setting is kept. */
+ key name. If it's NULL, the old setting is kept.
+
+ KLUDGE: For SET_STRLIST types if both source and destination have identical
+ keys, the duplicates in the source side are ignored. This is required to
+ make the current config code work correctly. */
int settings_parser_apply_changes(struct setting_parser_context *dest,
const struct setting_parser_context *src,
pool_t pool, const char **conflict_key_r);
More information about the dovecot-cvs
mailing list