app: call admin.vm.volume.Import as root

This is needed to write LVM data.
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-17 16:15:39 +02:00
parent f0151d73b3
commit ca399c1a5a
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -445,11 +445,12 @@ class QubesLocal(QubesBase):
if not os.path.exists(method_path):
raise qubesadmin.exc.QubesDaemonCommunicationError(
'{} not found'.format(method_path))
qrexec_call_env = os.environ.copy()
qrexec_call_env['QREXEC_REMOTE_DOMAIN'] = 'dom0'
qrexec_call_env['QREXEC_REQUESTED_TARGET'] = dest
proc = subprocess.Popen([method_path, arg], stdin=payload_stream,
stdout=subprocess.PIPE, env=qrexec_call_env)
command = ['env', 'QREXEC_REMOTE_DOMAIN=dom0',
'QREXEC_REQUESTED_TARGET=' + dest, method_path, arg]
if os.getuid() != 0:
command.insert(0, 'sudo')
proc = subprocess.Popen(command, stdin=payload_stream,
stdout=subprocess.PIPE)
payload_stream.close()
(return_data, _) = proc.communicate()
return self._parse_qubesd_response(return_data)