resolved: fix the canonical name returned by hosts lookup by name

In etc_hosts_lookup_by_name(), return the canonical name of the resolved
address instead of the name used to obtain that address.

Resolves: #20158
This commit is contained in:
Dmitry V. Levin
2023-07-14 13:13:53 +00:00
parent 0ff8f2a33a
commit 1ddc2f7fbc
2 changed files with 48 additions and 5 deletions
+9
View File
@@ -300,6 +300,15 @@ run getent -s resolve hosts 127.128.0.5
grep -qEx '127\.128\.0\.5\s+localhost5(\s+localhost5?\.localdomain[45]?){4}' "$RUN_OUT"
[ "$(wc -l <"$RUN_OUT")" -eq 1 ]
# Issue: https://github.com/systemd/systemd/issues/20158
run dig +noall +answer +additional localhost5.
grep -qEx 'localhost5\.\s+0\s+IN\s+A\s+127\.128\.0\.5' "$RUN_OUT"
[ "$(wc -l <"$RUN_OUT")" -eq 1 ]
run dig +noall +answer +additional localhost5.localdomain4.
grep -qEx 'localhost5\.localdomain4\.\s+0\s+IN\s+CNAME\s+localhost5\.' "$RUN_OUT"
grep -qEx 'localhost5\.\s+0\s+IN\s+A\s+127\.128\.0\.5' "$RUN_OUT"
[ "$(wc -l <"$RUN_OUT")" -eq 2 ]
: "--- Basic resolved tests ---"
# Issue: https://github.com/systemd/systemd/issues/22229
# PR: https://github.com/systemd/systemd/pull/22231