Re: [Exim] rewriting, redirecting, and the sendmail "+ hack"

Top Pagina
Delete this message
Reply to this message
Auteur: Kirill Miazine
Datum:  
Aan: Noah Meyerhans
CC: exim-users
Onderwerp: Re: [Exim] rewriting, redirecting, and the sendmail "+ hack"
Noah Meyerhans wrote:
> On Fri, Jul 11, 2003 at 10:00:05PM +0200, Kirill Miazine wrote:
> > > redirect:
> > >     driver = redirect
> > >     domains = ...
> > >     local_parts = dbm;/path/to/map.db
> > >     local_part_suffix = +*
> > >     local_part_suffix_optional
> > >     data = ${quote:\
> > >             ${extract{local_part}{$address_data}}$local_part_suffix\
> > >         }@${extract{domain}{$address_data}}

> >
> > Bummer!
> >
> > s/address_data/local_part_data/ in the above two lines.
>
> Hey, cool. That certainly seems to work, and it's definitely cleaner
> than the rewriting rule I was experimenting with before.
>
> The one question I have is: Why do you use the quote operator on the
> last line? That seems to double-quote the local part in the final
> destination, so envelope-to ends up containing addresses like
> "noahm+foo"@domain, which certainly doesn't seem right.


Yes it is. The local part was enclosed in double quotes because of the
"+" sign. No "+", no quotes:

    $ exim -be '${quote:user}@???'
    user@???


    $ exim -be '${quote:user+suffix}@???'
    "user+suffix"@???


> The Exim spec makes it clear that quote needs to be used if
> $local_part is in the expansion string somewhere, but it isn't present
> here.


There are situations when quoting is needed anyway. Exim specification
does not replace the brain. :)

> Removing the quote operator seems to result in a proper envelope-to
> header.


Ok, then you chose to shoot yourself in the leg. (I see nothing improper
with quotes around the local part.) You have $local_part_suffix! It is
much more "dangerous" than $local_part in this case. It can contain
anything. Say you send a message to

    "user+foo bar"@???


(Note the space in the local part suffix and quotes around the local part.)

Your map decides that mail to user@??? should go to
luser@???. With the local part suffix, that would result
in the following final addresses:

    * With ${quote:


        "lusr+foo bar"@???


    * Without ${quote:


        luser+foo bar@???


No further comments are needed, I hope.

> Just for fun, here's the bits of sendmail cf code to accomplish this in
> that other MTA:
> R$+ + $* < @ $=w . >    $: < $(xalias $1 $@ $1 $@ +$2 $: @ $) > $1 < @ $3 . >
> R$+ < @ $=w . >         $: < $(xalias $1 $@ $1 $: @ $) > $1 < @ $2 . >
> R$- + $-                $: < $(xalias $1 $@ $1 $@ +$2 $: @ $) > $1 < @ $j . >
> R$-                     $: < $(xalias $1 $@ $1 $: @ $) > $1 < @ $j . >
> R<@> $+                 $: $1
> R< error : $- $+ > $*   $#error $@ $(dequote $1 $) $: $2
> R< $+ > $+ < @ $+ >     $: $>97 $1

>
> Cute, huh?


I am not at all familiar with Sendmail, sorry.

--
Kirill Miazine, Stud.Jur.
Faculty of Law, University of Oslo