Skip to content

Commit

Permalink
VNC/SPICE should listen on all interfaces
Browse files Browse the repository at this point in the history
Until now, we only allowed VNC/SPICE console to listen on connections
coming from localhost. This however breaks "Desktop viewer" use case
where user wants to download a virt-viewer file to a client computer
and open a VNC/SPICE console connected to a remote VNC server.

Fixes cockpit-project#1078
  • Loading branch information
skobyda committed May 23, 2023
1 parent c905ae2 commit 0fbf07e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/scripts/install_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def get_graphics_capabilies(connection):

def prepare_graphics_params(connection):
graphics_config = {
'spice': {'listen': '127.0.0.1'},
'vnc': {'listen': '127.0.0.1'}
'spice': {'listen': '0.0.0.0'},
'vnc': {'listen': '0.0.0.0'}
}
try:
# Configparser needs a default section
Expand All @@ -57,12 +57,12 @@ def prepare_graphics_params(connection):
config = configparser.ConfigParser()
config.read_string(config_string)

graphics_config['spice']['listen'] = config['dummy_section'].get('spice_listen', '127.0.0.1')
graphics_config['spice']['listen'] = config['dummy_section'].get('spice_listen', '0.0.0.0')
spice_password = config['dummy_section'].get('spice_password', None)
if spice_password is not None:
graphics_config['spice']['password'] = spice_password

graphics_config['vnc']['listen'] = config['dummy_section'].get('vnc_listen', '127.0.0.1')
graphics_config['vnc']['listen'] = config['dummy_section'].get('vnc_listen', '0.0.0.0')
vnc_password = config['dummy_section'].get('vnc_password', None)
if vnc_password is not None:
graphics_config['vnc']['password'] = vnc_password
Expand Down
1 change: 0 additions & 1 deletion test/check-machines-consoles
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ class TestMachinesConsoles(VirtualMachinesCase):
".*Connection reset by peer")
self.allow_browser_errors("Disconnection timed out.")
self.allow_journal_messages(".* couldn't shutdown fd: Transport endpoint is not connected")
self.allow_journal_messages("127.0.0.1:5900: couldn't read: Connection refused")

def testBasic(self):
b = self.browser
Expand Down
8 changes: 4 additions & 4 deletions test/check-machines-create
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,15 @@ vnc_password= "{vnc_passwd}"
TestMachinesCreate.VmDialog(self, sourceType='file',
storage_pool=NO_STORAGE,
location=config.NOVELL_MOCKUP_ISO_PATH),
vnc_listen, "127.0.0.1", vnc_passwd, None)
vnc_listen, "0.0.0.0", vnc_passwd, None)

# Ensure that missing qemu.conf would not crash the script but just pick the 127.0.0.1 default value
# Ensure that missing qemu.conf would not crash the script but just pick the 0.0.0.0 default value
m.execute("rm /etc/libvirt/qemu.conf")
runner.createAndVerifyQemuConfParsedTest(
TestMachinesCreate.VmDialog(self, sourceType='file',
storage_pool=NO_STORAGE,
location=config.NOVELL_MOCKUP_ISO_PATH),
"127.0.0.1", "127.0.0.1", None, None)
"0.0.0.0", "0.0.0.0", None, None)

@skipImage("TODO: Arch Linux has no iscsi support", "arch")
def testCreateThenInstall(self):
Expand Down Expand Up @@ -515,7 +515,7 @@ vnc_password= "{vnc_passwd}"
target_iqn = "iqn.2019-09.cockpit.lan"
self.prepareStorageDeviceOnISCSI(target_iqn)
cmd = [
"virsh pool-define-as iscsi-pool --type iscsi --target /dev/disk/by-id --source-host 127.0.0.1 --source-dev {0}",
"virsh pool-define-as iscsi-pool --type iscsi --target /dev/disk/by-id --source-host 0.0.0.0 --source-dev {0}",
"ls -la /dev/disk/by-id",
"virsh pool-start iscsi-pool"
]
Expand Down

0 comments on commit 0fbf07e

Please sign in to comment.