bpo-37363: Add audit events for a range of modules (GH-14301)

This commit is contained in:
Steve Dower 2019-06-24 08:42:54 -07:00 committed by GitHub
parent 9bbf4d7083
commit 60419a7e96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 165 additions and 18 deletions

View file

@ -1268,6 +1268,11 @@ class Popen(object):
comspec = os.environ.get("COMSPEC", "cmd.exe")
args = '{} /c "{}"'.format (comspec, args)
if cwd is not None:
cwd = os.fsdecode(cwd)
sys.audit("subprocess.Popen", executable, args, cwd, env)
# Start the process
try:
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
@ -1276,7 +1281,7 @@ class Popen(object):
int(not close_fds),
creationflags,
env,
os.fsdecode(cwd) if cwd is not None else None,
cwd,
startupinfo)
finally:
# Child is launched. Close the parent's copy of those pipe
@ -1543,6 +1548,8 @@ class Popen(object):
if executable is None:
executable = args[0]
sys.audit("subprocess.Popen", executable, args, cwd, env)
if (_USE_POSIX_SPAWN
and os.path.dirname(executable)
and preexec_fn is None