]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10070 Allow running without a valid resolv.conf file
authorOndřej Kuzník <ondra@mistotebe.net>
Thu, 22 Jun 2023 15:20:22 +0000 (16:20 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 9 Oct 2023 20:24:17 +0000 (20:24 +0000)
servers/lloadd/daemon.c

index b88fd687de8fe1ccd13f714de8f3a1593f56bb29..e0489365361f9e78b82ba72fcb89dd2c231dba58 100644 (file)
@@ -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;