mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-09-03 20:52:56 -05:00
Unify access to FQDN
FreeIPA's Python and C code used different approaches to get the FQDN of the host. Some places assumed that gethostname() returns a FQDN. Other code paths used glibc's resolver to resolve the current node name to a FQDN. Python code now uses the ipalib.constants.FQDN where a fully qualified domain name is expected. The variable is initialized only once and avoids potential DNS lookups. C code uses a new helper function ipa_gethostfqdn() in util package. The function implements similar logic as gethostfqdn() except it uses more modern getaddrinfo(). The result is cached as well. Fixes: https://pagure.io/freeipa/issue/8501 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
This commit is contained in:
committed by
Fraser Tweedale
parent
5155280bb4
commit
e28ec76898
+4
-2
@@ -25,7 +25,6 @@ from optparse import (
|
||||
from copy import copy
|
||||
from configparser import SafeConfigParser
|
||||
from urllib.parse import urlsplit
|
||||
import socket
|
||||
import functools
|
||||
|
||||
from dns.exception import DNSException
|
||||
@@ -211,8 +210,11 @@ def __discover_config(discover_server = True):
|
||||
servers = query_srv(name)
|
||||
except DNSException:
|
||||
# try cycling on domain components of FQDN
|
||||
# pylint: disable=ipa-forbidden-import
|
||||
from ipalib.constants import FQDN
|
||||
# pylint: enable=ipa-forbidden-import
|
||||
try:
|
||||
domain = dns.name.from_text(socket.getfqdn())
|
||||
domain = dns.name.from_text(FQDN)
|
||||
except DNSException:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user