summaryrefslogtreecommitdiffstats
path: root/vnc.py
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2007-04-02 21:52:19 +0000
committerDavid Cantrell <dcantrell@redhat.com>2007-04-02 21:52:19 +0000
commitdda869bc0a1618ee05bf8db0296a2a9c21c4e581 (patch)
treebbd2f692f01d8bdf85a72e1e8ce43ef57cbe4b33 /vnc.py
parent60fd73651c45399283a7b3c09ba9b7c2020c17a5 (diff)
downloadanaconda-dda869bc0a1618ee05bf8db0296a2a9c21c4e581.tar.gz
anaconda-dda869bc0a1618ee05bf8db0296a2a9c21c4e581.tar.xz
anaconda-dda869bc0a1618ee05bf8db0296a2a9c21c4e581.zip
* vnc.py (startVNCServer): Better fix (#234747)
Diffstat (limited to 'vnc.py')
-rw-r--r--vnc.py45
1 files changed, 22 insertions, 23 deletions
diff --git a/vnc.py b/vnc.py
index 1f61024dd..6f5c7ec30 100644
--- a/vnc.py
+++ b/vnc.py
@@ -203,7 +203,7 @@ def startVNCServer(vncpassword="", root='/', vncconnecthost="",
ip = isys.getIPAddress(dev)
log.info("ip of %s is %s" % (dev, ip))
- if ip == "127.0.0.1":
+ if ip == "127.0.0.1" or ip == "::1":
ip = None
except Exception, e:
log.warning("Got an exception trying to get the ip addr "
@@ -211,21 +211,33 @@ def startVNCServer(vncpassword="", root='/', vncconnecthost="",
# If we have a real hostname that resolves against configured DNS
# servers, use that for the name to connect to.
- if netinfo.hostname != "localhost.localdomain" and netinfo.lookupHostname() is not None:
- srvname = netinfo.hostname
- elif ip is None:
- # If we get here and there's no valid IP address, just use the
- # hostname and hope for the best (better than displaying nothing)
- srvname = netinfo.hostname
+ if netinfo.hostname != "localhost.localdomain":
+ if netinfo.lookupHostname() is not None:
+ srvname = netinfo.hostname
+ elif ip is None:
+ # If we get here and there's no valid IP address, just use the
+ # hostname and hope for the best (better than displaying nothing)
+ srvname = netinfo.hostname
if srvname is not None:
connxinfo = "%s:1" % srvname
if ip is not None:
+ try:
+ tmp = socket.inet_pton(socket.AF_INET6, ip)
+ family = socket.AF_INET6
+ except socket.error:
+ family = socket.AF_INET
+
+ if family == socket.AF_INET6:
+ ipstr = "[%s]" % ip
+ else:
+ ipstr = ip
+
if connxinfo is not None:
- connxinfo = "%s:1" % ip
+ connxinfo = "%s:1" % ipstr
else:
- connxinfo += " (%s)" % ip
+ connxinfo += " (%s)" % ipstr
# figure out product info
if srvname is not None:
@@ -284,21 +296,8 @@ def startVNCServer(vncpassword="", root='/', vncconnecthost="",
if vncconnecthost != "":
stdoutLog.info(_("Attempting to connect to vnc client on host %s...") % (vncconnecthost,))
- res = []
- try:
- res = socket.getaddrinfo(vncconnecthost, None, socket.AF_INET6, socket.SOCK_STREAM)
- except socket.gaierror:
- try:
- res = socket.getaddrinfo(vncconnecthost, None, socket.AF_INET, socket.SOCK_STREAM)
- except socket.gaierror:
- hostarg = vncconnecthost
-
- if res != []:
- for (family, socktype, proto, canonname, sockaddr,) in res:
- (hostarg, port,) = sockaddr
-
if vncconnectport != "":
- hostarg = hostarg + ":" + vncconnectport
+ hostarg = vncconnecthost + ":" + vncconnectport
argv = ["-display", ":1", "-connect", hostarg]
ntries = 0