Re: [exim] Exim can't resolve hostname of database when seco…

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Viktor Dukhovni
Date:  
À: exim-users
Sujet: Re: [exim] Exim can't resolve hostname of database when second email is sended in one TCP connection
On Sat, Nov 16, 2013 at 10:54:11PM -0800, Phil Pennock wrote:

> Oh, right. We don't call `dns_init()` at program start, only when we're
> about to do something DNS-related for the purpose of mail-routing.
> That's ... unfortunate.
>
> [...]
>
> I'm tempted to just call dns_init() near the start of the program, to
> force state to be more consistent for external lookups, because this
> sort of ill-defined state is awkward to debug.


Perhaps what I propose below is impractical for Exim, but otherwise,
I think it makes sense to not change default DNS behaviour except
when performing MX lookups and resolving MX host IP addresses.

Postfix wraps its own libdns layer around libresolv. This is used
by the SMTP client to resolve SMTP destinations (and more recently
for DANE TLSA lookups). It is also used for RBL lookups in the
SMTP server. This code temporarily changes _res.options around a
lookup to disable any of:

    RES_DEBUG | RES_DNSRCH | RES_DEFNAMES | RES_USE_DNSSEC


that are not requested by the caller. The flags are restored to
their original values as soon as res_search() returns:

        _res.options &= ~saved_options;
        _res.options |= flags;
        len = res_search(name, C_IN, type, reply->buf, reply->buf_len);
        _res.options &= ~flags;
        _res.options |= saved_options;


when flags includes "RES_USE_DNSSEC", the additional flag RES_EDNSO
is automatically added to flags and its current setting to saved_options.

    http://www.postfix.org/postconf.5.html#smtp_dns_support_level


Since Postfix is not multi-threaded, this has no effect on hostname
lookups in other contexts. Thus, for example, when LDAP, MySQL,
PgSQL, etc., are configured with various server hostnames, these
are resolved just as they would in any other (DNS agnostic)
application with the same configuration.

-- 
    Viktor.