[Dovecot] v1.2: can't access other users shared INBOX

Bernhard Herzog bh at intevation.de
Wed Mar 25 19:05:41 EET 2009


On 19.03.2009, Bernhard Herzog wrote:
> The reason for that is maildir_fill_readdir always adds the virtual name of
> the INBOX even when MAILBOX_LIST_ITER_VIRTUAL_NAMES isn't set.  In lines
> 260ff of mailbox-list-maildir-iter.c, rev. 5284f45c249a  it unconditionally
> adds the prefix to "INBOX" when adding it to the tree:
>
> 		node = mailbox_tree_get(ctx->tree_ctx,
> 			t_strconcat(ns->prefix, "INBOX", NULL), NULL);
>
>
> The patch below fixes this, by only adding the virtual name of the INBOX if
> virtual_names is true, basically in the same way as earlier in the loop.
> I'm not sure whether it's really the correct fix, but in my tests so far it
> seems to work correctly.

As it turns out, there is one problem the patch doesn't address.  It fixes the 
problem of listing the INBOX when the search pattern is simply "*", but 
dovecot still doesn't list the inbox of user fred if the pattern 
is "users/fred/%" (or however the shared namespace is configured).  The 
reason is that "INBOX" simply doesn't match the pattern.  The namespace 
prefix has to be taken into account when doing the match.  The updated patch 
below fixes this.

Regards,

   Bernhard


diff -r d401e8f95bdc src/lib-storage/list/mailbox-list-maildir-iter.c
--- a/src/lib-storage/list/mailbox-list-maildir-iter.c	Tue Mar 24 18:04:18 
2009 -0400
+++ b/src/lib-storage/list/mailbox-list-maildir-iter.c	Wed Mar 25 17:39:07 
2009 +0100
@@ -250,16 +250,29 @@ maildir_fill_readdir(struct maildir_list
 			if (!update_only)
 				node->flags |= MAILBOX_MATCHED;
 		}
-	} else if (mailbox_tree_lookup(ctx->tree_ctx, "INBOX") == NULL &&
-		   imap_match(glob, "INBOX") == IMAP_MATCH_YES) {
-		/* see if INBOX exists. */
-		ret = ctx->ctx.list->v.
-			iter_is_mailbox(&ctx->ctx, ctx->dir, "", "INBOX",
-					MAILBOX_LIST_FILE_TYPE_UNKNOWN, &flags);
-		if (ret > 0) {
-			node = mailbox_tree_get(ctx->tree_ctx,
-				t_strconcat(ns->prefix, "INBOX", NULL), NULL);
-			node->flags = MAILBOX_NOCHILDREN | MAILBOX_MATCHED;
+	} else {
+		const char * inbox_name;
+		if (!virtual_names) {
+			inbox_name = "INBOX";
+		} else {
+			inbox_name = mail_namespace_get_vname(ns, mailbox,
+							      "INBOX");
+		}
+
+		if (mailbox_tree_lookup(ctx->tree_ctx, inbox_name) == NULL &&
+		    imap_match(glob, inbox_name) == IMAP_MATCH_YES) {
+			/* see if INBOX exists. */
+			ret = ctx->ctx.list->v.
+				iter_is_mailbox(&ctx->ctx, ctx->dir, "",
+						"INBOX",
+						MAILBOX_LIST_FILE_TYPE_UNKNOWN,
+						&flags);
+			if (ret > 0) {
+				node = mailbox_tree_get(ctx->tree_ctx,
+							inbox_name, NULL);
+				node->flags = (MAILBOX_NOCHILDREN |
+					       MAILBOX_MATCHED);
+			}
 		}
 	}
 	return 0;


-- 
Bernhard Herzog  |  ++49-541-335 08 30  |  http://www.intevation.de/
Intevation GmbH, Neuer Graben 17, 49074 Osnabrück | AG Osnabrück, HR B 18998
Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://dovecot.org/pipermail/dovecot/attachments/20090325/08d439e5/attachment.bin 


More information about the dovecot mailing list