On Mon, Feb 09, 2009 at 10:24:38AM +0000, Ian Eiloart wrote: > > > --On 7 February 2009 02:36:36 -0200 Carlos Horowicz > <carlos.horowicz@xxxxxxxxx> wrote: > >> I'm wondering what to do in a live system with may be hundreds of >> thousands of these strange e-mails already in users´ mailboxes, My god, that many? Nuke it from orbit. Only way to be sure. (alternative plan, grep for the bogus files, unlink them and reconstruct the mailboxes - cheaper and less radioactive) >> Should imapd be patched so that it just ignores the repetitions , both >> when building cyrus.cache and when it returns the headers to a client >> ? or should imapd really modify the original e-mail by stripping >> unnecessary/illegal headers and store a cleaned-up version ? > > It shouldn't be modifying messages. It should handle such messages > elegantly. Ignoring repetitions (beyond a threshold of repeats) seems the > most sensible option. However, failing to report them to a client could > cause confusion, so a threshold should be reasonably high. Of course some > headers are supposed to have multiple instances... Ditto with that. This patch ignores repetitions beyond a threshold. It turns out that ignoring specific headers separately is hard[tm], but just stopping parsing them after a count is way-easy. > Alerting the system administrator to the existence of such bogus messages > seems like a good idea, too. Perhaps through the logging system. Yeah, good point. Allow me to add that. > If you don't want a particular message in the system, then it should not > be accepted by LMTP or by any IMAP message creation mechanism. Ditto. Gosh. That makes 3 tunables. The gods of tunable non-proliferation will want my head for doing this: maxcacheheaders_warn = 500 maxcacheheaders_skip = 1000 (same as the current patch) maxcacheheaders_reject = 2000 Sound like reasonable defaults? I'm tempted to make the _reject be '0' (don't reject) by default. Bron.
Max header lines == 1000 by default to avoid supersized cache records --- a/imap/message.c +++ b/imap/message.c @@ -660,6 +660,7 @@ struct boundary *boundaries; int left, len; char *next; int sawboundary = 0; + int max_header_lines = config_getint(IMAPOPT_MAXHEADERLINES); body->header_offset = msg->offset; @@ -715,6 +716,8 @@ struct boundary *boundaries; for (next = headers; *next; next++) { if (*next == '\n') { body->header_lines++; + if (max_header_lines && body->header_lines > max_header_lines) + continue; /* we still want to get the full line count */ /* Check for headers in generic cache */ if (body->cacheheaders.start && diff --git a/lib/imapoptions b/lib/imapoptions index b17d831..43433e0 100644 --- a/lib/imapoptions +++ b/lib/imapoptions @@ -566,6 +566,10 @@ are listed with ``<none>''. /* Notifyd(8) method to use for "MAIL" notifications. If not set, "MAIL" notifications are disabled. */ +{ "maxheaderlines", 1000, INT } +/* Maximum number of lines of header that will be processed into cache + records. Default 1000. If set to zero, it is unlimited. */ + { "maxmessagesize", 0, INT } /* Maximum incoming LMTP message size. If non-zero, lmtpd will reject messages larger than \fImaxmessagesize\fR bytes. If set to 0, this -- 1.5.6.3
---- Cyrus Home Page: http://cyrusimap.web.cmu.edu/ Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html