[Avcheck] Re: Combined avcheck / Postfix question -- open relay issue

Michael Tokarev mjt@tls.msk.ru
Wed, 08 May 2002 17:05:39 +0400


Ralf Hildebrandt wrote:
> 
> On Wed, May 08, 2002 at 02:31:51PM +0200, Ralf Hildebrandt wrote:
> 
> > The original envelope information was:
> > MAIL FROM:<bitbucket@ordb.org>
> > RCPT TO:<"foo@bar.com"@charite.de>
> >
> > My virtual_maps entry:
> > /^(.*)@charite\.de$/   catchall+$1@hauptpostamt.charite.de
> > has stripped the "'s
> 
> Ah, now I know what "The table format does not understand quoting
> conventions." means :)

No, that's not quite right.  Postfix uses "raw" address format for
map lookups.  Internal form of addresses.  But it seems different
parts of postfix understands the same internal format differently.

Here is a code from avcheck:

static char *
_quoteaddr(const char *addr, int alloc)
{
  int l, r;
  const char *e = strrchr(addr, '@');
                  ^^^^^^^  note strRchr here.  I.e. *last* '@'.
  if (!e)
    e = addr + strlen(addr);
  if (is_rfc821_ok(addr, e))
    return (char*)addr;

The same is in postfix's quote_822_local() routine (822, 821... ;)

VSTRING *quote_822_local(VSTRING *dst, const char *mbox)
...
    if ((end = strrchr(start, '@')) == 0)
        end = start + strlen(start);
    if (is_822_dot_string(start, end)) {
        return (vstring_strcpy(dst, mbox));
    } else {
        ...

In pipe/pipe.c:

static void morph_recipient(VSTRING *buf, const char *address, int flags)
{
    char   *cp;

    /*
     * Quote the recipient address as appropriate.
     */
    if (flags & PIPE_OPT_QUOTE_LOCAL)          <= flags=q
        quote_822_local(buf, address);
    else
        vstring_strcpy(buf, address);

So, in avcheck, this address should be passed as "bar@baz.com"@example.com.
Following the rules.

It is interesting to try this with a trivial shell script that just
prints it's arguments to some file.  Hmm...  Avcheck SHOULD receive
quoted form.  And next, smtpd SHOULD interpret that properly.  Errm...
Next round... ;)

Regards,
 Michael.