diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
commit | efeb864cb547a2cbf96dc0053a8bdb4d9190b364 (patch) | |
tree | c0b83368f18be983fcc763200c4c24d633244588 /src/resolve/resolved-dns-synthesize.c | |
parent | Releasing progress-linux version 255.5-1~progress7.99u1. (diff) | |
download | systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.tar.xz systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.zip |
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/resolve/resolved-dns-synthesize.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/resolve/resolved-dns-synthesize.c b/src/resolve/resolved-dns-synthesize.c index 6144dc0..cccea54 100644 --- a/src/resolve/resolved-dns-synthesize.c +++ b/src/resolve/resolved-dns-synthesize.c @@ -439,6 +439,20 @@ static int synthesize_gateway_ptr( return answer_add_addresses_ptr(answer, "_gateway", addresses, n, af, address); } +bool shall_synthesize_own_hostname_rrs(void) { + static int cached = -1; + int r; + + if (cached >= 0) + return cached; + + r = secure_getenv_bool("SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME"); + if (r < 0 && r != -ENXIO) + log_debug_errno(r, "Failed to parse $SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME: %m"); + + return (cached = (r != 0)); +} + int dns_synthesize_answer( Manager *m, DnsQuestion *q, @@ -479,8 +493,9 @@ int dns_synthesize_answer( } else if (manager_is_own_hostname(m, name)) { - if (getenv_bool("SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME") == 0) + if (!shall_synthesize_own_hostname_rrs()) 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"); @@ -530,7 +545,7 @@ int dns_synthesize_answer( } else if (dns_name_address(name, &af, &address) > 0) { int v, w, u; - if (getenv_bool("SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME") == 0) + if (!shall_synthesize_own_hostname_rrs()) continue; v = synthesize_system_hostname_ptr(m, af, &address, ifindex, &answer); |