summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/installutils.py
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-05-27 17:05:45 +0200
committerMartin Kosek <mkosek@redhat.com>2011-05-27 18:00:47 +0200
commit17c3f9e84efcbeb3b5ae1de83d799974de3bb078 (patch)
treec219902aa7d2a98c63ac7605e712c33f59166dc8 /ipaserver/install/installutils.py
parent58c1950566f9fb03b61461f40074e47614113194 (diff)
downloadfreeipa-17c3f9e84efcbeb3b5ae1de83d799974de3bb078.tar.gz
freeipa-17c3f9e84efcbeb3b5ae1de83d799974de3bb078.tar.xz
freeipa-17c3f9e84efcbeb3b5ae1de83d799974de3bb078.zip
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
Diffstat (limited to 'ipaserver/install/installutils.py')
-rw-r--r--ipaserver/install/installutils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 3868c4d04..554e9b1cb 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