The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Defines functions for rlm module (re-)initialisation. More...
#include <freeradius-devel/server/cf_file.h>
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/global_lib.h>
#include <freeradius-devel/server/modpriv.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/pair.h>
#include <freeradius-devel/server/section.h>
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/server/virtual_servers.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/talloc.h>
#include <freeradius-devel/util/token.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/unlang/compile.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/unlang/xlat_redundant.h>
#include <pthread.h>
Go to the source code of this file.
Data Structures | |
struct | module_rlm_virtual_t |
Macros | |
#define | FIND_SIBLING_CF_KEY "find_sibling" |
#define | parent_name(_x) cf_section_name(cf_item_to_section(cf_parent(_x))) |
Functions | |
static int | _modules_rlm_free_atexit (UNUSED void *uctx) |
static int8_t | binding_name_cmp (void const *one, void const *two) |
Compare the section names of two module_method_binding_t structures. | |
static module_method_binding_t const * | module_binding_find (module_method_group_t const *mmg, section_name_t const *section) |
Iterate over an array of named module methods, looking for matches. | |
static int | module_conf_parse (module_list_t *ml, CONF_SECTION *mod_conf) |
static int | module_method_group_validate (module_method_group_t *group) |
static int | module_method_validate (module_instance_t *mi) |
static int | module_rlm_bootstrap_virtual (CONF_SECTION *cs) |
Create a virtual module. | |
fr_slen_t | module_rlm_by_name_and_method (TALLOC_CTX *ctx, module_method_call_t *mmc_out, virtual_server_t const *vs, section_name_t const *section, fr_sbuff_t *name, tmpl_rules_t const *t_rules) |
Find an existing module instance and verify it implements the specified method. | |
fr_pool_t * | module_rlm_connection_pool_init (CONF_SECTION *module, void *opaque, fr_pool_connection_create_t c, fr_pool_connection_alive_t a, char const *log_prefix, char const *trigger_prefix, fr_pair_list_t *trigger_args) |
Initialise a module specific connection pool. | |
module_instance_t * | module_rlm_dynamic_by_name (module_instance_t const *parent, char const *asked_name) |
exfile_t * | module_rlm_exfile_init (TALLOC_CTX *ctx, CONF_SECTION *module, uint32_t max_entries, fr_time_delta_t max_idle, bool locking, char const *trigger_prefix, fr_pair_list_t *trigger_args) |
Initialise a module specific exfile handle. | |
static module_instance_t * | module_rlm_instance_alloc (module_list_t *ml, module_instance_t const *parent, dl_module_type_t type, char const *mod_name, char const *inst_name, module_instance_state_t init_state) |
Allocate a rlm module instance. | |
void | module_rlm_list_debug (void) |
Print information on all loaded modules. | |
static void | module_rlm_methods_to_strerror (module_method_group_t const *mmg) |
Dump the available bindings for the module into the strerror stack. | |
bool | module_rlm_section_type_set (request_t *request, fr_dict_attr_t const *type_da, fr_dict_enum_value_t const *enumv) |
Set the next section type if it's not already set. | |
int | module_rlm_sibling_section_find (CONF_SECTION **out, CONF_SECTION *module, char const *name) |
Resolve polymorphic item's from a module's CONF_SECTION to a subsection in another module. | |
module_instance_t * | module_rlm_static_by_name (module_instance_t const *parent, char const *asked_name) |
int | module_rlm_submodule_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule) |
Generic conf_parser_t func for loading drivers. | |
CONF_SECTION * | module_rlm_virtual_by_name (char const *asked_name) |
static int8_t | module_rlm_virtual_name_cmp (void const *one, void const *two) |
Compare virtual modules by name. | |
xlat_t * | module_rlm_xlat_register (TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, char const *name, xlat_func_t func, fr_type_t return_type) |
int | modules_rlm_bootstrap (CONF_SECTION *root) |
Bootstrap modules and virtual modules. | |
int | modules_rlm_free (void) |
Cleanup all global structures. | |
int | modules_rlm_init (void) |
Initialise the module list structure. | |
int | modules_rlm_instantiate (void) |
Performs the instantiation phase for all backend modules. | |
void | modules_rlm_thread_detach (void) |
Frees thread-specific data for all registered backend modules. | |
int | modules_rlm_thread_instantiate (TALLOC_CTX *ctx, fr_event_list_t *el) |
Allocates thread-specific data for all registered backend modules. | |
Variables | |
static fr_rb_tree_t * | module_rlm_virtual_name_tree |
Lookup virtual module by name. | |
static module_list_t * | rlm_modules_dynamic |
Runtime instantiated list. | |
static module_list_t * | rlm_modules_static |
Global module list for all backend modules. | |
Defines functions for rlm module (re-)initialisation.
Definition in file module_rlm.c.
struct module_rlm_virtual_t |
Definition at line 64 of file module_rlm.c.
Data Fields | ||
---|---|---|
bool | all_same | |
CONF_SECTION * | cs | CONF_SECTION where it is defined. |
char const * | name | module name |
fr_rb_node_t | name_node | Entry in the name tree. |
#define FIND_SIBLING_CF_KEY "find_sibling" |
#define parent_name | ( | _x | ) | cf_section_name(cf_item_to_section(cf_parent(_x))) |
|
static |
Definition at line 1367 of file module_rlm.c.
|
static |
Compare the section names of two module_method_binding_t structures.
Definition at line 994 of file module_rlm.c.
|
static |
Iterate over an array of named module methods, looking for matches.
[in] | mmg | A structure containing a terminated array of module method bindings. pre-sorted using section_name_cmp with name2 sublists populated. |
[in] | section | name1 of the method being called can be one of the following:
|
Definition at line 464 of file module_rlm.c.
|
static |
Definition at line 1129 of file module_rlm.c.
|
static |
Definition at line 1002 of file module_rlm.c.
|
static |
Definition at line 1088 of file module_rlm.c.
|
static |
Create a virtual module.
[in] | cs | that defines the virtual module. |
Definition at line 840 of file module_rlm.c.
fr_slen_t module_rlm_by_name_and_method | ( | TALLOC_CTX * | ctx, |
module_method_call_t * | mmc_out, | ||
virtual_server_t const * | vs, | ||
section_name_t const * | section, | ||
fr_sbuff_t * | name, | ||
tmpl_rules_t const * | t_rules | ||
) |
Find an existing module instance and verify it implements the specified method.
Extracts the method from the module name where the format is
<module>[.<method1>[.<method2>]]
and ensures the module implements the specified method.
[in] | ctx | to allocate the dynamic module key tmpl from. |
[out] | mmc_out | the result from resolving the module method, plus the key tmpl for dynamic modules. This is not allocated from the ctx to save the runtime dereference. |
[in] | vs | Virtual server to search for alternative module names in. |
[in] | section | Section name containing the module call. |
[in] | name | The module method call i.e. module[<key>][.<method>] |
[in] | t_rules | for resolving the dynamic module key. |
If the module exists but the method doesn't exist, then method
is set to NULL.
Definition at line 569 of file module_rlm.c.
fr_pool_t * module_rlm_connection_pool_init | ( | CONF_SECTION * | module, |
void * | opaque, | ||
fr_pool_connection_create_t | c, | ||
fr_pool_connection_alive_t | a, | ||
char const * | log_prefix, | ||
char const * | trigger_prefix, | ||
fr_pair_list_t * | trigger_args | ||
) |
Initialise a module specific connection pool.
[in] | module | section. |
[in] | opaque | data pointer to pass to callbacks. |
[in] | c | Callback to create new connections. |
[in] | a | Callback to check the status of connections. |
[in] | log_prefix | override, if NULL will be set automatically from the module CONF_SECTION. |
[in] | trigger_prefix | if NULL will be set automatically from the module CONF_SECTION. |
[in] | trigger_args | to make available in any triggers executed by the connection pool. |
Definition at line 308 of file module_rlm.c.
module_instance_t * module_rlm_dynamic_by_name | ( | module_instance_t const * | parent, |
char const * | asked_name | ||
) |
exfile_t * module_rlm_exfile_init | ( | TALLOC_CTX * | ctx, |
CONF_SECTION * | module, | ||
uint32_t | max_entries, | ||
fr_time_delta_t | max_idle, | ||
bool | locking, | ||
char const * | trigger_prefix, | ||
fr_pair_list_t * | trigger_args | ||
) |
Initialise a module specific exfile handle.
[in] | ctx | to bind the lifetime of the exfile handle to. |
[in] | module | section. |
[in] | max_entries | Max file descriptors to cache, and manage locks for. |
[in] | max_idle | Maximum time a file descriptor can be idle before it's closed. |
[in] | locking | Whether or not to lock the files. |
[in] | trigger_prefix | if NULL will be set automatically from the module CONF_SECTION. |
[in] | trigger_args | to make available in any triggers executed by the connection pool. |
Definition at line 116 of file module_rlm.c.
|
inlinestatic |
Allocate a rlm module instance.
These have extra space allocated to hold the dlist of associated xlats.
[in] | ml | Module list to allocate from. |
[in] | parent | Parent module instance. |
[in] | type | Type of module instance. |
[in] | mod_name | Name of the module. |
[in] | inst_name | Name of the instance. |
[in] | init_state | Initial state of the module instance. |
Definition at line 1110 of file module_rlm.c.
void module_rlm_list_debug | ( | void | ) |
Print information on all loaded modules.
Definition at line 96 of file module_rlm.c.
|
static |
Dump the available bindings for the module into the strerror stack.
[in] | mmg | module method group to evaluate. |
Definition at line 517 of file module_rlm.c.
bool module_rlm_section_type_set | ( | request_t * | request, |
fr_dict_attr_t const * | type_da, | ||
fr_dict_enum_value_t const * | enumv | ||
) |
Set the next section type if it's not already set.
[in] | request | The current request. |
[in] | type_da | to use. Usually attr_auth_type. |
[in] | enumv | Enumeration value of the specified type_da. |
Definition at line 427 of file module_rlm.c.
int module_rlm_sibling_section_find | ( | CONF_SECTION ** | out, |
CONF_SECTION * | module, | ||
char const * | name | ||
) |
Resolve polymorphic item's from a module's CONF_SECTION to a subsection in another module.
This allows certain module sections to reference module sections in other instances of the same module and share CONF_DATA associated with them.
example { data { ... } } example inst { data = example } *
[out] | out | where to write the pointer to a module's config section. May be NULL on success, indicating the config item was not found within the module CONF_SECTION or the chain of module references was followed and the module at the end of the chain did not a subsection. |
[in] | module | CONF_SECTION. |
[in] | name | of the polymorphic sub-section. |
Definition at line 168 of file module_rlm.c.
module_instance_t * module_rlm_static_by_name | ( | module_instance_t const * | parent, |
char const * | asked_name | ||
) |
Definition at line 828 of file module_rlm.c.
int module_rlm_submodule_parse | ( | TALLOC_CTX * | ctx, |
void * | out, | ||
void * | parent, | ||
CONF_ITEM * | ci, | ||
conf_parser_t const * | rule | ||
) |
Generic conf_parser_t func for loading drivers.
Definition at line 950 of file module_rlm.c.
CONF_SECTION * module_rlm_virtual_by_name | ( | char const * | asked_name | ) |
Definition at line 810 of file module_rlm.c.
|
static |
Compare virtual modules by name.
Definition at line 73 of file module_rlm.c.
xlat_t * module_rlm_xlat_register | ( | TALLOC_CTX * | ctx, |
module_inst_ctx_t const * | mctx, | ||
char const * | name, | ||
xlat_func_t | func, | ||
fr_type_t | return_type | ||
) |
Definition at line 257 of file module_rlm.c.
int modules_rlm_bootstrap | ( | CONF_SECTION * | root | ) |
Bootstrap modules and virtual modules.
Parse the module config sections, and load and call each module's init() function.
[in] | root | of the server configuration. |
Definition at line 1214 of file module_rlm.c.
int modules_rlm_free | ( | void | ) |
Cleanup all global structures.
Automatically called on exit.
Definition at line 1357 of file module_rlm.c.
int modules_rlm_init | ( | void | ) |
Initialise the module list structure.
Definition at line 1375 of file module_rlm.c.
int modules_rlm_instantiate | ( | void | ) |
Performs the instantiation phase for all backend modules.
Definition at line 987 of file module_rlm.c.
void modules_rlm_thread_detach | ( | void | ) |
Frees thread-specific data for all registered backend modules.
Definition at line 963 of file module_rlm.c.
int modules_rlm_thread_instantiate | ( | TALLOC_CTX * | ctx, |
fr_event_list_t * | el | ||
) |
Allocates thread-specific data for all registered backend modules.
[in] | ctx | To allocate any thread-specific data in. |
[in] | el | to register events. |
Definition at line 976 of file module_rlm.c.
|
static |
Lookup virtual module by name.
Definition at line 62 of file module_rlm.c.
|
static |
Runtime instantiated list.
Definition at line 91 of file module_rlm.c.
|
static |
Global module list for all backend modules.
Definition at line 86 of file module_rlm.c.