mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-39184: Add audit events to functions in fcntl
, msvcrt
, os
, resource
, shutil
, signal
, syslog
(GH-18407)
This commit is contained in:
parent
597ebed748
commit
7514f4f625
15 changed files with 320 additions and 17 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue