summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSaiyang Gou <gousaiyang@163.com>2020-02-13 07:47:42 (GMT)
committerGitHub <noreply@github.com>2020-02-13 07:47:42 (GMT)
commit7514f4f6254f4a2d13ea8e5632a8e5f22b637e0b (patch)
tree9010a9077eaee0c66eea85e36f60086de6fba731 /Lib
parent597ebed748d0b0c061f8c108bd98270d103286c1 (diff)
downloadcpython-7514f4f6254f4a2d13ea8e5632a8e5f22b637e0b.zip
cpython-7514f4f6254f4a2d13ea8e5632a8e5f22b637e0b.tar.gz
cpython-7514f4f6254f4a2d13ea8e5632a8e5f22b637e0b.tar.bz2
bpo-39184: Add audit events to functions in `fcntl`, `msvcrt`, `os`, `resource`, `shutil`, `signal`, `syslog` (GH-18407)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/shutil.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 9a83a32..a4ce2c0 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -235,6 +235,8 @@ def copyfile(src, dst, *, follow_symlinks=True):
symlink will be created instead of copying the file it points to.
"""
+ sys.audit("shutil.copyfile", src, dst)
+
if _samefile(src, dst):
raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
@@ -289,6 +291,8 @@ def copymode(src, dst, *, follow_symlinks=True):
(e.g. Linux) this method does nothing.
"""
+ sys.audit("shutil.copymode", src, dst)
+
if not follow_symlinks and _islink(src) and os.path.islink(dst):
if hasattr(os, 'lchmod'):
stat_func, chmod_func = os.lstat, os.lchmod
@@ -340,6 +344,8 @@ def copystat(src, dst, *, follow_symlinks=True):
If the optional flag `follow_symlinks` is not set, symlinks aren't
followed if and only if both `src` and `dst` are symlinks.
"""
+ sys.audit("shutil.copystat", src, dst)
+
def _nop(*args, ns=None, follow_symlinks=None):
pass
@@ -778,6 +784,7 @@ def move(src, dst, copy_function=copy2):
the issues this implementation glosses over.
"""
+ sys.audit("shutil.move", src, dst)
real_dst = dst
if os.path.isdir(dst):
if _samefile(src, dst):
@@ -1208,6 +1215,8 @@ def unpack_archive(filename, extract_dir=None, format=None):
In case none is found, a ValueError is raised.
"""
+ sys.audit("shutil.unpack_archive", filename, extract_dir, format)
+
if extract_dir is None:
extract_dir = os.getcwd()
@@ -1275,6 +1284,7 @@ def chown(path, user=None, group=None):
user and group can be the uid/gid or the user/group names, and in that case,
they are converted to their respective uid/gid.
"""
+ sys.audit('shutil.chown', path, user, group)
if user is None and group is None:
raise ValueError("user and/or group must be set")