The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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/global_lib.h>
#include <freeradius-devel/server/modpriv.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/pair.h>
#include <freeradius-devel/server/virtual_servers.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/unlang/xlat_redundant.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 int module_rlm_bootstrap_virtual (CONF_SECTION *cs)
 Create a virtual module. More...
 
module_instance_tmodule_rlm_by_name (module_instance_t const *parent, char const *asked_name)
 
module_instance_tmodule_rlm_by_name_and_method (module_method_t *method, call_env_method_t const **method_env, char const **name1, char const **name2, char const *name)
 Find an existing module instance and verify it implements the specified method. More...
 
CONF_SECTIONmodule_rlm_by_name_virtual (char const *asked_name)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
char const * module_rlm_state_method_to_str (module_state_func_table_t const *table, module_method_t method, char const *def)
 
module_method_t module_rlm_state_str_to_method (module_state_func_table_t const *table, char const *name, module_method_t def)
 
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. More...
 
module_thread_instance_tmodule_rlm_thread_by_data (void const *data)
 
static int8_t module_rlm_virtual_name_cmp (void const *one, void const *two)
 Compare virtual modules by name. More...
 
int modules_rlm_bootstrap (CONF_SECTION *root)
 Bootstrap modules and virtual modules. More...
 
int modules_rlm_free (void)
 Cleanup all global structures. More...
 
int modules_rlm_init (void)
 Initialise the module list structure. More...
 
int modules_rlm_instantiate (void)
 Performs the instantiation phase for all backend modules. More...
 
void modules_rlm_thread_detach (void)
 Frees thread-specific data for all registered backend modules. More...
 
int modules_rlm_thread_instantiate (TALLOC_CTX *ctx, fr_event_list_t *el)
 Allocates thread-specific data for all registered backend modules. More...
 

Variables

static fr_rb_tree_tmodule_rlm_virtual_name_tree
 Lookup virtual module by name. More...
 
static module_list_trlm_modules
 Global module list for all backend modules. More...
 
char const * section_type_value [MOD_COUNT]
 

Detailed Description

Defines functions for rlm module (re-)initialisation.

Id
b0c063daa35a667673df5961e8d6842829f999d2

Definition in file module_rlm.c.


Data Structure Documentation

◆ module_rlm_virtual_t

struct module_rlm_virtual_t

Definition at line 45 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 1148 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 797 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()

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

Definition at line 785 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()

module_instance_t* module_rlm_by_name_and_method ( module_method_t method,
call_env_method_t const **  method_env,
char const **  name1,
char const **  name2,
char const *  name 
)

Find an existing module instance and verify it implements the specified method.

Extracts the method from the module name where the format is

<module>.<method> 

and ensures the module implements the specified method.

Parameters
[out]methodthe method function we will call
[out]method_envthe module_call_env to evaluate when compiling the method.
[out]name1name1 of the method being called
[out]name2name2 of the method being called
[in]nameThe name of the module we're attempting to find, possibly concatenated with the method
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 433 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_virtual()

CONF_SECTION* module_rlm_by_name_virtual ( char const *  asked_name)

Definition at line 767 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 248 of file module_rlm.c.

+ Here is the call graph for this function:
+ Here is the caller 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 92 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 397 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 144 of file module_rlm.c.

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

◆ module_rlm_state_method_to_str()

char const* module_rlm_state_method_to_str ( module_state_func_table_t const *  table,
module_method_t  method,
char const *  def 
)

Definition at line 381 of file module_rlm.c.

◆ module_rlm_state_str_to_method()

module_method_t module_rlm_state_str_to_method ( module_state_func_table_t const *  table,
char const *  name,
module_method_t  def 
)

Definition at line 364 of file module_rlm.c.

+ Here is the call 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 913 of file module_rlm.c.

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

◆ module_rlm_thread_by_data()

module_thread_instance_t* module_rlm_thread_by_data ( void const *  data)

Definition at line 780 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 54 of file module_rlm.c.

+ 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 964 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 1138 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 1156 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 950 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 926 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 939 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 43 of file module_rlm.c.

◆ rlm_modules

module_list_t* rlm_modules
static

Global module list for all backend modules.

Definition at line 75 of file module_rlm.c.

◆ section_type_value

char const* section_type_value[MOD_COUNT]
Initial value:
= {
"authenticate",
"authorize",
"preacct",
"accounting",
"post-auth"
}

Definition at line 64 of file module_rlm.c.