From dpc22 at cam.ac.uk Mon Oct 5 12:58:59 2009 From: dpc22 at cam.ac.uk (David Carter) Date: Mon, 5 Oct 2009 17:58:59 +0100 (BST) Subject: index_operatemailbox() / EXPUNGE bug Message-ID: Here's a rather nasty little bug in 2.3.15: . FETCH 1:2 fast * 1 FETCH (FLAGS (\Recent \Deleted \Seen) ... * 2 FETCH (FLAGS (\Recent \Seen) ... . OK Completed (0.000 sec) . SCAN "" a "hello world" . OK Completed (0.000 secs 1 calls) . EXPUNGE * 2 EXPUNGE <--- Whoops, didn't mean that one. * 1 EXISTS * 1 RECENT . OK Completed The correct message is expunged, imapd just reports the wrong message back to the client. Probably PINE or ALPINE given that this is an undocumented extension invented by the UW people. The root cause appears to be index_operatemailbox(). This restores static state in index.c and the global imapd_exists in imapd.c based on its mailbox argument, including: index_base = mailbox->index_base; index_len = mailbox->index_len; Unfortunately index.c works on the assumption that index_base is a private mmaped array (index_dirty = 1, set immediately by index_check()), so that it can compare the current cyrus.index with the previous version each time that index_check() is called. If index_base is just a copy of mailbox->index_base, then index_check() remaps both arrays (at least on Linux). You end up comparing two identical arrays, but with (mailbox->exists < imapd_exists), which means that index_check() is going to generate some untagged EXPUNGE responses. I attach a nasty patch to fix the SCAN extension by simply saving and then restoring all of the globals involved. index_operatemailbox() is called from two other functions in imapd.c: catenate_url() and cmd_urlfetch(). -- David Carter Email: David.Carter at ucs.cam.ac.uk University Computing Service, Phone: (01223) 334502 New Museums Site, Pembroke Street, Fax: (01223) 334679 Cambridge UK. CB2 3QH. -------------- next part -------------- A non-text attachment was scrubbed... Name: scan.patch Type: text/x-patch Size: 3108 bytes Desc: Url : http://lists.andrew.cmu.edu/pipermail/cyrus-devel/attachments/20091005/ed20b999/attachment.bin From zhangweiwu at realss.com Tue Oct 27 04:37:56 2009 From: zhangweiwu at realss.com (Zhang Weiwu) Date: Tue, 27 Oct 2009 16:37:56 +0800 Subject: sieve question: archive script Message-ID: <4AE6B164.1070203@realss.com> Hello. I could not find a sieve-specific forum so I had to ask here. It is in-top because I use cyrus imapd. I want to emulate the archive behavior of alpine (or pine) by using sieve, is it possible? In short, alpine does this: 1. At first of every month, e.g. July, create a new folder called sent-Jun 2. Move all emails in "sent" that dates before July to that folder I want to emulate this behavior once a year so that to put large amount of storage of historical emails to a separate folder to speed up opening INBOX.Sent as well as to move historical emails to folders symlinked from less expensive and less robust hardware. My question is, because of the limited time to deliver this, to avoid diving into sieve world with no result, may I know in advance with sieve language and all its extensions, is this task's client part possible using sieve? I would start alternative ways if sieve could not do it, e.g. perl + imap protocol library. I prefer sieve if possible. P. S. If I do it I'll share the result opensourced. Thanks in advance! Zhang Weiwu From brong at fastmail.fm Tue Oct 27 07:32:40 2009 From: brong at fastmail.fm (Bron Gondwana) Date: Tue, 27 Oct 2009 22:32:40 +1100 Subject: sieve question: archive script In-Reply-To: <4AE6B164.1070203@realss.com> References: <4AE6B164.1070203@realss.com> Message-ID: <20091027113240.GD9747@brong.net> On Tue, Oct 27, 2009 at 04:37:56PM +0800, Zhang Weiwu wrote: > Hello. I could not find a sieve-specific forum so I had to ask here. It > is in-top because I use cyrus imapd. > > I want to emulate the archive behavior of alpine (or pine) by using > sieve, is it possible? In short, alpine does this: > > 1. At first of every month, e.g. July, create a new folder called > sent-Jun > 2. Move all emails in "sent" that dates before July to that folder Sieve only runs during the LMTP phase. It doesn't move messages. > My question is, because of the limited time to deliver this, to avoid > diving into sieve world with no result, may I know in advance with sieve > language and all its extensions, is this task's client part possible > using sieve? I would start alternative ways if sieve could not do it, > e.g. perl + imap protocol library. I prefer sieve if possible. > > P. S. If I do it I'll share the result opensourced. I'd say go Perl + IMAP. It's pretty easy. Bron. From zhangweiwu at realss.com Tue Oct 27 20:51:45 2009 From: zhangweiwu at realss.com (Zhang Weiwu) Date: Wed, 28 Oct 2009 08:51:45 +0800 Subject: sieve question: archive script In-Reply-To: <20091027113240.GD9747@brong.net> References: <4AE6B164.1070203@realss.com> <20091027113240.GD9747@brong.net> Message-ID: <4AE795A1.4010100@realss.com> Bron Gondwana wrote: > Sieve only runs during the LMTP phase. It doesn't move messages. > > I'd say go Perl + IMAP. It's pretty easy. > Thanks. I guess I should start learning perl anyway.