svarshavchik / courier-libs

Courier Mail Server - shared libraries
10 stars 8 forks source link

incorrect flag sorting #28

Open jkroonza opened 2 years ago

jkroonza commented 2 years ago

http://cr.yp.to/proto/maildir.html

States:

New flags may be defined later. Flags must be stored in ASCII order: e.g., "2,FRS".

I'm seeing files stored with :2,TS

The correct ordering would thus be :2,ST

svarshavchik commented 2 years ago

There are many places in the code which update flags, so the sequence of steps needed to reproduce this would be needed, to look into this further. courier-imap, sqwebmail, and maildrop, all update message flags for multiple reasons. I checked courier-imap and sqwebmail's code, and it looks ok to me. maildrop uses whatever's set in FLAGS, so it's up to the recipe to set it correctly.

Having said that, this has been unnoticed for >20 years, some of this code is that old, so it hasn't caused any specific problems in practice. In any case, specific steps are needed to reproduce this.

jkroonza commented 2 years ago

I agree, not critical, only reason I picked up on it was because of other issues I was having and I wrote a checker to find issues that could potentially cause the symptoms we're seeing.

The repo of "quick and extremely nasty" tools here:

https://github.com/jkroonza/maildirtools/

We only use courier-imapd and courier-pop3d in combination with exim (which doesn't set any flags, just drops stuff in new/ - if that's of any help.

svarshavchik commented 2 years ago

Ok, I see where this is happening in the POP3 server if the IMAP server marked the message as deleted. The POP3 server only uses the S flag, so all it does is append it, without reordering it.

jkroonza commented 2 years ago

Cool. Don't worry about it though, if I get around to it I'll create a PR for you, but as you stated yourself, it's really not a major issue. I'm guessing if there are multiple maildir clients (eg, running some other mail server directly on the maildir as well) there MIGHT be a problem, but that would probably be the exception case rather than the rule, and if that was a problem someone would have reported already.