From: Markus Valentin Date: Wed, 2 Oct 2024 08:18:07 +0000 (+0200) Subject: imapc: If a shared namespace INBOX is listed as \Noselect enforce it X-Git-Tag: 2.4.0~1432 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=735f140cf46fbea1963170993d85655435fb5384;p=thirdparty%2Fdovecot%2Fcore.git imapc: If a shared namespace INBOX is listed as \Noselect enforce it 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. --- diff --git a/src/lib-storage/index/imapc/imapc-storage.c b/src/lib-storage/index/imapc/imapc-storage.c index bef51614e3..9eaf24f945 100644 --- a/src/lib-storage/index/imapc/imapc-storage.c +++ b/src/lib-storage/index/imapc/imapc-storage.c @@ -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);