From: Timo Sirainen Date: Tue, 27 Jun 2017 13:55:34 +0000 (+0300) Subject: sdbox: Don't create index directory when trying to open nonexistent mailboxes X-Git-Tag: 2.3.0.rc1~1374 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50bf6cfe2aa6111fb38af37970f9551b2286638c;p=thirdparty%2Fdovecot%2Fcore.git sdbox: Don't create index directory when trying to open nonexistent mailboxes --- diff --git a/src/lib-storage/index/dbox-common/dbox-storage.c b/src/lib-storage/index/dbox-common/dbox-storage.c index 2230f42392..cf728a5b05 100644 --- a/src/lib-storage/index/dbox-common/dbox-storage.c +++ b/src/lib-storage/index/dbox-common/dbox-storage.c @@ -189,7 +189,7 @@ dbox_cleanup_if_exists(struct mailbox_list *list, const char *path) return TRUE; } -int dbox_mailbox_open(struct mailbox *box) +int dbox_mailbox_check_existence(struct mailbox *box) { const char *box_path = mailbox_get_path(box); @@ -208,7 +208,11 @@ int dbox_mailbox_open(struct mailbox *box) "stat(%s) failed: %m", box_path); return -1; } + return 0; +} +int dbox_mailbox_open(struct mailbox *box) +{ if (index_storage_mailbox_open(box, FALSE) < 0) return -1; mail_index_set_fsync_mode(box->index, diff --git a/src/lib-storage/index/dbox-common/dbox-storage.h b/src/lib-storage/index/dbox-common/dbox-storage.h index 08daa91479..f6117a27b1 100644 --- a/src/lib-storage/index/dbox-common/dbox-storage.h +++ b/src/lib-storage/index/dbox-common/dbox-storage.h @@ -70,6 +70,7 @@ int dbox_storage_create(struct mail_storage *storage, void dbox_storage_destroy(struct mail_storage *storage); uint32_t dbox_get_uidvalidity_next(struct mailbox_list *list); void dbox_notify_changes(struct mailbox *box); +int dbox_mailbox_check_existence(struct mailbox *box); int dbox_mailbox_open(struct mailbox *box); int dbox_mailbox_create(struct mailbox *box, const struct mailbox_update *update, bool directory); diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage.c b/src/lib-storage/index/dbox-multi/mdbox-storage.c index 19ab9665ae..74718ef2ca 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c @@ -171,6 +171,8 @@ int mdbox_mailbox_open(struct mailbox *box) { struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)box; + if (dbox_mailbox_check_existence(box) < 0) + return -1; if (dbox_mailbox_open(box) < 0) return -1; diff --git a/src/lib-storage/index/dbox-single/sdbox-storage.c b/src/lib-storage/index/dbox-single/sdbox-storage.c index 1a628d5eda..049c9345da 100644 --- a/src/lib-storage/index/dbox-single/sdbox-storage.c +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c @@ -333,6 +333,9 @@ static int sdbox_mailbox_open(struct mailbox *box) struct sdbox_index_header hdr; bool need_resize; + if (dbox_mailbox_check_existence(box) < 0) + return -1; + if (sdbox_mailbox_alloc_index(mbox) < 0) return -1;