[Exim] Interesting tidbit on selecting domains from MySQL, +…

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Avleen Vig
Dátum:  
Címzett: exim-users
Tárgy: [Exim] Interesting tidbit on selecting domains from MySQL, + feature request
While working on the next release of Virtual Exim[1], Rossz and I
stumbled across this little bit of knowledge.. it's odd, maybe someone
else can explain it? I can only speculate:

Did a little fiddling, and this works on Exim 4.20:
VIRTUAL_DOMAINS = SELECT DISTINCT concat(domain, ' : ') from <table>

domainlist local_domains = localhost : ${lookup mysql{VIRTUAL_DOMAINS}}


I add the concat in, to put a : after each domain.
A nice strange thing I discovered:
Mysql returns the results, on per line.
Normally you have to put a \ at the end of each line, so Exim knows that
it should continue searching for a match on the next line.

This isn't necessary for MySQL results :-)
In fact, putting a ":\" at the end of the line actually broke it, and
caused Exim to think the result was a negative rather than a positive
match.

Here's some debug output:

>>> processing "accept"
>>> check domains = +local_domains
>>> silverwraith.com in "localhost : silverwraith.com :
>>> localhost.silverwraith.com :mail.silverwraith.com :
>>> pear.silverwraith.com : <mysql result 1> :
>>> <mysql result 2> :"? yes (matched "silverwraith.com")
>>> silverwraith.com in "+local_domains"? yes (matched "+local_domains")
>>> check verify = recipient
>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> routing lists-exim@???
>>> silverwraith.com in "localhost : silverwraith.com :
>>> localhost.silverwraith.com :mail.silverwraith.com :
>>> pear.silverwraith.com : <mysql result 1> :
>>> <mysql result 2> :"? yes (matched "silverwraith.com")
>>> silverwraith.com in "! +local_domains"? no (matched "!
>>> +local_domains")
>>> calling virtual_domains router
>>> routed by virtual_domains router



Something else I just realised:
If the domains are specified in the config file, Exim will cache the
results for the next time that questions is asked, eg:

>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> routing lists-exim@???
>>> silverwraith.com in "! +local_domains"? no (matched "! +local_domains" - cached)


But it appears this caching isn't happening on replied given by the
database? If anything, this SHOULD be done, to reduce the number of
calls to the database, which could end up being expensive is your
database is slow, or across a network.

--
Avleen Vig                   "Say no to cheese-eating surrender-monkeys"
Systems Admin                "Fast, Good, Cheap. Pick any two."
www.silverwraith.com         "Move BSD. For great justice!"