To get a consistent behavior and to simplify container setups FreeIPA code should use a consistent API to access the FQDN of the current host. At the moment FreeIPA uses:
gethostname()
nodename
uname()
socket.getfqdn()
gethostbyname(gethostname())
gethostbyname
The recommended way to get the canonical hostname of the current host is getaddrinfo(gethostname()) with AI_CANONNAME flag. The call uses NSS (name service switch) to look up the canonical hostname for the current node name. On modern systems with systemd-resolved or nss-myhostname NSS provider the call can never fail. Both NSS providers ensure that lookups for hostname from gethostname() always resolves to local interfaces. Like socket.getfqdn() the lookup may involve a DNS query. Therefore the result should be cached.
getaddrinfo(gethostname())
AI_CANONNAME
systemd-resolved
nss-myhostname
The command hostname --fqdn as well as some code paths in MIT KRB5 and Samba use the same approach. Eventually getaddrinfo(gethostname()) will allow FreeIPA to work on hosts that have a short name as node name.
hostname --fqdn
Metadata Update from @cheimes: - Custom field on_review adjusted to https://github.com/freeipa/freeipa/pull/5107
master:
Metadata Update from @abbra: - Issue set to the milestone: FreeIPA 4.9
ipa-4-8:
Metadata Update from @ftweedal: - Issue close_status updated to: fixed - Issue status updated to: Closed (was: Open)
Login to comment on this ticket.