Prototypes and functions for the SQL module. More...
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/connection.h>
#include <freeradius-devel/modpriv.h>
#include <freeradius-devel/exfile.h>
Go to the source code of this file.
Data Structures | |
struct | rlm_sql_handle |
struct | rlm_sql_module_t |
struct | sql_acct_section |
struct | sql_config |
struct | sql_grouplist |
struct | sql_inst |
struct | sql_log_entry |
Macros | |
#define | MOD_PREFIX "rlm_sql" |
#define | PW_ITEM_CHECK 0 |
#define | PW_ITEM_REPLY 1 |
#define | RLM_SQL_RCODE_FLAGS_ALT_QUERY 1 |
Can distinguish between other errors and those. More... | |
Typedefs | |
typedef struct sql_config | rlm_sql_config_t |
typedef struct sql_grouplist | rlm_sql_grouplist_t |
typedef struct rlm_sql_handle | rlm_sql_handle_t |
typedef struct rlm_sql_module_t | rlm_sql_module_t |
typedef char ** | rlm_sql_row_t |
typedef struct sql_inst | rlm_sql_t |
typedef struct sql_acct_section | sql_acct_section_t |
typedef size_t(* | sql_error_t )(TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen, rlm_sql_handle_t *handle, rlm_sql_config_t *config) |
Retrieve errors from the last query operation. More... | |
typedef struct sql_log_entry | sql_log_entry_t |
Enumerations | |
enum | sql_fall_through_t { FALL_THROUGH_DEFAULT = 0, FALL_THROUGH_YES, FALL_THROUGH_NO } |
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 = 2 } |
Functions | |
void * | mod_conn_create (TALLOC_CTX *ctx, void *instance, struct timeval const *timeout) |
Create a new connection pool handle. More... | |
void sql_rcode_t sql_rcode_t int | rlm_sql_fetch_row (rlm_sql_row_t *out, rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t **handle) |
Call the driver's sql_fetch_row function. More... | |
void | rlm_sql_print_error (rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t *handle, bool force_debug) |
Retrieve any errors from the SQL driver. More... | |
void sql_rcode_t sql_rcode_t | rlm_sql_query (rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t **handle, char const *query) CC_HINT(nonnull(1 |
void | rlm_sql_query_log (rlm_sql_t const *inst, REQUEST *request, sql_acct_section_t *section, char const *query) CC_HINT(nonnull(1 |
void sql_rcode_t | rlm_sql_select_query (rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t **handle, char const *query) CC_HINT(nonnull(1 |
int | sql_dict_init (rlm_sql_handle_t *handle) |
int | sql_fr_pair_list_afrom_str (TALLOC_CTX *ctx, REQUEST *request, VALUE_PAIR **first_pair, rlm_sql_row_t row) |
int | sql_getvpdata (TALLOC_CTX *ctx, rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t **handle, VALUE_PAIR **pair, char const *query) |
int | sql_read_clients (rlm_sql_handle_t *handle) |
int | sql_read_realms (rlm_sql_handle_t *handle) |
int | sql_set_user (rlm_sql_t const *inst, REQUEST *request, char const *username) |
Variables | |
const FR_NAME_NUMBER | sql_rcode_table [] |
Prototypes and functions for the SQL module.
Definition in file rlm_sql.h.
struct rlm_sql_handle |
Data Fields | ||
---|---|---|
void * | conn | Database specific connection handle. |
rlm_sql_t * | inst | The rlm_sql instance this connection belongs to. |
TALLOC_CTX * | log_ctx | Talloc pool used to avoid mallocing memory on when log strings need to be copied. |
rlm_sql_row_t | row | Row data from the last query. |
struct sql_acct_section |
Data Fields | ||
---|---|---|
CONF_SECTION * | cs | The CONF_SECTION representing the group of queries to process. |
char const * | logfile | |
char const ** | query | |
char const * | reference | Reference string, expanded to point to a group of queries. |
bool | reference_cp |
struct sql_config |
Data Fields | ||
---|---|---|
sql_acct_section_t | accounting | |
char const * | allowed_chars | Chars which done need escaping.. |
char const * | authorize_check_query | Query used get check VPs for a user. |
char const * | authorize_group_check_query | Query used get check VPs for a group. |
char const * | authorize_group_reply_query | Query used get reply VPs for a group. |
char const * | authorize_reply_query | Query used get reply VPs for a user. |
char const * | client_query | Query used to get FreeRADIUS client definitions. |
char const * | connect_query | Query executed after establishing new connection. |
char const * | default_profile | Default profile to use if no other profiles were configured. |
bool | delete_stale_sessions | Whether we should use session_zap to create a fake stop packet, to terminate any stale sessions. |
bool | do_clients | Read clients from SQL database. |
void * | driver | Where drivers should write a pointer to their configurations. |
char const * | group_attribute | Name of the group attribute. |
char const * | groupmemb_query | Query to determine group membership. |
char const * | logfile | Keep a log of all SQL queries executed Useful for batch insertion with the NULL drivers. |
sql_acct_section_t | postauth | |
uint32_t | query_timeout | How long to allow queries to run for. |
char const * | query_user | xlat expansion used to specify the user to use as the subject of queries. |
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 * | simul_count_query | Query used get number of active sessions for a user (basic simultaneous use check). |
char const * | simul_verify_query | Query to get active sessions for a user the result is fed to session_zap. |
char const * | sql_db | Database to run queries against. |
char const * | sql_driver_name | SQL driver module name e.g. rlm_sql_sqlite. |
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. |
struct sql_grouplist |
struct sql_log_entry |
Data Fields | ||
---|---|---|
char const * | msg | Log message. |
log_type_t | type | Type of log entry L_ERR, L_WARN, L_INFO, L_DBG etc.. |
#define RLM_SQL_RCODE_FLAGS_ALT_QUERY 1 |
typedef struct sql_config rlm_sql_config_t |
typedef struct sql_grouplist rlm_sql_grouplist_t |
typedef struct rlm_sql_handle rlm_sql_handle_t |
typedef struct rlm_sql_module_t rlm_sql_module_t |
typedef char** rlm_sql_row_t |
typedef struct sql_acct_section sql_acct_section_t |
typedef size_t(* sql_error_t)(TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen, rlm_sql_handle_t *handle, rlm_sql_config_t *config) |
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 strduped, 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] | handle | to retrieve errors from. |
[in] | config | of the SQL instance. |
typedef struct sql_log_entry sql_log_entry_t |
enum sql_fall_through_t |
enum sql_rcode_t |
void* mod_conn_create | ( | TALLOC_CTX * | ctx, |
void * | instance, | ||
struct timeval const * | timeout | ||
) |
Create a new connection pool handle.
Create a new connection to Couchbase within the pool and initialize information associated with the connection instance.
ctx | The connection parent context. |
instance | The module instance. |
timeout | Maximum time to establish the connection. |
Create a new connection pool handle.
Create a new ldap connection and allocate memory for a new rlm_handle_t
Create a new connection pool handle.
Matches the fr_connection_create_t function prototype, is passed to fr_connection_pool_init, and called when a new connection is required by the connection pool API.
Creates an instances of rlm_rest_handle_t, and rlm_rest_curl_context_t which hold the context data required for generating requests and parsing responses.
If instance->connect_uri is not NULL libcurl will attempt to open a TCP socket to the server specified in the URI. This is done so that when the socket is first used, there will already be a cached TCP connection to the REST server associated with the curl handle.
Create a new connection to Couchbase within the pool and initialize information associated with the connection instance.
ctx | The connection parent context. |
instance | The module instance. |
timeout | Maximum time to establish the connection. |
Create a new connection pool handle.
Create a new ldap connection and allocate memory for a new rlm_handle_t
Create a new connection pool handle.
Matches the fr_connection_create_t function prototype, is passed to fr_connection_pool_init, and called when a new connection is required by the connection pool API.
Creates an instances of rlm_rest_handle_t, and rlm_rest_curl_context_t which hold the context data required for generating requests and parsing responses.
If instance->connect_uri is not NULL libcurl will attempt to open a TCP socket to the server specified in the URI. This is done so that when the socket is first used, there will already be a cached TCP connection to the REST server associated with the curl handle.
Definition at line 68 of file mod.c.
void sql_rcode_t sql_rcode_t int rlm_sql_fetch_row | ( | rlm_sql_row_t * | out, |
rlm_sql_t const * | inst, | ||
REQUEST * | request, | ||
rlm_sql_handle_t ** | handle | ||
) |
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 (*handle)->row
.
out | Where to write row data. |
inst | Instance of rlm_sql_t. |
request | The Current request, may be NULL. |
handle | Handle to retrieve errors for. |
Definition at line 249 of file sql.c.
void rlm_sql_print_error | ( | rlm_sql_t const * | inst, |
REQUEST * | request, | ||
rlm_sql_handle_t * | handle, | ||
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. |
handle | Handle to retrieve errors for. |
force_debug | Force all errors to be logged as debug messages. |
Definition at line 280 of file sql.c.
void sql_rcode_t sql_rcode_t rlm_sql_query | ( | rlm_sql_t const * | inst, |
REQUEST * | request, | ||
rlm_sql_handle_t ** | handle, | ||
char const * | query | ||
) |
void rlm_sql_query_log | ( | rlm_sql_t const * | inst, |
REQUEST * | request, | ||
sql_acct_section_t * | section, | ||
char const * | query | ||
) |
void sql_rcode_t rlm_sql_select_query | ( | rlm_sql_t const * | inst, |
REQUEST * | request, | ||
rlm_sql_handle_t ** | handle, | ||
char const * | query | ||
) |
int sql_dict_init | ( | rlm_sql_handle_t * | handle | ) |
int sql_fr_pair_list_afrom_str | ( | TALLOC_CTX * | ctx, |
REQUEST * | request, | ||
VALUE_PAIR ** | first_pair, | ||
rlm_sql_row_t | row | ||
) |
int sql_getvpdata | ( | TALLOC_CTX * | ctx, |
rlm_sql_t const * | inst, | ||
REQUEST * | request, | ||
rlm_sql_handle_t ** | handle, | ||
VALUE_PAIR ** | pair, | ||
char const * | query | ||
) |
int sql_read_clients | ( | rlm_sql_handle_t * | handle | ) |
int sql_read_realms | ( | rlm_sql_handle_t * | handle | ) |
const FR_NAME_NUMBER sql_rcode_table[] |