dovecot-2.1: imapc: Fixes to handling non-empty imapc namespace ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 12 12:41:17 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/59c7b30973cf
changeset: 13444:59c7b30973cf
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Sep 12 12:41:09 2011 +0300
description:
imapc: Fixes to handling non-empty imapc namespace prefix.

diffstat:

 src/lib-storage/index/imapc/imapc-list.c    |  18 +++++++++++++++---
 src/lib-storage/index/imapc/imapc-storage.c |  10 ++++++++++
 2 files changed, 25 insertions(+), 3 deletions(-)

diffs (69 lines):

diff -r 84e31a32293e -r 59c7b30973cf src/lib-storage/index/imapc/imapc-list.c
--- a/src/lib-storage/index/imapc/imapc-list.c	Mon Sep 12 12:40:34 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-list.c	Mon Sep 12 12:41:09 2011 +0300
@@ -14,6 +14,8 @@
 struct imapc_mailbox_list_iterate_context {
 	struct mailbox_list_iterate_context ctx;
 	struct mailbox_tree_context *tree;
+	struct mailbox_node *ns_root;
+
 	struct mailbox_tree_iterate_context *iter;
 	struct mailbox_info info;
 };
@@ -321,6 +323,7 @@
 	struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list;
 	struct mailbox_list_iterate_context *_ctx;
 	struct imapc_mailbox_list_iterate_context *ctx;
+	const char *ns_root_name;
 	char sep;
 	int ret = 0;
 
@@ -353,6 +356,13 @@
 
 	ctx->tree = mailbox_tree_init(sep);
 	imapc_list_build_match_tree(ctx);
+
+	if (list->list.ns->prefix_len > 0) {
+		ns_root_name = t_strndup(_list->ns->prefix,
+					 _list->ns->prefix_len - 1);
+		ctx->ns_root = mailbox_tree_lookup(ctx->tree, ns_root_name);
+	}
+
 	ctx->iter = mailbox_tree_iterate_init(ctx->tree, NULL, 0);
 	if (ret < 0)
 		ctx->ctx.failed = TRUE;
@@ -373,9 +383,11 @@
 	if ((_ctx->flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0)
 		return mailbox_list_subscriptions_iter_next(_ctx);
 
-	node = mailbox_tree_iterate_next(ctx->iter, &name);
-	if (node == NULL)
-		return NULL;
+	do {
+		node = mailbox_tree_iterate_next(ctx->iter, &name);
+		if (node == NULL)
+			return NULL;
+	} while (node == ctx->ns_root);
 
 	ctx->info.name = name;
 	ctx->info.flags = node->flags;
diff -r 84e31a32293e -r 59c7b30973cf src/lib-storage/index/imapc/imapc-storage.c
--- a/src/lib-storage/index/imapc/imapc-storage.c	Mon Sep 12 12:40:34 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.c	Mon Sep 12 12:41:09 2011 +0300
@@ -378,6 +378,16 @@
 	examine = (box->flags & MAILBOX_FLAG_READONLY) != 0 &&
 		(box->flags & MAILBOX_FLAG_DROP_RECENT) == 0;
 
+	if (*box->name == '\0' &&
+	    (box->list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
+		/* trying to open INBOX as the namespace prefix.
+		   Don't allow this. */
+		mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
+				       "Mailbox isn't selectable");
+		mailbox_close(box);
+		return -1;
+	}
+
 	mbox->opening = TRUE;
 	ctx.mbox = mbox;
 	ctx.ret = -2;


More information about the dovecot-cvs mailing list