diff --git a/qrexec/tests/socket/agent.py b/qrexec/tests/socket/agent.py index 8aaa5fbc..94dfb133 100644 --- a/qrexec/tests/socket/agent.py +++ b/qrexec/tests/socket/agent.py @@ -47,6 +47,15 @@ class TestAgentBase(unittest.TestCase): target_domain = 43 target_port = 1024 + def check_dom0(self, dom0): + self.assertEqual( + dom0.recv_message(), + ( + qrexec.MSG_CONNECTION_TERMINATED, + struct.pack("&2') + target, dom0 = self.execute('echo "stdout"; echo "stderr" >&2') target.send_message(qrexec.MSG_DATA_STDIN, b"") messages = target.recv_all_messages() @@ -812,7 +793,7 @@ def test_stdin_stderr(self): ) def test_pass_stdin(self): - target = self.execute("cat") + target, dom0 = self.execute("cat") target.send_message(qrexec.MSG_DATA_STDIN, b"data 1") self.assertEqual( @@ -834,15 +815,16 @@ def test_pass_stdin(self): (qrexec.MSG_DATA_EXIT_CODE, b"\0\0\0\0"), ], ) + self.check_dom0(dom0) def test_close_stdin_early(self): # Make sure that we cover the error on writing stdin into living # process. - target = self.execute( + target, dom0 = self.execute( """ read exec <&- -echo closed stdin +echo "closed stdin" sleep 1 """ ) @@ -862,6 +844,7 @@ def test_close_stdin_early(self): (qrexec.MSG_DATA_EXIT_CODE, b"\0\0\0\0"), ], ) + self.check_dom0(dom0) def test_buffer_stdin(self): # Test to trigger WRITE_STDIN_BUFFERED. @@ -877,7 +860,7 @@ def test_buffer_stdin(self): fifo = os.path.join(self.tempdir, "fifo") os.mkfifo(fifo) - target = self.execute("read <{}; cat".format(fifo)) + target, dom0 = self.execute("read <{}; cat".format(fifo)) for i in range(0, data_size, msg_size): msg = data[i : i + msg_size] @@ -911,9 +894,10 @@ def test_buffer_stdin(self): (qrexec.MSG_DATA_EXIT_CODE, b"\0\0\0\0"), ], ) + self.check_dom0(dom0) def test_close_stdout_stderr_early(self): - target = self.execute( + target, dom0 = self.execute( """\ read echo closing stdout @@ -946,9 +930,10 @@ def test_close_stdout_stderr_early(self): target.recv_message(), (qrexec.MSG_DATA_EXIT_CODE, struct.pack("&0 @@ -973,11 +958,12 @@ def test_stdio_socket(self): (qrexec.MSG_DATA_EXIT_CODE, b"\0\0\0\0"), ], ) + self.check_dom0(dom0) def test_exit_before_closing_streams(self): fifo = os.path.join(self.tempdir, "fifo") os.mkfifo(fifo) - target = self.execute( + target, dom0 = self.execute( """\ # duplicate original stdin to fd 3, because bash will # close original stdin in child process @@ -1021,6 +1007,7 @@ def test_exit_before_closing_streams(self): (qrexec.MSG_DATA_EXIT_CODE, struct.pack("