]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
Support hostname that resolve to IPv6-only address
authorFrode Nordahl <frode@nordahl.net>
Thu, 27 Mar 2014 08:20:52 +0000 (09:20 +0100)
committerFrode Nordahl <frode@nordahl.net>
Thu, 27 Mar 2014 08:20:52 +0000 (09:20 +0100)
The current hostname validation does not cope with IPv6-only hostnames. Use getaddrinfo instead of gethostbyname to fix this. getaddrinfo raises the same exceptions and should work like a drop-in-replacement in this scenario.

We should also address the IPv4-only check for if then input is an IP-address but the use of split on ':' is problematic and prevents code to check for IPv6-addresses as input. I'm not sure what the thought behind allowing "name:host" is so leaving it untouched.

I have proposed code to check and warn for both IPv4 and IPv6 address input that I can provide as soon as I understand the scope of parsing "name:host" input.

ceph_deploy/util/arg_validators.py

index 422bba3b9cd0da3b6de8113bb3845fc6803b1eb5..571a182904b6909b47316ecdaf4aa1de0a7b28fb 100644 (file)
@@ -38,7 +38,7 @@ class Hostname(object):
         name = parts[0]
         host = parts[-1]
         try:
-            self.socket.gethostbyname(host)
+            self.socket.getaddrinfo(host, 0)
         except self.socket.gaierror:
             msg = "hostname: %s is not resolvable" % host
             raise argparse.ArgumentError(None, msg)