tools/qvm-start: use vm.run_with_args to call losetup in the VM

This will fix handling filenames with spaces and shell special
characters.

Reported by @v6ak

Fixes QubesOS/qubes-issues#4860
This commit is contained in:
Marek Marczykowski-Górecki 2019-02-28 05:51:49 +01:00
parent a35cb46342
commit a2629b1239
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 5 additions and 4 deletions

View File

@ -193,11 +193,11 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
as mock_run:
mock_run.return_value = (b'/dev/loop7', b'')
qubesadmin.tools.qvm_start.main([
'--cdrom=other-vm:/home/some/image.iso',
'--cdrom=other-vm:/home/some image.iso',
'some-vm'],
app=self.app)
mock_run.assert_called_once_with(
'losetup -f --show /home/some/image.iso',
'losetup -f --show \'/home/some image.iso\'',
user='root')
self.assertAllCalled()

View File

@ -115,8 +115,9 @@ def get_drive_assignment(app, drive_str):
loop_name = subprocess.check_output(
['sudo', 'losetup', '-f', '--show', ident])
else:
loop_name, _ = backend_domain.run(
'losetup -f --show ' + ident, user='root')
loop_name, _ = backend_domain.run_with_args(
'losetup', '-f', '--show', ident,
user='root')
except subprocess.CalledProcessError:
raise qubesadmin.exc.QubesException(
'Failed to setup loop device for %s', ident)