Skip to content

gh-107954: Add audit event to PyConfig_Set() #132958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 4 additions & 0 deletions Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -4527,6 +4527,10 @@ config_set_sys_flag(const PyConfigSpec *spec, int 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);
Expand Down
Loading