[Dovecot] dovecot, procmail and deliver

David Lee t.d.lee at durham.ac.uk
Thu Oct 5 13:26:36 UTC 2006


On Tue, 3 Oct 2006, David Lee wrote:

> [...]
> Second: "deliver" seems to add an unconditional "From " line at the start
> of each delivery.  From sendmail, using the 'n' flag, "Mlocal F=...n..."
> that is OK.  (Although I'm not convinced that "dovecot.deliver", nor its
> two-space separator (emphasis on "two") from the following date are
> ideal.  Nor, come to that, that line's lack of "@somewhere".)
>
> But from a procmail recipe, I end up with two "From " lines.  Surely this
> is incorrect.  How can this be reduced to one?  Shouldn't "deliver" ensure
> that there is only "From " line?
> [...]

The deeper I look into this, the more convinced I am that there is a real
problem in dovecot LDA, part of which is a misunderstanding by dovecot of
the "mbox" "From " line and a consequent problem in code structure (not
merely in code details).

In what follows, I'll use the term "From_" (with a visible underscore)
to refer to the "From " (word followed by a single space) which should
actually be in the file.

References to the code are based on rc7.

The mbox format (check, for example, "mail.local" man pages) says that
"mbox" delimits its messages by a prepended "From_" line at the start and
an appended blank line at the end.  (Dovecot does that.)

But it is also clear that the next part of the "From_" line should be both
a full email name "some.one at some.here", and also that this represents the
sender.  But dovecot's fixed text "dovecot.deliver" breaks both those.

Naturally, I then turned to the source code, with a view to patching it.
But this, I fear, seems to be much more convoluted than I had hoped.

"deliver.c", near line 525, calls "create_mbox_stream()".  This sets up
the stream with the fixed "From dovecot.deliver ..."  It then opens the
mbox, returning result "box".  Only then does it attempt to read the
incoming email, which may itself already contain a "From_" specification.
And that reading itself uses the "box" result which references the
erroneous, prematurely-set, fixed string.

What we need is something either:

1a Create the mbox stream, but without yet committing a "From_" spec.

1b Start reading the incoming email.  If it already contains a "From_"
   spec., use that, else create some sort of default (equivalent to the
   exiting "dovecot.deliver" but as a full email name).

1c Put that "From_" into the mbox stream.

1d Copy remainder of incoming email (without any residual "From_") into
   the stream (etc.)

or:

2a Read first line of incoming email.  If it is a "From_", store it and
   also remove it from incoming stream, else create some sort of default
   "From_".  (We now have a "From_" variable, and an incoming stream
   positioned after any leading "From_".)

2b Create mbox stream, very similarly to as at present, but using the
   "From_" variable.

2c Copy remainder of incoming email (without any residual "From_") into
   the stream (etc.)



This is probably fixable by someone who knows the code.  (But although
I've got many years of C "under the belt", I'm new to the dovecot
codebase, and this particular problem seems rather deeply embedded in the
code's structure.)

Any thoughts?  Timo?


-- 

:  David Lee                                I.T. Service          :
:  Senior Systems Programmer                Computer Centre       :
:                                           Durham University     :
:  http://www.dur.ac.uk/t.d.lee/            South Road            :
:                                           Durham DH1 3LE        :
:  Phone: +44 191 334 2752                  U.K.                  :


More information about the dovecot mailing list