The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Translates requests between the server an a python interpreter. More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/pairmove.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/lsan.h>
#include <Python.h>
#include <frameobject.h>
#include <libgen.h>
#include <dlfcn.h>
Go to the source code of this file.
Data Structures | |
struct | libpython_global_config_t |
Global config for python library. More... | |
struct | python_func_def_t |
Specifies the module.function to load for processing a section. More... | |
struct | rlm_python_t |
An instance of the rlm_python module. More... | |
struct | rlm_python_thread_t |
Tracks a python module inst/thread state pair. More... | |
Macros | |
#define | A(x) |
#define | A(x) { #x, x }, |
#define | LOAD_INFO(_fmt, ...) fr_log(LOG_DST, L_INFO, __FILE__, __LINE__, "rlm_python - " _fmt, ## __VA_ARGS__) |
#define | LOAD_WARN(_fmt, ...) |
#define | LOG_PREFIX mctx->mi->name |
#define | MOD_FUNC(x) |
#define | PYTHON_FUNC_DESTROY(_x) python_function_destroy(&inst->_x) |
#define | PYTHON_FUNC_LOAD(_x) if (python_function_load(mctx, &inst->_x) < 0) goto error |
Functions | |
static unlang_action_t | do_python (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, PyObject *p_func, char const *funcname) |
Thread safe call to a python function. More... | |
static unlang_action_t | do_python_single (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, PyObject *p_func, char const *funcname) |
static void | libpython_free (void) |
static int | libpython_init (void) |
static int | mod_detach (module_detach_ctx_t const *mctx) |
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
static PyObject * | mod_log (UNUSED PyObject *module, PyObject *args) |
Allow fr_log to be called from python. More... | |
static int | mod_populate_vptuple (module_ctx_t const *mctx, request_t *request, PyObject *pp, fr_pair_t *vp) |
static int | mod_thread_detach (module_thread_inst_ctx_t const *mctx) |
static int | mod_thread_instantiate (module_thread_inst_ctx_t const *mctx) |
static void | mod_vptuple (TALLOC_CTX *ctx, module_ctx_t const *mctx, request_t *request, fr_pair_list_t *vps, PyObject *p_value, char const *funcname, char const *list_name) |
static void | python_error_log (module_ctx_t const *mctx, request_t *request) |
Print out the current error. More... | |
static void | python_function_destroy (python_func_def_t *def) |
static int | python_function_load (module_inst_ctx_t const *mctx, python_func_def_t *def) |
Import a user module and load a function from it. More... | |
static void | python_interpreter_free (rlm_python_t *inst, PyThreadState *interp) |
static int | python_interpreter_init (module_inst_ctx_t const *mctx) |
static int | python_module_import_config (module_inst_ctx_t const *mctx, CONF_SECTION *conf, PyObject *module) |
Make the current instance's config available within the module we're initialising. More... | |
static int | python_module_import_constants (module_inst_ctx_t const *mctx, PyObject *module) |
Import integer constants into the module we're initialising. More... | |
static PyObject * | python_module_init (void) |
static void | python_obj_destroy (PyObject **ob) |
static int | python_parse_config (module_inst_ctx_t const *mctx, CONF_SECTION *cs, int lvl, PyObject *dict) |
Variables | |
static CONF_SECTION * | current_conf |
Used for communication with inittab functions. More... | |
static module_ctx_t const * | current_mctx |
Used for communication with inittab functions. More... | |
struct { | |
char const * | name |
int | value |
} | freeradius_constants [] |
static PyThreadState * | global_interpreter |
Our first interpreter. More... | |
static libpython_global_config_t | libpython_global_config |
static conf_parser_t | module_config [] |
static PyMethodDef | module_methods [] |
static void * | python_dlhandle |
static conf_parser_t const | python_global_config [] |
module_rlm_t | rlm_python |
static global_lib_autoinst_t | rlm_python_autoinst |
global_lib_autoinst_t const *const | rlm_python_lib [] |
Translates requests between the server an a python interpreter.
Definition in file rlm_python.c.
struct libpython_global_config_t |
Global config for python library.
Definition at line 78 of file rlm_python.c.
Data Fields | ||
---|---|---|
char const * | path | Path to search for python files in. |
bool | path_include_default |
Include the default python path in path |
struct python_func_def_t |
Specifies the module.function to load for processing a section.
Definition at line 46 of file rlm_python.c.
struct rlm_python_t |
An instance of the rlm_python module.
Definition at line 57 of file rlm_python.c.
Data Fields | ||
---|---|---|
python_func_def_t | accounting | |
python_func_def_t | authenticate | |
python_func_def_t | authorize | |
python_func_def_t | detach | |
python_func_def_t | instantiate | |
PyThreadState * | interpreter | The interpreter used for this instance of rlm_python. |
PyObject * | module | Local, interpreter specific module. |
char const * | name | Name of the module instance. |
python_func_def_t | post_auth | |
python_func_def_t | preacct | |
PyObject * | pythonconf_dict | Configuration parameters defined in the module made available to the python script. |
struct rlm_python_thread_t |
Tracks a python module inst/thread state pair.
Multiple instances of python create multiple interpreters and each thread must have a PyThreadState per interpreter, to track execution.
Definition at line 88 of file rlm_python.c.
Data Fields | ||
---|---|---|
PyThreadState * | state | Module instance/thread specific state. |
#define A | ( | x | ) |
#define A | ( | x | ) | { #x, x }, |
#define LOAD_INFO | ( | _fmt, | |
... | |||
) | fr_log(LOG_DST, L_INFO, __FILE__, __LINE__, "rlm_python - " _fmt, ## __VA_ARGS__) |
#define LOAD_WARN | ( | _fmt, | |
... | |||
) |
Definition at line 30 of file rlm_python.c.
#define MOD_FUNC | ( | x | ) |
Definition at line 627 of file rlm_python.c.
#define PYTHON_FUNC_DESTROY | ( | _x | ) | python_function_destroy(&inst->_x) |
#define PYTHON_FUNC_LOAD | ( | _x | ) | if (python_function_load(mctx, &inst->_x) < 0) goto error |
|
static |
Thread safe call to a python function.
Will swap in thread state specific to module/thread.
Definition at line 607 of file rlm_python.c.
|
static |
Definition at line 476 of file rlm_python.c.
|
static |
Definition at line 1146 of file rlm_python.c.
|
static |
|
static |
|
static |
|
static |
Allow fr_log to be called from python.
Definition at line 204 of file rlm_python.c.
|
static |
Definition at line 373 of file rlm_python.c.
|
static |
Definition at line 1041 of file rlm_python.c.
|
static |
Definition at line 1023 of file rlm_python.c.
|
static |
Definition at line 281 of file rlm_python.c.
|
static |
Print out the current error.
Must be called with a valid thread state set
Definition at line 231 of file rlm_python.c.
|
static |
|
static |
Import a user module and load a function from it.
Definition at line 657 of file rlm_python.c.
|
static |
|
static |
Definition at line 854 of file rlm_python.c.
|
static |
Make the current instance's config available within the module we're initialising.
Definition at line 777 of file rlm_python.c.
|
static |
Import integer constants into the module we're initialising.
Definition at line 813 of file rlm_python.c.
|
static |
Definition at line 831 of file rlm_python.c.
|
static |
|
static |
Definition at line 694 of file rlm_python.c.
|
static |
Used for communication with inittab functions.
Definition at line 96 of file rlm_python.c.
|
static |
Used for communication with inittab functions.
Definition at line 95 of file rlm_python.c.
struct { ... } freeradius_constants[] |
|
static |
Our first interpreter.
Definition at line 93 of file rlm_python.c.
|
static |
Definition at line 98 of file rlm_python.c.
|
static |
|
static |
Definition at line 218 of file rlm_python.c.
|
static |
Definition at line 92 of file rlm_python.c.
|
static |
Definition at line 103 of file rlm_python.c.
module_rlm_t rlm_python |
Definition at line 1169 of file rlm_python.c.
|
static |
Definition at line 112 of file rlm_python.c.
global_lib_autoinst_t const *const rlm_python_lib |
Definition at line 121 of file rlm_python.c.