diff --git a/qrexec/tests/socket/agent.py b/qrexec/tests/socket/agent.py index 97b97a5b..5e103370 100644 --- a/qrexec/tests/socket/agent.py +++ b/qrexec/tests/socket/agent.py @@ -26,6 +26,7 @@ import struct import getpass import itertools +import asyncio import psutil import pytest @@ -55,6 +56,10 @@ def setUp(self): def start_agent(self): env = os.environ.copy() + try: + del os.environ["QREXEC_SERVICE_ARGUMENT"] + except KeyError: + pass env["LD_LIBRARY_PATH"] = os.path.join(ROOT_PATH, "libqrexec") env["VCHAN_DOMAIN"] = str(self.domain) env["VCHAN_SOCKET_DIR"] = self.tempdir @@ -579,6 +584,38 @@ def test_exec_broken_specific_service(self): ) self.check_dom0(dom0) + @unittest.expectedFailure + def test_exec_null_argument_finds_service_for_empty_argument(self): + self.make_executable_service( + "local-rpc", + "qubes.Service+", + """\ +#!/bin/sh -- +echo "${QREXEC_SERVICE_ARGUMENT+specific} service: $QREXEC_SERVICE_FULL_NAME" +""", + ) + self.make_executable_service( + "rpc", + "qubes.Service", + """\ +#!/bin/sh +echo "general service" +""", + ) + target, dom0 = self.execute_qubesrpc("qubes.Service", "domX") + target.send_message(qrexec.MSG_DATA_STDIN, b"") + messages = target.recv_all_messages() + self.assertListEqual( + util.sort_messages(messages), + [ + (qrexec.MSG_DATA_STDOUT, b"specific service: qubes.Service+\n"), + (qrexec.MSG_DATA_STDOUT, b""), + (qrexec.MSG_DATA_STDERR, b""), + (qrexec.MSG_DATA_EXIT_CODE, b"\0\0\0\0"), + ], + ) + self.check_dom0(dom0) + def test_connect_socket_no_metadata(self): socket_path = os.path.join( self.tempdir, "rpc", "qubes.SocketService+arg2"