Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 119164 - Suggestion: USE flag for Cyrus-imapd to allow handling of non-RFC-compliant messages
Summary: Suggestion: USE flag for Cyrus-imapd to allow handling of non-RFC-compliant m...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Lowest enhancement (vote)
Assignee: Net-Mail Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-15 23:57 UTC by Janne Pikkarainen
Modified: 2006-08-08 13:47 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Modified ebuild for cyrus-imapd (cyrus-imapd-2.2.12-r4.ebuild,9.23 KB, text/plain)
2006-02-02 05:08 UTC, Arnaud Launay
Details
Patch allowing emails with NULL in them to go through (cyrus-imapd-unsupported-null.patch,1.55 KB, patch)
2006-02-02 05:09 UTC, Arnaud Launay
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Janne Pikkarainen 2006-01-15 23:57:02 UTC
Hello,

Here is the case: Cyrus IMAPd is annoyingly strict when it comes to following RFC's. For example, if a message contains NUL characters or "bare" newlines (only "\n", not "\r\n"), it gets rejected. There is no configuration option in imapd.conf for tuning this behaviour.

This can be very problematic in several cases:

- Broken MUAs sending out non-standard messages. Cyrus developers tell us "not to send broken messages", but unfortunately this does not apply in real world. Many webmails, press releases and so on are sent out in more or less malformed form. 

- During migration from some other mail system to Cyrus. Especially if you're doing IMAP-->IMAP copy (so one can preserve the message flags, such as \SEEN), things get nasty. You have to either massage the messages in the old server and fix them to be RFC-compliant before migration or patch the Cyrus to be more forgiving. Otherwise you will not be able to transfer your old mailboxes.

It's possible to partially tackle this problem by using some content filter at SMTP level and replace all the illegal stuff to be RFC-compliant, but I think that is very unnecessary overhead. Postfix is very fast without any external content filtering, but not so fast if it has to spawn (for example) /usr/bin/tr for every message. Due to structure of Postfix, it's not currently possible to remove NULs via a more light regexp mapping.

Thus I suggest a new USE flag ("allownonstandard", perhaps?), which would add a new configuration option to imapd.conf. I'll leave the actual coding to you Gentoo wizards :), but this should help you to get started. After the patch below I was able to migrate even a very broken mailbox (my spam folder with 15 000 messages) from an old uw-imapd to Cyrus.

The patch below relaxes Cyrus behaviour, allowing it to pass through messages with both NUL characters and bare newlines. Still needed is the configuration option and documentation part for it. 

---
--- imap/spool.c.original       2006-01-12 11:11:36.000000000 +0200
+++ imap/spool.c        2006-01-12 11:12:42.000000000 +0200
@@ -433,2 +432,0 @@
-           r = IMAP_MESSAGE_CONTAINSNULL;
-           continue; /* need to eat the rest of the message */
@@ -438,2 +435,0 @@
-           r = IMAP_MESSAGE_CONTAINSNULL;
-           continue; /* need to eat the rest of the message */
@@ -457,2 +452,0 @@
-           r = IMAP_MESSAGE_CONTAINSNULL;
-           continue;

--- imap/message.c.original     2006-01-12 11:24:00.000000000 +0200
+++ imap/message.c      2006-01-12 11:27:27.000000000 +0200
@@ -241 +241 @@
-       if (n != strlen(buf)) r = IMAP_MESSAGE_CONTAINSNULL;
+       /* if (n != strlen(buf)) r = IMAP_MESSAGE_CONTAINSNULL; */

--- imap/message.c.original     2006-01-16 09:24:42.000000000 +0200
+++ imap/message.c      2006-01-16 09:24:51.000000000 +0200
@@ -248 +248 @@
-               if (!sawcr) r = IMAP_MESSAGE_CONTAINSNL;
+/*             if (!sawcr) r = IMAP_MESSAGE_CONTAINSNL; */
Comment 1 Arnaud Launay 2006-02-02 05:08:26 UTC
Created attachment 78716 [details]
Modified ebuild for cyrus-imapd

Modified ebuild with a new flag, "unsupported_allownull", in concordance with the previous "unsupported_8bit"; it depends on next attachment.
Comment 2 Arnaud Launay 2006-02-02 05:09:19 UTC
Created attachment 78717 [details, diff]
Patch allowing emails with NULL in them to go through
Comment 3 Tuan Van (RETIRED) gentoo-dev 2006-07-11 17:33:23 UTC
With postfix 2.3 (coming soon), there is a "message_strip_characters" parameter that let postfix strip those NUL characters out or configure it to reject with "message_reject_characters". Would that work for you?
Comment 4 Janne Pikkarainen 2006-07-11 22:29:18 UTC
(In reply to comment #3)
> With postfix 2.3 (coming soon), there is a "message_strip_characters" parameter
> that let postfix strip those NUL characters out or configure it to reject with
> "message_reject_characters". Would that work for you?

Yes, that should be a reasonable way to fix this issue. You may resolve this bug at will. 

Thank you!

Comment 5 Arnaud Launay 2006-08-08 06:43:51 UTC
postfix 2.3 and according ebuilds are out, so maybe that one could be close ?
Comment 6 Tuan Van (RETIRED) gentoo-dev 2006-08-08 13:47:56 UTC
(In reply to comment #5)
> postfix 2.3 and according ebuilds are out, so maybe that one could be close ?
> 

and this one too.

Thanks,
Tuan