All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
rlm_python.c File Reference

Translates requests between the server an a python interpreter. More...

#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modules.h>
#include <Python.h>
#include <dlfcn.h>
+ Include dependency graph for rlm_python.c:

Go to the source code of this file.

Data Structures

struct  py_function_def
 
struct  rlm_python_t
 

Macros

#define A(x)
 
#define A(x)   { #x, x },
 
#define A(x)   mod_funcdef_clear(&inst->x)
 
#define A(x)   if (mod_load_function(&inst->x) < 0) goto failed
 
#define A(x)
 
#define Pyx_BLOCK_THREADS
 
#define Pyx_UNBLOCK_THREADS
 

Typedefs

typedef struct rlm_python_t rlm_python_t
 

Functions

 A (authenticate)
 
static rlm_rcode_t do_python (rlm_python_t *inst, REQUEST *request, PyObject *pFunc, char const *funcname, bool worker)
 
 fr_thread_local_setup (PyThreadState *, local_thread_state)
 
static int mod_detach (void *instance)
 
static void mod_error (void)
 
static void mod_funcdef_clear (struct py_function_def *def)
 
static int mod_init (rlm_python_t *inst)
 
static void mod_instance_clear (rlm_python_t *inst)
 
static int mod_instantiate (UNUSED CONF_SECTION *conf, void *instance)
 
static int mod_load_function (struct py_function_def *def)
 
static void mod_objclear (PyObject **ob)
 
static int mod_populate_vptuple (PyObject *pPair, VALUE_PAIR *vp)
 
static void mod_vptuple (TALLOC_CTX *ctx, VALUE_PAIR **vps, PyObject *pValue, char const *funcname)
 

Variables

static CONF_PARSER module_config []
 
static PyMethodDef module_methods []
 
struct {
char const * name
 
int value
 
radiusd_constants []
 

Detailed Description

Translates requests between the server an a python interpreter.

Id:
d82fc558fc29356130567efd0cdfa7914c6367c2
Note
Rewritten by Paul P. Komkoff Jr i@sti.nosp@m.ngr..nosp@m.net.

Definition in file rlm_python.c.


Data Structure Documentation

struct py_function_def

Definition at line 49 of file rlm_python.c.

Data Fields
PyObject * function
char const * function_name
PyObject * module
char const * module_name
struct rlm_python_t

Definition at line 57 of file rlm_python.c.

+ Collaboration diagram for rlm_python_t:
Data Fields
struct py_function_def
instantiate authorize
authenticate preacct
accounting checksimul
pre_proxy post_proxy post_auth
recv_coa send_coa
detach
void * libpython
PyThreadState * main_thread_state
char const * python_path

Macro Definition Documentation

#define A (   x)
Value:
{ FR_CONF_OFFSET("mod_" #x, PW_TYPE_STRING, rlm_python_t, x.module_name) }, \
{ FR_CONF_OFFSET("func_" #x, PW_TYPE_STRING, rlm_python_t, x.function_name) },
#define FR_CONF_OFFSET(_n, _t, _s, _f)
Definition: conffile.h:168
String of printable characters.
Definition: radius.h:33

Definition at line 719 of file rlm_python.c.

#define A (   x)    { #x, x },

Definition at line 719 of file rlm_python.c.

#define A (   x)    mod_funcdef_clear(&inst->x)

Definition at line 719 of file rlm_python.c.

#define A (   x)    if (mod_load_function(&inst->x) < 0) goto failed

Definition at line 719 of file rlm_python.c.

#define A (   x)
Value:
static rlm_rcode_t CC_HINT(nonnull) mod_##x(void *instance, REQUEST *request) { \
return do_python((rlm_python_t *) instance, request, ((rlm_python_t *)instance)->x.function, #x, true);\
}
#define CC_HINT(_x)
Definition: build.h:71
enum rlm_rcodes rlm_rcode_t
Return codes indicating the result of the module call.

Definition at line 719 of file rlm_python.c.

#define Pyx_BLOCK_THREADS

Definition at line 40 of file rlm_python.c.

#define Pyx_UNBLOCK_THREADS

Definition at line 41 of file rlm_python.c.

Typedef Documentation

typedef struct rlm_python_t rlm_python_t

Function Documentation

A ( authenticate  )

Definition at line 723 of file rlm_python.c.

+ Here is the call graph for this function:

static rlm_rcode_t do_python ( rlm_python_t inst,
REQUEST request,
PyObject *  pFunc,
char const *  funcname,
bool  worker 
)
static

Definition at line 406 of file rlm_python.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_thread_local_setup ( PyThreadState *  ,
local_thread_state   
)

Definition at line 139 of file rlm_python.c.

+ Here is the call graph for this function:

static int mod_detach ( void *  instance)
static

Definition at line 703 of file rlm_python.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void mod_error ( void  )
static

Definition at line 179 of file rlm_python.c.

+ Here is the caller graph for this function:

static void mod_funcdef_clear ( struct py_function_def def)
static

Definition at line 631 of file rlm_python.c.

+ Here is the call graph for this function:

static int mod_init ( rlm_python_t inst)
static

Definition at line 202 of file rlm_python.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void mod_instance_clear ( rlm_python_t inst)
static

Definition at line 637 of file rlm_python.c.

+ Here is the caller graph for this function:

static int mod_instantiate ( UNUSED CONF_SECTION conf,
void *  instance 
)
static

Definition at line 663 of file rlm_python.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int mod_load_function ( struct py_function_def def)
static

Definition at line 583 of file rlm_python.c.

+ Here is the call graph for this function:

static void mod_objclear ( PyObject **  ob)
static

Definition at line 621 of file rlm_python.c.

+ Here is the caller graph for this function:

static int mod_populate_vptuple ( PyObject *  pPair,
VALUE_PAIR vp 
)
static

Definition at line 362 of file rlm_python.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void mod_vptuple ( TALLOC_CTX *  ctx,
VALUE_PAIR **  vps,
PyObject *  pValue,
char const *  funcname 
)
static

Definition at line 286 of file rlm_python.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

CONF_PARSER module_config[]
static
Initial value:
= {
#define A(x)
A(instantiate)
A(authorize)
A(authenticate)
A(preacct)
A(accounting)
A(checksimul)
A(pre_proxy)
A(post_proxy)
A(post_auth)
A(recv_coa)
A(send_coa)
A(detach)
{ FR_CONF_OFFSET("python_path", PW_TYPE_STRING, rlm_python_t, python_path) },
}
#define A(x)
Definition: rlm_python.c:719
#define CONF_PARSER_TERMINATOR
Definition: conffile.h:289
#define FR_CONF_OFFSET(_n, _t, _s, _f)
Definition: conffile.h:168
String of printable characters.
Definition: radius.h:33

Definition at line 82 of file rlm_python.c.

PyMethodDef module_methods[]
static
Initial value:
= {
{ "radlog", &mod_radlog, METH_VARARGS,
"radiusd.radlog(level, msg)\n\n"
"Print a message using radiusd logging system. level should be one of the\n"
"constants L_DBG, L_AUTH, L_INFO, L_ERR, L_PROXY\n"
},
{ NULL, NULL, 0, NULL },
}

Definition at line 169 of file rlm_python.c.

struct { ... } radiusd_constants[]
Initial value:
= {
#define A(x)
{ NULL, 0 },
}
Only displayed when debugging is enabled.
Definition: log.h:41
The module is OK, continue.
Definition: radiusd.h:91
#define A(x)
Definition: rlm_python.c:719
Error message.
Definition: log.h:36
The module considers the request invalid.
Definition: radiusd.h:93
Reject the request (user is locked out).
Definition: radiusd.h:94
Immediately reject the request.
Definition: radiusd.h:89
Authentication message.
Definition: log.h:34
Module succeeded without doing anything.
Definition: radiusd.h:96
Module failed, don't reply.
Definition: radiusd.h:90
Proxy messages.
Definition: log.h:38
How many valid return codes there are.
Definition: radiusd.h:98
Informational message.
Definition: log.h:35
User not found.
Definition: radiusd.h:95
OK (pairs modified).
Definition: radiusd.h:97
The module handled the request, so stop.
Definition: radiusd.h:92