deliver appears to copy "^From " header lines from stdin when delivering
to Maildir.  The header filtering in mbox-save.c prevents this when
delivering to an mbox and instead a synthesized "^From " header is
written.

This is an issue when using, for example, Postfix and

  mailbox_command = /usr/libexec/dovecot/deliver

which does not appear to have an option not to write a "^From " header on
the mailbox_command input.

I'm attaching a patch that adds a save_header_callback() along the same
lines as in mbox-save.c but I'm really not sure this is the right way to
do it.
diff -r a0c3daf7e501 src/deliver/deliver.c
--- a/src/deliver/deliver.c     Mon Aug 13 18:00:18 2007 +0300
+++ b/src/deliver/deliver.c     Tue Aug 14 16:47:34 2007 +0100
@@ -16,6 +16,7 @@
 #include "strescape.h"
 #include "var-expand.h"
 #include "message-address.h"
+#include "message-parser.h"
 #include "istream-header-filter.h"
 #include "mbox-storage.h"
 #include "dict-client.h"
@@ -410,6 +411,18 @@ static const char *address_sanitize(cons
        return ret;
 }
 
+static void save_header_callback(struct message_header_line *hdr,
+                                 bool *matched, void *context)
+{
+       i_assert(matched && context == NULL);
+       if (hdr != NULL) {
+               if (strncmp(hdr->name, "From ", 5) == 0) {
+                       *matched = TRUE;
+               }
+       }
+       return;
+}
+
 static struct istream *create_mbox_stream(int fd, const char *envelope_sender)
 {
        const char *mbox_hdr;
@@ -426,7 +439,7 @@ static struct istream *create_mbox_strea
                                                     HEADER_FILTER_NO_CR,
                                                     mbox_hide_headers,
                                                     mbox_hide_headers_count,
-                                                    NULL, NULL);
+                                                    save_header_callback, 
NULL);
        i_stream_unref(&input);
 
        input_list[0] = i_stream_create_from_data(default_pool, mbox_hdr,

Reply via email to