summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/installutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipaserver/install/installutils.py')
-rw-r--r--ipaserver/install/installutils.py26
1 files changed, 5 insertions, 21 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 179909543..2a71ef7ac 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -55,6 +55,7 @@ from ipaserver.install import certs, service, sysupgrade
from ipaplatform import services
from ipaplatform.paths import paths
from ipaplatform.tasks import tasks
+from ipapython import dnsutil
if six.PY3:
unicode = str
@@ -444,24 +445,6 @@ def create_keytab(path, principal):
kadmin("ktadd -k " + path + " " + principal)
-def resolve_host(host_name):
- try:
- addrinfos = socket.getaddrinfo(host_name, None,
- socket.AF_UNSPEC, socket.SOCK_STREAM)
-
- ip_list = []
-
- for ai in addrinfos:
- ip = ai[4][0]
- if ip == "127.0.0.1" or ip == "::1":
- raise HostnameLocalhost("The hostname resolves to the localhost address")
-
- ip_list.append(ip)
-
- return ip_list
- except socket.error:
- return []
-
def get_host_name(no_host_dns):
"""
Get the current FQDN from the socket and verify that it is valid.
@@ -477,9 +460,10 @@ def get_host_name(no_host_dns):
def get_server_ip_address(host_name, unattended, setup_dns, ip_addresses):
# Check we have a public IP that is associated with the hostname
- try:
- hostaddr = resolve_host(host_name)
- except HostnameLocalhost:
+ hostaddr = dnsutil.resolve_ip_addresses(host_name)
+ if hostaddr.intersection(
+ {ipautil.CheckedIPAddress(ip, allow_loopback=True)
+ for ip in ['127.0.0.1', '::1']}):
print("The hostname resolves to the localhost address (127.0.0.1/::1)", file=sys.stderr)
print("Please change your /etc/hosts file so that the hostname", file=sys.stderr)
print("resolves to the ip address of your network interface.", file=sys.stderr)