diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-06-24 16:09:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-24 16:09:47 (GMT) |
commit | 8763d43a9558b345af6a3a298afa18e7d3b42fd0 (patch) | |
tree | 260bf9be22b743195365c927df1e7ad709371568 /Lib/tempfile.py | |
parent | 366dac99c0c0c416a37874140696f59178db4e43 (diff) | |
download | cpython-8763d43a9558b345af6a3a298afa18e7d3b42fd0.zip cpython-8763d43a9558b345af6a3a298afa18e7d3b42fd0.tar.gz cpython-8763d43a9558b345af6a3a298afa18e7d3b42fd0.tar.bz2 |
bpo-37363: Add audit events for a range of modules (GH-14301)
(cherry picked from commit 60419a7e96577cf783b3b45bf3984f9fb0d7ddff)
Co-authored-by: Steve Dower <steve.dower@python.org>
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r-- | Lib/tempfile.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py index e8b111e..45709cb 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -43,6 +43,7 @@ import os as _os import shutil as _shutil import errno as _errno from random import Random as _Random +import sys as _sys import weakref as _weakref import _thread _allocate_lock = _thread.allocate_lock @@ -244,6 +245,7 @@ def _mkstemp_inner(dir, pre, suf, flags, output_type): for seq in range(TMP_MAX): name = next(names) file = _os.path.join(dir, pre + name + suf) + _sys.audit("tempfile.mkstemp", file) try: fd = _os.open(file, flags, 0o600) except FileExistsError: @@ -352,6 +354,7 @@ def mkdtemp(suffix=None, prefix=None, dir=None): for seq in range(TMP_MAX): name = next(names) file = _os.path.join(dir, prefix + name + suffix) + _sys.audit("tempfile.mkdtemp", file) try: _os.mkdir(file, 0o700) except FileExistsError: @@ -546,7 +549,7 @@ def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None, _os.close(fd) raise -if _os.name != 'posix' or _os.sys.platform == 'cygwin': +if _os.name != 'posix' or _sys.platform == 'cygwin': # On non-POSIX and Cygwin systems, assume that we cannot unlink a file # while it is open. TemporaryFile = NamedTemporaryFile |