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

Write plaintext versions of packets to flatfiles. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/exfile.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/perm.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
+ Include dependency graph for rlm_detail.c:

Go to the source code of this file.

Data Structures

struct  rlm_detail_env_t
 
struct  rlm_detail_t
 Instance configuration for rlm_detail. More...
 

Macros

#define WRITE(fmt, ...)
 

Functions

static int call_env_filename_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 int call_env_suppress_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
 
static int8_t detail_cmp (void const *a, void const *b)
 
static unlang_action_t detail_do (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool compat)
 
static void detail_fr_pair_fprint (TALLOC_CTX *ctx, FILE *out, fr_pair_t const *stacked)
 
int detail_group_parse (UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
int detail_group_parse (UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 Generic function for parsing conf pair values as int. More...
 
static uint32_t detail_hash (void const *data)
 
static int detail_write (FILE *out, rlm_detail_t const *inst, request_t *request, fr_value_box_t *header, fr_packet_t *packet, fr_pair_list_t *list, bool compat, fr_hash_table_t *ht)
 Write a single detail entry to file pointer. More...
 
static void fr_pair_fprint (FILE *fp, fr_pair_t const *vp)
 Print one attribute and value to FP. More...
 
static unlang_action_t mod_accounting (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_authorize (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 
static unlang_action_t mod_post_auth (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 

Variables

static fr_dict_attr_t const * attr_net
 
static fr_dict_attr_t const * attr_net_dst_address
 
static fr_dict_attr_t const * attr_net_dst_port
 
static fr_dict_attr_t const * attr_net_src_address
 
static fr_dict_attr_t const * attr_net_src_port
 
static fr_dict_attr_t const * attr_protocol
 
static fr_dict_attr_t const * attr_user_password
 
static fr_dict_t const * dict_freeradius
 
static fr_dict_t const * dict_radius
 
static const call_env_method_t method_env
 
static const conf_parser_t module_config []
 
module_rlm_t rlm_detail
 
fr_dict_autoload_t rlm_detail_dict []
 
fr_dict_attr_autoload_t rlm_detail_dict_attr []
 

Detailed Description

Write plaintext versions of packets to flatfiles.

Id
2acf642fcd61161be0c9b442fab28f12c0e5dafb

Definition in file rlm_detail.c.


Data Structure Documentation

◆ rlm_detail_env_t

struct rlm_detail_env_t

Definition at line 63 of file rlm_detail.c.

+ Collaboration diagram for rlm_detail_env_t:
Data Fields
fr_value_box_t filename File / path to write to.
tmpl_t * filename_tmpl tmpl used to expand filename (for debug output)
fr_value_box_t header Header format.
fr_hash_table_t * ht Holds suppressed attributes.

◆ rlm_detail_t

struct rlm_detail_t

Instance configuration for rlm_detail.

Holds the configuration and preparsed data for a instance of rlm_detail.

Definition at line 49 of file rlm_detail.c.

+ Collaboration diagram for rlm_detail_t:
Data Fields
exfile_t * ef Log file handler.
bool escape do filename escaping, yes / no
gid_t group Resolved group.
bool group_is_set Whether group was set.
bool locking Whether the file should be locked.
bool log_srcdst Add IP src/dst attributes to entries.
uint32_t perm Permissions to use for new files.

Macro Definition Documentation

◆ WRITE

#define WRITE (   fmt,
  ... 
)
Value:
do {\
if (fprintf(out, fmt, ## __VA_ARGS__) < 0) {\
RERROR("Failed writing to detail file: %s", fr_syserror(errno));\
return -1;\
}\
} while(0)
static int const char * fmt
Definition: acutest.h:573
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
Definition: syserror.c:243
static size_t char ** out
Definition: value.h:997

Function Documentation

◆ call_env_filename_parse()

static int call_env_filename_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

Definition at line 405 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ call_env_suppress_parse()

static int call_env_suppress_parse ( TALLOC_CTX *  ctx,
call_env_parsed_head_t *  out,
tmpl_rules_t const *  t_rules,
CONF_ITEM ci,
UNUSED call_env_ctx_t const *  cec,
UNUSED call_env_parser_t const *  rule 
)
static

Definition at line 430 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ detail_cmp()

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

Definition at line 173 of file rlm_detail.c.

+ Here is the caller graph for this function:

◆ detail_do()

static unlang_action_t detail_do ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request,
fr_packet_t packet,
fr_pair_list_t list,
bool  compat 
)
static

Definition at line 323 of file rlm_detail.c.

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

◆ detail_fr_pair_fprint()

static void detail_fr_pair_fprint ( TALLOC_CTX *  ctx,
FILE *  out,
fr_pair_t const *  stacked 
)
static

Definition at line 198 of file rlm_detail.c.

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

◆ detail_group_parse() [1/2]

int detail_group_parse ( UNUSED TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)

◆ detail_group_parse() [2/2]

int detail_group_parse ( UNUSED TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
UNUSED conf_parser_t const *  rule 
)

Generic function for parsing conf pair values as int.

Note
This should be used for enum types as c99 6.4.4.3 states that the enumeration constants are of type int.

Definition at line 147 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ detail_hash()

static uint32_t detail_hash ( void const *  data)
static

Definition at line 167 of file rlm_detail.c.

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

◆ detail_write()

static int detail_write ( FILE *  out,
rlm_detail_t const *  inst,
request_t request,
fr_value_box_t header,
fr_packet_t packet,
fr_pair_list_t list,
bool  compat,
fr_hash_table_t ht 
)
static

Write a single detail entry to file pointer.

Parameters
[in]outWhere to write entry.
[in]instInstance of rlm_detail.
[in]requestThe current request.
[in]headerTo print above packet
[in]packetassociated with the request (request, reply...).
[in]listof pairs to write.
[in]compatWrite out entry in compatibility mode.
[in]htHash table containing attributes to be suppressed in the output.

Definition at line 222 of file rlm_detail.c.

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

◆ fr_pair_fprint()

static void fr_pair_fprint ( FILE *  fp,
fr_pair_t const *  vp 
)
static

Print one attribute and value to FP.

Complete string with '\t' and '\n' is written to buffer before printing to avoid issues when running with multiple threads.

Todo:
  • This function should print flattened lists.
Parameters
fpto output to.
vpto print.

Definition at line 125 of file rlm_detail.c.

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

◆ mod_accounting()

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

Definition at line 384 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ mod_authorize()

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

Definition at line 392 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Definition at line 181 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ mod_post_auth()

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

Definition at line 400 of file rlm_detail.c.

+ Here is the call graph for this function:

Variable Documentation

◆ attr_net

fr_dict_attr_t const* attr_net
static

Definition at line 92 of file rlm_detail.c.

◆ attr_net_dst_address

fr_dict_attr_t const* attr_net_dst_address
static

Definition at line 94 of file rlm_detail.c.

◆ attr_net_dst_port

fr_dict_attr_t const* attr_net_dst_port
static

Definition at line 96 of file rlm_detail.c.

◆ attr_net_src_address

fr_dict_attr_t const* attr_net_src_address
static

Definition at line 93 of file rlm_detail.c.

◆ attr_net_src_port

fr_dict_attr_t const* attr_net_src_port
static

Definition at line 95 of file rlm_detail.c.

◆ attr_protocol

fr_dict_attr_t const* attr_protocol
static

Definition at line 97 of file rlm_detail.c.

◆ attr_user_password

fr_dict_attr_t const* attr_user_password
static

Definition at line 99 of file rlm_detail.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 82 of file rlm_detail.c.

◆ dict_radius

fr_dict_t const* dict_radius
static

Definition at line 83 of file rlm_detail.c.

◆ method_env

const call_env_method_t method_env
static
Initial value:
= {
.env = (call_env_parser_t[]){
.pair.func = call_env_filename_parse },
.pair.dflt = "%t", .pair.dflt_quote = T_DOUBLE_QUOTED_STRING },
}
}
#define CALL_ENV_TERMINATOR
Definition: call_env.h:231
#define FR_CALL_ENV_PARSE_OFFSET(_name, _cast_type, _flags, _struct, _field, _parse_field)
Specify a call_env_parser_t which writes out runtime results and the result of the parsing phase to t...
Definition: call_env.h:360
#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_CONCAT
If the tmpl produced multiple boxes they should be concatenated.
Definition: call_env.h:76
@ CALL_ENV_FLAG_NONE
Definition: call_env.h:74
@ CALL_ENV_FLAG_REQUIRED
Associated conf pair or section is required.
Definition: call_env.h:75
#define FR_CALL_ENV_SUBSECTION_FUNC(_name, _name2, _flags, _func)
Specify a call_env_parser_t which parses a subsection using a callback function.
Definition: call_env.h:407
#define FR_CALL_ENV_OFFSET(_name, _cast_type, _flags, _struct, _field)
Specify a call_env_parser_t which writes out runtime results to the specified field.
Definition: call_env.h:335
Per method call config.
Definition: call_env.h:175
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
static int call_env_filename_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)
Definition: rlm_detail.c:405
static int call_env_suppress_parse(TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
Definition: rlm_detail.c:430
@ T_DOUBLE_QUOTED_STRING
Definition: token.h:121

Definition at line 490 of file rlm_detail.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("permissions", rlm_detail_t, perm), .dflt = "0600" },
{ FR_CONF_OFFSET("locking", rlm_detail_t, locking), .dflt = "no" },
{ FR_CONF_OFFSET("escape_filenames", rlm_detail_t, escape), .dflt = "no" },
{ FR_CONF_OFFSET("log_packet_header", rlm_detail_t, log_srcdst), .dflt = "no" },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:268
#define FR_CONF_OFFSET_IS_SET(_name, _type, _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:282
@ FR_TYPE_VOID
User data.
Definition: merged_model.c:127
int detail_group_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Instance configuration for rlm_detail.
Definition: rlm_detail.c:49

Definition at line 73 of file rlm_detail.c.

◆ rlm_detail

module_rlm_t rlm_detail
Initial value:
= {
.common = {
.name = "detail",
.inst_size = sizeof(rlm_detail_t),
},
.method_group = {
.bindings = (module_method_binding_t[]){
{ .section = SECTION_NAME("accounting", CF_IDENT_ANY), .method = mod_accounting, .method_env = &method_env },
{ .section = SECTION_NAME("recv", "accounting-request"), .method = mod_accounting, .method_env = &method_env },
{ .section = SECTION_NAME("send", "accounting-response"), .method = mod_accounting, .method_env = &method_env },
{ .section = SECTION_NAME("recv", CF_IDENT_ANY), .method = mod_authorize, .method_env = &method_env },
{ .section = SECTION_NAME("send", CF_IDENT_ANY), .method = mod_post_auth, .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_detail.c:490
static unlang_action_t mod_accounting(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_detail.c:384
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_detail.c:392
static const conf_parser_t module_config[]
Definition: rlm_detail.c:73
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_detail.c:181
static unlang_action_t mod_post_auth(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_detail.c:400
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1302
#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 504 of file rlm_detail.c.

◆ rlm_detail_dict

fr_dict_autoload_t rlm_detail_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ .out = &dict_radius, .proto = "radius" },
{ NULL }
}
static fr_dict_t const * dict_freeradius
Definition: rlm_detail.c:82
static fr_dict_t const * dict_radius
Definition: rlm_detail.c:83

Definition at line 86 of file rlm_detail.c.

◆ rlm_detail_dict_attr

fr_dict_attr_autoload_t rlm_detail_dict_attr
Initial value:
= {
{ .out = &attr_net, .name = "Net", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
{ .out = &attr_net_dst_address, .name = "Net.Dst.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius },
{ .out = &attr_net_dst_port, .name = "Net.Dst.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
{ .out = &attr_net_src_address, .name = "Net.Src.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius },
{ .out = &attr_net_src_port, .name = "Net.Src.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
{ .out = &attr_protocol, .name = "Protocol", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
{ .out = &attr_user_password, .name = "User-Password", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ NULL }
}
@ FR_TYPE_TLV
Contains nested attributes.
Definition: merged_model.c:118
@ FR_TYPE_UINT16
16 Bit unsigned integer.
Definition: merged_model.c:98
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
Definition: merged_model.c:91
static fr_dict_attr_t const * attr_user_password
Definition: rlm_detail.c:99
static fr_dict_attr_t const * attr_protocol
Definition: rlm_detail.c:97
static fr_dict_attr_t const * attr_net_dst_port
Definition: rlm_detail.c:96
static fr_dict_attr_t const * attr_net
Definition: rlm_detail.c:92
static fr_dict_attr_t const * attr_net_src_address
Definition: rlm_detail.c:93
static fr_dict_attr_t const * attr_net_dst_address
Definition: rlm_detail.c:94
static fr_dict_attr_t const * attr_net_src_port
Definition: rlm_detail.c:95

Definition at line 102 of file rlm_detail.c.