vm: add run_with_args method to call a single command with specific arguments
The method will ensure the parameters are properly handled as actual separate arguments, regardless of shell special characters in them. For now implement this with shlex.quote, later dedicated qrexec service could be used. QubesOS/qubes-issues#4850
This commit is contained in:
parent
88ab55b940
commit
0092c0ac99
@ -21,6 +21,7 @@
|
||||
'''Qubes VM objects.'''
|
||||
|
||||
import logging
|
||||
import shlex
|
||||
|
||||
import subprocess
|
||||
import warnings
|
||||
@ -305,6 +306,15 @@ class QubesVM(qubesadmin.base.PropertyHolder):
|
||||
e.cmd = command
|
||||
raise e
|
||||
|
||||
def run_with_args(self, *args, **kwargs):
|
||||
'''Run a single command inside the domain using qubes.VMShell qrexec.
|
||||
|
||||
This method execute a single command, without interpreting any shell
|
||||
special characters.
|
||||
|
||||
''' # pylint: disable=redefined-builtin
|
||||
return self.run(' '.join(shlex.quote(arg) for arg in args), **kwargs)
|
||||
|
||||
@property
|
||||
def appvms(self):
|
||||
''' Returns a generator containing all domains based on the current
|
||||
|
Loading…
Reference in New Issue
Block a user