diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-10-13 12:15:41 +0200 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2011-10-13 00:54:45 -0400 |
commit | 363c23a37c3631a0fb16df6b88bd5138677b818a (patch) | |
tree | ba48083177509119af8af8a74043c4cbfb923519 /install/tools/ipa-server-install | |
parent | 77cc5e024601ae7be6ce706499d5f403c8b71408 (diff) | |
download | freeipa-363c23a37c3631a0fb16df6b88bd5138677b818a.tar.gz freeipa-363c23a37c3631a0fb16df6b88bd5138677b818a.tar.xz freeipa-363c23a37c3631a0fb16df6b88bd5138677b818a.zip |
Check /etc/hosts file in ipa-server-install
There may already be a record in /etc/hosts for chosen IP address
which may not be detected under some circumstances. Make sure
that /etc/hosts is checked properly.
https://fedorahosted.org/freeipa/ticket/1923
Diffstat (limited to 'install/tools/ipa-server-install')
-rwxr-xr-x | install/tools/ipa-server-install | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install index 6d643883b..76d5f2f5a 100755 --- a/install/tools/ipa-server-install +++ b/install/tools/ipa-server-install @@ -796,11 +796,33 @@ def main(): ip = options.ip_address + ip_add_to_hosts = False if ip is None: ip = read_ip_address(host_name, fstore) logging.debug("read ip_address: %s\n" % str(ip)) + ip_add_to_hosts = True + ip_address = str(ip) + # check /etc/hosts sanity, add a record when needed + hosts_record = record_in_hosts(ip_address) + + if hosts_record is None: + if ip_add_to_hosts: + print "Adding ["+ip_address+" "+host_name+"] to your /etc/hosts file" + fstore.backup_file("/etc/hosts") + add_record_to_hosts(ip_address, host_name) + else: + primary_host = hosts_record[1][0] + if primary_host != host_name: + print >>sys.stderr, "Error: there is already a record in /etc/hosts for IP address %s:" \ + % ip_address + print >>sys.stderr, hosts_record[0], " ".join(hosts_record[1]) + print >>sys.stderr, "Chosen hostname %s does not match configured canonical hostname %s" \ + % (host_name, primary_host) + print >>sys.stderr, "Please fix your /etc/hosts file and restart the installation." + return 1 + if options.reverse_zone and not bindinstance.verify_reverse_zone(options.reverse_zone, ip): sys.exit(1) |