bpo-39184: Add audit events to command execution functions in os and pty modules (GH-17824)
(cherry picked from commit 95f60010219e142a436fae18e1695cbc45407afe)
Co-authored-by: Saiyang Gou <gousaiyang@163.com>
diff --git a/Lib/pty.py b/Lib/pty.py
index e841f12..a324320 100644
--- a/Lib/pty.py
+++ b/Lib/pty.py
@@ -8,6 +8,7 @@
from select import select
import os
+import sys
import tty
__all__ = ["openpty","fork","spawn"]
@@ -151,6 +152,7 @@
"""Create a spawned process."""
if type(argv) == type(''):
argv = (argv,)
+ sys.audit('pty.spawn', argv)
pid, master_fd = fork()
if pid == CHILD:
os.execlp(argv[0], *argv)