Re: [exim] Extracting values from a wildlsearch

トップ ページ
このメッセージを削除
このメッセージに返信
著者: W B Hacker
日付:  
To: exim users
題目: Re: [exim] Extracting values from a wildlsearch
Todd Lyons wrote:
> A guy came in to the #exim IRC channel today and asked what seemed
> like a simple question, but I couldn't figure out a way to make it
> work.
>
> He has a file that's used for mapping domain names to a relay server.
> For example:
> # cat test.conf
> domain.com:    192.168.1.8
> todd.com:    192.168.1.10
> blue.com:    192.168.1.40
> row.com:    192.168.1.10

>
> "Now I want to accept relay from IP addresses where I route manually,
> I do not find a way to build a list of<IP> from the file, any hins?
> (note the only way I found was to build a second file by extracting IP
> with some shell scripts
>
> So he wants to generate a hostlist of all IP's that he manually routes
> to. I figured a simple wildlsearch regex search on the file for .*
> would do exactly what he wanted, so I tested with:
>
> hostlist test_hosts = ${lookup{^.*}wildlsearch{/etc/exim/test.conf}
>
> But it doesn't work, it shows this when being processed in an acl:
>>>> processing "warn"
>>>> check hosts = +test_hosts
>>>> ^.* in "domain.com"? no (end of list)
>>>> ^.* in "todd.com"? no (end of list)
>>>> ^.* in "blue.com"? no (end of list)
>>>> ^.* in "row.com"? no (end of list)
>>>> host in ""? no (end of list)
>>>> host in "+test_hosts"? no (end of list)
>
> I also tried {^\N.*\N} and a few other combinations which had the same
> negative result.
>
> Is there a way to do it the way he wants? Does he have to use
> something other than wildlsearch? Or just a different regex? Or is
> the only solution (without external scripts) going to be to slurp the
> file in with readfile and transform it with sg?
>
> ...Todd


So long as one is trying to 'stuff' the returns into, or substitute for,
a hostlist structure?

Pass.

I side-stepped that by using a direct SQL call.

But that is not a general 'solution', nor even one I could in good
conscience recommend - given the overhead of the RDBMS.

It DOES, however, indicate that *direct* use of the 'lsearch' return
instead of using the return to populate a hostlist - which is in turn to
then be used as 'hostlist' are - (yet-another form of lookup, with rules
of its own...), might serve.

Which type of (x)search should then be driven by need.

A 'properly populated' flat file (or CDB, or ...wotever) for a vanilla
'lsearch' being easier in my mind to 'assure' that NEEDING a 'wild'
anything... even if that wanted external pre-processing to clean it up.

Plenty of scriptable tools for THAT that run less risk of clobbering the
smtpd.

Has that not already been done?

Bill
--
韓家標