dovecot-2.2: Merged changes from v2.1 tree.

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 30 22:05:17 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/1f95d4fe29c7
changeset: 15005:1f95d4fe29c7
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 30 22:05:02 2012 +0300
description:
Merged changes from v2.1 tree.

diffstat:

 configure.in                                |   14 +-
 src/auth/auth-client-connection.c           |    3 +-
 src/auth/auth-master-connection.c           |    6 +-
 src/auth/auth-request-handler.c             |    3 +-
 src/auth/mech.c                             |    1 +
 src/doveadm/Makefile.am                     |    2 +-
 src/doveadm/doveadm-mail-copymove.c         |  201 ++++++++++++++++++++++++++++
 src/doveadm/doveadm-mail-move.c             |  144 --------------------
 src/doveadm/doveadm-mail.c                  |    3 +
 src/doveadm/doveadm-mail.h                  |    2 +
 src/imap/cmd-list.c                         |   19 ++-
 src/imap/cmd-namespace.c                    |   11 +-
 src/imap/imap-commands-util.c               |   21 +-
 src/lib-dict/dict-file.c                    |    9 +-
 src/lib-dict/dict-redis.c                   |   43 ++---
 src/lib-imap-client/imapc-client.c          |    1 +
 src/lib-imap-client/imapc-connection.c      |    2 +
 src/lib-storage/index/imapc/imapc-list.c    |   12 +-
 src/lib-storage/list/mailbox-list-fs-iter.c |   22 ++-
 src/lib-storage/mail-storage-settings.c     |    5 +
 src/lmtp/commands.c                         |    1 +
 src/lmtp/lmtp-proxy.c                       |    6 +-
 src/lmtp/lmtp-proxy.h                       |    1 +
 23 files changed, 325 insertions(+), 207 deletions(-)

diffs (truncated from 921 to 300 lines):

diff -r 5ffcde8baa8a -r 1f95d4fe29c7 configure.in
--- a/configure.in	Thu Aug 30 21:12:23 2012 +0300
+++ b/configure.in	Thu Aug 30 22:05:02 2012 +0300
@@ -953,21 +953,13 @@
 AC_DEFINE_UNQUOTED(MEM_ALIGN_SIZE, $mem_align, Required memory alignment)
 
 dnl * find random source
-AC_MSG_CHECKING([for OpenBSD /dev/arandom])
-if test -c /dev/arandom; then
+AC_MSG_CHECKING([for /dev/urandom])
+if test -c /dev/urandom || test -s /dev/urandom; then
   AC_MSG_RESULT(yes)
-  AC_DEFINE(DEV_URANDOM_PATH, "/dev/arandom", Path to /dev/urandom)
+  AC_DEFINE(DEV_URANDOM_PATH, "/dev/urandom", Path to /dev/urandom)
   have_random_source=yes
 else
   AC_MSG_RESULT(no)
-  AC_MSG_CHECKING([for /dev/urandom])
-  if test -c /dev/urandom || test -s /dev/urandom; then
-    AC_MSG_RESULT(yes)
-    AC_DEFINE(DEV_URANDOM_PATH, "/dev/urandom", Path to /dev/urandom)
-    have_random_source=yes
-  else
-    AC_MSG_RESULT(no)
-  fi
 fi
 
 if test "$have_random_source" != "yes"; then
diff -r 5ffcde8baa8a -r 1f95d4fe29c7 src/auth/auth-client-connection.c
--- a/src/auth/auth-client-connection.c	Thu Aug 30 21:12:23 2012 +0300
+++ b/src/auth/auth-client-connection.c	Thu Aug 30 22:05:02 2012 +0300
@@ -65,7 +65,8 @@
 	}
 
 	if (conn->auth->set->debug) {
-		i_debug("client out: %s", conn->auth->set->debug_passwords ?
+		i_debug("client passdb out: %s",
+			conn->auth->set->debug_passwords ?
 			cmd : reply_line_hide_pass(cmd));
 	}
 }
diff -r 5ffcde8baa8a -r 1f95d4fe29c7 src/auth/auth-master-connection.c
--- a/src/auth/auth-master-connection.c	Thu Aug 30 21:12:23 2012 +0300
+++ b/src/auth/auth-master-connection.c	Thu Aug 30 22:05:02 2012 +0300
@@ -79,7 +79,7 @@
 	reply_str = auth_stream_reply_export(reply);
 
 	if (conn->auth->set->debug) {
-		i_debug("master out: %s",
+		i_debug("master userdb out: %s",
 			auth_master_reply_hide_passwords(conn, reply_str));
 	}
 
@@ -280,7 +280,7 @@
 	}
 
 	if (conn->auth->set->debug) {
-		i_debug("master out: %s",
+		i_debug("userdb out: %s",
 			auth_master_reply_hide_passwords(conn, str_c(str)));
 	}
 
@@ -342,7 +342,7 @@
 	}
 
 	if (conn->auth->set->debug)
-		i_debug("master out: %s", str_c(str));
+		i_debug("passdb out: %s", str_c(str));
 
 	str_append_c(str, '\n');
 	o_stream_nsend(conn->output, str_data(str), str_len(str));
diff -r 5ffcde8baa8a -r 1f95d4fe29c7 src/auth/auth-request-handler.c
--- a/src/auth/auth-request-handler.c	Thu Aug 30 21:12:23 2012 +0300
+++ b/src/auth/auth-request-handler.c	Thu Aug 30 22:05:02 2012 +0300
@@ -185,7 +185,8 @@
 			auth_stream_reply_add(reply, "pass",
 					      request->mech_password);
 		}
-		if (request->master_user != NULL) {
+		if (request->master_user != NULL &&
+		    auth_stream_reply_find(reply, "master") == NULL) {
 			/* the master username needs to be forwarded */
 			auth_stream_reply_add(reply, "master",
 					      request->master_user);
diff -r 5ffcde8baa8a -r 1f95d4fe29c7 src/auth/mech.c
--- a/src/auth/mech.c	Thu Aug 30 21:12:23 2012 +0300
+++ b/src/auth/mech.c	Thu Aug 30 22:05:02 2012 +0300
@@ -205,6 +205,7 @@
 #endif
 	}
 	mech_unregister_module(&mech_otp);
+	mech_unregister_module(&mech_scram_sha1);
 	mech_unregister_module(&mech_skey);
 	mech_unregister_module(&mech_rpa);
 	mech_unregister_module(&mech_anonymous);
diff -r 5ffcde8baa8a -r 1f95d4fe29c7 src/doveadm/Makefile.am
--- a/src/doveadm/Makefile.am	Thu Aug 30 21:12:23 2012 +0300
+++ b/src/doveadm/Makefile.am	Thu Aug 30 22:05:02 2012 +0300
@@ -73,7 +73,7 @@
 	doveadm-mail-iter.c \
 	doveadm-mail-mailbox.c \
 	doveadm-mail-mailbox-status.c \
-	doveadm-mail-move.c \
+	doveadm-mail-copymove.c \
 	doveadm-mailbox-list-iter.c \
 	doveadm-mail-search.c \
 	doveadm-mail-server.c \
diff -r 5ffcde8baa8a -r 1f95d4fe29c7 src/doveadm/doveadm-mail-copymove.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/doveadm/doveadm-mail-copymove.c	Thu Aug 30 22:05:02 2012 +0300
@@ -0,0 +1,201 @@
+/* Copyright (c) 2011-2012 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "mail-storage.h"
+#include "mail-namespace.h"
+#include "doveadm-print.h"
+#include "doveadm-mailbox-list-iter.h"
+#include "doveadm-mail-iter.h"
+#include "doveadm-mail.h"
+
+#include <stdio.h>
+
+struct copy_cmd_context {
+	struct doveadm_mail_cmd_context ctx;
+
+	struct mail_storage_service_user *source_service_user;
+	struct mail_user *source_user;
+
+	const char *destname;
+	bool move;
+};
+
+static int
+cmd_copy_box(struct copy_cmd_context *ctx, struct mailbox *destbox,
+	     const struct mailbox_info *info)
+{
+	struct doveadm_mail_iter *iter;
+	struct mailbox_transaction_context *trans;
+	struct mailbox_transaction_context *desttrans;
+	struct mail_save_context *save_ctx;
+	struct mail *mail;
+	int ret = 0;
+
+	if (doveadm_mail_iter_init(&ctx->ctx, info, ctx->ctx.search_args, 0,
+				   NULL, &trans, &iter) < 0)
+		return -1;
+
+	/* use a separately committed transaction for each mailbox.
+	   this guarantees that mails aren't expunged without actually having
+	   been copied. */
+	desttrans = mailbox_transaction_begin(destbox,
+					MAILBOX_TRANSACTION_FLAG_EXTERNAL);
+
+	while (doveadm_mail_iter_next(iter, &mail)) {
+		save_ctx = mailbox_save_alloc(desttrans);
+		mailbox_save_copy_flags(save_ctx, mail);
+		if (mailbox_copy(&save_ctx, mail) == 0) {
+			if (ctx->move)
+				mail_expunge(mail);
+		} else {
+			i_error("Copying message UID %u from '%s' failed: %s",
+				mail->uid, info->vname,
+				mailbox_get_last_error(destbox, NULL));
+			doveadm_mail_failed_mailbox(&ctx->ctx, destbox);
+			ret = -1;
+		}
+	}
+
+	if (mailbox_transaction_commit(&desttrans) < 0) {
+		i_error("Committing %s mails failed: %s",
+			ctx->move ? "moved" : "copied",
+			mailbox_get_last_error(destbox, NULL));
+		doveadm_mail_failed_mailbox(&ctx->ctx, destbox);
+		/* rollback expunges */
+		doveadm_mail_iter_deinit_rollback(&iter);
+		ret = -1;
+	} else {
+		if (doveadm_mail_iter_deinit_sync(&iter) < 0)
+			ret = -1;
+	}
+	return ret;
+}
+
+static void
+cmd_copy_alloc_source_user(struct copy_cmd_context *ctx, const char *username)
+{
+	struct mail_storage_service_input input;
+	const char *error;
+
+	input = ctx->ctx.storage_service_input;
+	input.username = username;
+
+	if (mail_storage_service_lookup_next(ctx->ctx.storage_service, &input,
+					     &ctx->source_service_user,
+					     &ctx->source_user,
+					     &error) < 0)
+		i_fatal("Couldn't lookup user %s: %s", input.username, error);
+}
+
+static int
+cmd_copy_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
+{
+	struct copy_cmd_context *ctx = (struct copy_cmd_context *)_ctx;
+	const enum mailbox_list_iter_flags iter_flags =
+		MAILBOX_LIST_ITER_RAW_LIST |
+		MAILBOX_LIST_ITER_NO_AUTO_BOXES |
+		MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
+	struct doveadm_mailbox_list_iter *iter;
+	struct mail_user *src_user;
+	struct mail_namespace *ns;
+	struct mailbox *destbox;
+	const struct mailbox_info *info;
+	int ret = 0;
+
+	ns = mail_namespace_find(user->namespaces, ctx->destname);
+	if (ns == NULL) {
+		i_fatal_status(DOVEADM_EX_NOTFOUND,
+			       "Can't find namespace for: %s", ctx->destname);
+	}
+
+	destbox = mailbox_alloc(ns->list, ctx->destname, MAILBOX_FLAG_SAVEONLY);
+	if (mailbox_open(destbox) < 0) {
+		i_error("Can't open mailbox '%s': %s", ctx->destname,
+			mailbox_get_last_error(destbox, NULL));
+		doveadm_mail_failed_mailbox(&ctx->ctx, destbox);
+		mailbox_free(&destbox);
+		return -1;
+	}
+
+	src_user = ctx->source_user != NULL ? ctx->source_user : user;
+	iter = doveadm_mailbox_list_iter_init(_ctx, src_user, _ctx->search_args,
+					      iter_flags);
+	while ((info = doveadm_mailbox_list_iter_next(iter)) != NULL) T_BEGIN {
+		if (cmd_copy_box(ctx, destbox, info) < 0)
+			ret = -1;
+	} T_END;
+	if (doveadm_mailbox_list_iter_deinit(&iter) < 0)
+		ret = -1;
+
+	if (mailbox_sync(destbox, 0) < 0) {
+		i_error("Syncing mailbox '%s' failed: %s", ctx->destname,
+			mailbox_get_last_error(destbox, NULL));
+		doveadm_mail_failed_mailbox(&ctx->ctx, destbox);
+		ret = -1;
+	}
+	mailbox_free(&destbox);
+	return ret;
+}
+
+static void cmd_copy_init(struct doveadm_mail_cmd_context *_ctx,
+			  const char *const args[])
+{
+	struct copy_cmd_context *ctx = (struct copy_cmd_context *)_ctx;
+	const char *destname = args[0], *cmdname = ctx->move ? "move" : "copy";
+
+	if (destname == NULL || args[1] == NULL)
+		doveadm_mail_help_name(cmdname);
+	args++;
+
+	if (args[0] != NULL && args[1] != NULL &&
+	    strcasecmp(args[0], "user") == 0) {
+		if ((_ctx->service_flags &
+		     MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) == 0)
+			i_fatal("Use -u parameter to specify destination user");
+
+		cmd_copy_alloc_source_user(ctx, args[1]);
+		args += 2;
+	}
+
+	ctx->destname = p_strdup(ctx->ctx.pool, destname);
+	_ctx->search_args = doveadm_mail_build_search_args(args);
+	expunge_search_args_check(ctx->ctx.search_args, cmdname);
+}
+
+static void cmd_copy_deinit(struct doveadm_mail_cmd_context *_ctx)
+{
+	struct copy_cmd_context *ctx = (struct copy_cmd_context *)_ctx;
+
+	if (ctx->source_user != NULL) {
+		mail_storage_service_user_free(&ctx->source_service_user);
+		mail_user_unref(&ctx->source_user);
+	}
+}
+
+static struct doveadm_mail_cmd_context *cmd_copy_alloc(void)
+{
+	struct copy_cmd_context *ctx;
+
+	ctx = doveadm_mail_cmd_alloc(struct copy_cmd_context);
+	ctx->ctx.v.init = cmd_copy_init;
+	ctx->ctx.v.deinit = cmd_copy_deinit;
+	ctx->ctx.v.run = cmd_copy_run;
+	doveadm_print_init(DOVEADM_PRINT_TYPE_FLOW);
+	return &ctx->ctx;
+}
+
+static struct doveadm_mail_cmd_context *cmd_move_alloc(void)
+{
+	struct copy_cmd_context *ctx;


More information about the dovecot-cvs mailing list