From 45f2e0a7aad762af94eedd70b6fc0b91ae8e3376 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 15 Dec 2009 23:52:47 +0400 Subject: Backport from 6.0-codebase. WL#3771 "Audit Plugin Interface" Implement new plug-in type - AUDIT New plug-in: audit_null simply increments counter for how many times it was called. include/Makefile.am: wl3771 add new headers to distribution include/mysql/plugin.h: wl3771 define new AUDIT plugin type Split out fulltext plugin type into its own header include/mysql/plugin.h.pp: wl3771 no real API change, just re-arranged some code include/mysql/plugin_audit.h: wl3771 pluggable audit interface include/mysql/plugin_ftparser.h: wl3771 Split out fulltext plugin type into its own header libmysqld/CMakeLists.txt: wl3771 add sql_audit.cc to build libmysqld/Makefile.am: wl3771 add sql_audit.cc to build plugin/audit_null: wl3771 an example plugin for testing pluggable audit interface plugin/audit_null/Makefile.am: wl3771 an example plugin for testing pluggable audit interface plugin/audit_null/audit_null.c: wl3771 an example plugin for testing pluggable audit interface plugin/audit_null/plug.in: wl3771 an example plugin for testing pluggable audit interface sql/CMakeLists.txt: wl3771 add sql_audit.cc to build sql/Makefile.am: wl3771 add sql_audit.cc to build sql/event_queue.cc: wl3771 release audit resources before waiting sql/log.cc: wl3771 add general audit call for log sql/mysqld.cc: wl3771 add audit initialize/finalize add general audit call for error sql/sql_audit.cc: wl3771 pluggable audit interface implementation sql/sql_audit.h: wl3771 pluggable audit interface implementation sql/sql_class.cc: wl3771 add thd audit init/deinit calls sql/sql_class.h: wl3771 add required data structures for audit to THD sql/sql_connect.cc: wl3771 release audit resources before waiting sql/sql_insert.cc: wl3771 release audit plugins before waiting sql/sql_parse.cc: wl3771 add general audit call for results sql/sql_plugin.cc: wl3771 add declarations for audit plugin type --- sql/log.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sql/log.cc') diff --git a/sql/log.cc b/sql/log.cc index f488dda1e56..ce309a0d1b2 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -28,6 +28,7 @@ #include "sql_repl.h" #include "rpl_filter.h" #include "rpl_rli.h" +#include "sql_audit.h" #include #include @@ -1088,6 +1089,14 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command, user_host_buff; current_time= my_time(0); + + mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_LOG, 0, current_time, + user_host_buff, user_host_len, + command_name[(uint) command].str, + command_name[(uint) command].length, + query, query_length, + thd->variables.character_set_client,0); + while (*current_handler) error|= (*current_handler++)-> log_general(thd, current_time, user_host_buff, -- cgit v1.2.1 From 9130563708cbdbb488e5361af79eb9f4b9dab0ea Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 16 Dec 2009 15:56:36 +0400 Subject: Backport from 6.0-codebase. Bug #36098 Audit plugin (wl 3771) feature disabled in 6.0 avoid recusrive locking of LOCK_plugin include/mysql/plugin_audit.h: fix incorrect version sql/log.cc: move the common code to a shared header sql/mysqld.cc: restore the deleted functionality sql/set_var.cc: remove unused parameter sql/sql_audit.h: two inline convenience functions sql/sql_parse.cc: use a simplified convenience call sql/sql_plugin.cc: unlock LOCK_plugin for plugin->init() call, add missing OOM check, issue "unknown variable" error in find_sys_var, not down the stack --- sql/log.cc | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'sql/log.cc') diff --git a/sql/log.cc b/sql/log.cc index ce309a0d1b2..267ca90db29 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -43,7 +43,6 @@ /* max size of the log message */ #define MAX_LOG_BUFFER_SIZE 1024 -#define MAX_USER_HOST_SIZE 512 #define MAX_TIME_SIZE 32 #define MY_OFF_T_UNDEF (~(my_off_t)0UL) @@ -1069,7 +1068,6 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command, bool error= FALSE; Log_event_handler **current_handler= general_log_handler_list; char user_host_buff[MAX_USER_HOST_SIZE + 1]; - Security_context *sctx= thd->security_ctx; uint user_host_len= 0; time_t current_time; @@ -1081,21 +1079,15 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command, unlock(); return 0; } - user_host_len= strxnmov(user_host_buff, MAX_USER_HOST_SIZE, - sctx->priv_user ? sctx->priv_user : "", "[", - sctx->user ? sctx->user : "", "] @ ", - sctx->host ? sctx->host : "", " [", - sctx->ip ? sctx->ip : "", "]", NullS) - - user_host_buff; + user_host_len= make_user_name(thd, user_host_buff); current_time= my_time(0); - mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_LOG, 0, current_time, - user_host_buff, user_host_len, - command_name[(uint) command].str, - command_name[(uint) command].length, - query, query_length, - thd->variables.character_set_client,0); + mysql_audit_general_log(thd, current_time, + user_host_buff, user_host_len, + command_name[(uint) command].str, + command_name[(uint) command].length, + query, query_length); while (*current_handler) error|= (*current_handler++)-> -- cgit v1.2.1