MDEV-258 audit plugin only see queries if general log is enabled
This commit is contained in:
parent
06365bf841
commit
d473199744
@ -8,9 +8,9 @@ select foobar;
|
|||||||
ERROR 42S22: Unknown column 'foobar' in 'field list'
|
ERROR 42S22: Unknown column 'foobar' in 'field list'
|
||||||
show status like 'audit_null%';
|
show status like 'audit_null%';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Audit_null_called 6
|
Audit_null_called 9
|
||||||
Audit_null_general_error 1
|
Audit_null_general_error 1
|
||||||
Audit_null_general_log 0
|
Audit_null_general_log 3
|
||||||
Audit_null_general_result 2
|
Audit_null_general_result 2
|
||||||
uninstall plugin audit_null;
|
uninstall plugin audit_null;
|
||||||
Warnings:
|
Warnings:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
if (!$ADT_NULL_SO) {
|
if (!$ADT_NULL_SO) {
|
||||||
skip No NULL_AUDIT plugin;
|
skip No NULL_AUDIT plugin;
|
||||||
}
|
}
|
||||||
@ -5,6 +6,7 @@ if (!$ADT_NULL_SO) {
|
|||||||
set @old_global_general_log=@@global.general_log;
|
set @old_global_general_log=@@global.general_log;
|
||||||
set global general_log=OFF;
|
set global general_log=OFF;
|
||||||
|
|
||||||
|
--disable_ps_protocol
|
||||||
install plugin audit_null soname 'adt_null';
|
install plugin audit_null soname 'adt_null';
|
||||||
|
|
||||||
select 1;
|
select 1;
|
||||||
@ -13,6 +15,7 @@ select foobar;
|
|||||||
show status like 'audit_null%';
|
show status like 'audit_null%';
|
||||||
|
|
||||||
uninstall plugin audit_null;
|
uninstall plugin audit_null;
|
||||||
|
--enable_ps_protocol
|
||||||
|
|
||||||
set global general_log=@old_global_general_log;
|
set global general_log=@old_global_general_log;
|
||||||
|
|
||||||
|
12
sql/log.cc
12
sql/log.cc
@ -1279,12 +1279,6 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command,
|
|||||||
|
|
||||||
DBUG_ASSERT(thd);
|
DBUG_ASSERT(thd);
|
||||||
|
|
||||||
lock_shared();
|
|
||||||
if (!opt_log)
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
user_host_len= make_user_name(thd, user_host_buff);
|
user_host_len= make_user_name(thd, user_host_buff);
|
||||||
|
|
||||||
current_time= my_hrtime();
|
current_time= my_hrtime();
|
||||||
@ -1295,6 +1289,9 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command,
|
|||||||
command_name[(uint) command].length,
|
command_name[(uint) command].length,
|
||||||
query, query_length);
|
query, query_length);
|
||||||
|
|
||||||
|
if (opt_log && log_command(thd, command))
|
||||||
|
{
|
||||||
|
lock_shared();
|
||||||
while (*current_handler)
|
while (*current_handler)
|
||||||
error|= (*current_handler++)->
|
error|= (*current_handler++)->
|
||||||
log_general(thd, current_time, user_host_buff,
|
log_general(thd, current_time, user_host_buff,
|
||||||
@ -1304,6 +1301,7 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command,
|
|||||||
query, query_length,
|
query, query_length,
|
||||||
thd->variables.character_set_client) || error;
|
thd->variables.character_set_client) || error;
|
||||||
unlock();
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -5333,7 +5331,7 @@ bool general_log_write(THD *thd, enum enum_server_command command,
|
|||||||
const char *query, uint query_length)
|
const char *query, uint query_length)
|
||||||
{
|
{
|
||||||
/* Write the message to the log if we want to log this king of commands */
|
/* Write the message to the log if we want to log this king of commands */
|
||||||
if (logger.log_command(thd, command))
|
if (logger.log_command(thd, command) || mysql_audit_general_enabled())
|
||||||
return logger.general_log_write(thd, command, query, query_length);
|
return logger.general_log_write(thd, command, query, query_length);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -53,6 +53,11 @@ static inline uint make_user_name(THD *thd, char *buf)
|
|||||||
sctx->ip ? sctx->ip : "", "]", NullS) - buf;
|
sctx->ip ? sctx->ip : "", "]", NullS) - buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool mysql_audit_general_enabled()
|
||||||
|
{
|
||||||
|
return mysql_global_audit_mask[0] & MYSQL_AUDIT_GENERAL_CLASSMASK;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Call audit plugins of GENERAL audit class, MYSQL_AUDIT_GENERAL_LOG subtype.
|
Call audit plugins of GENERAL audit class, MYSQL_AUDIT_GENERAL_LOG subtype.
|
||||||
|
|
||||||
@ -72,8 +77,7 @@ void mysql_audit_general_log(THD *thd, time_t time,
|
|||||||
const char *cmd, uint cmdlen,
|
const char *cmd, uint cmdlen,
|
||||||
const char *query, uint querylen)
|
const char *query, uint querylen)
|
||||||
{
|
{
|
||||||
#ifndef EMBEDDED_LIBRARY
|
if (mysql_audit_general_enabled())
|
||||||
if (mysql_global_audit_mask[0] & MYSQL_AUDIT_GENERAL_CLASSMASK)
|
|
||||||
{
|
{
|
||||||
CHARSET_INFO *clientcs= thd ? thd->variables.character_set_client
|
CHARSET_INFO *clientcs= thd ? thd->variables.character_set_client
|
||||||
: global_system_variables.character_set_client;
|
: global_system_variables.character_set_client;
|
||||||
@ -82,7 +86,6 @@ void mysql_audit_general_log(THD *thd, time_t time,
|
|||||||
0, time, user, userlen, cmd, cmdlen,
|
0, time, user, userlen, cmd, cmdlen,
|
||||||
query, querylen, clientcs, 0);
|
query, querylen, clientcs, 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,8 +104,7 @@ static inline
|
|||||||
void mysql_audit_general(THD *thd, uint event_subtype,
|
void mysql_audit_general(THD *thd, uint event_subtype,
|
||||||
int error_code, const char *msg)
|
int error_code, const char *msg)
|
||||||
{
|
{
|
||||||
#ifndef EMBEDDED_LIBRARY
|
if (mysql_audit_general_enabled())
|
||||||
if (mysql_global_audit_mask[0] & MYSQL_AUDIT_GENERAL_CLASSMASK)
|
|
||||||
{
|
{
|
||||||
time_t time= my_time(0);
|
time_t time= my_time(0);
|
||||||
uint msglen= msg ? strlen(msg) : 0;
|
uint msglen= msg ? strlen(msg) : 0;
|
||||||
@ -130,7 +132,6 @@ void mysql_audit_general(THD *thd, uint event_subtype,
|
|||||||
error_code, time, user, userlen, msg, msglen,
|
error_code, time, user, userlen, msg, msglen,
|
||||||
query.str(), query.length(), query.charset(), rows);
|
query.str(), query.length(), query.charset(), rows);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT(thd) mysql_audit_notify(\
|
#define MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT(thd) mysql_audit_notify(\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user