From: Timo Sirainen Date: Thu, 18 May 2017 20:13:38 +0000 (+0300) Subject: lib-storage: Fix mailbox list index records without guid having invalid flags X-Git-Tag: 2.2.30.rc1~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=65e20e8878b3381543696788c394ca28a031e395;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fix mailbox list index records without guid having invalid flags 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. --- diff --git a/src/lib-storage/list/mailbox-list-index-sync.c b/src/lib-storage/list/mailbox-list-index-sync.c index e86c73f84d..dad5375793 100644 --- a/src/lib-storage/list/mailbox-list-index-sync.c +++ b/src/lib-storage/list/mailbox-list-index-sync.c @@ -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); diff --git a/src/lib-storage/list/mailbox-list-index.c b/src/lib-storage/list/mailbox-list-index.c index 8012615420..052b4c19b7 100644 --- a/src/lib-storage/list/mailbox-list-index.c +++ b/src/lib-storage/list/mailbox-list-index.c @@ -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 */ diff --git a/src/lib-storage/list/mailbox-list-index.h b/src/lib-storage/list/mailbox-list-index.h index 491191da80..bb3b83f142 100644 --- a/src/lib-storage/list/mailbox-list-index.h +++ b/src/lib-storage/list/mailbox-list-index.h @@ -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; };