From: Ondřej Kuzník Date: Thu, 22 Jun 2023 15:20:22 +0000 (+0100) Subject: ITS#10070 Allow running without a valid resolv.conf file X-Git-Tag: OPENLDAP_REL_ENG_2_5_17~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=255e66b4325d2bad9f4f2aab6f069a28321bdb58;p=thirdparty%2Fopenldap.git ITS#10070 Allow running without a valid resolv.conf file --- diff --git a/servers/lloadd/daemon.c b/servers/lloadd/daemon.c index b88fd687de..e048936536 100644 --- a/servers/lloadd/daemon.c +++ b/servers/lloadd/daemon.c @@ -92,6 +92,11 @@ struct event_base *listener_base = NULL; LloadListener **lload_listeners = NULL; static ldap_pvt_thread_t listener_tid, *daemon_tid; +#ifndef RESOLV_CONF_PATH +#define RESOLV_CONF_PATH "/etc/resolv.conf" +#endif +char *lload_resolvconf_path = RESOLV_CONF_PATH; + struct event_base *daemon_base = NULL; struct evdns_base *dnsbase; @@ -1238,13 +1243,22 @@ lloadd_daemon( struct event_base *daemon_base ) assert( daemon_base != NULL ); - dnsbase = evdns_base_new( daemon_base, EVDNS_BASE_INITIALIZE_NAMESERVERS ); + dnsbase = evdns_base_new( daemon_base, 0 ); if ( !dnsbase ) { Debug( LDAP_DEBUG_ANY, "lloadd startup: " "failed to set up for async name resolution\n" ); return -1; } + /* + * ITS#10070: Allow both operation without working DNS (test environments) + * and e.g. containers that don't have a /etc/resolv.conf but do have a + * server listening on 127.0.0.1 which is the default. + */ + (void)evdns_base_resolv_conf_parse( dnsbase, + DNS_OPTION_NAMESERVERS|DNS_OPTION_HOSTSFILE, + lload_resolvconf_path ); + if ( lload_daemon_threads > SLAPD_MAX_DAEMON_THREADS ) lload_daemon_threads = SLAPD_MAX_DAEMON_THREADS;