From: Timo Sirainen Date: Mon, 25 Dec 2017 09:10:19 +0000 (+0200) Subject: imapc: Add imapc_features=no-msn-updates X-Git-Tag: 2.2.34~125 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1267bd08f79c1eabaf76665f99c45eeb52c456af;p=thirdparty%2Fdovecot%2Fcore.git imapc: Add imapc_features=no-msn-updates This is a stricter version of fetch-msn-workarounds. The MSNs aren't trusted at all. This means any new untagged EXISTS and EXPUNGE replies are ignored, as well as untagged FETCH replies that don't include UID. A potential downside with this feature is that UID FETCH/STORE commands sent to expunged messages will likely fail without the IMAP client being notified of the EXPUNGEs. New mails are also not noticed, so this should be used only when it's known that the clients don't keep the connection open for long. --- diff --git a/src/lib-storage/index/imapc/imapc-mailbox.c b/src/lib-storage/index/imapc/imapc-mailbox.c index 2045b1dd75..7e5b134ec6 100644 --- a/src/lib-storage/index/imapc/imapc-mailbox.c +++ b/src/lib-storage/index/imapc/imapc-mailbox.c @@ -274,7 +274,7 @@ imapc_untagged_exists(const struct imapc_untagged_reply *reply, uint32_t exists_count = reply->num; const struct mail_index_header *hdr; - if (mbox == NULL) + if (mbox == NULL || IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES)) return; mbox->exists_count = exists_count; @@ -352,7 +352,8 @@ imapc_mailbox_msgmap_update(struct imapc_mailbox *mbox, msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box); msg_count = imapc_msgmap_count(msgmap); if (fetch_uid != 0 && - IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_FETCH_MSN_WORKAROUNDS)) { + (IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_FETCH_MSN_WORKAROUNDS) || + IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES))) { /* if we know the UID, use own own generated rseq instead of the potentially broken rseq that the server sent. */ uint32_t fixed_rseq; @@ -474,6 +475,11 @@ static void imapc_untagged_fetch(const struct imapc_untagged_reply *reply, } } } + if (fetch_uid == 0 && + IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES)) { + /* UID missing and we're not tracking MSNs */ + return; + } imapc_mailbox_init_delayed_trans(mbox); if (imapc_mailbox_msgmap_update(mbox, rseq, fetch_uid, @@ -576,7 +582,8 @@ static void imapc_untagged_expunge(const struct imapc_untagged_reply *reply, struct imapc_msgmap *msgmap; uint32_t lseq, uid, rseq = reply->num; - if (mbox == NULL || rseq == 0) + if (mbox == NULL || rseq == 0 || + IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES)) return; mbox->prev_skipped_rseq = 0; diff --git a/src/lib-storage/index/imapc/imapc-settings.c b/src/lib-storage/index/imapc/imapc-settings.c index 89d43591db..c215d896d3 100644 --- a/src/lib-storage/index/imapc/imapc-settings.c +++ b/src/lib-storage/index/imapc/imapc-settings.c @@ -103,6 +103,7 @@ static const struct imapc_feature_list imapc_feature_list[] = { { "delay-login", IMAPC_FEATURE_DELAY_LOGIN }, { "fetch-bodystructure", IMAPC_FEATURE_FETCH_BODYSTRUCTURE }, { "fetch-empty-is-expunged", IMAPC_FEATURE_FETCH_EMPTY_IS_EXPUNGED }, + { "no-msn-updates", IMAPC_FEATURE_NO_MSN_UPDATES }, { NULL, 0 } }; diff --git a/src/lib-storage/index/imapc/imapc-settings.h b/src/lib-storage/index/imapc/imapc-settings.h index bdf331d985..f705ec216b 100644 --- a/src/lib-storage/index/imapc/imapc-settings.h +++ b/src/lib-storage/index/imapc/imapc-settings.h @@ -19,6 +19,7 @@ enum imapc_features { IMAPC_FEATURE_DELAY_LOGIN = 0x800, IMAPC_FEATURE_FETCH_BODYSTRUCTURE = 0x1000, IMAPC_FEATURE_FETCH_EMPTY_IS_EXPUNGED = 0x4000, + IMAPC_FEATURE_NO_MSN_UPDATES = 0x8000, }; /* */