diff options
author | Steve Dower <steve.dower@microsoft.com> | 2019-05-23 15:45:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-23 15:45:22 (GMT) |
commit | b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184 (patch) | |
tree | 5370a2a075707cb0b37ce135cad6ffe23da424c4 /Modules/posixmodule.c | |
parent | e788057a9188ff37e232729815dfda2529079420 (diff) | |
download | cpython-b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184.zip cpython-b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184.tar.gz cpython-b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184.tar.bz2 |
bpo-36842: Implement PEP 578 (GH-12613)
Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 9f15866..8ebe3a0 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4264,6 +4264,11 @@ os_system_impl(PyObject *module, const Py_UNICODE *command) /*[clinic end generated code: output=5b7c3599c068ca42 input=303f5ce97df606b0]*/ { long result; + + if (PySys_Audit("system", "(u)", command) < 0) { + return -1; + } + Py_BEGIN_ALLOW_THREADS _Py_BEGIN_SUPPRESS_IPH result = _wsystem(command); @@ -4286,6 +4291,11 @@ os_system_impl(PyObject *module, PyObject *command) { long result; const char *bytes = PyBytes_AsString(command); + + if (PySys_Audit("system", "(O)", command) < 0) { + return -1; + } + Py_BEGIN_ALLOW_THREADS result = system(bytes); Py_END_ALLOW_THREADS @@ -8279,6 +8289,10 @@ os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd) flags |= O_CLOEXEC; #endif + if (PySys_Audit("open", "OOi", path->object, Py_None, flags) < 0) { + return -1; + } + _Py_BEGIN_SUPPRESS_IPH do { Py_BEGIN_ALLOW_THREADS @@ -9598,6 +9612,10 @@ os_ftruncate_impl(PyObject *module, int fd, Py_off_t length) int result; int async_err = 0; + if (PySys_Audit("os.truncate", "in", fd, length) < 0) { + return NULL; + } + do { Py_BEGIN_ALLOW_THREADS _Py_BEGIN_SUPPRESS_IPH @@ -9641,6 +9659,10 @@ os_truncate_impl(PyObject *module, path_t *path, Py_off_t length) if (path->fd != -1) return os_ftruncate_impl(module, path->fd, length); + if (PySys_Audit("os.truncate", "On", path->object, length) < 0) { + return NULL; + } + Py_BEGIN_ALLOW_THREADS _Py_BEGIN_SUPPRESS_IPH #ifdef MS_WINDOWS |