diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2010-12-01 17:22:56 +0100 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2010-12-20 11:27:34 -0500 |
commit | ee4d2739f11465ba6a7d817f9b988da5bfe86e2c (patch) | |
tree | 2640194c2e0adb7a95471420250b9b9ce0eb702f /install | |
parent | b328d845deaa2f894a6842a9920f46ea341572f2 (diff) | |
download | freeipa-ee4d2739f11465ba6a7d817f9b988da5bfe86e2c.tar.gz freeipa-ee4d2739f11465ba6a7d817f9b988da5bfe86e2c.tar.xz freeipa-ee4d2739f11465ba6a7d817f9b988da5bfe86e2c.zip |
Make the IPA installer IPv6 friendly
Notable changes include:
* parse AAAA records in dnsclient
* also ask for AAAA records when verifying FQDN
* do not use functions that are not IPv6 aware - notably socket.gethostbyname()
The complete list of functions was taken from http://www.akkadia.org/drepper/userapi-ipv6.html
section "Interface Checklist"
Diffstat (limited to 'install')
-rwxr-xr-x | install/tools/ipa-dns-install | 23 | ||||
-rwxr-xr-x | install/tools/ipa-replica-install | 19 | ||||
-rwxr-xr-x | install/tools/ipa-server-install | 27 |
3 files changed, 41 insertions, 28 deletions
diff --git a/install/tools/ipa-dns-install b/install/tools/ipa-dns-install index bf6679e38..a91938f9e 100755 --- a/install/tools/ipa-dns-install +++ b/install/tools/ipa-dns-install @@ -62,16 +62,19 @@ def parse_options(): def resolve_host(host_name): ip = None try: - ip = socket.gethostbyname(host_name) - - if ip == "127.0.0.1" or ip == "::1": - print "The hostname resolves to the localhost address (127.0.0.1/::1)" - print "Please change your /etc/hosts file so that the hostname" - print "resolves to the ip address of your network interface." - print "" - print "Please fix your /etc/hosts file and restart the setup program" - return None - + addrinfos = socket.getaddrinfo(host_name, None, + socket.AF_UNSPEC, socket.SOCK_DGRAM) + for ai in addrinfos: + ip = ai[4][0] + if ip == "127.0.0.1" or ip == "::1": + print "The hostname resolves to the localhost address (127.0.0.1/::1)" + print "Please change your /etc/hosts file so that the hostname" + print "resolves to the ip address of your network interface." + print "" + print "Please fix your /etc/hosts file and restart the setup program" + return None + + ip = addrinfos[0][4][0] except: print "Unable to lookup the IP address of the provided host" return ip diff --git a/install/tools/ipa-replica-install b/install/tools/ipa-replica-install index 0826afa59..906a098d2 100755 --- a/install/tools/ipa-replica-install +++ b/install/tools/ipa-replica-install @@ -127,12 +127,17 @@ def get_host_name(no_host_dns): return hostname def resolve_host(host_name): - ip = socket.gethostbyname(host_name) - - if ip == "127.0.0.1" or ip == "::1": - raise HostnameLocalhost - - return ip + 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 + + return addrinfos[0][4][0] + except: + return None def set_owner(config, dir): pw = pwd.getpwnam(config.ds_user) @@ -240,6 +245,8 @@ def install_bind(config, options): forwarders = () bind = bindinstance.BindInstance(dm_password=config.dirman_password) ip_address = resolve_host(config.host_name) + if not ip_address: + sys.exit("Unable to resolve IP address for host name") create_reverse = bindinstance.create_reverse(options.unattended) bind.setup(config.host_name, ip_address, config.realm_name, config.domain_name, forwarders, options.conf_ntp, create_reverse) diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install index 5b9e65216..774e87fdf 100755 --- a/install/tools/ipa-server-install +++ b/install/tools/ipa-server-install @@ -279,19 +279,22 @@ def read_host_name(host_default,no_host_dns=False): return host_name def resolve_host(host_name): - ip = "" + ip = None try: - ip = socket.gethostbyname(host_name) - - if ip == "127.0.0.1" or ip == "::1": - print "The hostname resolves to the localhost address (127.0.0.1/::1)" - print "Please change your /etc/hosts file so that the hostname" - print "resolves to the ip address of your network interface." - print "The KDC service does not listen on localhost" - print "" - print "Please fix your /etc/hosts file and restart the setup program" - return None + addrinfos = socket.getaddrinfo(host_name, None, + socket.AF_UNSPEC, socket.SOCK_DGRAM) + for ai in addrinfos: + ip = ai[4][0] + if ip == "127.0.0.1" or ip == "::1": + print "The hostname resolves to the localhost address (127.0.0.1/::1)" + print "Please change your /etc/hosts file so that the hostname" + print "resolves to the ip address of your network interface." + print "The KDC service does not listen on localhost" + print "" + print "Please fix your /etc/hosts file and restart the setup program" + return None + ip = addrinfos[0][4][0] except: print "Unable to lookup the IP address of the provided host" return ip @@ -549,7 +552,7 @@ def main(): sys.exit("Aborting installation") # check the hostname is correctly configured, it must be as the kldap - # utilities just use the hostname as returned by gethostbyname to set + # utilities just use the hostname as returned by getaddrinfo to set # up some of the standard entries host_default = "" |