The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Functions | Variables
rlm_files.c File Reference

Process simple 'users' policy files. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/pairmove.h>
#include <freeradius-devel/server/users_file.h>
#include <freeradius-devel/util/htrie.h>
#include <freeradius-devel/unlang/call_env.h>
#include <freeradius-devel/unlang/function.h>
#include <freeradius-devel/unlang/transaction.h>
#include <ctype.h>
#include <fcntl.h>
+ Include dependency graph for rlm_files.c:

Go to the source code of this file.

Data Structures

struct  rlm_files_data_t
 Structure produced by custom call_env parser. More...
 
struct  rlm_files_env_t
 Call_env structure. More...
 
struct  rlm_files_t
 

Functions

static int call_env_parse (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED char const *section_name1, UNUSED char const *section_name2, void const *data, UNUSED call_env_parser_t const *rule)
 Custom call_env parser for loading files data. More...
 
static int getrecv_filename (TALLOC_CTX *ctx, char const *filename, fr_htrie_t **ptree, PAIR_LIST_LIST **pdefault, fr_type_t data_type, fr_dict_t const *dict)
 
static unlang_action_t mod_files (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 Initiate a files data lookup. More...
 
static unlang_action_t mod_files_resume (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
 Lookup the expanded key value in files data. More...
 
static int8_t pairlist_cmp (void const *a, void const *b)
 
static uint32_t pairlist_hash (void const *a)
 
static int pairlist_to_key (uint8_t **out, size_t *outlen, void const *a)
 

Variables

static fr_dict_attr_t const * attr_fall_through
 
static fr_dict_attr_t const * attr_next_shortest_prefix
 
static fr_dict_t const * dict_freeradius
 
static const call_env_method_t method_env
 
static const conf_parser_t module_config []
 
module_rlm_t rlm_files
 
fr_dict_autoload_t rlm_files_dict []
 
fr_dict_attr_autoload_t rlm_files_dict_attr []
 

Detailed Description

Process simple 'users' policy files.

Id
a22000bc83fcdf197d33c276820a210f2574ea7e

Definition in file rlm_files.c.


Data Structure Documentation

◆ rlm_files_data_t

struct rlm_files_data_t

Structure produced by custom call_env parser.

Definition at line 45 of file rlm_files.c.

+ Collaboration diagram for rlm_files_data_t:
Data Fields
PAIR_LIST_LIST * def parsed files DEFAULT data.
fr_htrie_t * htrie parsed files "user" data.
tmpl_t * key_tmpl tmpl used to evaluate lookup key.

◆ rlm_files_env_t

struct rlm_files_env_t

Call_env structure.

Definition at line 53 of file rlm_files.c.

+ Collaboration diagram for rlm_files_env_t:
Data Fields
rlm_files_data_t * data Data from parsed call_env.
char const * name Name of module instance - for debug output.
fr_value_box_list_t values Where the expanded tmpl value will be written.

◆ rlm_files_t

struct rlm_files_t

Definition at line 39 of file rlm_files.c.

Data Fields
char const * filename

Function Documentation

◆ call_env_parse()

static int call_env_parse ( TALLOC_CTX *  ctx,
void *  out,
tmpl_rules_t const *  t_rules,
CONF_ITEM ci,
UNUSED char const *  section_name1,
UNUSED char const *  section_name2,
void const *  data,
UNUSED call_env_parser_t const *  rule 
)
static

Custom call_env parser for loading files data.

Definition at line 629 of file rlm_files.c.

+ Here is the call graph for this function:

◆ getrecv_filename()

static int getrecv_filename ( TALLOC_CTX *  ctx,
char const *  filename,
fr_htrie_t **  ptree,
PAIR_LIST_LIST **  pdefault,
fr_type_t  data_type,
fr_dict_t const *  dict 
)
static

Definition at line 102 of file rlm_files.c.

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

◆ mod_files()

static unlang_action_t mod_files ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Initiate a files data lookup.

The results of call_env parsing are a structure containing the tmpl_t representing the key and the parsed files data, meaning tmpl expansion does not happen by default. First we push the tmpl onto the stack for evaluation, then the lookup is done in mod_files_resume.

Definition at line 607 of file rlm_files.c.

+ Here is the call graph for this function:

◆ mod_files_resume()

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

Lookup the expanded key value in files data.

Definition at line 398 of file rlm_files.c.

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

◆ pairlist_cmp()

static int8_t pairlist_cmp ( void const *  a,
void const *  b 
)
static

Definition at line 89 of file rlm_files.c.

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

◆ pairlist_hash()

static uint32_t pairlist_hash ( void const *  a)
static

Definition at line 84 of file rlm_files.c.

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

◆ pairlist_to_key()

static int pairlist_to_key ( uint8_t **  out,
size_t outlen,
void const *  a 
)
static

Definition at line 97 of file rlm_files.c.

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

Variable Documentation

◆ attr_fall_through

fr_dict_attr_t const* attr_fall_through
static

Definition at line 67 of file rlm_files.c.

◆ attr_next_shortest_prefix

fr_dict_attr_t const* attr_next_shortest_prefix
static

Definition at line 68 of file rlm_files.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 59 of file rlm_files.c.

◆ method_env

const call_env_method_t method_env
static
Initial value:
= {
.env = (call_env_parser_t[]){
.pair.dflt = "%{%{Stripped-User-Name} || %{User-Name}}", .pair.dflt_quote = T_DOUBLE_QUOTED_STRING,
.pair.func = call_env_parse },
},
}
#define CALL_ENV_TERMINATOR
Definition: call_env.h:212
#define FR_CALL_ENV_METHOD_OUT(_inst)
Helper macro for populating the size/type fields of a call_env_method_t from the output structure typ...
Definition: call_env.h:216
@ CALL_ENV_FLAG_PARSE_ONLY
The result of parsing will not be evaluated at runtime.
Definition: call_env.h:83
#define FR_CALL_ENV_PARSE_ONLY_OFFSET(_name, _cast_type, _flags, _struct, _parse_field)
Specify a call_env_parser_t which writes out the result of the parsing phase to the field specified.
Definition: call_env.h:365
Per method call config.
Definition: call_env.h:171
@ FR_TYPE_VOID
User data.
Definition: merged_model.c:127
static int call_env_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED char const *section_name1, UNUSED char const *section_name2, void const *data, UNUSED call_env_parser_t const *rule)
Custom call_env parser for loading files data.
Definition: rlm_files.c:629
Call_env structure.
Definition: rlm_files.c:53
@ T_DOUBLE_QUOTED_STRING
Definition: token.h:121
static fr_slen_t data
Definition: value.h:1259

Definition at line 659 of file rlm_files.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:256
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition: cf_parse.h:406
@ CONF_FLAG_FILE_INPUT
File matching value must exist, and must be readable.
Definition: cf_parse.h:412

Definition at line 78 of file rlm_files.c.

◆ rlm_files

module_rlm_t rlm_files
Initial value:
= {
.common = {
.name = "files",
.inst_size = sizeof(rlm_files_t),
},
.method_names = (module_method_name_t[]){
{ .name1 = CF_IDENT_ANY, .name2 = CF_IDENT_ANY, .method = mod_files,
.method_env = &method_env },
}
}
char const * name1
Name of the CONF_ITEM to parse.
Definition: cf_parse.h:564
#define CF_IDENT_ANY
Definition: cf_util.h:78
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:65
Specifies a module method identifier.
Definition: module_method.c:36
static const conf_parser_t config[]
Definition: base.c:188
static const call_env_method_t method_env
Definition: rlm_files.c:659
static unlang_action_t mod_files(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Initiate a files data lookup.
Definition: rlm_files.c:607
static const conf_parser_t module_config[]
Definition: rlm_files.c:78
#define MODULE_NAME_TERMINATOR
Definition: module.h:135

Definition at line 671 of file rlm_files.c.

◆ rlm_files_dict

fr_dict_autoload_t rlm_files_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ NULL }
}
static fr_dict_t const * dict_freeradius
Definition: rlm_files.c:59

Definition at line 62 of file rlm_files.c.

◆ rlm_files_dict_attr

fr_dict_attr_autoload_t rlm_files_dict_attr
Initial value:
= {
{ .out = &attr_fall_through, .name = "Fall-Through", .type = FR_TYPE_BOOL, .dict = &dict_freeradius },
{ .out = &attr_next_shortest_prefix, .name = "Next-Shortest-Prefix", .type = FR_TYPE_BOOL, .dict = &dict_freeradius },
{ NULL }
}
@ FR_TYPE_BOOL
A truth value.
Definition: merged_model.c:95
static fr_dict_attr_t const * attr_fall_through
Definition: rlm_files.c:67
static fr_dict_attr_t const * attr_next_shortest_prefix
Definition: rlm_files.c:68

Definition at line 71 of file rlm_files.c.