httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Kew <n...@webthing.com>
Subject Re: mod_smtpd design.
Date Tue, 05 Jul 2005 02:01:44 GMT
Jem Berkes wrote:

> Nick, in one of the background docs you sent me

[aside: that's the material to be used for the ApacheCon tutorial,
and work-in-progress on the book]

>	 the 'connection filters' 
> were described as operating outside the scope of HTTP or any request_rec.

Indeed.  An HTTP connection, like an SMTP connection, can carry more
than one request.

> know this is a living, changing work in progress but it seems confusing, at 
> least to me, to shoehorn arbitrary protocols into HTTP-ish "requests".

Yes.  As discussed elsewhere in this thread, Apache is protocol-agnostic
only at a fairly limited level.  The request_rec can surely be re-used
for SMTP, but doing so is ugly.

> I'm having difficulty envisioning how an SMTP communication can be broken 
> up into requests, i.e. something like HTTP requests. For example:
> 
> 01  HELO joe
> 02  MAIL FROM:<sender1>
> 03  RCPT TO:<abc>
> 04  RCPT TO:<xyz>
> 05  DATA
> 06  ...
> 07  MAIL FROM:<sender2>
> 08  RCPT TO:<niq>
> 09  DATA
> 10  ...
> 11  QUIT
> 
> Now how do you split this up into requests? Does 05 represent a single 
> request, or does that DATA generate two different requests

That's a very good question.

I think in practical terms it has to be two requests: the processing
may diverge a lot - e.g. if the recipients have different antispam
policies, .forward files, or if one of them is an alias.  ISTR reading
some more general reasons for one request per recipient in Dan
Bernstein's explanation of why qmail works like that.

The difficulty then is how the DATA can be fed to both requests.
Bear in mind that in SMTP, compared to HTTP, reliability is more
important than performance.  Mailservers spool messages to a queue
before attempting to deliver.

I think the answer to that has to be for the core SMTP filter to
spool messages in three parts: envelope, SMTP headers, and body.
It should also use a lock *file* while spooling, so that it can
reliably detect an incompletely-spooled message after an event
such as power failure.

Of course, the headers will only be read if the envelope is accepted.
And the body should only be spooled when someone starts to read it -
after any headers-based filtering has taken place.

If I were coding this, I'd start with the above as overall scheme,
and dig deep into existing mailservers for further inspiration.

>	 - 03 and 04 (one 
> for each recipient)?


>	 Or is the whole thing, until 11, a single request? 

That's easy.  No chance!

> Perhaps the MAIL FROM's start new requests, i.e. 02 and 07 (two requests).

The envelope is exactly what the protocol module has to deal with.

> 
> It just seems ambiguous and difficult to justify in any way. Mind you I 
> still might be not fully understanding Apache's request paradigm.

No, you've raised a good question, to which mine may not be the only -
or even the best - answer.

-- 
Nick Kew

Mime
View raw message