Re: [exim] DBM Lookup Question

Startseite
Nachricht löschen
Nachricht beantworten
Autor: W B Hacker
Datum:  
To: exim users
Betreff: Re: [exim] DBM Lookup Question
Marc Perkel wrote:
> Trying to do a DBM lookup.
>
> condition =
> ${lookup{$domain}dbm{/etc/exim/control/run/alllocal.db}{yes}{no}}
>
> But - if example.com is in the file it will also match xxx.example.com
>
> How do I do a lookup where xxx.example.com won't match if example.com is
> in the file but will match if xxx.example.com is in the file.
>
> Thanks in advance.
>
>


Marc,

AFAIK the crux of it is that the Exim variable '$domain' actually
matches <domain>.<tld>, and parses for that, ignoring any and all
prefixes (unless otherwise directed - for which Exim DOES already have
tools).

I haven't looked at the code, but the action appears to be to take the
two fields from the 'rightmost' end of the string (only).

If a more specific match is what you seek, the simplest way may be to
dump the contents of $domain into an acl_c|acl_m variable, then do a
straight string match wherein the inherent <domain<.<tld> portion
slicing is no longer in effect.

As in:

set acl_cX = $domain

followed by:

= {lookup{$acl_cX}dbm{/etc/exim/control/run/alllocal.db}{yes}{no}}


CAVEAT: Above sample not tested.

ELSE - implement your own slicing... But that is avoidable.

OTOH - I do a similar thing with BOTH hostname and helo using a
different sort of search, but against the same multi-purpose plaintext
flatfile:

${lookup{$sender_host_name}wildlsearch{/var/mail/filters/REGEXP-block}{yes}{no}}


${lookup{$sender_helo_name}wildlsearch{/var/mail/filters/REGEXP-block}{yes}{no}}

... which holds one entry per line of the form:

*hihellogoobye.com
*newsletter.autoeurope.com

Note that I am after a different goal than what you mention - going for
EITHER all-inclusive prefixes, (if any), OR ONLY the prefixed version -
and to have it all maintained in one place so it catches either a
careless network or a 'bot forging a distinctive HELO.

Note too that I do NOT want to trigger a DNS call, hence the use of a
plain string tool vs a 'hostlist' structure.

A CDB or cousin would be faster.

But ..

The flatfile is easier to maintain or eyeball, and ours are small enough
the efficiency loss is 'de minimus'.

For a multiple-server operation, I'd be inclined to maintain all the
lists in PostgreSQL, have it spit out and emplace 'fresh' CDB for Exim's
best speed AND avoidance of reliance on PostgreSQL being up and
available 24 X 7.

YMMV on those last two points...

Bill