The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
module_rlm.c File Reference

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>
+ Include dependency graph for module_rlm.c:

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_tmodule_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_tmodule_rlm_dynamic_by_name (module_instance_t const *parent, char const *asked_name)
 
exfile_tmodule_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_tmodule_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_tmodule_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_SECTIONmodule_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_tmodule_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_tmodule_rlm_virtual_name_tree
 Lookup virtual module by name.
 
static module_list_trlm_modules_dynamic
 Runtime instantiated list.
 
static module_list_trlm_modules_static
 Global module list for all backend modules.
 

Detailed Description

Defines functions for rlm module (re-)initialisation.

Id
259093b1c729fbc355ca7edc2a7bdca27c4f250e

Definition in file module_rlm.c.


Data Structure Documentation

◆ module_rlm_virtual_t

struct module_rlm_virtual_t

Definition at line 64 of file module_rlm.c.

+ Collaboration diagram for module_rlm_virtual_t:
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.

Macro Definition Documentation

◆ FIND_SIBLING_CF_KEY

#define FIND_SIBLING_CF_KEY   "find_sibling"

◆ parent_name

#define parent_name (   _x)    cf_section_name(cf_item_to_section(cf_parent(_x)))

Function Documentation

◆ _modules_rlm_free_atexit()

static int _modules_rlm_free_atexit ( UNUSED void *  uctx)
static

Definition at line 1367 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ binding_name_cmp()

static int8_t binding_name_cmp ( void const *  one,
void const *  two 
)
static

Compare the section names of two module_method_binding_t structures.

Definition at line 994 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_binding_find()

static module_method_binding_t const * module_binding_find ( module_method_group_t const *  mmg,
section_name_t const *  section 
)
static

Iterate over an array of named module methods, looking for matches.

Parameters
[in]mmgA structure containing a terminated array of module method bindings. pre-sorted using section_name_cmp with name2 sublists populated.
[in]sectionname1 of the method being called can be one of the following:
  • An itenfier.
  • CF_IDENT_ANY if the method is a wildcard. name2 of the method being called can be one of the following:
  • An itenfier.
  • NULL to match section names with only a name1.
  • CF_IDENT_ANY if the method is a wildcard.
Returns
  • The module_method_name_t on success.
  • NULL on not found.

Definition at line 464 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_conf_parse()

static int module_conf_parse ( module_list_t ml,
CONF_SECTION mod_conf 
)
static

Definition at line 1129 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_method_group_validate()

static int module_method_group_validate ( module_method_group_t group)
static

Definition at line 1002 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_method_validate()

static int module_method_validate ( module_instance_t mi)
static

Definition at line 1088 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_bootstrap_virtual()

static int module_rlm_bootstrap_virtual ( CONF_SECTION cs)
static

Create a virtual module.

Parameters
[in]csthat defines the virtual module.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 840 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_by_name_and_method()

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.

Parameters
[in]ctxto allocate the dynamic module key tmpl from.
[out]mmc_outthe 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]vsVirtual server to search for alternative module names in.
[in]sectionSection name containing the module call.
[in]nameThe module method call i.e. module[<key>][.<method>]
[in]t_rulesfor resolving the dynamic module key.
Returns
  • The module instance on success.
  • NULL on not found

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.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_connection_pool_init()

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.

See also
fr_pool_init
Parameters
[in]modulesection.
[in]opaquedata pointer to pass to callbacks.
[in]cCallback to create new connections.
[in]aCallback to check the status of connections.
[in]log_prefixoverride, if NULL will be set automatically from the module CONF_SECTION.
[in]trigger_prefixif NULL will be set automatically from the module CONF_SECTION.
[in]trigger_argsto make available in any triggers executed by the connection pool.
Returns
  • New connection pool.
  • NULL on error.

Definition at line 308 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_dynamic_by_name()

module_instance_t * module_rlm_dynamic_by_name ( module_instance_t const *  parent,
char const *  asked_name 
)

Definition at line 823 of file module_rlm.c.

+ Here is the call graph for this function:

◆ module_rlm_exfile_init()

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.

See also
exfile_init
Parameters
[in]ctxto bind the lifetime of the exfile handle to.
[in]modulesection.
[in]max_entriesMax file descriptors to cache, and manage locks for.
[in]max_idleMaximum time a file descriptor can be idle before it's closed.
[in]lockingWhether or not to lock the files.
[in]trigger_prefixif NULL will be set automatically from the module CONF_SECTION.
[in]trigger_argsto make available in any triggers executed by the connection pool.
Returns
  • New connection pool.
  • NULL on error.

Definition at line 116 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_instance_alloc()

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 
)
inlinestatic

Allocate a rlm module instance.

These have extra space allocated to hold the dlist of associated xlats.

Parameters
[in]mlModule list to allocate from.
[in]parentParent module instance.
[in]typeType of module instance.
[in]mod_nameName of the module.
[in]inst_nameName of the instance.
[in]init_stateInitial state of the module instance.
Returns
  • The allocated module instance on success.
  • NULL on failure.

Definition at line 1110 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_list_debug()

void module_rlm_list_debug ( void  )

Print information on all loaded modules.

Definition at line 96 of file module_rlm.c.

+ Here is the call graph for this function:

◆ module_rlm_methods_to_strerror()

static void module_rlm_methods_to_strerror ( module_method_group_t const *  mmg)
static

Dump the available bindings for the module into the strerror stack.

Note
Methods from all linked module method groups will be pushed onto the error stack.
Parameters
[in]mmgmodule method group to evaluate.

Definition at line 517 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_section_type_set()

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.

Parameters
[in]requestThe current request.
[in]type_dato use. Usually attr_auth_type.
[in]enumvEnumeration value of the specified type_da.

Definition at line 427 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_sibling_section_find()

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
  }
* 
Parameters
[out]outwhere 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]moduleCONF_SECTION.
[in]nameof the polymorphic sub-section.
Returns
  • 0 on success with referenced section.
  • 1 on success with local section.
  • -1 on failure.

Definition at line 168 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_static_by_name()

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.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_submodule_parse()

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.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_virtual_by_name()

CONF_SECTION * module_rlm_virtual_by_name ( char const *  asked_name)

Definition at line 810 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_rlm_virtual_name_cmp()

static int8_t module_rlm_virtual_name_cmp ( void const *  one,
void const *  two 
)
static

Compare virtual modules by name.

Definition at line 73 of file module_rlm.c.

+ Here is the caller graph for this function:

◆ module_rlm_xlat_register()

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.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modules_rlm_bootstrap()

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.

Parameters
[in]rootof the server configuration.
Returns
  • 0 if all modules were bootstrapped successfully.
  • -1 if a module/virtual module failed to bootstrap.

Definition at line 1214 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modules_rlm_free()

int modules_rlm_free ( void  )

Cleanup all global structures.

Automatically called on exit.

Definition at line 1357 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modules_rlm_init()

int modules_rlm_init ( void  )

Initialise the module list structure.

Definition at line 1375 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modules_rlm_instantiate()

int modules_rlm_instantiate ( void  )

Performs the instantiation phase for all backend modules.

Returns
  • 0 if all modules were instantiated successfully.
  • -1 if a module failed instantiation.

Definition at line 987 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modules_rlm_thread_detach()

void modules_rlm_thread_detach ( void  )

Frees thread-specific data for all registered backend modules.

Definition at line 963 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modules_rlm_thread_instantiate()

int modules_rlm_thread_instantiate ( TALLOC_CTX *  ctx,
fr_event_list_t el 
)

Allocates thread-specific data for all registered backend modules.

Parameters
[in]ctxTo allocate any thread-specific data in.
[in]elto register events.
Returns
  • 0 if all modules were instantiated successfully.
  • -1 if a module failed instantiation.

Definition at line 976 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ module_rlm_virtual_name_tree

fr_rb_tree_t* module_rlm_virtual_name_tree
static

Lookup virtual module by name.

Definition at line 62 of file module_rlm.c.

◆ rlm_modules_dynamic

module_list_t* rlm_modules_dynamic
static

Runtime instantiated list.

Definition at line 91 of file module_rlm.c.

◆ rlm_modules_static

module_list_t* rlm_modules_static
static

Global module list for all backend modules.

Definition at line 86 of file module_rlm.c.