From 17c3f9e84efcbeb3b5ae1de83d799974de3bb078 Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Fri, 27 May 2011 17:05:45 +0200 Subject: Fix reverse zone creation in ipa-replica-prepare When a new reverse zone was created in ipa-replica-prepare (this may happen when a new replica is from different subnet), the master DNS address was corrupted by invalid A/AAAA record. This caused problems for example in installing replica. https://fedorahosted.org/freeipa/ticket/1223 --- ipaserver/install/installutils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ipaserver/install/installutils.py') diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 3868c4d0..554e9b1c 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -33,6 +33,9 @@ import time from ipapython import ipautil from ipapython import dnsclient +class HostnameLocalhost(Exception): + pass + def get_fqdn(): fqdn = "" try: @@ -421,3 +424,15 @@ def wait_for_open_ports(host, ports, timeout=0): else: raise e +def resolve_host(host_name): + try: + addrinfos = socket.getaddrinfo(host_name, None, + socket.AF_UNSPEC, socket.SOCK_STREAM) + 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") + + return addrinfos[0][4][0] + except: + return None -- cgit