From: Siavash Tavakoli Date: Wed, 16 Dec 2020 10:08:11 +0000 (+0000) Subject: lib-storage: Move checking autocreated boxes to storage backends X-Git-Tag: 2.3.14.rc1~159 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9dc72c3091fb92471126b782fda9b4575a4728e9;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Move checking autocreated boxes to storage backends This allows acl plugin to check ACLs for autocreated mailboxes as well. --- diff --git a/src/lib-storage/index/imapc/imapc-storage.c b/src/lib-storage/index/imapc/imapc-storage.c index 2746fdd3a3..0234e7b2d4 100644 --- a/src/lib-storage/index/imapc/imapc-storage.c +++ b/src/lib-storage/index/imapc/imapc-storage.c @@ -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; diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index a3d0237248..82d721f97c 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -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); } diff --git a/src/lib-storage/index/maildir/maildir-storage.c b/src/lib-storage/index/maildir/maildir-storage.c index 8fb36f54df..b400be3981 100644 --- a/src/lib-storage/index/maildir/maildir-storage.c +++ b/src/lib-storage/index/maildir/maildir-storage.c @@ -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); } diff --git a/src/lib-storage/index/pop3c/pop3c-storage.c b/src/lib-storage/index/pop3c/pop3c-storage.c index d1e761b3e5..26931e5314 100644 --- a/src/lib-storage/index/pop3c/pop3c-storage.c +++ b/src/lib-storage/index/pop3c/pop3c-storage.c @@ -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; diff --git a/src/lib-storage/list/mailbox-list-index-backend.c b/src/lib-storage/list/mailbox-list-index-backend.c index d62daf1f6d..7f21f9f0d5 100644 --- a/src/lib-storage/list/mailbox-list-index-backend.c +++ b/src/lib-storage/list/mailbox-list-index-backend.c @@ -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; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 80880e29a0..1fd1c1fdfa 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -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;