policy: accept localhost hostnames if statically configured
Summary
Prevents NetworkManager from trying to determine the transient hostname via DHCP or other means if "localhost" is already configured as a static hostname, as the transient hostname will be ignored by hostnamed if a static hostname has already been set.
Purpose
https://issues.redhat.com/browse/RHEL-55730
This behavior is confusing: if there is already a static hostname NetworkManager should not even start the machinery to determine the transient hostname, because that is unnecessary work; and especially because when reading the log it is not clear why the transient hostname is not being set in the system, as there is no error or warning.
Checklist
Please read https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/CONTRIBUTING.md before opening the merge request. In particular, check that:
-
the subject for all commits is concise and explicative -
the message for all commits explains the reason for the change -
the source is properly formatted -
any relevant documentation is up to date -
you have added unit tests if applicable -
the NEWS file is updated when the change deserves to be mentioned, for example for new features, behavior changes, API deprecations, etc.