![]() |
The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
|
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"
Include dependency graph for rlm_sql_mysql.c:Go to the source code of this file.
Data Structures | |
| struct | rlm_sql_mysql_conn_t |
| struct | rlm_sql_mysql_esc_ctx_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, UNUSED int fd, UNUSED int flags, void *uctx) |
| Callback for I/O events in response to mysql_real_connect_start() | |
| 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) |
| static connection_state_t | _sql_connection_init (void **h, connection_t *conn, void *uctx) |
| static void | _sql_escape_post_conn (connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
| Capture our copy of the connection details for escaping purposes. | |
| 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. | |
| 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. | |
| 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. | |
| static void | sql_escape_arg_free (void *uctx) |
| static int | sql_escape_func (request_t *request, fr_value_box_t *vb, void *arg) |
| static unlang_action_t | sql_fetch_row (unlang_result_t *p_result, 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. | |
| 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 void | sql_mysql_fd_release (rlm_sql_mysql_conn_t *c, fr_event_list_t *el) |
| Stop tracking our fd for a connection. | |
| static int | sql_mysql_fd_track (rlm_sql_mysql_conn_t *c, fr_event_list_t *el) |
| Track the socket actually being used by the client library. | |
| static int | sql_num_rows (fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config) |
| static void | sql_request_cancel (connection_t *conn, void *preq, trunk_cancel_reason_t reason, UNUSED void *uctx) |
| static void | sql_request_cancel_mux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx) |
| SQL_QUERY_FAIL static SQL_QUERY_RESUME unlang_action_t | sql_select_query_resume (unlang_result_t *p_result, 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 void | sql_trunk_request_demux (UNUSED fr_event_list_t *el, UNUSED trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx) |
| static void | sql_trunk_request_mux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx) |
| static ssize_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. | |
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.
Collaboration diagram for rlm_sql_mysql_conn_t:| Data Fields | ||
|---|---|---|
| int | client_fd | Socket the client library last reported, for detecting fd changes. |
| connection_t * | conn | Generic connection structure for this connection. |
| MYSQL | db | Structure representing connection details. |
| int | fd | Our 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_esc_ctx_t |
Definition at line 104 of file rlm_sql_mysql.c.
Collaboration diagram for rlm_sql_mysql_esc_ctx_t:| Data Fields | ||
|---|---|---|
| connection_t * | conn | Connection used to fetch server status. |
| MYSQL | db | Our copy of the connection details - holds the flags needed by mysql_real_escape_string() |
| bool | ready | Has the db structure been populated. |
| struct rlm_sql_mysql_t |
Definition at line 79 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 29 of file rlm_sql_mysql.c.
| #define LOG_PREFIX "rlm_sql_mysql" |
Definition at line 29 of file rlm_sql_mysql.c.
| #define LOG_PREFIX log_prefix |
Definition at line 29 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 280 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 336 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 470 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
For MariaDB, It should be true as can be seen in https://github.com/MariaDB/server/blob/mariadb-5.5.68/sql-common/client.c#L4338
Definition at line 369 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Capture our copy of the connection details for escaping purposes.
After an "escape" connection has been started and again after it is established. Then close the connection. mysql_real_escape_string only looks at one flag inside the MYSQL structure, so no need to keep an open connection.
Definition at line 1203 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 148 of file rlm_sql_mysql.c.
|
static |
Definition at line 184 of file rlm_sql_mysql.c.
|
static |
Definition at line 179 of file rlm_sql_mysql.c.
|
static |
Definition at line 923 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 490 of file rlm_sql_mysql.c.
Here is the caller graph for this function:
|
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. |
Definition at line 781 of file rlm_sql_mysql.c.
Here is the call graph for this function:
|
static |
Allocate the argument used for the SQL escape function.
In this case, a dedicated connection is made to fetch server flags used by the escape function, though no packets ever flow after the connection is made. Once the server flags have been retrieved, the connection is closed, by a watch function.
Definition at line 1222 of file rlm_sql_mysql.c.
Here is the call graph for this function:
|
static |
|
static |
|
static |
|
static |
Definition at line 590 of file rlm_sql_mysql.c.
|
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 857 of file rlm_sql_mysql.c.
Here is the call graph for this function:
|
static |
Here is the caller graph for this function:
|
static |
Definition at line 689 of file rlm_sql_mysql.c.
|
static |
Stop tracking our fd for a connection.
Removes the event and closes our descriptor. Safe to call repeatedly.
Definition at line 202 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Track the socket actually being used by the client library.
The client library owns its socket and potentially both closes and replaces it without telling us during connection setup, meaning events are still registered on the wrong fd.
Create a dup() of the fd which gets used in the event list to avoid this issue.
Call after each mysql_real_connect_* call to ensure the correct fd is in the event list.
| [in] | c | connection to update. |
| [in] | el | event list the old event is registered in, may be NULL if nothing is registered yet. |
Definition at line 231 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 581 of file rlm_sql_mysql.c.
|
static |
|
static |
|
static |
Definition at line 1176 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 561 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
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. |
Definition at line 718 of file rlm_sql_mysql.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 137 of file rlm_sql_mysql.c.
| rlm_sql_driver_t rlm_sql_mysql |
Definition at line 1265 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 111 of file rlm_sql_mysql.c.
1.9.8