dovecot-2.1: doveconf: Added -d parameter for dumping default se...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Jan 28 22:24:37 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/41cb0217b7c3
changeset: 14025:41cb0217b7c3
user: Timo Sirainen <tss at iki.fi>
date: Sat Jan 28 22:24:26 2012 +0200
description:
doveconf: Added -d parameter for dumping default settings.
diffstat:
src/config/config-parser-private.h | 1 +
src/config/config-parser.c | 22 ++++++++++++++++------
src/config/doveconf.c | 9 +++++++--
3 files changed, 24 insertions(+), 8 deletions(-)
diffs (102 lines):
diff -r 6b902f2be944 -r 41cb0217b7c3 src/config/config-parser-private.h
--- a/src/config/config-parser-private.h Sat Jan 28 22:05:52 2012 +0200
+++ b/src/config/config-parser-private.h Sat Jan 28 22:24:26 2012 +0200
@@ -55,6 +55,7 @@
struct config_filter_context *filter;
unsigned int expand_values:1;
+ unsigned int hide_errors:1;
};
extern void (*hook_config_parser_begin)(struct config_parser_context *ctx);
diff -r 6b902f2be944 -r 41cb0217b7c3 src/config/config-parser.c
--- a/src/config/config-parser.c Sat Jan 28 22:05:52 2012 +0200
+++ b/src/config/config-parser.c Sat Jan 28 22:24:26 2012 +0200
@@ -684,7 +684,9 @@
(void)array_append_space(&ctx->all_parsers);
config_filter_add_all(new_filter, array_idx(&ctx->all_parsers, 0));
- if ((ret = config_all_parsers_check(ctx, new_filter, &error)) < 0) {
+ if (ctx->hide_errors)
+ ret = 0;
+ else if ((ret = config_all_parsers_check(ctx, new_filter, &error)) < 0) {
*error_r = t_strdup_printf("Error in configuration file %s: %s",
ctx->path, error);
}
@@ -886,15 +888,21 @@
int fd, ret = 0;
bool handled;
- fd = open(path, O_RDONLY);
- if (fd < 0) {
- *error_r = t_strdup_printf("open(%s) failed: %m", path);
- return 0;
+ if (path == NULL) {
+ path = "<defaults>";
+ fd = -1;
+ } else {
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ *error_r = t_strdup_printf("open(%s) failed: %m", path);
+ return 0;
+ }
}
memset(&ctx, 0, sizeof(ctx));
ctx.pool = pool_alloconly_create("config file parser", 1024*256);
ctx.path = path;
+ ctx.hide_errors = fd == -1;
for (count = 0; all_roots[count] != NULL; count++) ;
ctx.root_parsers =
@@ -918,7 +926,9 @@
ctx.str = str_new(ctx.pool, 256);
full_line = str_new(default_pool, 512);
- ctx.cur_input->input = i_stream_create_fd(fd, (size_t)-1, TRUE);
+ ctx.cur_input->input = fd != -1 ?
+ i_stream_create_fd(fd, (size_t)-1, TRUE) :
+ i_stream_create_from_data("", 0);
i_stream_set_return_partial_line(ctx.cur_input->input, TRUE);
old_settings_init(&ctx);
if (hook_config_parser_begin != NULL)
diff -r 6b902f2be944 -r 41cb0217b7c3 src/config/doveconf.c
--- a/src/config/doveconf.c Sat Jan 28 22:05:52 2012 +0200
+++ b/src/config/doveconf.c Sat Jan 28 22:24:26 2012 +0200
@@ -596,6 +596,7 @@
int c, ret, ret2;
bool config_path_specified, expand_vars = FALSE, hide_key = FALSE;
bool parse_full_config = FALSE, simple_output = FALSE;
+ bool dump_defaults = FALSE;
if (getenv("USE_SYSEXITS") != NULL) {
/* we're coming from (e.g.) LDA */
@@ -605,7 +606,7 @@
memset(&filter, 0, sizeof(filter));
master_service = master_service_init("config",
MASTER_SERVICE_FLAG_STANDALONE,
- &argc, &argv, "af:hm:nNpexS");
+ &argc, &argv, "adf:hm:nNpexS");
orig_config_path = master_service_get_config_path(master_service);
i_set_failure_prefix("doveconf: ");
@@ -617,6 +618,9 @@
switch (c) {
case 'a':
break;
+ case 'd':
+ dump_defaults = TRUE;
+ break;
case 'f':
filter_parse_arg(&filter, optarg);
break;
@@ -666,7 +670,8 @@
master_service_init_finish(master_service);
config_parse_load_modules();
- if ((ret = config_parse_file(config_path, expand_vars,
+ if ((ret = config_parse_file(dump_defaults ? NULL : config_path,
+ expand_vars,
parse_full_config ? "" : module,
&error)) == 0 &&
access(EXAMPLE_CONFIG_DIR, X_OK) == 0) {
More information about the dovecot-cvs
mailing list