]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix mailbox list index records without guid having invalid flags
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 18 May 2017 20:13:38 +0000 (23:13 +0300)
committerGitLab <gitlab@git.dovecot.net>
Fri, 19 May 2017 07:51:05 +0000 (10:51 +0300)
With LAYOUT=index the mailbox is found with its GUID. If it doesn't exist,
the mailbox has to be either \NonExistent or \NoSelect. It probably doesn't
make much difference which one, so we'll fix them by adding \NoSelect.

With other layouts the GUID is allowed to be empty, because it can be looked
up from the actual mailbox.

src/lib-storage/list/mailbox-list-index-sync.c
src/lib-storage/list/mailbox-list-index.c
src/lib-storage/list/mailbox-list-index.h

index 52a24b300ecaab49d46722d1e3303b14e580b999..33b267df0e5b6cd201c5675c1a26f28c7e946414 100644 (file)
@@ -389,7 +389,11 @@ mailbox_list_index_sync_update_corrupted_node(struct mailbox_list_index_sync_con
                                      sync_ctx->ilist->ext_id, &irec, NULL);
                node->corrupted_ext = FALSE;
        }
-       if ((node->flags & MAILBOX_LIST_INDEX_FLAG_CORRUPTED_NAME) != 0) {
+       if (node->corrupted_flags) {
+               mail_index_update_flags(sync_ctx->trans, seq, MODIFY_REPLACE,
+                                       (enum mail_flags)node->flags);
+               node->corrupted_flags = FALSE;
+       } else if ((node->flags & MAILBOX_LIST_INDEX_FLAG_CORRUPTED_NAME) != 0) {
                /* rely on lib-index to drop unnecessary updates */
                mail_index_update_flags(sync_ctx->trans, seq, MODIFY_ADD,
                        (enum mail_flags)MAILBOX_LIST_INDEX_FLAG_CORRUPTED_NAME);
index 80126154204c1db4e88ec190620d42e5b5ad9d41..052b4c19b724ba99784dcbef1a6bc43877e3c759 100644 (file)
@@ -318,6 +318,17 @@ static int mailbox_list_index_parse_records(struct mailbox_list_index *ilist,
                }
                irec = data;
 
+               if (!ilist->has_backing_store && guid_128_is_empty(irec->guid) &&
+                   (rec->flags & (MAILBOX_LIST_INDEX_FLAG_NONEXISTENT |
+                                  MAILBOX_LIST_INDEX_FLAG_NOSELECT)) == 0) {
+                       /* no backing store and mailbox has no GUID.
+                          it can't be selectable, but the flag is missing. */
+                       node->flags |= MAILBOX_LIST_INDEX_FLAG_NOSELECT;
+                       *error_r = "mailbox is missing guid - "
+                               "setting it non-selectable";
+                       node->corrupted_flags = TRUE;
+               }
+
                node->name_id = irec->name_id;
                if (node->name_id == 0) {
                        /* invalid name_id - assign a new one */
index 2284f3af888d39e845ebb83dea92528064c5bc42..4825c3189cf1ba2a420ed084bcc0a4943e773729 100644 (file)
@@ -83,6 +83,8 @@ struct mailbox_list_index_node {
        enum mailbox_list_index_flags flags;
        /* extension data is corrupted on disk - need to update it */
        bool corrupted_ext;
+       /* flags are corrupted on disk - need to update it */
+       bool corrupted_flags;
        const char *name;
 };