The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
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"
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 |
Implements FreeTDS rlm_sql driver.
Implements SQL 'users' file, and SQL accounting.
Definition in file rlm_sql.c.
struct rlm_sql_grouplist_s |
struct 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. |
struct 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? |
struct sql_group_xlat_call_env_t |
Data Fields | ||
---|---|---|
tmpl_t * | membership_query | |
fr_value_box_t | user |
struct sql_group_xlat_ctx_t |
struct 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. |
struct 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. |
struct sql_xlat_call_env_t |
#define MAX_SQL_FIELD_INDEX (64) |
#define sql_unset_user | ( | _i, | |
_r | |||
) | fr_pair_delete_by_da(&_r->request_pairs, _i->sql_user) |
typedef struct rlm_sql_grouplist_s rlm_sql_grouplist_t |
enum sql_autz_status_t |
Status of the authorization process.
|
static |
|
static |
Converts a string value into a fr_pair_t.
[in,out] | ctx | to allocate fr_pair_t (s). |
[out] | out | where to write the resulting fr_pair_t. |
[in] | request | The current request. |
[in] | map | to process. |
[in] | uctx | The value to parse. |
Definition at line 491 of file rlm_sql.c.
|
static |
Process a "check" map.
Any entries using an assignment operator will be moved to the reply map for later merging into the request.
request | Current request. |
check_map | to process. |
reply_map | where any assignment entries will be moved. |
Definition at line 1005 of file rlm_sql.c.
|
static |
|
static |
|
static |
|
static |
|
static |
Resume function called after authorization check / reply tmpl expansion.
p_result | Result of current authorization. |
priority | Unused. |
request | Current request. |
uctx | Current authorization context. |
Definition at line 1261 of file rlm_sql.c.
|
static |
Resume function called after authorization group / profile expansion of check / reply query tmpl.
Groups and profiles are treated almost identically except:
cache_groups
is set, groups populate &control.SQL-GroupProfiles 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.
p_result | Result of current authorization. |
priority | Unused. |
request | Current request. |
uctx | Current authorization context. |
Definition at line 1071 of file rlm_sql.c.
|
static |
|
static |
|
static |
|
static |
Executes a SELECT query and maps the result to server attributes.
p_result | Result of map expansion:
|
mod_inst | rlm_sql_t instance. |
proc_inst | Instance data for this specific mod_proc call (unused). |
request | The current request. |
query | string to execute. |
maps | Head of the map list. |
Definition at line 541 of file rlm_sql.c.
|
static |
|
static |
Resume function called after expansion of next query in a redundant list of queries.
p_result | Result of current module call. |
priority | Unused. |
request | Current request. |
uctx | Current redundant sql context. |
Definition at line 1478 of file rlm_sql.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
module_rlm_t rlm_sql |
fr_dict_autoload_t rlm_sql_dict |
fr_dict_attr_autoload_t rlm_sql_dict_attr |
|
static |
|
static |