dovecot-2.0: doveadm: Added -s parameter to execute mail command...

dovecot at dovecot.org dovecot at dovecot.org
Tue Nov 23 17:30:38 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/8c14551c5e26
changeset: 12456:8c14551c5e26
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Nov 23 15:30:06 2010 +0000
description:
doveadm: Added -s parameter to execute mail command via given doveadm socket.

diffstat:

 src/doveadm/doveadm.c |  26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diffs (71 lines):

diff -r 8b82ccf48f32 -r 8c14551c5e26 src/doveadm/doveadm.c
--- a/src/doveadm/doveadm.c	Tue Nov 23 15:28:47 2010 +0000
+++ b/src/doveadm/doveadm.c	Tue Nov 23 15:30:06 2010 +0000
@@ -220,7 +220,7 @@
 	return doveadm_mail_has_subcommands(cmd_name);
 }
 
-static void doveadm_read_settings(void)
+static void doveadm_read_settings(const char *socket_path)
 {
 	static const struct setting_parser_info *set_roots[] = {
 		&doveadm_setting_parser_info,
@@ -239,6 +239,21 @@
 		i_fatal("Error reading configuration: %s", error);
 
 	doveadm_settings = master_service_settings_get_others(master_service)[0];
+	if (socket_path != NULL) {
+		struct setting_parser_context *set_parser =
+			master_service_get_settings_parser(master_service);
+		const char *set_line =
+			t_strconcat("doveadm_socket_path=", socket_path, NULL);
+
+		if (settings_parse_line(set_parser, set_line) < 0)
+			i_unreached();
+		if (doveadm_settings->doveadm_worker_count == 0) {
+			if (settings_parse_line(set_parser,
+						"doveadm_worker_count=1") < 0)
+				i_unreached();
+		}
+	}
+
 	doveadm_settings = settings_dup(&doveadm_setting_parser_info,
 					doveadm_settings,
 					pool_datastack_create());
@@ -266,7 +281,7 @@
 	enum master_service_flags service_flags =
 		MASTER_SERVICE_FLAG_STANDALONE |
 		MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN;
-	const char *cmd_name;
+	const char *cmd_name, *socket_path = NULL;
 	unsigned int i;
 	bool quick_init = FALSE;
 	int c;
@@ -274,7 +289,7 @@
 	/* "+" is GNU extension to stop at the first non-option.
 	   others just accept -+ option. */
 	master_service = master_service_init("doveadm", service_flags,
-					     &argc, &argv, "+Df:v");
+					     &argc, &argv, "+Df:s:v");
 	while ((c = master_getopt(master_service)) > 0) {
 		switch (c) {
 		case 'D':
@@ -284,6 +299,9 @@
 		case 'f':
 			doveadm_print_init(optarg);
 			break;
+		case 's':
+			socket_path = optarg;
+			break;
 		case 'v':
 			doveadm_verbose = TRUE;
 			break;
@@ -298,7 +316,7 @@
 		/* "help cmd" doesn't need any configuration */
 		quick_init = TRUE;
 	} else {
-		doveadm_read_settings();
+		doveadm_read_settings(socket_path);
 	}
 
 	i_array_init(&doveadm_cmds, 32);


More information about the dovecot-cvs mailing list