From 56b0217c626349748c5cc6f2fbccfa6a905f75a4 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 14 Feb 2012 14:55:39 +0000 Subject: [PATCH] Don't hardcode 'localhost' in no @listen parameter is given If no @listen parameter is given, we must not hardcode 'localhost' since we can't assume we are running on the same host. Instead use the hostname from the connection URI --- src/virt-viewer.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/virt-viewer.c b/src/virt-viewer.c index b4c3b20..3143104 100644 --- a/src/virt-viewer.c +++ b/src/virt-viewer.c @@ -332,8 +332,6 @@ virt_viewer_extract_connect_info(VirtViewer *self, free(xpath); xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@listen)", type); ghost = virt_viewer_extract_xpath_string(xmldesc, xpath); - if (ghost == NULL) - ghost = g_strdup("localhost"); } if (ghost && gport) @@ -353,11 +351,11 @@ virt_viewer_extract_connect_info(VirtViewer *self, * from a remote host. Instead we fallback to the hostname used in * the libvirt URI. This isn't perfect but it is better than nothing */ - if (ghost && + if (!ghost || (strcmp(ghost, "0.0.0.0") == 0 || strcmp(ghost, "::") == 0)) { - DEBUG_LOG("Guest graphics listen '%s' is a wildcard, replacing with '%s'", - ghost, host); + DEBUG_LOG("Guest graphics listen '%s' is NULL or a wildcard, replacing with '%s'", + ghost ? ghost : "", host); g_free(ghost); ghost = g_strdup(host); }