]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-107954: Add audit event to PyConfig_Set() (#132958)
authorVictor Stinner <vstinner@python.org>
Fri, 25 Apr 2025 16:30:39 +0000 (18:30 +0200)
committerGitHub <noreply@github.com>
Fri, 25 Apr 2025 16:30:39 +0000 (18:30 +0200)
Doc/c-api/init_config.rst
Python/initconfig.c

index d8d442cff03f3c123adbad0091595bfa56e1f3f2..bc5b236393be15c84523457fc16f8c625fb92b30 100644 (file)
@@ -619,6 +619,8 @@ Some options are read from the :mod:`sys` attributes. For example, the option
    The caller must have an :term:`attached thread state`. The function cannot
    be called before Python initialization nor after Python finalization.
 
+   .. audit-event:: cpython.PyConfig_Set name,value c.PyConfig_Set
+
    .. versionadded:: 3.14
 
 
index 43b85a383d3bb206482893b9c881f5571c50b00f..7d3043dd5d1dd95df2a138a1b6483950771f011f 100644 (file)
@@ -4539,6 +4539,10 @@ config_set_int_attr(const PyConfigSpec *spec, int value)
 int
 PyConfig_Set(const char *name, PyObject *value)
 {
+    if (PySys_Audit("cpython.PyConfig_Set", "sO", name, value) < 0) {
+        return -1;
+    }
+
     const PyConfigSpec *spec = config_find_spec(name);
     if (spec == NULL) {
         spec = preconfig_find_spec(name);