Add offsets for MySQL 5.6.32. Some whitespace cleanups.
parent
50b52078a4
commit
7c16d68069
|
@ -530,7 +530,7 @@ protected:
|
||||||
virtual void handler_stop();
|
virtual void handler_stop();
|
||||||
virtual bool handler_start_internal() = 0;
|
virtual bool handler_start_internal() = 0;
|
||||||
virtual void handler_stop_internal() = 0;
|
virtual void handler_stop_internal() = 0;
|
||||||
virtual bool handler_log_audit(ThdSesData *pThdData) =0;
|
virtual bool handler_log_audit(ThdSesData *pThdData) = 0;
|
||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
bool m_failed;
|
bool m_failed;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "static_assert.h"
|
#include "static_assert.h"
|
||||||
|
|
||||||
// utility macro to log also with a date as a prefix
|
// utility macro to log also with a date as a prefix
|
||||||
|
// FIXME: This is no longer used. Remove?
|
||||||
#define log_with_date(f, ...) do {\
|
#define log_with_date(f, ...) do {\
|
||||||
struct tm tm_tmp;\
|
struct tm tm_tmp;\
|
||||||
time_t result = time(NULL);\
|
time_t result = time(NULL);\
|
||||||
|
@ -44,7 +45,7 @@
|
||||||
// initialize static stuff
|
// initialize static stuff
|
||||||
ThdOffsets Audit_formatter::thd_offsets = { 0 };
|
ThdOffsets Audit_formatter::thd_offsets = { 0 };
|
||||||
Audit_handler *Audit_handler::m_audit_handler_list[Audit_handler::MAX_AUDIT_HANDLERS_NUM];
|
Audit_handler *Audit_handler::m_audit_handler_list[Audit_handler::MAX_AUDIT_HANDLERS_NUM];
|
||||||
const char *Audit_json_formatter::DEF_MSG_DELIMITER = "\\n";
|
const char *Audit_json_formatter::DEF_MSG_DELIMITER = "\\n"; // FIXME: This is used ...
|
||||||
|
|
||||||
#if MYSQL_VERSION_ID < 50709
|
#if MYSQL_VERSION_ID < 50709
|
||||||
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
|
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
|
||||||
|
@ -233,7 +234,7 @@ int Audit_file_handler::open(const char *io_dest, bool log_errors)
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
sql_print_error(
|
sql_print_error(
|
||||||
"%s unable to set bufzie [%zd (%ld)] for file %s: %s.",
|
"%s unable to set bufsize [%zd (%ld)] for file %s: %s.",
|
||||||
AUDIT_LOG_PREFIX, bufsize, m_bufsize, m_io_dest, strerror(errno));
|
AUDIT_LOG_PREFIX, bufsize, m_bufsize, m_io_dest, strerror(errno));
|
||||||
}
|
}
|
||||||
sql_print_information("%s bufsize for file [%s]: %zd. Value of json_file_bufsize: %ld.", AUDIT_LOG_PREFIX, m_io_dest,
|
sql_print_information("%s bufsize for file [%s]: %zd. Value of json_file_bufsize: %ld.", AUDIT_LOG_PREFIX, m_io_dest,
|
||||||
|
@ -830,7 +831,7 @@ bool ThdSesData::getNextObject(const char **db_name, const char **obj_name, cons
|
||||||
case OBJ_QUERY_CACHE:
|
case OBJ_QUERY_CACHE:
|
||||||
{
|
{
|
||||||
if (m_index < m_tableInf->num_of_elem &&
|
if (m_index < m_tableInf->num_of_elem &&
|
||||||
m_index< MAX_NUM_QUERY_TABLE_ELEM)
|
m_index < MAX_NUM_QUERY_TABLE_ELEM)
|
||||||
{
|
{
|
||||||
*db_name = m_tableInf->db[m_index];
|
*db_name = m_tableInf->db[m_index];
|
||||||
*obj_name = m_tableInf->table_name[m_index];
|
*obj_name = m_tableInf->table_name[m_index];
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
const ThdOffsets thd_offsets_arr[] =
|
const ThdOffsets thd_offsets_arr[] =
|
||||||
{
|
{
|
||||||
/* +++ MYSQL 64 OFFSETS GO HERE +++ */
|
/* +++ MYSQL 64 OFFSETS GO HERE +++ */
|
||||||
|
//offsets for: /mysqlrpm/5.6.32/usr/sbin/mysqld (5.6.32)
|
||||||
|
{"5.6.32","e7fb65c8c8c817e58de0a1ce9dcad845", 6992, 7040, 4000, 4520, 72, 2704, 96, 0, 32, 104, 136, 7128},
|
||||||
//offsets for: /mysqlrpm/5.5.50/usr/sbin/mysqld (5.5.50)
|
//offsets for: /mysqlrpm/5.5.50/usr/sbin/mysqld (5.5.50)
|
||||||
{"5.5.50","c1b990f432d684f1d5abe3969146ee9d", 6144, 6192, 3816, 4312, 88, 2592, 96, 0, 32, 104, 120, 6264},
|
{"5.5.50","c1b990f432d684f1d5abe3969146ee9d", 6144, 6192, 3816, 4312, 88, 2592, 96, 0, 32, 104, 120, 6264},
|
||||||
//offsets for: /mysqlrpm/5.6.31/usr/sbin/mysqld (5.6.31)
|
//offsets for: /mysqlrpm/5.6.31/usr/sbin/mysqld (5.6.31)
|
||||||
|
@ -437,6 +439,8 @@ const ThdOffsets thd_offsets_arr[] =
|
||||||
const ThdOffsets thd_offsets_arr[] =
|
const ThdOffsets thd_offsets_arr[] =
|
||||||
{
|
{
|
||||||
/* +++ MYSQL 32 OFFSETS GO HERE +++ */
|
/* +++ MYSQL 32 OFFSETS GO HERE +++ */
|
||||||
|
//offsets for: /mysqlrpm/5.6.32/usr/sbin/mysqld (5.6.32)
|
||||||
|
{"5.6.32","f3b529d1a6c2d051f9ee0930004129ab", 4676, 4704, 2660, 3052, 36, 1748, 60, 0, 20, 64, 72, 4776},
|
||||||
//offsets for: /mysqlrpm/5.5.50/usr/sbin/mysqld (5.5.50)
|
//offsets for: /mysqlrpm/5.5.50/usr/sbin/mysqld (5.5.50)
|
||||||
{"5.5.50","2adacdba4c475e574dedbf97366159c7", 3872, 3900, 2368, 2748, 44, 1656, 60, 0, 20, 64, 60, 3956},
|
{"5.5.50","2adacdba4c475e574dedbf97366159c7", 3872, 3900, 2368, 2748, 44, 1656, 60, 0, 20, 64, 60, 3956},
|
||||||
//offsets for: /mysqlrpm/5.6.31/usr/sbin/mysqld (5.6.31)
|
//offsets for: /mysqlrpm/5.6.31/usr/sbin/mysqld (5.6.31)
|
||||||
|
|
|
@ -396,11 +396,11 @@ static int audit_send_result_to_client(Query_cache *pthis, THD *thd, const LEX_
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
void *pList = thd_alloc (thd, sizeof (QueryTableInf));
|
void *pList = thd_alloc(thd, sizeof (QueryTableInf));
|
||||||
|
|
||||||
if (pList)
|
if (pList)
|
||||||
{
|
{
|
||||||
memset (pList,0,sizeof (QueryTableInf));
|
memset(pList,0,sizeof (QueryTableInf));
|
||||||
THDVAR(thd, query_cache_table_list) =(ulong)pList;
|
THDVAR(thd, query_cache_table_list) =(ulong)pList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,8 +411,8 @@ static int audit_send_result_to_client(Query_cache *pthis, THD *thd, const LEX_
|
||||||
#endif
|
#endif
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
ThdSesData thd_data (thd);
|
ThdSesData thd_data(thd);
|
||||||
audit (&thd_data);
|
audit(&thd_data);
|
||||||
}
|
}
|
||||||
THDVAR(thd, query_cache_table_list) = 0;
|
THDVAR(thd, query_cache_table_list) = 0;
|
||||||
return res;
|
return res;
|
||||||
|
@ -502,8 +502,8 @@ static int audit_notify(THD *thd, mysql_event_class_t event_class,
|
||||||
// only audit for connect and change_user. disconnect is caught by general event
|
// only audit for connect and change_user. disconnect is caught by general event
|
||||||
if (event_connection->event_subclass != MYSQL_AUDIT_CONNECTION_DISCONNECT)
|
if (event_connection->event_subclass != MYSQL_AUDIT_CONNECTION_DISCONNECT)
|
||||||
{
|
{
|
||||||
ThdSesData ThdData (thd);
|
ThdSesData ThdData(thd);
|
||||||
audit (&ThdData);
|
audit(&ThdData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ! defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50709
|
#if ! defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50709
|
||||||
|
@ -617,7 +617,7 @@ int is_remove_patches(ThdSesData *pThdData)
|
||||||
const char *cmd = pThdData->getCmdName();
|
const char *cmd = pThdData->getCmdName();
|
||||||
const char *sUninstallPlugin = "uninstall_plugin";
|
const char *sUninstallPlugin = "uninstall_plugin";
|
||||||
LEX *pLex = Audit_formatter::thd_lex(pThdData->getTHD());
|
LEX *pLex = Audit_formatter::thd_lex(pThdData->getTHD());
|
||||||
if (pThdData->getTHD() && pLex!=NULL && strncasecmp(cmd, sUninstallPlugin, strlen(sUninstallPlugin)) == 0)
|
if (pThdData->getTHD() && pLex != NULL && strncasecmp(cmd, sUninstallPlugin, strlen(sUninstallPlugin)) == 0)
|
||||||
{
|
{
|
||||||
LEX_STRING Lex_comment = *(LEX_STRING*)(((unsigned char *) pLex) + Audit_formatter::thd_offsets.lex_comment);
|
LEX_STRING Lex_comment = *(LEX_STRING*)(((unsigned char *) pLex) + Audit_formatter::thd_offsets.lex_comment);
|
||||||
if (strncasecmp(Lex_comment.str, "AUDIT", 5) == 0)
|
if (strncasecmp(Lex_comment.str, "AUDIT", 5) == 0)
|
||||||
|
@ -778,7 +778,7 @@ static bool parse_thd_offsets_string (char *poffsets_string)
|
||||||
|
|
||||||
for (size_t j = 0; j < len; j++)
|
for (size_t j = 0; j < len; j++)
|
||||||
{
|
{
|
||||||
if (!((poffset_str[j] >= '0' && poffset_str[j] <= '9') || poffset_str[j] == ' ' || poffset_str[j] == ','))
|
if (! (isdigit(poffset_str[j]) || poffset_str[j] == ' ' || poffset_str[j] == ','))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1050,7 +1050,7 @@ static int setup_offsets()
|
||||||
if (offsets_by_version_enable)
|
if (offsets_by_version_enable)
|
||||||
{
|
{
|
||||||
bool server_is_ndb = strstr(server_version, "ndb") != NULL;
|
bool server_is_ndb = strstr(server_version, "ndb") != NULL;
|
||||||
for (size_t i=0; i < arr_size; i++)
|
for (size_t i = 0; i < arr_size; i++)
|
||||||
{
|
{
|
||||||
offset = thd_offsets_arr + i;
|
offset = thd_offsets_arr + i;
|
||||||
const char *version = offset->version;
|
const char *version = offset->version;
|
||||||
|
@ -1430,7 +1430,8 @@ static void json_socket_name_update(THD *thd, struct st_mysql_sys_var *var, void
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *str = str_val;
|
const char *str = str_val;
|
||||||
const size_t buff_len = array_elements( json_socket_name_buff) -1;
|
const size_t buff_len = array_elements(json_socket_name_buff) - 1;
|
||||||
|
|
||||||
// copy str to buffer only if str is not pointing to buff
|
// copy str to buffer only if str is not pointing to buff
|
||||||
if (NULL == str)
|
if (NULL == str)
|
||||||
{
|
{
|
||||||
|
@ -1438,11 +1439,12 @@ static void json_socket_name_update(THD *thd, struct st_mysql_sys_var *var, void
|
||||||
}
|
}
|
||||||
else if (str != json_socket_name_buff)
|
else if (str != json_socket_name_buff)
|
||||||
{
|
{
|
||||||
strncpy( json_socket_name_buff , str, buff_len);
|
strncpy(json_socket_name_buff, str, buff_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(json_socket_name_buff) == 0 && (mysqld_port > 0 || mysqld_unix_port)) // set default
|
if (strlen(json_socket_name_buff) == 0 && (mysqld_port > 0 || mysqld_unix_port)) // set default
|
||||||
{
|
{
|
||||||
const char *name_prefix = "/tmp/mysql.audit_";
|
const char *name_prefix = "/var/run/db-audit/mysql.audit_";
|
||||||
|
|
||||||
size_t indx = strlen(name_prefix); // count how much to move forward the buff
|
size_t indx = strlen(name_prefix); // count how much to move forward the buff
|
||||||
strncpy(json_socket_name_buff, name_prefix, buff_len);
|
strncpy(json_socket_name_buff, name_prefix, buff_len);
|
||||||
|
@ -1830,7 +1832,7 @@ static MYSQL_SYSVAR_STR(json_log_file, json_file_handler.m_io_dest,
|
||||||
NULL, NULL, "mysql-audit.json");
|
NULL, NULL, "mysql-audit.json");
|
||||||
static MYSQL_SYSVAR_LONG(json_file_bufsize, json_file_handler.m_bufsize,
|
static MYSQL_SYSVAR_LONG(json_file_bufsize, json_file_handler.m_bufsize,
|
||||||
PLUGIN_VAR_RQCMDARG,
|
PLUGIN_VAR_RQCMDARG,
|
||||||
"AUDIT plugin json log file buffer size. Buffer size in bytes (lager size may improve performance). 0 = use default size, 1 = no buffering. If changed during runtime need to perform a flush for the new value to take affect.",
|
"AUDIT plugin json log file buffer size. Buffer size in bytes (larger size may improve performance). 0 = use default size, 1 = no buffering. If changed during runtime need to perform a flush for the new value to take affect.",
|
||||||
NULL, NULL, 0, 1, 262144, 0);
|
NULL, NULL, 0, 1, 262144, 0);
|
||||||
|
|
||||||
static MYSQL_SYSVAR_UINT(json_file_sync, json_file_handler.m_sync_period,
|
static MYSQL_SYSVAR_UINT(json_file_sync, json_file_handler.m_sync_period,
|
||||||
|
@ -1922,7 +1924,7 @@ static MYSQL_SYSVAR_STR(password_masking_cmds, password_masking_cmds_string,
|
||||||
PLUGIN_VAR_RQCMDARG,
|
PLUGIN_VAR_RQCMDARG,
|
||||||
"AUDIT plugin commands to apply password masking regex to, comma separated",
|
"AUDIT plugin commands to apply password masking regex to, comma separated",
|
||||||
NULL, password_masking_cmds_string_update,
|
NULL, password_masking_cmds_string_update,
|
||||||
// set passowrd is recoreded as set_option
|
// set password is recorded as set_option
|
||||||
"CREATE_USER,GRANT,SET_OPTION,SLAVE_START,CREATE_SERVER,ALTER_SERVER,CHANGE_MASTER");
|
"CREATE_USER,GRANT,SET_OPTION,SLAVE_START,CREATE_SERVER,ALTER_SERVER,CHANGE_MASTER");
|
||||||
static MYSQL_SYSVAR_STR(whitelist_users, whitelist_users_string,
|
static MYSQL_SYSVAR_STR(whitelist_users, whitelist_users_string,
|
||||||
PLUGIN_VAR_RQCMDARG,
|
PLUGIN_VAR_RQCMDARG,
|
||||||
|
|
Loading…
Reference in New Issue