Re: [exim] SMTP-time rewriting

Top Pagina
Delete this message
Reply to this message
Auteur: John Jetmore
Datum:  
Aan: exim-users
Onderwerp: Re: [exim] SMTP-time rewriting
On Tue, Jun 22, 2010 at 5:51 AM, Dave Evans
<exim-users-20081202@???> wrote:
> On Mon, Jun 21, 2010 at 02:38:37PM +0300, Nikita Koshikov wrote:
>> Hello exim experts,
>>
>> I need exim to rewrite addresses like: <user@domain*admin> to the form <user@domain>.
>>
>> Here is the rule I made for this:
>>
>> \N^(.*)\*admin(.*)?$\N          $1$2 S
>>
>> This is working on smtp-time MAIL FROM stage as I needed, but headers doesn't touched by it.
>> Adding one more rule without S flag didn't help and body headers From, Sender, etc list unrewritten data.
>>
>> What's wrong and how can I fix this ?
>
> Well on my box, rewriting aside,
>
> # exim4 -brw 'user@???*admin'
> Syntax error in user@???*admin
> Malformed address: *admin may not follow user@???
>
> Since user@???*admin isn't a valid address (on account of "*" not being
> allowed in domain names), it looks to me like you're going to have a really
> hard time making it work.


Dave's right, though it took me a few minutes to prove it to myself.
I thought the "Malformed address" error was lingering from other
checks, but it seems to be core to rewriting. The address won't even
be considered if it's invalid like that. For instance, this logically
behaves the way you want, rewriting both the SMTP and Message headers
when tested against user*admin@???.

\N^(.*)\*admin(.*)?$\N          $1$2 Sh


However, when tested against user@???*admin, the SMTP-time
rewrite works because it is defined as not caring about the syntax.
However, it looks like exim's concept of what a domain is is so
ingrained that it doesn't recognize user@???*admin as a valid
email and therefore never even attempts to apply a rewrite rule to it.
I did prove to myself that the one rule/two rule thing is a red
herring - it doesn't work because, in header rewrites, exim doesn't
see it as an email address.

I don't really understand whether this is a bug or not. My initial
impression is that, in address rewriting, this is the correct behavior
because it's not actually an address. I wonder if any of the more
generic rewriting functionality available in routers and transports
might be of more use to you.

FWIW, because I was initially confused by whether the -brw output was
doing the right thing, I used a cut down config file and variations of
the following to find the exact behavior:

swaks -t user@???*admin --pipe 'exim -bh 127.0.0.1 -d+rewrite
-C ./configure'

swaks -t user@??? --header-To 'user@???*admin' --pipe
'exim -bh 127.0.0.1 -d+rewrite -C ./configure'

swaks -t user@??? --header-To 'user*admin@???' --pipe
'exim -bh 127.0.0.1 -d+rewrite -C ./configure'

swaks -t user*admin@??? --pipe 'exim -bh 127.0.0.1 -d+rewrite
-C ./configure'

--John