[Exim] domainlists and perl

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Roy Hooper
Dátum:  
Címzett: exim-users
Tárgy: [Exim] domainlists and perl
Hi There,

I have encountered a fun problem to do with domainlist expansion. It seems
that when a domainlist is expanded that contains a perl subroutine call in
the expansion string that returns undef, both a positive domainlist
expansion and a negative domainlist expansion fail! The only workaround is
to be sure that "" is used as the return value for no results.

This problem reared its ugly head at me when I was tying to use the
domainlist:

PRIMARY_HOSTNAME = kosh.momentous.ca
ALIASDOMAINS = ${perl{domainlookup}{$domain}}
domainlist local_delivery_domains = @ : PRIMARY_HOSTNAME : \
        lsearch;/usr/local/etc/exim/local-host-names
domainlist local_domains = +local_delivery_domains : ALIASDOMAINS
domainlist relay_domains = lsearch;/usr/local/etc/exim/relay-domains


domainlookup is a perl routine to query a MSSQL database via FreeTDS
(DBI/DBD::Sybase).

The routine was returning undef for various reasons that were non-critical
failures, and using die for critical failures.

The problem was manifesting itself as:

routing postmaster@???
--------> lookuphost router <--------
local_part=postmaster domain=kosh.momentous.ca
checking domains
kosh.momentous.ca in "!+local_domains"? yes (end of list)
calling lookuphost router
lookuphost router called for postmaster@???
domain = kosh.momentous.ca

After much confusion during debugging, it occurs to me that I could have
saved a lot of time if the following debugging facilities existed:
- string expansion debugging that shows each individual expansion taking
place and the results, say something like:
expanding "$primary_hostname"
expansion result is "kosh.momentous.ca"
- perl call diagnostics (routine, parameters, and results), especially
noting when an undef was returned.
- domainlist indicating when a failure occured causing the domainlist to
fail

I also encountered that a result value other than a scalar seems to behave
just like undef -- so returning arrays (or hashes) doesn't result in
expected behaviour. I expected array results to be interpreted in-context,
either by concatenating values with newlines or spaces (alias data context)
or as individual list items (domainlist context).

Either way, I don't feel any changes are necessary to Exim, but I thought
I'd share my experiences so that other people using Perl to do magic have
some more notes.

Cheers,
Roy