From: Nick Porter Date: Wed, 16 Apr 2025 10:35:53 +0000 (+0100) Subject: Add functions to set and get current request from Python thread state X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5025ed779ee10b998df34c0f7d11da0810f6b79;p=thirdparty%2Ffreeradius-server.git Add functions to set and get current request from Python thread state --- diff --git a/src/modules/rlm_python/rlm_python.c b/src/modules/rlm_python/rlm_python.c index 007beacb685..f6b518ac3d5 100644 --- a/src/modules/rlm_python/rlm_python.c +++ b/src/modules/rlm_python/rlm_python.c @@ -297,6 +297,32 @@ static rlm_python_t const *rlm_python_get_inst(void) return p_state->inst; } +/** Return the request associated with the current thread state + * + */ +static request_t *rlm_python_get_request(void) +{ + py_freeradius_state_t const *p_state; + + p_state = rlm_python_state_obj(); + if (unlikely(!p_state)) return NULL; + + return p_state->request; +} + +/** Set the request associated with the current thread state + * + */ +static void rlm_python_set_request(request_t *request) +{ + py_freeradius_state_t *p_state; + + p_state = rlm_python_state_obj(); + if (unlikely(!p_state)) return; + + p_state->request = request; +} + /** Allow fr_log to be called from python * */