#8501 Unify how FreeIPA gets FQDN of current host
Closed: fixed 2 years ago by ftweedal. Opened 2 years ago by cheimes.

Request for enhancement

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 member from uname()
  • Python's socket.getfqdn() which uses gethostbyname(gethostname()) internally. gethostbyname is an obsolete API.

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.

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.


Metadata Update from @cheimes:
- Custom field on_review adjusted to https://github.com/freeipa/freeipa/pull/5107

2 years ago

master:

  • 731c5b2 Lookup ipa-ca record with NSS

Metadata Update from @abbra:
- Issue set to the milestone: FreeIPA 4.9

2 years ago

ipa-4-8:

  • 81cf1db Lookup ipa-ca record with NSS

master:

  • e28ec76 Unify access to FQDN
  • 5d4ed65 Replace nodename with ipa_gethostfqdn()
  • b66b961 Remove problematic optimization from gethostfqdn()
  • 3d796a7 Update debug strings to reflect new calls
  • 727a2ff Easier to use ipa_gethostfqdn()
  • 3f59118 (HEAD) ipa_sam: do not modify static buffer holding fqdn

Metadata Update from @ftweedal:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Login to comment on this ticket.

Metadata