![]() |
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/server/rcode.h>#include <freeradius-devel/server/trigger.h>#include <freeradius-devel/util/debug.h>#include <freeradius-devel/util/dict.h>#include <freeradius-devel/util/skip.h>#include <freeradius-devel/util/table.h>#include <freeradius-devel/unlang/action.h>#include <freeradius-devel/unlang/function.h>#include <freeradius-devel/unlang/xlat_func.h>#include <freeradius-devel/unlang/module.h>#include <freeradius-devel/unlang/map.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_boot_t |
| struct | rlm_sql_grouplist_s |
| struct | sql_autz_call_env_t |
| struct | sql_autz_ctx_t |
| Context for SQL authorization. More... | |
| struct | sql_group_ctx_t |
| Context for group membership query evaluation. 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->mi->name |
| #define | MAX_SQL_FIELD_INDEX (64) |
| #define | QUERY_ESCAPE |
| #define | SQL_AUTZ_STAGE_GROUP 0x20 |
| #define | SQL_AUTZ_STAGE_PROFILE 0x40 |
| #define | SQL_SAFE_FOR (fr_value_box_safe_for_t)inst->driver |
| #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 = 0x12 , SQL_AUTZ_CHECK_RESUME = 0x13 , SQL_AUTZ_REPLY = 0x14 , SQL_AUTZ_REPLY_RESUME = 0x15 , SQL_AUTZ_GROUP_MEMB = 0x20 , SQL_AUTZ_GROUP_MEMB_RESUME = 0x21 , SQL_AUTZ_GROUP_CHECK = 0x22 , SQL_AUTZ_GROUP_CHECK_RESUME = 0x23 , SQL_AUTZ_GROUP_REPLY = 0x24 , SQL_AUTZ_GROUP_REPLY_RESUME = 0x25 , SQL_AUTZ_PROFILE_START = 0x40 , SQL_AUTZ_PROFILE_CHECK = 0x42 , SQL_AUTZ_PROFILE_CHECK_RESUME = 0x43 , SQL_AUTZ_PROFILE_REPLY = 0x44 , SQL_AUTZ_PROFILE_REPLY_RESUME = 0x45 } |
| 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. | |
| static int | check_map_process (request_t *request, map_list_t *check_map, map_list_t *reply_map) |
| Process a "check" map. | |
| 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, call_env_ctx_t const *cec, 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, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule) |
| static unlang_action_t | mod_authorize (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| Start of module authorize method. | |
| static unlang_action_t | mod_authorize_resume (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| Resume function called after authorization check / reply tmpl expansion. | |
| static unlang_action_t | mod_autz_group_resume (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| Resume function called after authorization group / profile expansion of check / reply query tmpl. | |
| 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 (unlang_result_t *p_result, map_ctx_t const *mpctx, request_t *request, fr_value_box_list_t *query, UNUSED map_list_t const *maps) |
| Executes a SELECT query and maps the result to server attributes. | |
| static unlang_action_t | mod_map_resume (unlang_result_t *p_result, map_ctx_t const *mpctx, request_t *request, UNUSED fr_value_box_list_t *query, map_list_t const *maps) |
| Process the results of an SQL map query. | |
| static unlang_action_t | mod_sql_redundant (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| Generic module call for failing between a bunch of queries. | |
| static unlang_action_t | mod_sql_redundant_query_resume (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| Resume function called after executing an SQL query in a redundant list of queries. | |
| static unlang_action_t | mod_sql_redundant_resume (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| Resume function called after expansion of next query in a redundant list of queries. | |
| static int | mod_thread_detach (module_thread_inst_ctx_t const *mctx) |
| static int | mod_thread_instantiate (module_thread_inst_ctx_t const *mctx) |
| Initialise thread specific data structure. | |
| static int | query_call_env_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *cc, call_env_ctx_t const *cec, 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, call_env_ctx_t const *cec, 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 int | sql_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 parser for sql call env queries. | |
| static ssize_t | sql_escape_func (request_t *, char *out, size_t outlen, char const *in, void *arg) |
| static ssize_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 | |
| static void * | sql_escape_uctx_alloc (UNUSED request_t *request, void const *uctx) |
| static xlat_action_t | sql_escape_xlat (UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| Escape a value to make it SQL safe. | |
| static xlat_action_t | sql_fetch_xlat (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| Execute an arbitrary SQL query, expecting results to be returned. | |
| static unlang_action_t | sql_get_grouplist (unlang_result_t *p_result, sql_group_ctx_t *group_ctx, trunk_t *trunk, request_t *request) |
| static unlang_action_t | sql_get_grouplist_resume (unlang_result_t *p_result, request_t *request, void *uctx) |
| 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. | |
| static xlat_action_t | sql_group_xlat_query_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, fr_value_box_list_t *in) |
| Compare list of groups returned from SQL query to xlat argument. | |
| static xlat_action_t | sql_group_xlat_resume (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in) |
| Run SQL query for group membership to return list of groups. | |
| static int | sql_map_verify (CONF_SECTION *cs, UNUSED void const *mod_inst, UNUSED void *proc_inst, tmpl_t const *src, UNUSED map_list_t const *maps) |
| static xlat_action_t | sql_modify_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, returning the number of rows affected. | |
| static int | sql_redundant_ctx_free (sql_redundant_ctx_t *to_free) |
| Tidy up when freeing an SQL redundant context. | |
| 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. | |
| static int | sql_xlat_escape (request_t *request, fr_value_box_t *vb, void *uctx) |
| Escape a tainted VB used as an xlat argument. | |
| static xlat_action_t | sql_xlat_query_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in) |
| static xlat_action_t | sql_xlat_select_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in) |
| static int | submodule_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule) |
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_boot_t |
Collaboration diagram for rlm_sql_boot_t:| Data Fields | ||
|---|---|---|
| fr_dict_attr_t const * | group_da | |
| fr_dict_attr_t const * | query_number_da | |
| struct rlm_sql_grouplist_s |
| struct sql_autz_call_env_t |
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. |
| struct sql_autz_ctx_t |
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. |
| sql_group_ctx_t * | group_ctx | Context used for retrieving user group membership. |
| rlm_sql_t const * | inst | Module instance. |
| fr_sql_map_ctx_t * | map_ctx | Context used for retrieving attribute value pairs as a map list. |
| 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. |
| trunk_t * | trunk | Trunk connection for current authorization. |
| bool | user_found | Has the user been found anywhere? |
| struct sql_group_ctx_t |
Collaboration diagram for sql_group_ctx_t:| Data Fields | ||
|---|---|---|
| rlm_sql_grouplist_t * | groups | List of groups retrieved. |
| rlm_sql_t const * | inst | Module instance. |
| int | num_groups | How many groups have been retrieved. |
| fr_value_box_t * | query | Query string used for evaluating group membership. |
| fr_sql_query_t * | query_ctx | Query context. |
| struct sql_group_xlat_call_env_t |
Collaboration diagram for sql_group_xlat_call_env_t:| Data Fields | ||
|---|---|---|
| tmpl_t * | membership_query | |
| fr_value_box_t | user | |
| struct sql_group_xlat_ctx_t |
Collaboration diagram for sql_group_xlat_ctx_t:| Data Fields | ||
|---|---|---|
| sql_group_ctx_t * | group_ctx | |
| fr_value_box_list_t | query | |
| struct sql_redundant_call_env_t |
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. |
| struct sql_redundant_ctx_t |
Collaboration diagram for sql_redundant_ctx_t:| Data Fields | ||
|---|---|---|
| sql_redundant_call_env_t * | call_env | Call environment data. |
| rlm_sql_t const * | inst | Module instance. |
| fr_value_box_list_t | query | Where expanded query tmpl will be written. |
| fr_sql_query_t * | query_ctx | Query context for current query. |
| size_t | query_no | Current query number. |
| fr_value_box_t * | query_vb | Current query string. |
| request_t * | request | Request being processed. |
| trunk_t * | trunk | Trunk connection for queries. |
| struct sql_xlat_call_env_t |
| #define QUERY_ESCAPE |
| #define SQL_SAFE_FOR (fr_value_box_safe_for_t)inst->driver |
| #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 683 of file rlm_sql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 1243 of file rlm_sql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
|
static |
Resume function called after authorization check / reply tmpl expansion.
| p_result | Result of current authorization. |
| mctx | Module call ctx. |
| request | Current request. |
Definition at line 1540 of file rlm_sql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
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. |
| mctx | Current request. |
| request | Current authorization context. |
Definition at line 1307 of file rlm_sql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
Executes a SELECT query and maps the result to server attributes.
| p_result | Result of map expansion:
|
| mpctx | Map context, containing the module instance. |
| request | The current request. |
| query | string to execute. |
| maps | Head of the map list. |
Definition at line 874 of file rlm_sql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Process the results of an SQL map query.
| p_result | Result of map expansion:
|
| mpctx | Map context, containing the module instance. |
| request | The current request. |
| query | string to execute. |
| maps | Head of the map list. |
Definition at line 736 of file rlm_sql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
Resume function called after executing an SQL query in a redundant list of queries.
| p_result | Result of current module call. |
| mctx | Current module ctx. |
| request | Current request. |
Definition at line 1785 of file rlm_sql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Resume function called after expansion of next query in a redundant list of queries.
| p_result | Result of current module call. |
| mctx | Current module ctx. |
| request | Current request. |
Definition at line 1873 of file rlm_sql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Here is the caller graph for this function:
|
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 |
1.9.8