]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: add option to toggle reading /etc/hosts
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Jul 2018 12:46:00 +0000 (21:46 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Jul 2018 12:46:00 +0000 (21:46 +0900)
Workaround for #9718.

man/resolved.conf.xml
src/resolve/resolved-etc-hosts.c
src/resolve/resolved-gperf.gperf
src/resolve/resolved-manager.c
src/resolve/resolved-manager.h
src/resolve/resolved.conf.in

index dbd07e8151e2010a6184508f5d19b0fd3f547a83..055c47459262972db1eaf34176ef60bef1b28dc4 100644 (file)
         in use.</para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><varname>ReadEtcHosts=</varname></term>
+        <listitem><para>Takes a boolean argument. If <literal>yes</literal> (the default), the DNS stub resolver will read
+        <filename>/etc/hosts</filename>, and try to resolve hosts or address by using the entries in the file before
+        sending query to DNS servers.</para></listitem>
+      </varlistentry>
+
     </variablelist>
   </refsect1>
 
index 2c52c91b72f49cd138e15e0263e77347013bf607..5d394a863939f7c9a2f46b535d1659eab5af58df 100644 (file)
@@ -324,6 +324,9 @@ int manager_etc_hosts_lookup(Manager *m, DnsQuestion* q, DnsAnswer **answer) {
         assert(q);
         assert(answer);
 
+        if (!m->read_etc_hosts)
+                return 0;
+
         r = manager_etc_hosts_read(m);
         if (r < 0)
                 return r;
index 648ca4d8a24b674dff1937ecd215a21ee550b0e1..9b9290b727eae87a7a5c30e870922898a1bd2c14 100644 (file)
@@ -26,3 +26,4 @@ Resolve.DNSSEC,          config_parse_dnssec_mode,            0,
 Resolve.DNSOverTLS,      config_parse_dns_over_tls_mode,      0,                   offsetof(Manager, dns_over_tls_mode)
 Resolve.Cache,           config_parse_bool,                   0,                   offsetof(Manager, enable_cache)
 Resolve.DNSStubListener, config_parse_dns_stub_listener_mode, 0,                   offsetof(Manager, dns_stub_listener_mode)
+Resolve.ReadEtcHosts,    config_parse_bool,                   0,                   offsetof(Manager, read_etc_hosts)
index 44a53952d2450b7d3befd2ed43a74bae4a9eea6a..03ca5188cb8ca2d6cf5dd428f98955155c9f351e 100644 (file)
@@ -581,6 +581,7 @@ int manager_new(Manager **ret) {
         m->read_resolv_conf = true;
         m->need_builtin_fallbacks = true;
         m->etc_hosts_last = m->etc_hosts_mtime = USEC_INFINITY;
+        m->read_etc_hosts = true;
 
         r = dns_trust_anchor_load(&m->trust_anchor);
         if (r < 0)
index be7ad2d10ddb15b1e0cb22d0993df1bb6a5b00e7..5251ca795de068c5719ac557824e410827722397 100644 (file)
@@ -117,6 +117,7 @@ struct Manager {
         Set* etc_hosts_by_address;
         Hashmap* etc_hosts_by_name;
         usec_t etc_hosts_last, etc_hosts_mtime;
+        bool read_etc_hosts;
 
         /* Local DNS stub on 127.0.0.53:53 */
         int dns_stub_udp_fd;
index 2528340f74ad8af1db3a34709a65cc4ec6053fee..e559291f66ca88187203b106064851bcb253b2ab 100644 (file)
@@ -21,3 +21,4 @@
 #DNSOverTLS=@DEFAULT_DNS_OVER_TLS_MODE@
 #Cache=yes
 #DNSStubListener=udp
+#ReadEtcHosts=yes