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, call_env_ctx_t const *cec, 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_attr_t const *key_enum, 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
f8e96ec7f41a8c40c96119b5d61e6b1c9a7f186d

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.
tmpl_t * match_attr Attribute to populate with matched key value.
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,
call_env_ctx_t const *  cec,
UNUSED call_env_parser_t const *  rule 
)
static

Custom call_env parser for loading files data.

Definition at line 652 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_attr_t const *  key_enum,
fr_dict_t const *  dict 
)
static

Definition at line 103 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 630 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 399 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 90 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 85 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 98 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 68 of file rlm_files.c.

◆ attr_next_shortest_prefix

fr_dict_attr_t const* attr_next_shortest_prefix
static

Definition at line 69 of file rlm_files.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 60 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:231
#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:235
@ CALL_ENV_FLAG_ATTRIBUTE
Tmpl must contain an attribute reference.
Definition: call_env.h:86
@ CALL_ENV_FLAG_PARSE_ONLY
The result of parsing will not be evaluated at runtime.
Definition: call_env.h:85
#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:384
Per method call config.
Definition: call_env.h:175
@ 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, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
Custom call_env parser for loading files data.
Definition: rlm_files.c:652
Call_env structure.
Definition: rlm_files.c:53
@ T_DOUBLE_QUOTED_STRING
Definition: token.h:121
static fr_slen_t data
Definition: value.h:1265

Definition at line 687 of file rlm_files.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#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:405
@ CONF_FLAG_FILE_INPUT
File matching value must exist, and must be readable.
Definition: cf_parse.h:411

Definition at line 79 of file rlm_files.c.

◆ rlm_files

module_rlm_t rlm_files
Initial value:
= {
.common = {
.name = "files",
.inst_size = sizeof(rlm_files_t),
},
.method_group = {
.bindings = (module_method_binding_t[]){
{ .section = SECTION_NAME(CF_IDENT_ANY, CF_IDENT_ANY), .method = mod_files, .method_env = &method_env },
}
}
}
#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:63
static const conf_parser_t config[]
Definition: base.c:183
static const call_env_method_t method_env
Definition: rlm_files.c:687
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:630
static const conf_parser_t module_config[]
Definition: rlm_files.c:79
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition: section.h:40
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Definition: module.h:151
Named methods exported by a module.
Definition: module.h:173

Definition at line 700 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:60

Definition at line 63 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:68
static fr_dict_attr_t const * attr_next_shortest_prefix
Definition: rlm_files.c:69

Definition at line 72 of file rlm_files.c.