]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Move checking autocreated boxes to storage backends
authorSiavash Tavakoli <siavash.tavakoli@open-xchange.com>
Wed, 16 Dec 2020 10:08:11 +0000 (10:08 +0000)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 13 Jan 2021 09:52:36 +0000 (09:52 +0000)
This allows acl plugin to check ACLs for autocreated mailboxes as well.

src/lib-storage/index/imapc/imapc-storage.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/pop3c/pop3c-storage.c
src/lib-storage/list/mailbox-list-index-backend.c
src/lib-storage/mail-storage.c

index 2746fdd3a3647095f9d938842f00ba1146d9f011..0234e7b2d4c168847cf7c82b7ad84dd7fa7d7458 100644 (file)
@@ -519,9 +519,14 @@ const char *imapc_mailbox_get_remote_name(struct imapc_mailbox *mbox)
 }
 
 static int
-imapc_mailbox_exists(struct mailbox *box, bool auto_boxes ATTR_UNUSED,
+imapc_mailbox_exists(struct mailbox *box, bool auto_boxes,
                     enum mailbox_existence *existence_r)
 {
+       if (auto_boxes && mailbox_is_autocreated(box)) {
+               *existence_r = MAILBOX_EXISTENCE_SELECT;
+               return 0;
+       }
+
        if (strcmp(box->list->name, MAILBOX_LIST_NAME_IMAPC) != 0) {
                if (box->inbox_any)
                        *existence_r = MAILBOX_EXISTENCE_SELECT;
index a3d023724833dbb38d30aea47636a1d5301236bd..82d721f97cf63b619dcacb35396f7aac9a058681 100644 (file)
@@ -169,10 +169,14 @@ index_mailbox_alloc_index(struct mailbox *box, struct mail_index **index_r)
        return 0;
 }
 
-int index_storage_mailbox_exists(struct mailbox *box,
-                                bool auto_boxes ATTR_UNUSED,
+int index_storage_mailbox_exists(struct mailbox *box, bool auto_boxes,
                                 enum mailbox_existence *existence_r)
 {
+       if (auto_boxes && mailbox_is_autocreated(box)) {
+               *existence_r = MAILBOX_EXISTENCE_SELECT;
+               return 0;
+       }
+
        return index_storage_mailbox_exists_full(box, NULL, existence_r);
 }
 
index 8fb36f54df5d85c40d467ca41b78e9a7d0ab047d..b400be3981742bb75c52dfe311c02780008e4ba7 100644 (file)
@@ -337,9 +337,14 @@ static bool maildir_storage_is_readonly(struct mailbox *box)
 }
 
 static int
-maildir_mailbox_exists(struct mailbox *box, bool auto_boxes ATTR_UNUSED,
+maildir_mailbox_exists(struct mailbox *box, bool auto_boxes,
                       enum mailbox_existence *existence_r)
 {
+       if (auto_boxes && mailbox_is_autocreated(box)) {
+               *existence_r = MAILBOX_EXISTENCE_SELECT;
+               return 0;
+       }
+
        return index_storage_mailbox_exists_full(box, "cur", existence_r);
 }
 
index d1e761b3e52a96ed91363b0c56c086f7596e80db..26931e5314589c67369282f3b610e48afc23def2 100644 (file)
@@ -127,10 +127,10 @@ pop3c_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 }
 
 static int
-pop3c_mailbox_exists(struct mailbox *box, bool auto_boxes ATTR_UNUSED,
+pop3c_mailbox_exists(struct mailbox *box, bool auto_boxes,
                     enum mailbox_existence *existence_r)
 {
-       if (box->inbox_any)
+       if ((auto_boxes && mailbox_is_autocreated(box)) || box->inbox_any)
                *existence_r = MAILBOX_EXISTENCE_SELECT;
        else
                *existence_r = MAILBOX_EXISTENCE_NONE;
index d62daf1f6d0786523d4374886c9a42590a4813de..7f21f9f0d503e4a7e7254bbdb190a25a2004c674 100644 (file)
@@ -465,9 +465,14 @@ index_list_mailbox_update(struct mailbox *box,
 }
 
 static int
-index_list_mailbox_exists(struct mailbox *box, bool auto_boxes ATTR_UNUSED,
+index_list_mailbox_exists(struct mailbox *box, bool auto_boxes,
                          enum mailbox_existence *existence_r)
 {
+       if (auto_boxes && mailbox_is_autocreated(box)) {
+               *existence_r = MAILBOX_EXISTENCE_SELECT;
+               return 0;
+       }
+
        struct index_mailbox_list *list =
                (struct index_mailbox_list *)box->list;
 
index 80880e29a06be105c1be28d96d62c07f39bfdc65..1fd1c1fdfabc33c736d6af27f5aff87447067ccc 100644 (file)
@@ -1388,11 +1388,6 @@ int mailbox_exists(struct mailbox *box, bool auto_boxes,
                return 0;
        }
 
-       if (auto_boxes && mailbox_is_autocreated(box)) {
-               *existence_r = MAILBOX_EXISTENCE_SELECT;
-               return 0;
-       }
-
        if (box->v.exists(box, auto_boxes, existence_r) < 0)
                return -1;