Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,11 @@ always available. Unless explicitly noted otherwise, all variables are read-only
interpreter is pre-release (alpha, beta, or release candidate) then the
local and remote interpreters must be the same exact version.

.. audit-event:: remove_exec pid script_path

When the code is executed in the remote process, an :ref:`auditing event <auditing>`
``remove_exec`` is raised with the *pid* and the path to the script file.

.. availability:: Unix, Windows.
.. versionadded:: 3.14

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,7 @@ def audit_hook(event, arg):
self.assertEqual(returncode, 0)
self.assertIn(b"Remote script executed successfully!", stdout)
self.assertIn(b"Audit event: remote_debugger_script, arg: ", stdout)
self.assertIn(b"Audit event: remote_exec, arg: ", stdout)
self.assertEqual(stderr, b"")

def test_remote_exec_with_exception(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
emit ``sys.remote_exec`` audit event when ``sys.remote_exec`` has been
called
4 changes: 4 additions & 0 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,10 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
PyObject *path;
const char *debugger_script_path;

if (PySys_Audit("remote_exec", "iO", pid, script) < 0) {
return NULL;
}

if (PyUnicode_FSConverter(script, &path) == 0) {
return NULL;
}
Expand Down
Loading