dovecot-2.2: dsync: Set broken_char to a control char, so invali...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 5 18:22:04 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/12a0c383703e
changeset: 16458:12a0c383703e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 05 18:21:55 2013 +0300
description:
dsync: Set broken_char to a control char, so invalid mailbox names are handled properly.
The dsync will now fail if there are invalid mailbox names (e.g. valid UTF8
when they should have been mUTF7), instead of simply printing "mailbox
doesn't exist" error and exiting with 0.

diffstat:

 src/doveadm/dsync/doveadm-dsync.c |  24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diffs (69 lines):

diff -r 66a6ff2fdee9 -r 12a0c383703e src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c	Wed Jun 05 18:15:22 2013 +0300
+++ b/src/doveadm/dsync/doveadm-dsync.c	Wed Jun 05 18:21:55 2013 +0300
@@ -19,7 +19,7 @@
 #include "mail-storage-service.h"
 #include "mail-user.h"
 #include "mail-namespace.h"
-#include "mailbox-list.h"
+#include "mailbox-list-private.h"
 #include "doveadm-settings.h"
 #include "doveadm-mail.h"
 #include "doveadm-print.h"
@@ -38,6 +38,12 @@
 
 #define DSYNC_COMMON_GETOPT_ARGS "+dEfg:l:m:n:Nr:Rs:Ux:"
 #define DSYNC_REMOTE_CMD_EXIT_WAIT_SECS 30
+/* The broken_char is mainly set to get a proper error message when trying to
+   convert a mailbox with a name that can't be used properly translated between
+   vname/storage_name and would otherwise be mixed up with a normal "mailbox
+   doesn't exist" error message. This could be any control character, since
+   none of them are allowed to be created in regular mailbox names. */
+#define DSYNC_LIST_BROKEN_CHAR '\003'
 
 enum dsync_run_type {
 	DSYNC_RUN_TYPE_LOCAL,
@@ -279,6 +285,15 @@
 	return TRUE;
 }
 
+static void doveadm_user_init_dsync(struct mail_user *user)
+{
+	struct mail_namespace *ns;
+
+	user->dsyncing = TRUE;
+	for (ns = user->namespaces; ns != NULL; ns = ns->next)
+		ns->list->set.broken_char = DSYNC_LIST_BROKEN_CHAR;
+}
+
 static bool paths_are_equal(struct mail_user *user1, struct mail_user *user2,
 			    enum mailbox_list_path_type type)
 {
@@ -322,7 +337,7 @@
 		ctx->ctx.exit_code = ret == -1 ? EX_TEMPFAIL : EX_CONFIG;
 		return -1;
 	}
-	user2->dsyncing = TRUE;
+	doveadm_user_init_dsync(user2);
 
 	if (mail_namespaces_get_root_sep(user->namespaces) !=
 	    mail_namespaces_get_root_sep(user2->namespaces)) {
@@ -504,8 +519,7 @@
 		/* array is NULL-terminated in init() */
 		set.exclude_mailboxes = array_idx(&ctx->exclude_mailboxes, 0);
 	}
-
-	user->dsyncing = TRUE;
+	doveadm_user_init_dsync(user);
 
 	if (ctx->namespace_prefix != NULL) {
 		set.sync_ns = mail_namespace_find(user->namespaces,
@@ -946,7 +960,7 @@
 		ctx->output = _ctx->conn->output;
 		o_stream_nsend(ctx->output, "\n+\n", 3);
 	}
-	user->dsyncing = TRUE;
+	doveadm_user_init_dsync(user);
 
 	i_set_failure_prefix("dsync-remote(%s): ", user->username);
 


More information about the dovecot-cvs mailing list