]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: index_list_mailbox_open() - Check that mailbox has not been deleted
authorMarco Bettini <marco.bettini@open-xchange.com>
Thu, 13 Apr 2023 08:03:57 +0000 (08:03 +0000)
committerMarco Bettini <marco.bettini@open-xchange.com>
Fri, 21 Apr 2023 07:11:56 +0000 (07:11 +0000)
Without this, removing a mailbox (obox) used in a virtual box
fails to understand that the box has been removed intentionally
and tries to recreate/rebuild it.

src/lib-storage/list/mailbox-list-index-backend.c

index 88dd6c74e28ab791341c344cdd977c70bf40fddc..70f79ccef367a4a8ea674b4d15849b81a2d3f288 100644 (file)
@@ -539,6 +539,16 @@ static int index_list_mailbox_open(struct mailbox *box)
        const unsigned char *name_hdr;
        size_t name_hdr_size;
 
+       if (!box->creating && (box->flags & MAILBOX_FLAG_OPEN_DELETED) == 0) {
+               if (mailbox_list_index_refresh(box->list) < 0)
+                       return -1;
+               if (mailbox_list_index_lookup(box->list, box->name) == NULL) {
+                       mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
+                                              T_MAIL_ERR_MAILBOX_NOT_FOUND(box->name));
+                       return -1;
+               }
+       }
+
        if (ibox->module_ctx.super.open(box) < 0)
                return -1;