The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Prototypes and functions for the SQL module. More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/pool.h>
#include <freeradius-devel/server/modpriv.h>
#include <freeradius-devel/server/exfile.h>
#include <freeradius-devel/server/trunk.h>
#include <freeradius-devel/unlang/function.h>
Go to the source code of this file.
Data Structures | |
struct | fr_sql_map_ctx_t |
Context used when fetching attribute value pairs as a map list. More... | |
struct | fr_sql_query_t |
struct | rlm_sql_config_t |
struct | rlm_sql_driver_t |
struct | rlm_sql_escape_uctx_t |
struct | rlm_sql_thread_t |
struct | sql_inst |
struct | sql_log_entry_t |
struct | sql_state_entry_t |
Macros | |
#define | FR_ITEM_CHECK 0 |
#define | FR_ITEM_REPLY 1 |
#define | RLM_SQL_MULTI_QUERY_CONN 2 |
Can support multiple queries on a single connection. | |
#define | RLM_SQL_RCODE_FLAGS_ALT_QUERY 1 |
Can distinguish between other errors and those resulting from a unique key violation. | |
Typedefs | |
typedef char ** | rlm_sql_row_t |
typedef struct sql_inst | rlm_sql_t |
typedef size_t(* | sql_error_t) (TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen, fr_sql_query_t *query_ctx) |
Retrieve errors from the last query operation. | |
Enumerations | |
enum | fr_sql_query_status_t { SQL_QUERY_FAILED = -1 , SQL_QUERY_PREPARED = 0 , SQL_QUERY_SUBMITTED , SQL_QUERY_RETURNED , SQL_QUERY_FETCHING_RESULTS , SQL_QUERY_RESULTS_FETCHED , SQL_QUERY_CANCELLED } |
Status of an SQL query. More... | |
enum | fr_sql_query_type_t { SQL_QUERY_SELECT , SQL_QUERY_OTHER } |
enum | sql_fall_through_t { FALL_THROUGH_NO = 0 , FALL_THROUGH_YES , FALL_THROUGH_DEFAULT } |
enum | sql_rcode_t { RLM_SQL_QUERY_INVALID = -3 , RLM_SQL_ERROR = -2 , RLM_SQL_OK = 0 , RLM_SQL_RECONNECT = 1 , RLM_SQL_ALT_QUERY , RLM_SQL_NO_MORE_ROWS } |
Action to take at end of an SQL query. More... | |
Functions | |
fr_sql_query_t * | fr_sql_query_alloc (TALLOC_CTX *ctx, rlm_sql_t const *inst, request_t *request, trunk_t *trunk, char const *query_str, fr_sql_query_type_t type) |
Allocate an sql query structure. | |
unlang_action_t | rlm_sql_fetch_row (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx) |
Call the driver's sql_fetch_row function. | |
void | rlm_sql_print_error (rlm_sql_t const *inst, request_t *request, fr_sql_query_t *query_ctx, bool force_debug) |
Retrieve any errors from the SQL driver. | |
void | rlm_sql_query_log (rlm_sql_t const *inst, char const *filename, char const *query) |
unlang_action_t | rlm_sql_trunk_query (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx) |
Submit an SQL query using a trunk connection. | |
unlang_action_t | sql_get_map_list (request_t *request, fr_sql_map_ctx_t *map_ctx, trunk_t *trunk) |
Submit the query to get any user / group check or reply pairs. | |
int | sql_state_entries_from_cs (fr_trie_t *states, CONF_SECTION *overrides) |
Insert the contents of a CONF_SECTION into the state trie. | |
int | sql_state_entries_from_table (fr_trie_t *states, sql_state_entry_t const table[]) |
Insert the contents of a state table into the state trie. | |
sql_state_entry_t const * | sql_state_entry_find (fr_trie_t const *states, char const *sql_state) |
Lookup an SQL state based on an error code returned from the SQL server or client library. | |
fr_trie_t * | sql_state_trie_alloc (TALLOC_CTX *ctx) |
Allocate a sql_state trie, and insert the initial set of entries. | |
Variables | |
fr_table_num_sorted_t const | sql_rcode_description_table [] |
size_t | sql_rcode_description_table_len |
fr_table_num_sorted_t const | sql_rcode_table [] |
size_t | sql_rcode_table_len |
Prototypes and functions for the SQL module.
Definition in file rlm_sql.h.
struct fr_sql_map_ctx_t |
Context used when fetching attribute value pairs as a map list.
Data Fields | ||
---|---|---|
TALLOC_CTX * | ctx | To allocate map entries in. |
rlm_sql_t const * | inst | Module instance data. |
fr_dict_attr_t const * | list | Default list for pair evaluation. |
map_list_t * | out | List to append entries to. |
fr_value_box_t * | query | Query string used for fetching pairs. |
fr_sql_query_t * | query_ctx | Query context. |
int | rows | How many rows the query returned. |
struct fr_sql_query_t |
Data Fields | ||
---|---|---|
rlm_sql_t const * | inst | Module instance for this query. |
char const * | query_str | Query string to run. |
sql_rcode_t | rcode | Result code. |
request_t * | request | Request this query relates to. |
rlm_sql_row_t | row | Row data from the last query. |
fr_sql_query_status_t | status | Status of the query. |
trunk_connection_t * | tconn | Trunk connection this query is being run on. |
trunk_request_t * | treq | Trunk request for this query. |
trunk_t * | trunk | Trunk this query is being run on. |
fr_sql_query_type_t | type | Type of query. |
void * | uctx | Driver specific data. |
struct rlm_sql_config_t |
Data Fields | ||
---|---|---|
char const * | allowed_chars | Chars which done need escaping.. |
bool | cache_groups | cache group names in &control.SQL-Group |
char const * | connect_query | Query executed after establishing new connection. |
char const * | group_attribute | Name of the group attribute. |
fr_time_delta_t | query_timeout | How long to allow queries to run for. |
bool | read_groups |
Read user groups by default. If false, Fall-Through = yes is required in the previous reply list to process groups. |
bool | read_profiles |
Read user profiles by default. If false, Fall-Through = yes is required in the previous reply list to process profiles. |
char const * | sql_db | Database to run queries against. |
char const * | sql_login | Login credentials to use. |
char const * | sql_password | Login password to use. |
uint32_t | sql_port | Port to connect to. |
char const * | sql_server | Server to connect to. |
trunk_conf_t | trunk_conf | Configuration for trunk connections. |
struct rlm_sql_escape_uctx_t |
struct rlm_sql_thread_t |
struct sql_log_entry_t |
Data Fields | ||
---|---|---|
char const * | msg | Log message. |
fr_log_type_t | type | Type of log entry L_ERR, L_WARN, L_INFO, L_DBG etc. |
struct sql_state_entry_t |
Data Fields | ||
---|---|---|
char const * | meaning | Verbose description. |
sql_rcode_t | rcode | What should happen if we receive this error. |
char const * | sql_state | 2-5 char error code. |
#define RLM_SQL_MULTI_QUERY_CONN 2 |
#define RLM_SQL_RCODE_FLAGS_ALT_QUERY 1 |
typedef char** rlm_sql_row_t |
typedef size_t(* sql_error_t) (TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen, fr_sql_query_t *query_ctx) |
Retrieve errors from the last query operation.
[in,out] | ctx | to allocate any buffers required. If static buffers are provided by the driver they need not be talloc_strdupd, just write the pointer to those buffers to the .msg field of a sql_log_entry_t element. |
[out] | out | a pre-allocated array of log entries to fill. Need not be NULL terminated. |
[in] | outlen | Number of log entries available for populating. Do not write to index out[outlen] or higher. |
[in] | query_ctx | to retrieve errors from. |
Status of an SQL query.
enum fr_sql_query_type_t |
enum sql_fall_through_t |
enum sql_rcode_t |
Action to take at end of an SQL query.
fr_sql_query_t * fr_sql_query_alloc | ( | TALLOC_CTX * | ctx, |
rlm_sql_t const * | inst, | ||
request_t * | request, | ||
trunk_t * | trunk, | ||
char const * | query_str, | ||
fr_sql_query_type_t | type | ||
) |
unlang_action_t rlm_sql_fetch_row | ( | rlm_rcode_t * | p_result, |
UNUSED int * | priority, | ||
request_t * | request, | ||
void * | uctx | ||
) |
Call the driver's sql_fetch_row function.
Calls the driver's sql_fetch_row logging any errors. On success, will write row data to uctx->row
.
The rcode within the query context is updated to
p_result | Result of current module call. |
priority | Unused. |
request | Current request. |
uctx | query context containing query to execute. |
Definition at line 80 of file sql.c.
void rlm_sql_print_error | ( | rlm_sql_t const * | inst, |
request_t * | request, | ||
fr_sql_query_t * | query_ctx, | ||
bool | force_debug | ||
) |
Retrieve any errors from the SQL driver.
Retrieves errors from the driver from the last operation and writes them to to request/global log, in the ERROR, WARN, INFO and DEBUG categories.
inst | Instance of rlm_sql. |
request | Current request, may be NULL. |
query_ctx | Query context to retrieve errors for. |
force_debug | Force all errors to be logged as debug messages. |
Definition at line 123 of file sql.c.
void rlm_sql_query_log | ( | rlm_sql_t const * | inst, |
char const * | filename, | ||
char const * | query | ||
) |
unlang_action_t rlm_sql_trunk_query | ( | rlm_rcode_t * | p_result, |
UNUSED int * | priority, | ||
request_t * | request, | ||
void * | uctx | ||
) |
Submit an SQL query using a trunk connection.
p_result | Result of current module call. |
priority | Unused. |
request | Current request. |
uctx | query context containing query to execute. |
Definition at line 235 of file sql.c.
unlang_action_t sql_get_map_list | ( | request_t * | request, |
fr_sql_map_ctx_t * | map_ctx, | ||
trunk_t * | trunk | ||
) |
int sql_state_entries_from_cs | ( | fr_trie_t * | states, |
CONF_SECTION * | cs | ||
) |
Insert the contents of a CONF_SECTION into the state trie.
The attribute side of the CONF_PAIR specifies the sqlclass and the value specifies the error code.
[in] | states | Trie of states. |
[in] | cs | Containing overrides to define new sql state entries or change existing ones. |
Definition at line 153 of file sql_state.c.
int sql_state_entries_from_table | ( | fr_trie_t * | states, |
sql_state_entry_t const | table[] | ||
) |
Insert the contents of a state table into the state trie.
[in] | states | Trie of states. |
[in] | table | to insert. |
Definition at line 124 of file sql_state.c.
sql_state_entry_t const * sql_state_entry_find | ( | fr_trie_t const * | states, |
char const * | sql_state | ||
) |
Lookup an SQL state based on an error code returned from the SQL server or client library.
[in] | states | Trie of states. |
[in] | sql_state | to lookup. |
Definition at line 203 of file sql_state.c.
fr_trie_t * sql_state_trie_alloc | ( | TALLOC_CTX * | ctx | ) |
Allocate a sql_state trie, and insert the initial set of entries.
[in] | ctx | to allocate states in. |
Definition at line 102 of file sql_state.c.
|
extern |
|
extern |