Re: [Exim] Looking for a driver/router/transport that will d…

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Peter Radcliffe
Fecha:  
A: exim-users
Asunto: Re: [Exim] Looking for a driver/router/transport that will do qmail-style aliases?
Lorens Kockum <lk-m-exim@???> probably said:
> This looks useful (searching list archives on DSUFFIX
> immediately yields more info than searching for ".qmail"), but
> I'm not quite sure it'll go as far as I need.
>
> To use -default files, I suppose it would work to add as a
> condition that the .forward${local_part_suffix} exists, and
> put a repeat driver without that condition, but with file =
> .forward-default, if that exists, and if not just the .forward,
> and if not, the user. Well, I don't need that much complexity.


You can do most anything.

> What I do need is local-parts with several DSUFFIXes in. If I
> have a DSUFFIX several times, won't it take only the last one?
> Hmmm, maybe it should. Since suffix isn't a regexp, there's not
> a great deal of control over that.


DSUFFIX is just a macro (I use - and other people use + so I thought
I'd make it easy to change when I wrote the config).

It will match username-FOO where FOO may contain more -s, and then you
can use that to split it down if the exact file doesn't exist.

> The qmail algorithm is (as far as I can see), that given
>
> $user-$1-$2-$3@domain
>
> try in this order, stopping when file is found:
>
> .forward-$1-$2-$3
> .forward-$1-$2-default
> .forward-$1-$2
> .forward-$1-default
> .forward-$1
> .forward-default
> .forward
> regular delivery to user
>
> I don't have more than three dashes, but three dashes I do have,
> and the $1 $2 $3 parameters are not usually known, they're
> (mostly but not always) arbitrary numbers. For, say, 200 that
> go into $1-$2-default, I might want special treatment for one or
> two.
>
> Easy way to do this? Otherwise I think I can hack together a
> procmail file to do it, or some kind of script anyway.


Hrrm. I can see how to do that easily enough for a fixed number
of -es, but for an arbitary number ...

I guess I'd be tempted to use embedded perl in a forwardfile director
and a condition, to return the file it should use to deliver.

userforward:
  driver = forwardfile
  file_transport = address_file
  pipe_transport = address_pipe
  reply_transport = address_reply
  no_verify
  no_expn
  check_ancestor
  file = ${perl {forwardfile} \
                {${local_part}${local_part_suffix}} }
  filter
  suffix = DSUFFIX*
  suffix_optional
  condition = ${if eq \
                 {}{${perl {forwardfile} \
                           {${local_part}${local_part_suffix}} }} \
               {no}{yes}}


Where "forwardfile" is a perl function which works out what forward
file to use to and returns the name of it, or empty if there was no match.

Philip, would that ${perl...} expansion be cached ? I'd put a fail in
the 'file = $...' line if the perl returns nothing, but the docs say that
will make exim panic. If you have an empty "file =" it'll defer ...

Hmmm - docs say an empty file would cause it to be skipped, a
non-existant file would cause it to be skipped too. You could drop
the condition = if the perl returned, say, "/does/not/exist" if
it couldn't find an appropriate forwardfile ...

P.

-- 
pir                  pir@???                    pir@???