Re: [exim] prepending to the localuser - what would be "the …

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Phil Pennock
Dátum:  
Címzett: Ray Chudzinski
CC: exim-users
Tárgy: Re: [exim] prepending to the localuser - what would be "the eximway"?
On 2008-02-07 at 11:40 -0800, Ray Chudzinski wrote:
> In a nutshell, I need to:
>
> - recognize an incoming message is one of the 'special' messages (most easily done by examining the source host. all of these will come from one MTA)
> - verify that the localuser is all numeric
> - rewrite the localhost portion by pre-pending a string
> - forward the re-written message to a specific remote host for delivery
>
> My question is were should I perform each piece of the logic.
>
> e.g.
> 1) matching the format in a router (and reccomendations on the router)
> 2) verification of the localuser in the router
> 3) pre-pending the string via a re-write (really not sure of this step)
> 4) deliverly using the remote_smtp transport


Do 1,2,3 in a redirect router; follow that router with a manualroute
router. The first router should use "address_data = ..." to cause
$address_data to be set and the second router should use "condition =
..." to check $address_data.

There are other ways, but you're then either tying together stuff from
the ACLs with variables to Routers in a different part of the config, or
you're relying upon the router ordering and how careful you are to use
no_more when needed (eg, redirect_router on the first to point to a
router after the last one that can normally ever be invoked, instead of
using $address_data).

Eg, if you have "hostlist the_weirdo = ...." defining the IP address of
the source host which does this, then:

mangle_special_foo:
  driver = redirect
  local_parts = ^\\d+\$
  condition = ${if and{\
      {match_ip{$sender_host_address}{+the_weirdo}}\
    {your_other_verification_goes_here}}}
  data = ${local_part}@PREFIX.$domain
  address_data = is_foo
  redirect_router = send_foo


send_foo:
driver = manualroute
transport = remote_smtp
condition = ${if eq{$address_data}{is_foo}}
route_data = specific.remote.host.tld

Note that this means that if the local-part doesn't verify, then it will
be tried by later routers. I suspect that if the local number is
invalid, then instead of having it in the condition then instead you
want to fail the address. In which case, you can use "allow_fail" on
the redirect and then use an explicit fail on the data expansion.
Especially if the PREFIX is the result of that lookup. Eg,

  allow_fail
  data = ${lookup{$local_part}cdb{/some/file.cdb} \
      {${local_part}@${value}.$domain}\
    {:fail: Unrecognised magic foo}}


Note that I don't ${quote_local_part:...} because it's verified to be a
number; otherwise, you might want to do so.

Checking the source host is easier in an ACL, so you might do that
instead of the match_ip stuff, and then check an $acl_m_whatever
variable; the only real downside is that some of your relevant logic is
then separated from the rest.