Re: [Exim] check host_accept_relay from script?

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Philip Hazel
Dátum:  
Címzett: Dave C.
CC: exim-users
Tárgy: Re: [Exim] check host_accept_relay from script?
On Tue, 27 Feb 2001, Dave C. wrote:

> Say it contained:
>
> 10.34.0.0/18 : 192.168.5.0/24 : 192.168.19.0/24
>
> If I put that in a file, one per line, and used
>
> host_accept_relay = net-lsearch;/some/file


If you are never going to consider turning it into anything other than
lsearch, you could in fact just omit "net-lsearch;" altogether. The file
is valid as an insertion.

> Grumble.. Testing suggests that while this:
>
> > host_accept_relay = net-lsearch;/some/file
>
> would probably work fine, this:
>
> > ${lookup{$sender_host_address}net-lsearch{/some/file}{yes}{no}}
>
> will not. The spec implies that the net- appendage to lsearch is only
> valid when exim is parsing a host list.. Sigh...


But

${lookup{$sender_host_address}lsearch{/some/file}{yes}{no}}

will work.[1] You need to have the "net-" prefix in host lists to tell Exim
to search using the address instead of the name. But in this lookup, you
are giving the key explicitly, so there's no need.

[1] Actually, it won't work. Your file has keys like "10.34.0.0/18" but
$sender_host_address contains just an IP address. However, all is not
lost. You can use the ${mask... construction to turn it into the right
form. But unfortunately, you have two different key lengths. You'll have
to use

${lookup{${mask:$sender_host_address/18}}lsearch{/some/file}{yes}
{
${lookup{${mask:$sender_host_address/24}}lsearch{/some/file}{yes}{no}}
}}

(Untested. Please check matching {} constructions.)


-- 
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.