Skip to content

Commit

Permalink
imapc: If a shared namespace INBOX is listed as \Noselect enforce it
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vmo69 committed Oct 22, 2024
1 parent 16de26f commit 735f140
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib-storage/index/imapc/imapc-storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 735f140

Please sign in to comment.