[Avcheck] Patch: Preventing use of emtpy from

Michael Tokarev mjt@tls.msk.ru
Sun, 27 Oct 2002 15:24:17 +0300


[Answering an old, about a month ago, email]

Thomas Weiss wrote at Tue, 24 Sep 2002 22:23:52 +0200:
> * On Tue, Sep 24 you wrote:
> 
[]
>>And, why this strange method of determining if from address is
>>empty:
>>
>>
>>
>>>+      p = from;
>>>+      while (*p != 0) {
>>>+	   if (!isspace(*p)) {
>>>+	     from_empty = 0;
>>>+	     break;
>>>+	   }
>>>+	   p++;
>>>+      }
>>
>>That is, why test for spaces (tabs, newlines), instead
>>of just using (*from != '\0') ?  Bare spaces are illegal
>>in email address, a space should be either quoted (") or
>>escaped (\) or else it's an illegal character.  Where such
>>addresses with spaces comes from at your site (I assume
>>such situation happens there as you wrote this).
> 
> This is because for exim the value given with the -f switch on the
> command line is _exactly_ the same value as the value given via smtp
> with the "mail from:" command (that is, everything after the colon).
> This value goes into the address parser and that one croaks if it's
> emtpy (i.e. contains not a single non-space character) - the same with
> -f and "mail from:". sendmail and postfix seem to handle this another
> way.

Hmm, but exim strips out <> chars, yes? (so the argument isn't _exactly_
all after a colon in SMTP MAIL FROM command).  In this case, avcheck
should perhaps "canonicalize" every address (that is, strip all whitespaces)
before trying any deliveries, right at command line processing.

But the whole issue seems a bit odd to me.  There should be some flag(s)
in exim to tell it to use an address form that is sutable for it's own
sendmail wrapper, just like flags=q in postfix's pipe agent.

There are other questions around: what'll happen with other addresses
(recipients, or sender too) that may be legal for exim's smtp daemon
but illegal with it's sendmail wrapper?  Does such forms exists?  I.e.
what will happen with addresses that contains spaces, quotes, backslashes?
(There is a funny quirk in postfix that comes from sendmail: when command-
line sendmail wrapper encounters address like `a b', in _one_ argument,
it splits such an address and uses two separate addresses, `a' and `b', -
this is why flags=q is used with postfix, - in order to properly quote
original addresses, to be `a\ b' or `"a b"').

Without a good knowlege of this information, solution becomes somewhat
fragile at least.

Also, is it possible to use smtp instead of sendmail command-line interface
with exim?

[]
>>BTW, do you use avcheck with exim?
> 
> Yes. That is why I ran into this problem. Generally, of course, it is
> a really good and stable solution. Only the installation was a bit hard,
> since when I first installed the exim+avcheck combination (not very long
> ago) I was new to exim (I had mostly used postfix before). And with the
> documentation in README.Exim I had a real hard time getting it to work.
> I finally had to use a totally different solution as described there.
> But at least it was a good introduction to exim.

Just like stated in README.Exim, this is completely untested (by me)
and just stolen from DrWeb's documentation.  And since you used different
method, may you share it with us, updating README.Exim appropriately?

Thanks.

/mjt