The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
trigger.c File Reference
#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/unlang/function.h>
#include <freeradius-devel/unlang/interpret.h>
#include <freeradius-devel/util/debug.h>
#include <sys/wait.h>
+ Include dependency graph for trigger.c:

Go to the source code of this file.

Data Structures

struct  fr_trigger_t
 
struct  trigger_last_fired_t
 Describes a rate limiting entry for a trigger. More...
 

Macros

#define REQUEST_INDEX_TRIGGER_ARGS   2
 
#define REQUEST_INDEX_TRIGGER_NAME   1
 

Functions

static int _mutex_free (pthread_mutex_t *mutex)
 
static int8_t _trigger_last_fired_cmp (void const *one, void const *two)
 Compares two last fired structures. More...
 
static void _trigger_last_fired_free (void *data)
 
void trigger_args_afrom_server (TALLOC_CTX *ctx, fr_pair_list_t *list, char const *server, uint16_t port)
 Create trigger arguments to describe the server the pool connects to. More...
 
static unlang_action_t trigger_done (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *rctx)
 
bool trigger_enabled (void)
 Return whether triggers are enabled. More...
 
int trigger_exec (unlang_interpret_t *intp, CONF_SECTION const *cs, char const *name, bool rate_limit, fr_pair_list_t *args)
 Execute a trigger - call an executable to process an event. More...
 
void trigger_exec_free (void)
 Free trigger resources. More...
 
int trigger_exec_init (CONF_SECTION const *cs)
 Set the global trigger section trigger_exec will search in, and register xlats. More...
 
static unlang_action_t trigger_resume (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *rctx)
 
static unlang_action_t trigger_run (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
 
xlat_action_t trigger_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
 Retrieve attributes from a special trigger list. More...
 

Variables

static CONF_SECTION const * trigger_exec_main
 
static CONF_SECTION const * trigger_exec_subcs
 
static fr_rb_tree_ttrigger_last_fired_tree
 
static pthread_mutex_ttrigger_mutex
 
xlat_arg_parser_t const trigger_xlat_args []
 
static bool triggers_init
 Whether triggers are enabled globally. More...
 

Data Structure Documentation

◆ fr_trigger_t

struct fr_trigger_t

Definition at line 187 of file trigger.c.

+ Collaboration diagram for fr_trigger_t:
Data Fields
fr_value_box_list_t args Arguments to pass to the trigger exec.
char * command Name of the trigger.
fr_exec_state_t exec Used for asynchronous execution.
fr_time_delta_t timeout How long the trigger has to run.
xlat_exp_head_t * xlat xlat representation of the trigger args.

◆ trigger_last_fired_t

struct trigger_last_fired_t

Describes a rate limiting entry for a trigger.

Definition at line 50 of file trigger.c.

+ Collaboration diagram for trigger_last_fired_t:
Data Fields
CONF_ITEM * ci Config item this rate limit counter is associated with.
fr_time_t last_fired When this trigger last fired.
fr_rb_node_t node Entry in the trigger last fired tree.

Macro Definition Documentation

◆ REQUEST_INDEX_TRIGGER_ARGS

#define REQUEST_INDEX_TRIGGER_ARGS   2

Definition at line 45 of file trigger.c.

◆ REQUEST_INDEX_TRIGGER_NAME

#define REQUEST_INDEX_TRIGGER_NAME   1

Definition at line 44 of file trigger.c.

Function Documentation

◆ _mutex_free()

static int _mutex_free ( pthread_mutex_t mutex)
static

Definition at line 105 of file trigger.c.

+ Here is the caller graph for this function:

◆ _trigger_last_fired_cmp()

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

Compares two last fired structures.

Parameters
onefirst pointer to compare.
twosecond pointer to compare.
Returns
CMP(one, two)

Definition at line 122 of file trigger.c.

+ Here is the caller graph for this function:

◆ _trigger_last_fired_free()

static void _trigger_last_fired_free ( void *  data)
static

Definition at line 111 of file trigger.c.

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

◆ trigger_args_afrom_server()

void trigger_args_afrom_server ( TALLOC_CTX *  ctx,
fr_pair_list_t list,
char const *  server,
uint16_t  port 
)

Create trigger arguments to describe the server the pool connects to.

Note
trigger_exec_init must be called before calling this function, else it will return NULL.
Parameters
[in]ctxto allocate fr_pair_t s in.
[out]listto append Pool-Server and Pool-Port pairs to
[in]serverwe're connecting to.
[in]porton that server.

Definition at line 501 of file trigger.c.

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

◆ trigger_done()

static unlang_action_t trigger_done ( rlm_rcode_t p_result,
UNUSED int *  priority,
request_t request,
void *  rctx 
)
static

Definition at line 196 of file trigger.c.

+ Here is the caller graph for this function:

◆ trigger_enabled()

bool trigger_enabled ( void  )

Return whether triggers are enabled.

Definition at line 182 of file trigger.c.

+ Here is the caller graph for this function:

◆ trigger_exec()

int trigger_exec ( unlang_interpret_t intp,
CONF_SECTION const *  cs,
char const *  name,
bool  rate_limit,
fr_pair_list_t args 
)

Execute a trigger - call an executable to process an event.

Note
Calls to this function will be ignored if trigger_exec_init has not been called.
Parameters
[in]intpInterpreter to run the trigger with. If this is NULL the trigger will be executed synchronously.
[in]csto search for triggers in. If cs is not NULL, the portion after the last '.' in name is used for the trigger. If cs is NULL, the entire name is used to find the trigger in the global trigger section.
[in]namethe path relative to the global trigger section ending in the trigger name e.g. module.ldap.pool.start.
[in]rate_limitwhether to rate limit triggers.
[in]argsto make available via the
%trigger(<arg>) 
xlat.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 280 of file trigger.c.

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

◆ trigger_exec_free()

void trigger_exec_free ( void  )

Free trigger resources.

Definition at line 173 of file trigger.c.

+ Here is the caller graph for this function:

◆ trigger_exec_init()

int trigger_exec_init ( CONF_SECTION const *  cs)

Set the global trigger section trigger_exec will search in, and register xlats.

This function exists because triggers are used by the connection pool, which is used in the server library which may not have the mainconfig available. Additionally, utilities may want to set their own root config sections.

We don't register the trigger xlat here, as we may inadvertently initialise the xlat code, which is annoying when this is called from a utility.

Parameters
[in]csto use as global trigger section.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 143 of file trigger.c.

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

◆ trigger_resume()

static unlang_action_t trigger_resume ( rlm_rcode_t p_result,
UNUSED int *  priority,
request_t request,
void *  rctx 
)
static

Definition at line 211 of file trigger.c.

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

◆ trigger_run()

static unlang_action_t trigger_run ( rlm_rcode_t p_result,
UNUSED int *  priority,
request_t request,
void *  uctx 
)
static

Definition at line 249 of file trigger.c.

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

◆ trigger_xlat()

xlat_action_t trigger_xlat ( TALLOC_CTX *  ctx,
fr_dcursor_t out,
UNUSED xlat_ctx_t const *  xctx,
request_t request,
fr_value_box_list_t *  in 
)

Retrieve attributes from a special trigger list.

Definition at line 64 of file trigger.c.

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

Variable Documentation

◆ trigger_exec_main

CONF_SECTION const* trigger_exec_main
static

Definition at line 40 of file trigger.c.

◆ trigger_exec_subcs

CONF_SECTION const * trigger_exec_subcs
static

Definition at line 40 of file trigger.c.

◆ trigger_last_fired_tree

fr_rb_tree_t* trigger_last_fired_tree
static

Definition at line 41 of file trigger.c.

◆ trigger_mutex

pthread_mutex_t* trigger_mutex
static

Definition at line 42 of file trigger.c.

◆ trigger_xlat_args

xlat_arg_parser_t const trigger_xlat_args[]
Initial value:
= {
{ .required = true, .single = true, .type = FR_TYPE_STRING },
}
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
#define XLAT_ARG_PARSER_TERMINATOR
Definition: xlat.h:166

Definition at line 56 of file trigger.c.

◆ triggers_init

bool triggers_init
static

Whether triggers are enabled globally.

Definition at line 39 of file trigger.c.