summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-05-31 12:51:38 +0200
committerMartin Kosek <mkosek@redhat.com>2011-06-10 08:29:14 +0200
commit915235859cb67d4f350ff506b435586fd15505e7 (patch)
tree6cd153414ded558f5ed3e987830469d99a6b321d
parenta26fb5aacafa91bd67061cb85bc9f0c88b735604 (diff)
downloadfreeipa-915235859cb67d4f350ff506b435586fd15505e7.tar.gz
freeipa-915235859cb67d4f350ff506b435586fd15505e7.tar.xz
freeipa-915235859cb67d4f350ff506b435586fd15505e7.zip
IPA installation with --no-host-dns fails
--no-host-dns option should allow installing IPA server on a host without a DNS resolvable name. Update parse_ip_address and verify_ip_address functions has been changed not to return None and print error messages in case of an error, but rather let the Exception be handled by the calling routine. https://fedorahosted.org/freeipa/ticket/1246
-rwxr-xr-xinstall/tools/ipa-dns-install9
-rwxr-xr-xinstall/tools/ipa-replica-prepare5
-rwxr-xr-xinstall/tools/ipa-server-install21
-rw-r--r--ipaserver/install/installutils.py37
4 files changed, 42 insertions, 30 deletions
diff --git a/install/tools/ipa-dns-install b/install/tools/ipa-dns-install
index 91edcca8a..39998ac47 100755
--- a/install/tools/ipa-dns-install
+++ b/install/tools/ipa-dns-install
@@ -108,7 +108,14 @@ def main():
else:
hostaddr = resolve_host(api.env.host)
ip_address = hostaddr and ipautil.CheckedIPAddress(hostaddr)
- if not ip_address or not verify_ip_address(ip_address):
+
+ try:
+ verify_ip_address(ip_address)
+ except Exception, e:
+ print "Error: Invalid IP Address %s: %s" % (ip_address, e)
+ ip_address = None
+
+ if not ip_address:
if options.unattended:
sys.exit("Unable to resolve IP address for host name")
else:
diff --git a/install/tools/ipa-replica-prepare b/install/tools/ipa-replica-prepare
index df44934de..cd13f5d93 100755
--- a/install/tools/ipa-replica-prepare
+++ b/install/tools/ipa-replica-prepare
@@ -78,11 +78,6 @@ def parse_options():
if cnt > 0 and cnt < num:
parser.error("All PKCS#12 options are required if any are used.")
- if options.ip_address:
- if not installutils.verify_ip_address(options.ip_address, match_local=False):
- parser.error("Bad IP address")
- sys.exit(1)
-
if len(args) != 1:
parser.error("must provide the fully-qualified name of the replica")
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index a62aa150a..18319bed9 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -598,14 +598,20 @@ def main():
if hostaddr is not None:
ip = CheckedIPAddress(hostaddr)
else:
+ if not options.ip_address:
+ print "Unable to resolve IP address for host name"
ip = options.ip_address
if ip is None and options.unattended:
sys.exit("Unable to resolve IP address for host name")
- if not verify_ip_address(ip):
- ip = None
- if options.unattended:
- sys.exit(1)
+ if ip:
+ try:
+ verify_ip_address(ip)
+ except Exception, e:
+ print "Error: Invalid IP Address %s: %s" % (ip, e)
+ if options.unattended:
+ sys.exit(1)
+ ip = None
if options.ip_address:
if options.ip_address != ip and not options.setup_dns:
@@ -615,8 +621,11 @@ def main():
return 1
ip = options.ip_address
- if not verify_ip_address(ip):
- return 1
+ try:
+ verify_ip_address(ip)
+ except Exception, e:
+ print "Error: Invalid IP Address %s: %s" % (ip, e)
+ sys.exit(1)
if ip is None:
ip = read_ip_address(host_name, fstore)
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index d99af3742..d203f4f93 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -108,6 +108,10 @@ def verify_fqdn(host_name,no_host_dns=False):
if host_name != host_name.lower():
raise RuntimeError("Invalid hostname '%s', must be lower-case." % host_name)
+ if no_host_dns:
+ print "Warning: skipping DNS resolution of host", host_name
+ return
+
try:
hostaddr = socket.getaddrinfo(host_name, None)
except:
@@ -127,10 +131,6 @@ def verify_fqdn(host_name,no_host_dns=False):
if revname != host_name:
raise RuntimeError("The host name %s does not match the reverse lookup %s" % (host_name, revname))
- if no_host_dns:
- print "Warning: skipping DNS resolution of host", host_name
- return
-
# Verify this is NOT a CNAME
rs = dnsclient.query(host_name+".", dnsclient.DNS_C_IN, dnsclient.DNS_T_CNAME)
if len(rs) != 0:
@@ -152,17 +152,13 @@ def verify_fqdn(host_name,no_host_dns=False):
print "Warning: Hostname (%s) not found in DNS" % host_name
def parse_ip_address(addr, match_local=True, parse_netmask=True):
- try:
- ip = ipautil.CheckedIPAddress(addr, match_local=match_local, parse_netmask=parse_netmask)
- if match_local and not ip.is_local():
- print "Warning: No network interface matches IP address %s" % addr
- return ip
- except Exception as e:
- print "Error: Invalid IP Address %s: %s" % (addr, e)
- return None
+ ip = ipautil.CheckedIPAddress(addr, match_local=match_local, parse_netmask=parse_netmask)
+ if match_local and not ip.is_local():
+ print "Warning: No network interface matches IP address %s" % addr
+ return ip
def verify_ip_address(addr, match_local=True, parse_netmask=True):
- return parse_ip_address(addr, match_local, parse_netmask) is not None
+ ip = parse_ip_address(addr, match_local, parse_netmask)
def record_in_hosts(ip, host_name, file="/etc/hosts"):
hosts = open(file, 'r').readlines()
@@ -195,9 +191,12 @@ def add_record_to_hosts(ip, host_name, file="/etc/hosts"):
def read_ip_address(host_name, fstore):
while True:
ip = ipautil.user_input("Please provide the IP address to be used for this host name", allow_empty = False)
- ip_parsed = parse_ip_address(ip)
-
- if ip_parsed is not None:
+ try:
+ ip_parsed = parse_ip_address(ip)
+ except Exception, e:
+ print "Error: Invalid IP Address %s: %s" % (ip, e)
+ continue
+ else:
break
ip = str(ip_parsed)
@@ -217,8 +216,10 @@ def read_dns_forwarders():
allow_empty=True)
if not ip:
break
- ip_parsed = parse_ip_address(ip, match_local=False, parse_netmask=False)
- if ip_parsed is None:
+ try:
+ ip_parsed = parse_ip_address(ip, match_local=False, parse_netmask=False)
+ except Exception, e:
+ print "Error: Invalid IP Address %s: %s" % (ip, e)
print "DNS forwarder %s not added" % ip
continue