]> 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)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 22 May 2017 12:12:03 +0000 (15:12 +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 e86c73f84d63eb4d5092a6d6663550cf2e35123c..dad5375793498586902858cfac493b2a1fa74bd4 100644 (file)
@@ -388,7 +388,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 491191da80e1d357777fe3018a733ada6883f75f..bb3b83f142c1cc28ac3e83ff37896d917e016a69 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;
 };