tests: adjust SystemTestCase.create_remote_file to create executables
The main use case for this function is to create qrexec services in VMs. Since qrexec now require service scripts to be executable, make create_remote_file() adjust permissions.
This commit is contained in:
parent
27e8d9ef4d
commit
3ce4e5eaa5
@ -1260,9 +1260,9 @@ class SystemTestCase(QubesTestCase):
|
|||||||
file.write(content)
|
file.write(content)
|
||||||
self.addCleanup(os.unlink, filename)
|
self.addCleanup(os.unlink, filename)
|
||||||
|
|
||||||
def create_remote_file(self, vm, filename, content):
|
def create_remote_file(self, vm, filename, content, mode=0o755):
|
||||||
self.loop.run_until_complete(vm.run_for_stdio(
|
self.loop.run_until_complete(vm.run_for_stdio(
|
||||||
'cat > {}'.format(shlex.quote(filename)),
|
'cat > {0}; chmod {1:o} {0}'.format(shlex.quote(filename), mode),
|
||||||
user='root', input=content.encode('utf-8')))
|
user='root', input=content.encode('utf-8')))
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -239,10 +239,9 @@ class TC_00_AppVMMixin(object):
|
|||||||
self.loop.run_until_complete(asyncio.wait([
|
self.loop.run_until_complete(asyncio.wait([
|
||||||
self.wait_for_session(self.testvm1),
|
self.wait_for_session(self.testvm1),
|
||||||
self.wait_for_session(self.testvm2)]))
|
self.wait_for_session(self.testvm2)]))
|
||||||
self.loop.run_until_complete(self.testvm2.run_for_stdio(
|
self.create_remote_file(self.testvm2,
|
||||||
'cat > /etc/qubes-rpc/test.EOF',
|
'/etc/qubes-rpc/test.EOF',
|
||||||
user='root',
|
'#!/bin/sh\n/bin/cat\n')
|
||||||
input=b'/bin/cat'))
|
|
||||||
|
|
||||||
with self.qrexec_policy('test.EOF', self.testvm1, self.testvm2):
|
with self.qrexec_policy('test.EOF', self.testvm1, self.testvm2):
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user