Re: [Exim] lsearch*@ on a CDB file

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: Paul Makepeace
CC: exim-users
Subject: Re: [Exim] lsearch*@ on a CDB file
On Mon, 14 Jul 2003, Paul Makepeace wrote:

> driver = redirect
> data = ${lookup{$local_part@$domain} lsearch*@ {/etc/mail/forwards}{$value}fail}
>
> I would now like to instead perform that same search but using a
> constant database file. This feels like it should be obvious but to me
> isn't, despite scouring chaps 9 and 11. Can someone please help?


1. Download a cdb distribution (I believe there are now several).
2. Build it, but install only the utility for making cdb files (unless
of course you want to use cdb for other things).
3. Use the utility to build /etc/mail/forwards.cdb from your original.
4. Change lsearch@* to cdb@* and change the file name.

Voila.

> (FWIW, I find the disjoint and forward reference between lookup types
> and their syntax confusing.</lone-voice>)


Sorry. One of the things that nearly drove me to give up writing the
book was the fact that there is no straightforward way to describe it
all because is is so self-referential.

> Ideally I would like this driver to only be run on condition _an_ entry
> appears in the file, e.g. if there are no entries for example.com then
> skip the driver, but if there are they it should fail if it's not found.


Strictly, if you want to skip a driver, you have to do the test in a
precondition. But this probably isn't what you want.

If you just use a very simple lookup, e.g.

data = ${lookup{$local_part@$domain} cdb*@ {/etc/mail/forwards.cdb}}

(missing out the "fail" stuff), the result of a failed lookup is an
empty string, and in that case the driver will decline. Technically,
skipping and declining are different (the "more" option affects the
latter and not the former). However, it won't make any difference here.

> Previously it was thus,
> data = ${if exists{/etc/mail/domain_aliases/$domain}{${lookup{$local_part}lsearch*{/etc/mail/domain_aliases/$domain}}}fail}


You could use a "require_files" option instead of the exists test.

> Has someone compiled a lookup cookbook that is on the Web & indexable?
> (I.e. doesn't require FTP and an evening of spelunking a large
>       text file.)


I don't know of a lookup cookbook.

However, the HTML form of the reference manual has an index with
hyperlinks. It is online, but also downloadable. The info format of the
manual has links of various kinds. The book has a chapter about lookups.


--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book