dovecot-2.0: doveadm help: Don't read settings (doveconf seems t...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 30 22:35:14 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/8468998b98ab
changeset: 11662:8468998b98ab
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 30 20:35:09 2010 +0100
description:
doveadm help: Don't read settings (doveconf seems to mess up terminal)

diffstat:

 src/doveadm/doveadm.c |  46 +++++++++++++++++++++++++++++-----------------
 1 files changed, 29 insertions(+), 17 deletions(-)

diffs (79 lines):

diff -r 1799fbbd104b -r 8468998b98ab src/doveadm/doveadm.c
--- a/src/doveadm/doveadm.c	Wed Jun 30 18:49:23 2010 +0000
+++ b/src/doveadm/doveadm.c	Wed Jun 30 20:35:09 2010 +0100
@@ -251,6 +251,25 @@
 	module_dir_init(modules);
 }
 
+static void doveadm_read_settings(void)
+{
+	static const struct setting_parser_info *set_roots[] = {
+		&doveadm_setting_parser_info,
+		NULL
+	};
+	struct master_service_settings_input input;
+	struct master_service_settings_output output;
+	const char *error;
+
+	memset(&input, 0, sizeof(input));
+	input.roots = set_roots;
+	input.module = "doveadm";
+	input.preserve_home = TRUE;
+	if (master_service_settings_read(master_service, &input,
+					 &output, &error) < 0)
+		i_fatal("Error reading configuration: %s", error);
+	doveadm_settings = master_service_settings_get_others(master_service)[0];
+}
 
 static struct doveadm_cmd *doveadm_commands[] = {
 	&doveadm_cmd_help,
@@ -268,18 +287,12 @@
 
 int main(int argc, char *argv[])
 {
-	static const struct setting_parser_info *set_roots[] = {
-		&doveadm_setting_parser_info,
-		NULL
-	};
 	enum master_service_flags service_flags =
 		MASTER_SERVICE_FLAG_STANDALONE |
 		MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN;
-	struct master_service_settings_input input;
-	struct master_service_settings_output output;
-	const char *cmd_name, *error;
+	const char *cmd_name;
 	unsigned int i;
-	bool quick_init;
+	bool quick_init = FALSE;
 	int c;
 
 	/* "+" is GNU extension to stop at the first non-option.
@@ -304,20 +317,19 @@
 	}
 	cmd_name = argv[optind];
 
-	memset(&input, 0, sizeof(input));
-	input.roots = set_roots;
-	input.module = "doveadm";
-	input.preserve_home = TRUE;
-	if (master_service_settings_read(master_service, &input,
-					 &output, &error) < 0)
-		i_fatal("Error reading configuration: %s", error);
-	doveadm_settings = master_service_settings_get_others(master_service)[0];
+	if (cmd_name != NULL && strcmp(cmd_name, "help") == 0) {
+		/* help doesn't need any configuration */
+		quick_init = TRUE;
+	} else {
+		doveadm_read_settings();
+	}
 
 	i_array_init(&doveadm_cmds, 32);
 	for (i = 0; i < N_ELEMENTS(doveadm_commands); i++)
 		doveadm_register_cmd(doveadm_commands[i]);
 
-	if (cmd_name != NULL && (strcmp(cmd_name, "stop") == 0 ||
+	if (cmd_name != NULL && (quick_init ||
+				 strcmp(cmd_name, "stop") == 0 ||
 				 strcmp(cmd_name, "reload") == 0)) {
 		/* special case commands: even if there is something wrong
 		   with the config (e.g. mail_plugins), don't fail these


More information about the dovecot-cvs mailing list