dovecot-2.0: doveadm server: Fixes to command/parameter handling.

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/490138318288
changeset: 12457:490138318288
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Nov 23 15:30:32 2010 +0000
description:
doveadm server: Fixes to command/parameter handling.

diffstat:

 src/doveadm/doveadm-mail-server.c |  11 +++++++----
 src/doveadm/doveadm-mail.c        |  10 ++++------
 src/doveadm/doveadm-mail.h        |   3 ++-
 src/doveadm/main.c                |   3 ++-
 4 files changed, 15 insertions(+), 12 deletions(-)

diffs (116 lines):

diff -r 8c14551c5e26 -r 490138318288 src/doveadm/doveadm-mail-server.c
--- a/src/doveadm/doveadm-mail-server.c	Tue Nov 23 15:30:06 2010 +0000
+++ b/src/doveadm/doveadm-mail-server.c	Tue Nov 23 15:30:32 2010 +0000
@@ -121,6 +121,8 @@
 	str_append_c(cmd, '\t');
 
 	str_tabescape_write(cmd, username);
+	str_append_c(cmd, '\t');
+	str_tabescape_write(cmd, cmd_ctx->cmd->name);
 	for (i = 0; cmd_ctx->args[i] != NULL; i++) {
 		str_append_c(cmd, '\t');
 		str_tabescape_write(cmd, cmd_ctx->args[i]);
@@ -159,7 +161,8 @@
 }
 
 int doveadm_mail_server_user(struct doveadm_mail_cmd_context *ctx,
-			     struct mail_storage_service_user *user)
+			     struct mail_storage_service_user *user,
+			     const char **error_r)
 {
 	const struct mail_storage_service_input *input;
 	struct doveadm_server *server;
@@ -178,9 +181,8 @@
 	if (userdb_field_find(input->userdb_fields, "proxy") != NULL) {
 		host = userdb_field_find(input->userdb_fields, "host");
 		if (host == NULL) {
-			i_error("user %s: Proxy is missing destination host",
-				input->username);
-			return 0;
+			*error_r = "Proxy is missing destination host";
+			return -1;
 		}
 	} else {
 		host = doveadm_settings->doveadm_socket_path;
@@ -201,6 +203,7 @@
 		username_dup = i_strdup(input->username);
 		array_append(&server->queue, &username_dup, 1);
 	}
+	*error_r = "doveadm server failure";
 	return DOVEADM_MAIL_SERVER_FAILED() ? -1 : 0;
 }
 
diff -r 8c14551c5e26 -r 490138318288 src/doveadm/doveadm-mail.c
--- a/src/doveadm/doveadm-mail.c	Tue Nov 23 15:30:06 2010 +0000
+++ b/src/doveadm/doveadm-mail.c	Tue Nov 23 15:30:32 2010 +0000
@@ -204,10 +204,8 @@
 
 	if (doveadm_settings->doveadm_worker_count > 0 && !doveadm_server) {
 		/* execute this command via doveadm server */
-		T_BEGIN {
-			ret = doveadm_mail_server_user(ctx, service_user);
-			mail_storage_service_user_free(&service_user);
-		} T_END;
+		ret = doveadm_mail_server_user(ctx, service_user, error_r);
+		mail_storage_service_user_free(&service_user);
 		return ret < 0 ? -1 : 1;
 	}
 
@@ -322,7 +320,6 @@
 	if (ret < 0)
 		i_error("Failed to iterate through some users");
 	mail_storage_service_deinit(&ctx->storage_service);
-	doveadm_mail_server_flush();
 }
 
 static void
@@ -374,7 +371,6 @@
 		service_flags |= MAIL_STORAGE_SERVICE_FLAG_DEBUG;
 
 	ctx = doveadm_mail_cmd_init(cmd);
-	ctx->args = (const void *)argv;
 
 	getopt_args = t_strconcat("Au:", ctx->getopt_args, NULL);
 	username = getenv("USER");
@@ -403,6 +399,7 @@
 		i_fatal("doveadm %s: Unknown parameter: %s",
 			cmd->name, argv[0]);
 	}
+	ctx->args = (const void *)argv;
 
 	ctx->iterate_single_user =
 		!ctx->iterate_all_users && wildcard_user == NULL;
@@ -418,6 +415,7 @@
 		service_flags |= MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP;
 		doveadm_mail_all_users(ctx, argv, wildcard_user, service_flags);
 	}
+	doveadm_mail_server_flush();
 	ctx->v.deinit(ctx);
 	doveadm_print_flush();
 
diff -r 8c14551c5e26 -r 490138318288 src/doveadm/doveadm-mail.h
--- a/src/doveadm/doveadm-mail.h	Tue Nov 23 15:30:06 2010 +0000
+++ b/src/doveadm/doveadm-mail.h	Tue Nov 23 15:30:32 2010 +0000
@@ -85,7 +85,8 @@
 			      char *argv[], const char *username,
 			      enum mail_storage_service_flags service_flags);
 int doveadm_mail_server_user(struct doveadm_mail_cmd_context *ctx,
-			     struct mail_storage_service_user *user);
+			     struct mail_storage_service_user *user,
+			     const char **error_r);
 void doveadm_mail_server_flush(void);
 
 int doveadm_mailbox_find_and_sync(struct mail_user *user, const char *mailbox,
diff -r 8c14551c5e26 -r 490138318288 src/doveadm/main.c
--- a/src/doveadm/main.c	Tue Nov 23 15:30:06 2010 +0000
+++ b/src/doveadm/main.c	Tue Nov 23 15:30:32 2010 +0000
@@ -19,7 +19,8 @@
 struct client_connection *doveadm_client;
 
 int doveadm_mail_server_user(struct doveadm_mail_cmd_context *ctx ATTR_UNUSED,
-			     struct mail_storage_service_user *user ATTR_UNUSED)
+			     struct mail_storage_service_user *user ATTR_UNUSED,
+			     const char **error_r ATTR_UNUSED)
 {
 	/* this function should be called only by doveadm client code */
 	i_unreached();


More information about the dovecot-cvs mailing list