The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
MySQL driver. More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/util/debug.h>
#include <sys/stat.h>
#include "config.h"
#include "rlm_sql.h"
#include "rlm_sql_trunk.h"
Go to the source code of this file.
Data Structures | |
struct | rlm_sql_mysql_conn_t |
struct | rlm_sql_mysql_t |
Macros | |
#define | LOG_PREFIX log_prefix |
#define | LOG_PREFIX "rlm_sql_mysql" |
#define | LOG_PREFIX log_prefix |
Enumerations | |
enum | rlm_sql_mysql_warnings { SERVER_WARNINGS_AUTO = 0 , SERVER_WARNINGS_YES , SERVER_WARNINGS_NO } |
Functions | |
static void | _sql_connect_io_notify (fr_event_list_t *el, int fd, UNUSED int flags, void *uctx) |
Callback for I/O events in response to mysql_real_connect_start() More... | |
static void | _sql_connect_query_run (connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
static void | _sql_connection_close (fr_event_list_t *el, void *h, UNUSED void *uctx) |
CC_NO_UBSAN (function) | |
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
static int | mod_load (void) |
static void | mod_unload (void) |
static int | sql_affected_rows (fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config) |
static sql_rcode_t | sql_check_error (MYSQL *server, int client_errno) |
Analyse the last error that occurred on the socket, and determine an action. More... | |
static size_t | sql_error (TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen, fr_sql_query_t *query_ctx) |
Retrieves any errors associated with the query context. More... | |
static void * | sql_escape_arg_alloc (TALLOC_CTX *ctx, fr_event_list_t *el, void *uctx) |
Allocate the argument used for the SQL escape function. More... | |
static void | sql_escape_arg_free (void *uctx) |
static ssize_t | sql_escape_func (request_t *request, char *out, size_t outlen, char const *in, void *arg) |
static unlang_action_t | sql_fetch_row (rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx) |
static sql_rcode_t | sql_fields (char const **out[], fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config) |
static sql_rcode_t | sql_finish_query (fr_sql_query_t *query_ctx, rlm_sql_config_t const *config) |
Finish query. More... | |
static sql_rcode_t | sql_free_result (fr_sql_query_t *, rlm_sql_config_t const *) |
static sql_rcode_t | sql_free_result (fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config) |
static int | sql_num_rows (fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config) |
SQL_QUERY_FAIL static SQL_QUERY_RESUME unlang_action_t | sql_select_query_resume (rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx) |
static sql_rcode_t | sql_store_result (rlm_sql_mysql_conn_t *conn, UNUSED rlm_sql_config_t const *config) |
static size_t | sql_warnings (TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen, rlm_sql_mysql_conn_t *conn) |
Retrieves any warnings associated with the last query. More... | |
Variables | |
static const conf_parser_t | driver_config [] |
rlm_sql_driver_t | rlm_sql_mysql |
static fr_table_num_sorted_t const | server_warnings_table [] |
static size_t | server_warnings_table_len = NUM_ELEMENTS(server_warnings_table) |
static conf_parser_t | tls_config [] |
MySQL driver.
Definition in file rlm_sql_mysql.c.
struct rlm_sql_mysql_conn_t |
Definition at line 68 of file rlm_sql_mysql.c.
Data Fields | ||
---|---|---|
connection_t * | conn | Generic connection structure for this connection. |
MYSQL | db | Structure representing connection details. |
int | fd | fd for this connection's I/O events. |
fr_sql_query_t * | query_ctx | Current query running on this connection. |
MYSQL_RES * | result | Result from most recent query. |
MYSQL * | sock | Connection details as returned by connection init functions. |
int | status | returned by the most recent non-blocking function call. |
struct rlm_sql_mysql_t |
Definition at line 78 of file rlm_sql_mysql.c.
Data Fields | ||
---|---|---|
char const * | character_set | Character set to use on connections. |
char const * | tls_ca_file | Path to the CA used to validate the server's certificate. |
char const * | tls_ca_path | Directory containing CAs that may be used to validate the servers certificate. |
char const * | tls_certificate_file | Public certificate we present to the server. |
bool | tls_check_cert | Verify there's a trust relationship between the server's cert and one of the CAs we have configured. |
bool | tls_check_cert_cn | Verify that the CN in the server cert matches the host we passed to mysql_real_connect(). |
char const * | tls_cipher | Colon separated list of TLS ciphers for TLS <= 1.2. |
char const * | tls_crl_file | Public certificate we present to the server. |
char const * | tls_crl_path | Private key for the certificate we present to the server. |
char const * | tls_private_key_file | Private key for the certificate we present to the server. |
bool | tls_required | Require that the connection is encrypted. |
rlm_sql_mysql_warnings | warnings | mysql_warning_count() doesn't appear to work with NDB cluster |
char const * | warnings_str | Whether we always query the server for additional warnings. |
#define LOG_PREFIX log_prefix |
Definition at line 881 of file rlm_sql_mysql.c.
#define LOG_PREFIX "rlm_sql_mysql" |
Definition at line 881 of file rlm_sql_mysql.c.
#define LOG_PREFIX log_prefix |
Definition at line 881 of file rlm_sql_mysql.c.
Enumerator | |
---|---|
SERVER_WARNINGS_AUTO | |
SERVER_WARNINGS_YES | |
SERVER_WARNINGS_NO |
Definition at line 55 of file rlm_sql_mysql.c.
|
static |
Callback for I/O events in response to mysql_real_connect_start()
Definition at line 192 of file rlm_sql_mysql.c.
|
static |
Definition at line 227 of file rlm_sql_mysql.c.
|
static |
Definition at line 389 of file rlm_sql_mysql.c.
CC_NO_UBSAN | ( | function | ) |
|
static |
Definition at line 140 of file rlm_sql_mysql.c.
|
static |
Definition at line 176 of file rlm_sql_mysql.c.
|
static |
Definition at line 171 of file rlm_sql_mysql.c.
|
static |
Definition at line 843 of file rlm_sql_mysql.c.
|
static |
Analyse the last error that occurred on the socket, and determine an action.
server | Socket from which to extract the server error. May be NULL. |
client_errno | Error from the client. |
Definition at line 408 of file rlm_sql_mysql.c.
|
static |
Retrieves any errors associated with the query context.
ctx | to allocate temporary error buffers in. |
out | Array of sql_log_entrys to fill. |
outlen | Length of out array. |
query_ctx | Query context to retrieve error for. |
config | rlm_sql config. |
Definition at line 701 of file rlm_sql_mysql.c.
|
static |
Allocate the argument used for the SQL escape function.
In this case, a dedicated connection to allow the escape function to have access to server side parameters, though no packets ever flow after the connection is made.
Definition at line 1110 of file rlm_sql_mysql.c.
|
static |
|
static |
Definition at line 850 of file rlm_sql_mysql.c.
|
static |
|
static |
|
static |
Finish query.
As a single SQL statement may return multiple results sets, (for example stored procedures) it is necessary to check whether more results exist and process them in turn if so.
Definition at line 777 of file rlm_sql_mysql.c.
|
static |
|
static |
Definition at line 607 of file rlm_sql_mysql.c.
|
static |
Definition at line 499 of file rlm_sql_mysql.c.
|
static |
|
static |
Definition at line 479 of file rlm_sql_mysql.c.
|
static |
Retrieves any warnings associated with the last query.
MySQL stores a limited number of warnings associated with the last query executed. These can be very useful in diagnosing issues, or in some cases working around bugs in MySQL which causes it to return the wrong error.
ctx | to allocate temporary error buffers in. |
out | Array of sql_log_entrys to fill. |
outlen | Length of out array. |
conn | MySQL connection the query was run on. |
config | rlm_sql config. |
Definition at line 637 of file rlm_sql_mysql.c.
|
static |
Definition at line 129 of file rlm_sql_mysql.c.
rlm_sql_driver_t rlm_sql_mysql |
Definition at line 1141 of file rlm_sql_mysql.c.
|
static |
Definition at line 61 of file rlm_sql_mysql.c.
|
static |
Definition at line 66 of file rlm_sql_mysql.c.
|
static |
Definition at line 103 of file rlm_sql_mysql.c.