commit 576780f072e0f8c953b5e9936a271a383205f846
Author: Oswald Buddenhagen <[email protected]>
Date: Tue May 3 09:42:27 2011 +0200
make maildir uidvalidity change fatal
it's best to give the user a chance to fix it rather than completely
messing up the syncstate by re-enumerating the UIDs.
src/drv_maildir.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index c8226bc..9d4a00e 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -399,6 +399,15 @@ maildir_uidval_lock( maildir_store_t *ctx )
lseek( ctx->uvfd, 0, SEEK_SET );
if ((n = read( ctx->uvfd, buf, sizeof(buf) )) <= 0 ||
(buf[n] = 0, sscanf( buf, "%d\n%d", &ctx->gen.uidvalidity,
&ctx->nuid ) != 2)) {
+#if 1
+ /* In a generic driver, resetting the UID validity would be the
right thing.
+ * But this would mess up the sync state completely. So better
bail out and
+ * give the user a chance to fix the mailbox. */
+ if (n) {
+ error( "Maildir error: cannot read UIDVALIDITY.\n" );
+ return DRV_BOX_BAD;
+ }
+#endif
return maildir_init_uid_new( ctx );
} else
ctx->uvok = 1;
@@ -624,6 +633,12 @@ maildir_scan( maildir_store_t *ctx, msglist_t *msglist )
entry = &msglist->ents[i];
if (entry->uid != INT_MAX) {
if (uid == entry->uid) {
+#if 1
+ /* See comment in maildir_uidval_lock()
why this is fatal. */
+ error( "Maildir error: duplicate UID
%d.\n", uid );
+ maildir_free_scan( msglist );
+ return DRV_BOX_BAD;
+#else
info( "Maildir notice: duplicate UID;
changing UIDVALIDITY.\n");
if ((ret = maildir_init_uid( ctx )) !=
DRV_OK) {
maildir_free_scan( msglist );
@@ -631,6 +646,7 @@ maildir_scan( maildir_store_t *ctx, msglist_t *msglist )
}
maildir_free_scan( msglist );
goto again;
+#endif
}
uid = entry->uid;
if ((ctx->gen.opts & OPEN_SIZE) ||
((ctx->gen.opts & OPEN_FIND) && uid >= ctx->newuid))
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel