core: also use /etc/hosts for hostname resolution

Before introducing the hostname lookup via nm-daemon-helper and
systemd-resolved, we used GLib's GResolver which internally relies on
the libc resolver and generally also returns results from /etc/hosts.

With the new mechanism we only ask to systemd-resolved (with
NO_SYNTHESIZE) or perform the lookup via the "dns" NSS module. In both
ways, /etc/hosts is not evaluated.

Since users relied on having the hostname resolved via /etc/hosts,
restore that behavior. Now, after trying the resolution via
systemd-resolved and the "dns" NSS module, we also try via the "files"
NSS module which reads /etc/hosts.

Fixes: 27eae4043b ('device: add a nm_device_resolve_address()')
This commit is contained in:
Beniamino Galvani
2024-06-19 20:29:37 +02:00
parent 229bebfae9
commit 410afccb32
2 changed files with 39 additions and 13 deletions

3
NEWS
View File

@@ -11,6 +11,9 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE!
* Support matching a OVS system interface by MAC address.
* Add a timeout option to connectivity checking.
* Support configuring veth interfaces in nmtui.
* When looking up the system hostname from the reverse DNS lookup of
addresses configured on interfaces, NetworkManager now takes into
account the content of /etc/hosts.
=============================================
NetworkManager-1.48