]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: If a shared namespace INBOX is listed as \Noselect enforce it
authorMarkus Valentin <markus.valentin@open-xchange.com>
Wed, 2 Oct 2024 08:18:07 +0000 (10:18 +0200)
committerMarkus Valentin <markus.valentin@open-xchange.com>
Tue, 22 Oct 2024 09:21:01 +0000 (11:21 +0200)
In specific configurations a shared namespace INBOX is listed as
\Noselect
* LIST (\HasChildren) "/" shared/user
* LIST (\HasChildren \Noselect) "/" shared/user/INBOX

This is fixed by adding this extra check.

src/lib-storage/index/imapc/imapc-storage.c

index bef51614e3fda4c38efce491991de7da461a746b..9eaf24f9454a471fad2c7d78e3f17e47e4f6f05e 100644 (file)
@@ -824,6 +824,8 @@ int imapc_mailbox_select(struct imapc_mailbox *mbox)
 static int imapc_mailbox_open(struct mailbox *box)
 {
        struct imapc_mailbox *mbox = IMAPC_MAILBOX(box);
+       struct imapc_mailbox_list *list =
+               container_of(box->list, struct imapc_mailbox_list, list);
 
        if (index_storage_mailbox_open(box, FALSE) < 0)
                return -1;
@@ -842,6 +844,21 @@ static int imapc_mailbox_open(struct mailbox *box)
                mailbox_close(box);
                return -1;
        }
+       /* If mail_shared_explicit_inbox is not set, a shared mailbox can list
+          INBOX as \Noselect (usually with child mailboxes), as well as
+          listing the selectable namespace prefix itself (containing the
+          actual INBOX). Make sure that in these situations the \Noselect is
+          actually enforced for the INBOX. */
+       if (!box->storage->set->mail_shared_explicit_inbox &&
+            list->set->imapc_list_prefix[0] == '\0' &&
+            list->list.ns->type ==  MAIL_NAMESPACE_TYPE_SHARED &&
+            strcmp(box->vname, t_strdup_printf("%sINBOX",
+                                               box->list->ns->prefix)) == 0) {
+               mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
+                                      "Mailbox isn't selectable");
+               mailbox_close(box);
+               return -1;
+       }
 
        if (imapc_mailbox_select(mbox) < 0) {
                mailbox_close(box);