]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: control system hostname synthesis via environment variable
authorJacek Migacz <jmigacz@redhat.com>
Mon, 22 Aug 2022 16:24:29 +0000 (18:24 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 26 Aug 2022 02:19:17 +0000 (11:19 +0900)
docs/ENVIRONMENT.md
src/resolve/resolved-dns-synthesize.c

index fc173289d96aaf3bd6b77470ed0c44db9da4e90c..e5afafbe102a78249bf280e6c2be46379b25b2e6 100644 (file)
@@ -286,6 +286,11 @@ All tools:
   the installed ones. By default non-UTF-8 locales are suppressed from the
   selection, since we are living in the 21st century.
 
+`systemd-resolved`:
+
+* `$SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME` — if set to "0", `systemd-resolved`
+  won't synthesize system hostname on both regular and reverse lookups.
+
 `systemd-sysext`:
 
 * `$SYSTEMD_SYSEXT_HIERARCHIES` — this variable may be used to override which
index 9712322a0abccfb596a4dcaf8bb24672322fe8c2..b3442ad90674818f0f6f4410bb1870e525b7055e 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "alloc-util.h"
+#include "env-util.h"
 #include "hostname-util.h"
 #include "local-addresses.h"
 #include "missing_network.h"
@@ -410,6 +411,8 @@ int dns_synthesize_answer(
 
                 } else if (manager_is_own_hostname(m, name)) {
 
+                        if (getenv_bool("SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME") == 0)
+                                continue;
                         r = synthesize_system_hostname_rr(m, key, ifindex, &answer);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to synthesize system hostname RRs: %m");
@@ -444,6 +447,9 @@ int dns_synthesize_answer(
                 } else if (dns_name_address(name, &af, &address) > 0) {
                         int v, w;
 
+                        if (getenv_bool("SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME") == 0)
+                                continue;
+
                         v = synthesize_system_hostname_ptr(m, af, &address, ifindex, &answer);
                         if (v < 0)
                                 return log_error_errno(v, "Failed to synthesize system hostname PTR RR: %m");