From: Nick Porter Date: Fri, 11 Apr 2025 16:09:01 +0000 (+0100) Subject: Add libpython global option to enable verbose logs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8687e2e108ee5c20104a33d478a7f5b9dbb4bcf2;p=thirdparty%2Ffreeradius-server.git Add libpython global option to enable verbose logs For deep debugging of Python behaviour --- diff --git a/raddb/global.d/python b/raddb/global.d/python index 5bc6df7953e..4eca12850eb 100644 --- a/raddb/global.d/python +++ b/raddb/global.d/python @@ -14,4 +14,9 @@ python { # path components will be prepended to the the default search path. # # path_include_default = "yes" + + # verbose:: + # + # If "yes", enable libpython verbose logging messages. +# verbose = no } diff --git a/src/modules/rlm_python/rlm_python.c b/src/modules/rlm_python/rlm_python.c index 7400b0fc6e7..2d86f0dbf76 100644 --- a/src/modules/rlm_python/rlm_python.c +++ b/src/modules/rlm_python/rlm_python.c @@ -78,6 +78,7 @@ typedef struct { typedef struct { char const *path; //!< Path to search for python files in. bool path_include_default; //!< Include the default python path in `path` + bool verbose; //!< Enable libpython verbose logging } libpython_global_config_t; /** Tracks a python module inst/thread state pair @@ -103,6 +104,7 @@ static libpython_global_config_t libpython_global_config = { static conf_parser_t const python_global_config[] = { { FR_CONF_OFFSET("path", libpython_global_config_t, path) }, { FR_CONF_OFFSET("path_include_default", libpython_global_config_t, path_include_default) }, + { FR_CONF_OFFSET("verbose", libpython_global_config_t, verbose) }, CONF_PARSER_TERMINATOR }; @@ -1159,6 +1161,8 @@ static int libpython_init(void) config.install_signal_handlers = 0; /* Don't override signal handlers - noop on subs calls */ + if (libpython_global_config.verbose) config.verbose = 1; /* Enable libpython logging*/ + LSAN_DISABLE(status = Py_InitializeFromConfig(&config)); if (PyStatus_Exception(status)) goto fail;