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

Implements FreeTDS rlm_sql driver. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/exfile.h>
#include <freeradius-devel/server/map_proc.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/pairmove.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/unlang/function.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <sys/stat.h>
#include "rlm_sql.h"
+ Include dependency graph for rlm_sql.c:

Go to the source code of this file.

Data Structures

struct  rlm_sql_grouplist_s
 
struct  sql_autz_call_env_t
 
struct  sql_autz_ctx_t
 Context for SQL authorization. More...
 
struct  sql_group_xlat_call_env_t
 
struct  sql_group_xlat_ctx_t
 
struct  sql_redundant_call_env_t
 
struct  sql_redundant_ctx_t
 Context for tracking redundant SQL query sets. More...
 
struct  sql_xlat_call_env_t
 

Macros

#define LOG_PREFIX   mctx->inst->name
 
#define MAX_SQL_FIELD_INDEX   (64)
 
#define SQL_AUTZ_STAGE_GROUP   0x20
 
#define SQL_AUTZ_STAGE_PROFILE   0x40
 
#define sql_unset_user(_i, _r)   fr_pair_delete_by_da(&_r->request_pairs, _i->sql_user)
 

Typedefs

typedef struct rlm_sql_grouplist_s rlm_sql_grouplist_t
 

Enumerations

enum  sql_autz_status_t {
  SQL_AUTZ_CHECK = 0x11 ,
  SQL_AUTZ_REPLY = 0x12 ,
  SQL_AUTZ_GROUP_MEMB = 0x20 ,
  SQL_AUTZ_GROUP_CHECK = 0x21 ,
  SQL_AUTZ_GROUP_REPLY = 0x22 ,
  SQL_AUTZ_PROFILE_START = 0x40 ,
  SQL_AUTZ_PROFILE_CHECK = 0x41 ,
  SQL_AUTZ_PROFILE_REPLY = 0x42
}
 Status of the authorization process. More...
 

Functions

static int _sql_escape_uxtx_free (void *uctx)
 
static int _sql_map_proc_get_value (TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx)
 Converts a string value into a fr_pair_t. More...
 
static int check_map_process (request_t *request, map_list_t *check_map, map_list_t *reply_map)
 Process a "check" map. More...
 
static sql_fall_through_t fall_through (map_list_t *maps)
 
static int logfile_call_env_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *cc, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)
 
static int logfile_call_env_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, char const *section_name1, char const *section_name2, UNUSED void const *data, UNUSED call_env_parser_t const *rule)
 
static unlang_action_t mod_authorize (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 Start of module authorize method. More...
 
static unlang_action_t mod_authorize_resume (rlm_rcode_t *p_result, int *priority, request_t *request, void *uctx)
 Resume function called after authorization check / reply tmpl expansion. More...
 
static unlang_action_t mod_autz_group_resume (rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx)
 Resume function called after authorization group / profile expansion of check / reply query tmpl. More...
 
static int mod_bootstrap (module_inst_ctx_t const *mctx)
 
static int mod_detach (module_detach_ctx_t const *mctx)
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 
static unlang_action_t mod_map_proc (rlm_rcode_t *p_result, void *mod_inst, UNUSED void *proc_inst, request_t *request, fr_value_box_list_t *query, map_list_t const *maps)
 Executes a SELECT query and maps the result to server attributes. More...
 
static unlang_action_t mod_sql_redundant (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 Generic module call for failing between a bunch of queries. More...
 
static unlang_action_t mod_sql_redundant_resume (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
 Resume function called after expansion of next query in a redundant list of queries. More...
 
static int query_call_env_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *cc, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)
 
static int query_call_env_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED char const *section_name1, char const *section_name2, void const *data, UNUSED call_env_parser_t const *rule)
 
static int sql_autz_ctx_free (sql_autz_ctx_t *to_free)
 
static int sql_box_escape (fr_value_box_t *vb, void *uctx)
 
static bool sql_check_group (rlm_sql_t const *inst, request_t *request, char const *query, char const *name)
 Check if a given group is in the SQL group for this user. More...
 
static size_t sql_escape_func (request_t *, char *out, size_t outlen, char const *in, void *arg)
 
static size_t sql_escape_func (UNUSED request_t *request, char *out, size_t outlen, char const *in, void *arg)
 xlat escape function for drivers which do not provide their own More...
 
static void * sql_escape_uctx_alloc (request_t *request, void const *uctx)
 
static int sql_get_grouplist (rlm_sql_t const *inst, rlm_sql_handle_t **handle, request_t *request, char const *query, rlm_sql_grouplist_t **phead)
 
static xlat_action_t sql_group_xlat (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in)
 Check if the user is a member of a particular group. More...
 
static xlat_action_t sql_group_xlat_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
 
static int sql_map_verify (CONF_SECTION *cs, UNUSED void *mod_inst, UNUSED void *proc_inst, tmpl_t const *src, UNUSED map_list_t const *maps)
 
static int sql_redundant_ctx_free (sql_redundant_ctx_t *to_free)
 Tidy up when freeing an SQL redundant context. More...
 
static void sql_set_user (rlm_sql_t const *inst, request_t *request, fr_value_box_t *user)
 
static xlat_action_t sql_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
 Execute an arbitrary SQL query. More...
 
static int sql_xlat_escape (request_t *request, fr_value_box_t *vb, void *uctx)
 Escape a tainted VB used as an xlat argument. More...
 

Variables

static const call_env_method_t accounting_method_env
 
static fr_dict_attr_t const * attr_expr_bool_enum
 
static fr_dict_attr_t const * attr_fall_through
 
static fr_dict_attr_t const * attr_sql_user_name
 
static fr_dict_attr_t const * attr_user_profile
 
static const call_env_method_t authorize_method_env
 
static fr_dict_t const * dict_freeradius
 
static const call_env_method_t group_xlat_method_env
 
static const conf_parser_t module_config []
 
module_rlm_t rlm_sql
 
fr_dict_autoload_t rlm_sql_dict []
 
fr_dict_attr_autoload_t rlm_sql_dict_attr []
 
static const call_env_method_t send_method_env
 
static const call_env_method_t xlat_method_env
 

Detailed Description

Implements FreeTDS rlm_sql driver.

Implements SQL 'users' file, and SQL accounting.

Id
79bb8e20596127214fdbefce24aed84675523aef
Id
acefc287ac964fcefcd620f508b96fc7ea5a2e4e

Definition in file rlm_sql.c.


Data Structure Documentation

◆ rlm_sql_grouplist_s

struct rlm_sql_grouplist_s

Definition at line 844 of file rlm_sql.c.

+ Collaboration diagram for rlm_sql_grouplist_s:
Data Fields
char * name
rlm_sql_grouplist_t * next

◆ sql_autz_call_env_t

struct sql_autz_call_env_t

Definition at line 94 of file rlm_sql.c.

+ Collaboration diagram for sql_autz_call_env_t:
Data Fields
tmpl_t * check_query Tmpl to expand to form authorize_check_query.
tmpl_t * group_check_query Tmpl to expand to form authorize_group_check_query.
tmpl_t * group_reply_query Tmpl to expand to form authorize_group_reply_query.
tmpl_t * membership_query Tmpl to expand to form group_membership_query.
tmpl_t * reply_query Tmpl to expand to form authorize_reply_query.
fr_value_box_t user Expansion of the sql_user_name.

◆ sql_autz_ctx_t

struct sql_autz_ctx_t

Context for SQL authorization.

Definition at line 161 of file rlm_sql.c.

+ Collaboration diagram for sql_autz_ctx_t:
Data Fields
sql_autz_call_env_t * call_env Call environment data.
map_list_t check_tmp List to store check items before processing.
rlm_sql_grouplist_t * group Current group being processed.
rlm_sql_grouplist_t * groups List of groups returned by the group membership query.
rlm_sql_handle_t * handle Database connection handle in use for current authorization.
rlm_sql_t const * inst Module instance.
fr_pair_t * profile Current profile being processed.
fr_value_box_list_t query Where expanded query tmpls will be written.
rlm_rcode_t rcode Module return code.
map_list_t reply_tmp List to store reply items before processing.
request_t * request Request being processed.
fr_pair_t * sql_group Pair to update with group being processed.
sql_autz_status_t status Current status of the authorization.
bool user_found Has the user been found anywhere?

◆ sql_group_xlat_call_env_t

struct sql_group_xlat_call_env_t

Definition at line 215 of file rlm_sql.c.

+ Collaboration diagram for sql_group_xlat_call_env_t:
Data Fields
tmpl_t * membership_query
fr_value_box_t user

◆ sql_group_xlat_ctx_t

struct sql_group_xlat_ctx_t

Definition at line 934 of file rlm_sql.c.

Data Fields
fr_value_box_list_t query

◆ sql_redundant_call_env_t

struct sql_redundant_call_env_t

Definition at line 178 of file rlm_sql.c.

+ Collaboration diagram for sql_redundant_call_env_t:
Data Fields
fr_value_box_t filename File name to write SQL logs to.
tmpl_t ** query Array of tmpls for list of queries to run.
fr_value_box_t user Expansion of sql_user_name.

◆ sql_redundant_ctx_t

struct sql_redundant_ctx_t

Context for tracking redundant SQL query sets.

Definition at line 206 of file rlm_sql.c.

+ Collaboration diagram for sql_redundant_ctx_t:
Data Fields
sql_redundant_call_env_t * call_env Call environment data.
rlm_sql_handle_t * handle Database connection handle.
rlm_sql_t const * inst Module instance.
fr_value_box_list_t query Where expanded query tmpl will be written.
size_t query_no Current query number.
request_t * request Request being processed.

◆ sql_xlat_call_env_t

struct sql_xlat_call_env_t

Definition at line 122 of file rlm_sql.c.

+ Collaboration diagram for sql_xlat_call_env_t:
Data Fields
fr_value_box_t filename

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   mctx->inst->name

Definition at line 30 of file rlm_sql.c.

◆ MAX_SQL_FIELD_INDEX

#define MAX_SQL_FIELD_INDEX   (64)

◆ SQL_AUTZ_STAGE_GROUP

#define SQL_AUTZ_STAGE_GROUP   0x20

Definition at line 156 of file rlm_sql.c.

◆ SQL_AUTZ_STAGE_PROFILE

#define SQL_AUTZ_STAGE_PROFILE   0x40

Definition at line 157 of file rlm_sql.c.

◆ sql_unset_user

#define sql_unset_user (   _i,
  _r 
)    fr_pair_delete_by_da(&_r->request_pairs, _i->sql_user)

Definition at line 841 of file rlm_sql.c.

Typedef Documentation

◆ rlm_sql_grouplist_t

Definition at line 126 of file rlm_sql.c.

Enumeration Type Documentation

◆ sql_autz_status_t

Status of the authorization process.

Enumerator
SQL_AUTZ_CHECK 

Running user check query.

SQL_AUTZ_REPLY 

Running user reply query.

SQL_AUTZ_GROUP_MEMB 

Running group membership query.

SQL_AUTZ_GROUP_CHECK 

Running group check query.

SQL_AUTZ_GROUP_REPLY 

Running group reply query.

SQL_AUTZ_PROFILE_START 

Starting processing user profiles.

SQL_AUTZ_PROFILE_CHECK 

Running profile check query.

SQL_AUTZ_PROFILE_REPLY 

Running profile reply query.

Definition at line 145 of file rlm_sql.c.

Function Documentation

◆ _sql_escape_uxtx_free()

static int _sql_escape_uxtx_free ( void *  uctx)
static

Definition at line 229 of file rlm_sql.c.

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

◆ _sql_map_proc_get_value()

static int _sql_map_proc_get_value ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
request_t request,
map_t const *  map,
void *  uctx 
)
static

Converts a string value into a fr_pair_t.

Parameters
[in,out]ctxto allocate fr_pair_t (s).
[out]outwhere to write the resulting fr_pair_t.
[in]requestThe current request.
[in]mapto process.
[in]uctxThe value to parse.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 491 of file rlm_sql.c.

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

◆ check_map_process()

static int check_map_process ( request_t request,
map_list_t *  check_map,
map_list_t *  reply_map 
)
static

Process a "check" map.

Any entries using an assignment operator will be moved to the reply map for later merging into the request.

Parameters
requestCurrent request.
check_mapto process.
reply_mapwhere any assignment entries will be moved.
Returns
  • 0 if all the check entries pass.
  • -1 if the checks fail.

Definition at line 1005 of file rlm_sql.c.

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

◆ fall_through()

static sql_fall_through_t fall_through ( map_list_t *  maps)
static

Definition at line 257 of file rlm_sql.c.

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

◆ logfile_call_env_parse() [1/2]

static int logfile_call_env_parse ( TALLOC_CTX *  ctx,
call_env_parsed_head_t *  out,
tmpl_rules_t const *  t_rules,
CONF_ITEM cc,
char const *  section_name1,
char const *  section_name2,
void const *  data,
call_env_parser_t const *  rule 
)
static

◆ logfile_call_env_parse() [2/2]

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

Definition at line 1602 of file rlm_sql.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

Start of module authorize method.

Pushes the tmpl relating to the first required query for evaluation

Definition at line 1385 of file rlm_sql.c.

+ Here is the call graph for this function:

◆ mod_authorize_resume()

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

Resume function called after authorization check / reply tmpl expansion.

Parameters
p_resultResult of current authorization.
priorityUnused.
requestCurrent request.
uctxCurrent authorization context.
Returns
one of the RLM_MODULE_* values.

Definition at line 1261 of file rlm_sql.c.

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

◆ mod_autz_group_resume()

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

Resume function called after authorization group / profile expansion of check / reply query tmpl.

Groups and profiles are treated almost identically except:

  • groups are read from an SQL query
  • profiles are read from &control.User-Profile
  • if cache_groups is set, groups populate &control.SQL-Group

Profiles are handled after groups, and will not happend if the last group resulted in Fall-Through = no

Before each query is run, &request.SQL-Group is populated with the value of the group being evaluated.

Parameters
p_resultResult of current authorization.
priorityUnused.
requestCurrent request.
uctxCurrent authorization context.
Returns
one of the RLM_MODULE_* values.

Definition at line 1071 of file rlm_sql.c.

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

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 1764 of file rlm_sql.c.

+ Here is the call graph for this function:

◆ mod_detach()

static int mod_detach ( module_detach_ctx_t const *  mctx)
static

Definition at line 1745 of file rlm_sql.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 1867 of file rlm_sql.c.

+ Here is the call graph for this function:

◆ mod_map_proc()

static unlang_action_t mod_map_proc ( rlm_rcode_t p_result,
void *  mod_inst,
UNUSED void *  proc_inst,
request_t request,
fr_value_box_list_t *  query,
map_list_t const *  maps 
)
static

Executes a SELECT query and maps the result to server attributes.

Parameters
p_resultResult of map expansion:
mod_instrlm_sql_t instance.
proc_instInstance data for this specific mod_proc call (unused).
requestThe current request.
querystring to execute.
mapsHead of the map list.
Returns
UNLANG_ACTION_CALCULATE_RESULT

Definition at line 541 of file rlm_sql.c.

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

◆ mod_sql_redundant()

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

Generic module call for failing between a bunch of queries.

Used for accounting and send module calls

Definition at line 1563 of file rlm_sql.c.

+ Here is the call graph for this function:

◆ mod_sql_redundant_resume()

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

Resume function called after expansion of next query in a redundant list of queries.

Parameters
p_resultResult of current module call.
priorityUnused.
requestCurrent request.
uctxCurrent redundant sql context.
Returns
one of the RLM_MODULE_* values.

Definition at line 1478 of file rlm_sql.c.

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

◆ query_call_env_parse() [1/2]

static int query_call_env_parse ( TALLOC_CTX *  ctx,
call_env_parsed_head_t *  out,
tmpl_rules_t const *  t_rules,
CONF_ITEM cc,
char const *  section_name1,
char const *  section_name2,
void const *  data,
call_env_parser_t const *  rule 
)
static

◆ query_call_env_parse() [2/2]

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

Definition at line 1677 of file rlm_sql.c.

+ Here is the call graph for this function:

◆ sql_autz_ctx_free()

static int sql_autz_ctx_free ( sql_autz_ctx_t to_free)
static

Definition at line 1043 of file rlm_sql.c.

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

◆ sql_box_escape()

static int sql_box_escape ( fr_value_box_t vb,
void *  uctx 
)
static

Definition at line 355 of file rlm_sql.c.

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

◆ sql_check_group()

static bool sql_check_group ( rlm_sql_t const *  inst,
request_t request,
char const *  query,
char const *  name 
)
static

Check if a given group is in the SQL group for this user.

Definition at line 895 of file rlm_sql.c.

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

◆ sql_escape_func() [1/2]

static size_t sql_escape_func ( request_t ,
char *  out,
size_t  outlen,
char const *  in,
void *  arg 
)
static
+ Here is the caller graph for this function:

◆ sql_escape_func() [2/2]

static size_t sql_escape_func ( UNUSED request_t request,
char *  out,
size_t  outlen,
char const *  in,
void *  arg 
)
static

xlat escape function for drivers which do not provide their own

Definition at line 705 of file rlm_sql.c.

+ Here is the call graph for this function:

◆ sql_escape_uctx_alloc()

static void* sql_escape_uctx_alloc ( request_t request,
void const *  uctx 
)
static

Definition at line 238 of file rlm_sql.c.

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

◆ sql_get_grouplist()

static int sql_get_grouplist ( rlm_sql_t const *  inst,
rlm_sql_handle_t **  handle,
request_t request,
char const *  query,
rlm_sql_grouplist_t **  phead 
)
static

Definition at line 849 of file rlm_sql.c.

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

◆ sql_group_xlat_resume()

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

Definition at line 938 of file rlm_sql.c.

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

◆ sql_map_verify()

static int sql_map_verify ( CONF_SECTION cs,
UNUSED void *  mod_inst,
UNUSED void *  proc_inst,
tmpl_t const *  src,
UNUSED map_list_t const *  maps 
)
static

Definition at line 516 of file rlm_sql.c.

+ Here is the caller graph for this function:

◆ sql_redundant_ctx_free()

static int sql_redundant_ctx_free ( sql_redundant_ctx_t to_free)
static

Tidy up when freeing an SQL redundant context.

Release the connection handle and unset the SQL-User attribute.

Definition at line 1461 of file rlm_sql.c.

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

◆ sql_set_user()

static void sql_set_user ( rlm_sql_t const *  inst,
request_t request,
fr_value_box_t user 
)
static

Definition at line 819 of file rlm_sql.c.

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

◆ sql_xlat_escape()

static int sql_xlat_escape ( request_t request,
fr_value_box_t vb,
void *  uctx 
)
static

Escape a tainted VB used as an xlat argument.

Definition at line 296 of file rlm_sql.c.

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

Variable Documentation

◆ accounting_method_env

const call_env_method_t accounting_method_env
static
Initial value:
= {
.env = (call_env_parser_t[]) {
}
}
#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
#define FR_CALL_ENV_SUBSECTION_FUNC(_name, _ident2, _flags, _func)
Specify a call_env_parser_t which parses a subsection using a callback function.
Definition: call_env.h:388
@ CALL_ENV_FLAG_CONCAT
If the tmpl produced multiple boxes they should be concatenated.
Definition: call_env.h:74
@ CALL_ENV_FLAG_SUBSECTION
This is a subsection.
Definition: call_env.h:85
#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:316
Per method call config.
Definition: call_env.h:171
#define CF_IDENT_ANY
Definition: cf_util.h:78
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
static int logfile_call_env_parse(TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *cc, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)
static int query_call_env_parse(TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *cc, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)

Definition at line 184 of file rlm_sql.c.

◆ attr_expr_bool_enum

fr_dict_attr_t const* attr_expr_bool_enum
static

Definition at line 83 of file rlm_sql.c.

◆ attr_fall_through

fr_dict_attr_t const* attr_fall_through
static

Definition at line 80 of file rlm_sql.c.

◆ attr_sql_user_name

fr_dict_attr_t const* attr_sql_user_name
static

Definition at line 81 of file rlm_sql.c.

◆ attr_user_profile

fr_dict_attr_t const* attr_user_profile
static

Definition at line 82 of file rlm_sql.c.

◆ authorize_method_env

const call_env_method_t authorize_method_env
static
Initial value:
= {
.env = (call_env_parser_t[]) {
{ FR_CALL_ENV_PARSE_ONLY_OFFSET("authorize_group_check_query", FR_TYPE_STRING, CALL_ENV_FLAG_PARSE_ONLY, sql_autz_call_env_t, group_check_query) },
{ FR_CALL_ENV_PARSE_ONLY_OFFSET("authorize_group_reply_query", FR_TYPE_STRING, CALL_ENV_FLAG_PARSE_ONLY, sql_autz_call_env_t, group_reply_query) },
}
}
@ 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

Definition at line 103 of file rlm_sql.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 72 of file rlm_sql.c.

◆ group_xlat_method_env

const call_env_method_t group_xlat_method_env
static

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET_TYPE_FLAGS("driver", FR_TYPE_VOID, 0, rlm_sql_t, driver_submodule), .dflt = "null",
{ FR_CONF_OFFSET("server", rlm_sql_config_t, sql_server), .dflt = "" },
{ FR_CONF_OFFSET("port", rlm_sql_config_t, sql_port), .dflt = "0" },
{ FR_CONF_OFFSET("login", rlm_sql_config_t, sql_login), .dflt = "" },
{ FR_CONF_OFFSET_FLAGS("password", CONF_FLAG_SECRET, rlm_sql_config_t, sql_password), .dflt = "" },
{ FR_CONF_OFFSET("radius_db", rlm_sql_config_t, sql_db), .dflt = "radius" },
{ FR_CONF_OFFSET("read_groups", rlm_sql_config_t, read_groups), .dflt = "yes" },
{ FR_CONF_OFFSET("group_attribute", rlm_sql_config_t, group_attribute) },
{ FR_CONF_OFFSET("cache_groups", rlm_sql_config_t, cache_groups) },
{ FR_CONF_OFFSET("read_profiles", rlm_sql_config_t, read_profiles), .dflt = "yes" },
{ FR_CONF_OFFSET("open_query", rlm_sql_config_t, connect_query) },
{ FR_CONF_OFFSET("safe_characters", rlm_sql_config_t, allowed_chars), .dflt = "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /" },
{ FR_CONF_OFFSET("query_timeout", rlm_sql_config_t, query_timeout) },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#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_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_SECRET
Only print value if debug level >= 3.
Definition: cf_parse.h:410
#define FR_CONF_OFFSET_TYPE_FLAGS(_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:241
@ FR_TYPE_VOID
User data.
Definition: merged_model.c:127
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: module_rlm.c:913

Definition at line 48 of file rlm_sql.c.

◆ rlm_sql

module_rlm_t rlm_sql
Initial value:
= {
.common = {
.name = "sql",
.inst_size = sizeof(rlm_sql_t),
.bootstrap = mod_bootstrap,
.detach = mod_detach
},
.method_names = (module_method_name_t[]){
{ .name1 = "authorize", .name2 = CF_IDENT_ANY, .method = mod_authorize,
.method_env = &authorize_method_env },
{ .name1 = "recv", .name2 = CF_IDENT_ANY, .method = mod_authorize,
.method_env = &authorize_method_env },
{ .name1 = "accounting", .name2 = CF_IDENT_ANY, .method = mod_sql_redundant,
.method_env = &accounting_method_env },
{ .name1 = "send", .name2 = CF_IDENT_ANY, .method = mod_sql_redundant,
.method_env = &send_method_env },
}
}
#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 int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1312
static int mod_detach(module_detach_ctx_t const *mctx)
Definition: rlm_sql.c:1745
static const call_env_method_t authorize_method_env
Definition: rlm_sql.c:103
static unlang_action_t mod_sql_redundant(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Generic module call for failing between a bunch of queries.
Definition: rlm_sql.c:1563
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition: rlm_sql.c:1764
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Start of module authorize method.
Definition: rlm_sql.c:1385
static const call_env_method_t accounting_method_env
Definition: rlm_sql.c:184
static const conf_parser_t module_config[]
Definition: rlm_sql.c:48
static const call_env_method_t send_method_env
Definition: rlm_sql.c:194
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_sql.c:1867
struct sql_inst rlm_sql_t
Definition: rlm_sql.h:98
@ MODULE_TYPE_THREAD_SAFE
Module is threadsafe.
Definition: module.h:49
#define MODULE_NAME_TERMINATOR
Definition: module.h:135

Definition at line 1934 of file rlm_sql.c.

◆ rlm_sql_dict

fr_dict_autoload_t rlm_sql_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ NULL }
}
static fr_dict_t const * dict_freeradius
Definition: rlm_sql.c:72

Definition at line 75 of file rlm_sql.c.

◆ rlm_sql_dict_attr

fr_dict_attr_autoload_t rlm_sql_dict_attr
Initial value:
= {
{ .out = &attr_fall_through, .name = "Fall-Through", .type = FR_TYPE_BOOL, .dict = &dict_freeradius },
{ .out = &attr_sql_user_name, .name = "SQL-User-Name", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_user_profile, .name = "User-Profile", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_expr_bool_enum, .name = "Expr-Bool-Enum", .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_sql_user_name
Definition: rlm_sql.c:81
static fr_dict_attr_t const * attr_fall_through
Definition: rlm_sql.c:80
static fr_dict_attr_t const * attr_expr_bool_enum
Definition: rlm_sql.c:83
static fr_dict_attr_t const * attr_user_profile
Definition: rlm_sql.c:82

Definition at line 86 of file rlm_sql.c.

◆ send_method_env

const call_env_method_t send_method_env
static

◆ xlat_method_env

const call_env_method_t xlat_method_env
static
Initial value:
= {
.env = (call_env_parser_t[]) {
.pair.escape = {
},
},
}
}
int rad_filename_box_make_safe(fr_value_box_t *vb, UNUSED void *uxtc)
Definition: util.c:165
@ TMPL_ESCAPE_PRE_CONCAT
Pre-concatenation escaping is useful for DSLs where elements of the expansion are static,...
Definition: tmpl_escape.h:61
uintptr_t fr_value_box_safe_for_t
Escaping that's been applied to a value box.
Definition: value.h:155

Definition at line 126 of file rlm_sql.c.