From: <ad...@be...> - 2007-08-18 23:54:39
|
Bug #11797, was updated on 2007-Aug-19 01:53 Here is a current snapshot of the bug. Project: Community Fetchmail Category: None Status: Open Resolution: None Bug Group: None Priority: 5 Submitted by: cqrs Assigned to : none Summary: imap_mark_seen doesn't consider expunged messages Details: There seems to be a bug in the imap_mark_seen function -- it doesn't take expunged messages into account. Here is an example. First, .fetchmailrc : ====================================================================== poll XXXXXXXXXX protocol IMAP plugin "ssh %h /usr/sbin/imapd" auth ssh mda "formail >> fetched.mail" keep flush ====================================================================== Suppose there are two messages on the server -- one old (seen) and one new. With the config above fetchmail should expunge the first message, then fetch the second message and mark it seen. In fact fetchmail cannot mark the second message seen because of the wrong number. Output of "fetchmail -v": ====================================================================== fetchmail: 6.3.8 querying XXXXXXXXXX (protocol IMAP) at Thu Aug 9 20:03:53 2007: poll started fetchmail: running ssh %h /usr/sbin/imapd (host XXXXXXXXXX service imap) fetchmail: IMAP< * PREAUTH [CAPABILITY IMAP4REV1 LITERAL+ IDLE NAMESPACE MAILBOX-REFERRALS BINARY UNSELECT SCAN SORT THREAD=REFERENCES THREAD=ORDEREDSUBJECT MULTIAPPEND] Pre-authenticated user YYYYYYYYYY XXXXXXXXXX IMAP4rev1 2004.352 at Thu, 9 Aug 2007 20:05:13 +0400 (MSD) fetchmail: IMAP> A0001 CAPABILITY fetchmail: IMAP< * CAPABILITY IMAP4REV1 LITERAL+ IDLE NAMESPACE MAILBOX-REFERRALS BINARY UNSELECT SCAN SORT THREAD=REFERENCES THREAD=ORDEREDSUBJECT MULTIAPPEND SASL-IR LOGIN-REFERRALS AUTH=LOGIN fetchmail: IMAP< A0001 OK CAPABILITY completed fetchmail: IMAP> A0002 SELECT "INBOX" fetchmail: IMAP< * 2 EXISTS fetchmail: IMAP< * 0 RECENT fetchmail: IMAP< * OK [UIDVALIDITY 1104692132] UID validity status fetchmail: IMAP< * OK [UIDNEXT 147861] Predicted next UID fetchmail: IMAP< * FLAGS (\Answered \Flagged \Deleted \Draft \Seen) fetchmail: IMAP< * OK [PERMANENTFLAGS (\* \Answered \Flagged \Deleted \Draft \Seen)] Permanent flags fetchmail: IMAP< * OK [UNSEEN 2] first unseen message in /var/spool/mail/YYYYYYYYYY fetchmail: IMAP< A0002 OK [READ-WRITE] SELECT completed fetchmail: IMAP> A0003 SEARCH UNSEEN NOT DELETED fetchmail: IMAP< * SEARCH 2 fetchmail: IMAP< A0003 OK SEARCH completed 2 messages (1 seen) for YYYYYYYYYY at XXXXXXXXXX. skipping message YYYYYYYYYY@XXXXXXXXXX:1 flushed fetchmail: IMAP> A0004 STORE 1 +FLAGS (\Seen \Deleted) fetchmail: IMAP< * 1 FETCH (FLAGS (\Seen \Deleted)) fetchmail: IMAP< A0004 OK STORE completed fetchmail: IMAP> A0005 EXPUNGE fetchmail: IMAP< * 1 EXPUNGE fetchmail: IMAP< * 1 EXISTS fetchmail: IMAP< * 0 RECENT fetchmail: IMAP< A0005 OK Expunged 1 messages fetchmail: IMAP> A0006 FETCH 1 RFC822.SIZE fetchmail: IMAP< * 1 FETCH (RFC822.SIZE 939) fetchmail: IMAP< A0006 OK FETCH completed fetchmail: IMAP> A0007 FETCH 1 RFC822.HEADER fetchmail: IMAP< * 1 FETCH (RFC822.HEADER {933} reading message YYYYYYYYYY@XXXXXXXXXX:2 of 2 (933 header octets) fetchmail: IMAP< ) fetchmail: IMAP< A0007 OK FETCH completed fetchmail: IMAP> A0008 FETCH 1 BODY.PEEK[TEXT] fetchmail: IMAP< * 1 FETCH (BODY[TEXT] {6} (6 body octets)fetchmail: IMAP< ) fetchmail: IMAP< A0008 OK FETCH completed not flushed fetchmail: IMAP> A0009 STORE 2 +FLAGS (\Seen) fetchmail: IMAP< A0009 BAD Bogus sequence in STORE: Sequence out of range fetchmail: IMAP> A0010 LOGOUT fetchmail: IMAP< * BYE XXXXXXXXXX IMAP4rev1 server terminating connection fetchmail: IMAP< A0010 OK LOGOUT completed fetchmail: client/server synchronization error while fetching from YYYYYYYYYY@XXXXXXXXXX fetchmail: 6.3.8 querying XXXXXXXXXX (protocol IMAP) at Thu Aug 9 20:03:58 2007: poll completed fetchmail: Query status=7 (ERROR) fetchmail: normal termination, status 7 ====================================================================== When there are more messages on the server wrong messages would be marked seen before fetchmail fail. These messages will be lost on the next run. Even worse, some IMAP servers happily allow wrong message numbers in STORE command. In such cases a user will not even see any error message. Adding "expunge 0" to config mitigates the problem. And the following patch seems to solve it: ====================================================================== diff -urN fetchmail-6.3.8.orig/imap.c fetchmail-6.3.8/imap.c --- fetchmail-6.3.8.orig/imap.c 2006-12-16 03:34:38.000000000 +0300 +++ fetchmail-6.3.8/imap.c 2007-08-08 15:37:10.000000000 +0400 @@ -1239,6 +1239,9 @@ static int imap_mark_seen(int sock, struct query *ctl, int number) /* mark the given message as seen */ { + /* expunges change the fetch numbers */ + number -= expunged; + (void)ctl; return(gen_transact(sock, imap_version == IMAP4 ====================================================================== Tested on fetchmail 6.3.8. P.S. Thanks for the great program. For detailed info, follow this link: http://developer.berlios.de/bugs/?func=detailbug&bug_id=11797&group_id=1824 |