![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Translates requests between the server an a perl interpreter. More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/unlang/xlat.h>
#include <freeradius-devel/radius/radius.h>
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
#include <dlfcn.h>
#include <semaphore.h>
Go to the source code of this file.
Data Structures | |
struct | fr_perl_pair_s |
struct | perl_call_env_t |
struct | perl_func_def_t |
struct | rlm_perl_t |
struct | rlm_perl_thread_t |
Macros | |
#define | dl_librefs "DynaLoader::dl_librefs" |
#define | dl_modules "DynaLoader::dl_modules" |
#define | GET_PAIR_MAGIC(count) |
Convenience macro for fetching C data associated with tied hash / array and validating stack size. | |
#define | LOAD_INFO(_fmt, ...) fr_log(LOG_DST, L_INFO, __FILE__, __LINE__, "rlm_perl - " _fmt, ## __VA_ARGS__) |
#define | LOAD_WARN(_fmt, ...) |
#define | LOG_PREFIX "perl" |
#define | PERLINT(_size) |
#define | PERLSETINT(_size) |
#define | PERLSETUINT(_size) |
#define | PERLUINT(_size) |
Typedefs | |
typedef struct fr_perl_pair_s | fr_perl_pair_t |
Functions | |
EXTERN_C void | boot_DynaLoader (pTHX_ CV *cv) |
static int | fr_perl_pair_parent_build (fr_perl_pair_t *pair_data) |
Build parent structural pairs needed when a leaf node is set. | |
static int | mod_bootstrap (module_inst_ctx_t const *mctx) |
static int | mod_detach (module_detach_ctx_t const *mctx) |
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
static int | mod_load (void) |
static unlang_action_t | mod_perl (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request) |
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_unload (void) |
static fr_dict_attr_t const * | perl_attr_lookup (fr_perl_pair_t *pair_data, char const *attr) |
Helper function for turning hash keys into dictionary attributes. | |
static int8_t | perl_func_def_cmp (void const *one, void const *two) |
How to compare two Perl function calls. | |
static bool | perl_func_exists (char const *func) |
Check if a given Perl subroutine exists. | |
static void | perl_func_name_safe (char *name) |
static int | perl_func_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *out, UNUSED tmpl_rules_t const *t_rules, UNUSED CONF_ITEM *ci, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule) |
static void | perl_pair_list_tie (HV *parent, HV *frpair_stash, char const *name, fr_pair_t *vp, fr_dict_attr_t const *da) |
Create a Perl tied hash representing a pair list. | |
static void | perl_parse_config (CONF_SECTION *cs, int lvl, HV *rad_hv) |
static int | perl_sv_to_vblist (TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, SV *sv) |
Parse a Perl SV and create value boxes, appending to a list. | |
static int | perl_value_marshal (fr_pair_t *vp, SV **value) |
Functions to implement subroutines required for a tied array. | |
static int | perl_value_unmarshal (fr_pair_t *vp, SV *value) |
Convert a Perl SV to a pair value. | |
static int | perl_vblist_to_av (AV *av, fr_value_box_list_t *head) |
Convert a list of value boxes to a Perl array for passing to subroutines. | |
static xlat_action_t | perl_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
Call perl code using an xlat. | |
static void | rlm_perl_clear_handles (pTHX) |
static void | rlm_perl_close_handles (void **handles) |
static void ** | rlm_perl_get_handles (pTHX) |
static void | rlm_perl_interp_free (PerlInterpreter *perl) |
static | XS (XS_freeradius_log) |
static | XS (XS_freeradius_xlat) |
static | XS (XS_pairlist_DELETE) |
Called to delete a key from a tied hash. | |
static | XS (XS_pairlist_EXISTS) |
Called to test the existence of a key in a tied hash. | |
static | XS (XS_pairlist_FETCH) |
Functions to implement subroutines required for a tied hash. | |
static | XS (XS_pairlist_FIRSTKEY) |
Called when functions like keys() want the first key in a tied hash. | |
static | XS (XS_pairlist_NEXTKEY) |
Called by functions like keys() which iterate over the keys in a tied hash. | |
static | XS (XS_pairlist_STORE) |
Called when a hash value is set / updated. | |
static | XS (XS_pairs_DELETE) |
Called when an array entry is deleted. | |
static | XS (XS_pairs_EXISTS) |
Called when an array entry's existence is tested. | |
static | XS (XS_pairs_FETCH) |
Called to retrieve the value of an array entry. | |
static | XS (XS_pairs_FETCHSIZE) |
Called when Perl wants the size of a tied array. | |
static | XS (XS_pairs_POP) |
Called when values are popped off a tied array. | |
static | XS (XS_pairs_PUSH) |
Called when values are pushed on a tied array. | |
static | XS (XS_pairs_SHIFT) |
Called when values are "shifted" off a tied array. | |
static | XS (XS_pairs_STORE) |
Called when an array value is set / updated. | |
static | XS (XS_pairs_STORESIZE) |
Called when attempting to set the size of an array. | |
static | XS (XS_pairs_UNSHIFT) |
Called when values are "unshifted" onto a tied array. | |
static void | xs_init (pTHX) |
Variables | |
static const conf_parser_t | module_config [] |
static void * | perl_dlhandle |
To allow us to load perl's symbols into the global symbol table. | |
static const call_env_method_t | perl_method_env |
static xlat_arg_parser_t const | perl_xlat_args [] |
module_rlm_t | rlm_perl |
static _Thread_local request_t * | rlm_perl_request |
static MGVTBL | rlm_perl_vtbl = { 0, 0, 0, 0, 0, 0, 0, 0 } |
Translates requests between the server an a perl interpreter.
Definition in file rlm_perl.c.
struct fr_perl_pair_s |
Definition at line 97 of file rlm_perl.c.
Data Fields | ||
---|---|---|
fr_dcursor_t | cursor | Cursor used for iterating over the keys of a tied hash. |
fr_dict_attr_t const * | da | Dictionary attribute associated with hash / array. |
unsigned int | idx | Instance number. |
fr_perl_pair_t * | parent | Parent attribute data. |
fr_pair_t * | vp | Real pair associated with the hash / array, if it exists. |
struct perl_call_env_t |
Definition at line 64 of file rlm_perl.c.
Data Fields | ||
---|---|---|
perl_func_def_t * | func |
struct perl_func_def_t |
Definition at line 57 of file rlm_perl.c.
Data Fields | ||
---|---|---|
char const * | function_name | Name of the function being called. |
char * | name1 | Section name1 where this is called. |
char * | name2 | Section name2 where this is called. |
fr_rb_node_t | node | Node in tree of function calls. |
struct rlm_perl_t |
Definition at line 75 of file rlm_perl.c.
Data Fields | ||
---|---|---|
char const * | func_detach | Function to run when mod_detach is run. |
char const *fr_rb_tree_t | funcs | Tree of function calls found by call_env parser. |
bool | funcs_init | Has the tree been initialised. |
PerlInterpreter * | perl | |
char const * | perl_flags | |
bool | perl_parsed | |
HV * | rad_perlconf_hv | holds "config" items (perl RAD_PERLCONF hash). |
struct rlm_perl_thread_t |
Definition at line 89 of file rlm_perl.c.
Data Fields | ||
---|---|---|
PerlInterpreter * | perl | Thread specific perl interpreter. |
#define dl_librefs "DynaLoader::dl_librefs" |
Definition at line 148 of file rlm_perl.c.
#define dl_modules "DynaLoader::dl_modules" |
Definition at line 149 of file rlm_perl.c.
Convenience macro for fetching C data associated with tied hash / array and validating stack size.
Definition at line 288 of file rlm_perl.c.
#define LOAD_INFO | ( | _fmt, | |
... | |||
) | fr_log(LOG_DST, L_INFO, __FILE__, __LINE__, "rlm_perl - " _fmt, ## __VA_ARGS__) |
#define LOAD_WARN | ( | _fmt, | |
... | |||
) |
#define LOG_PREFIX "perl" |
Definition at line 27 of file rlm_perl.c.
#define PERLINT | ( | _size | ) |
#define PERLSETINT | ( | _size | ) |
#define PERLSETUINT | ( | _size | ) |
#define PERLUINT | ( | _size | ) |
typedef struct fr_perl_pair_s fr_perl_pair_t |
Definition at line 96 of file rlm_perl.c.
EXTERN_C void boot_DynaLoader | ( | pTHX_ CV * | cv | ) |
|
static |
Build parent structural pairs needed when a leaf node is set.
Definition at line 653 of file rlm_perl.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 1838 of file rlm_perl.c.
|
inlinestatic |
Helper function for turning hash keys into dictionary attributes.
Definition at line 269 of file rlm_perl.c.
|
static |
How to compare two Perl function calls.
Definition at line 128 of file rlm_perl.c.
|
static |
Check if a given Perl subroutine exists.
Definition at line 1591 of file rlm_perl.c.
|
static |
|
static |
|
static |
Create a Perl tied hash representing a pair list.
Definition at line 1418 of file rlm_perl.c.
|
static |
Definition at line 1356 of file rlm_perl.c.
|
static |
Parse a Perl SV and create value boxes, appending to a list.
For parsing values passed back from a Perl subroutine
When hashes are returned, first the key is added as a value box then the value
[in] | ctx | to allocate boxes in. |
[out] | list | to append value boxes to. |
[in] | request | being handled - only used for debug messages |
[in] | sv | to parse |
Definition at line 1112 of file rlm_perl.c.
|
static |
Functions to implement subroutines required for a tied array.
Leaf attributes are represented by tied arrays to allow multiple instances.
Definition at line 547 of file rlm_perl.c.
|
static |
Convert a Perl SV to a pair value.
Definition at line 689 of file rlm_perl.c.
|
static |
Convert a list of value boxes to a Perl array for passing to subroutines.
The Perl array object should be created before calling this to populate it.
[in,out] | av | Perl array object to append values to. |
[in] | head | of VB list. |
Definition at line 1058 of file rlm_perl.c.
|
static |
|
static |
Definition at line 192 of file rlm_perl.c.
|
static |
|
static |
Definition at line 1524 of file rlm_perl.c.
|
static |
|
static |
|
static |
Called to delete a key from a tied hash.
The stack contains
Definition at line 521 of file rlm_perl.c.
|
static |
Called to test the existence of a key in a tied hash.
The stack contains
Definition at line 441 of file rlm_perl.c.
|
static |
Functions to implement subroutines required for a tied hash.
All structural components of attributes are represented by tied hashes Called when fetching hash values
The stack contains
When a numeric key is requested, we treat that as in instruction to find a specific instance of the key of the parent.
Whilst this is a bit odd, the alternative would be for every attribute to be returned as an array so you would end up with crazy syntax like p{'request'}{'Vendor-Specific'}[0]{'Cisco'}[0]{'AVPair}[0]
Definition at line 318 of file rlm_perl.c.
|
static |
Called when functions like keys() want the first key in a tied hash.
The stack contains just the tied SV
Definition at line 481 of file rlm_perl.c.
|
static |
Called by functions like keys() which iterate over the keys in a tied hash.
The stack contains
Definition at line 500 of file rlm_perl.c.
|
static |
Called when a hash value is set / updated.
This is not allowed - only leaf node arrays can have values set
Definition at line 415 of file rlm_perl.c.
|
static |
Called when an array entry is deleted.
Definition at line 821 of file rlm_perl.c.
|
static |
Called when an array entry's existence is tested.
Definition at line 801 of file rlm_perl.c.
|
static |
Called to retrieve the value of an array entry.
In our case, retrieve the value of a specific instance of a leaf attribute
The stack contains
The magic data will hold the DA of the attribute.
Definition at line 630 of file rlm_perl.c.
|
static |
Called when Perl wants the size of a tied array.
The stack contains just the tied SV
Definition at line 842 of file rlm_perl.c.
|
static |
Called when values are popped off a tied array.
The stack contains just the tied SV
Definition at line 929 of file rlm_perl.c.
|
static |
Called when values are pushed on a tied array.
The stack contains
Definition at line 901 of file rlm_perl.c.
|
static |
Called when values are "shifted" off a tied array.
The stack contains just the tied SV
Definition at line 955 of file rlm_perl.c.
|
static |
Called when an array value is set / updated.
The stack contains
Definition at line 755 of file rlm_perl.c.
|
static |
Called when attempting to set the size of an array.
We don't allow expanding the array this way, but will allow deleting pairs
The stack contains
Definition at line 859 of file rlm_perl.c.
|
static |
Called when values are "unshifted" onto a tied array.
The stack contains
Definition at line 983 of file rlm_perl.c.
|
static |
Definition at line 1010 of file rlm_perl.c.
|
static |
Definition at line 115 of file rlm_perl.c.
|
static |
To allow us to load perl's symbols into the global symbol table.
Definition at line 110 of file rlm_perl.c.
|
static |
Definition at line 1909 of file rlm_perl.c.
|
static |
Definition at line 1219 of file rlm_perl.c.
module_rlm_t rlm_perl |
Definition at line 1927 of file rlm_perl.c.
|
static |
Definition at line 146 of file rlm_perl.c.
|
static |
Definition at line 108 of file rlm_perl.c.