parent
6dae35653a
commit
e38bc05f0f
|
@ -1,66 +1,66 @@
|
||||||
Compiling instructions
|
Compiling instructions
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
Make sure you have installed the following packages:
|
Make sure you have installed the following packages:
|
||||||
|
|
||||||
autoconf
|
autoconf
|
||||||
automake
|
automake
|
||||||
gcc-c++
|
gcc-c++
|
||||||
|
|
||||||
To compile you will need to obtain the MySQL source code. MySQL source code is available at:
|
To compile you will need to obtain the MySQL source code. MySQL source code is available at:
|
||||||
|
|
||||||
http://dev.mysql.com/downloads/mysql/
|
http://dev.mysql.com/downloads/mysql/
|
||||||
|
|
||||||
==== MySQL 5.1 ======
|
==== MySQL 5.1 ======
|
||||||
|
|
||||||
Extract the MySQL source code in the root directory. For example:
|
Extract the MySQL source code in the root directory. For example:
|
||||||
|
|
||||||
unzip zip-sources/mysql-5.1.40.zip
|
unzip zip-sources/mysql-5.1.40.zip
|
||||||
|
|
||||||
|
|
||||||
Then run the following command:
|
Then run the following command:
|
||||||
|
|
||||||
cd mysql-5.1.40
|
cd mysql-5.1.40
|
||||||
CXX=gcc ./configure
|
CXX=gcc ./configure
|
||||||
cd include
|
cd include
|
||||||
make
|
make
|
||||||
|
|
||||||
Then goto top dir and run:
|
Then goto top dir and run:
|
||||||
|
|
||||||
chmod +x bootstrap.sh
|
chmod +x bootstrap.sh
|
||||||
./bootstrap.sh
|
./bootstrap.sh
|
||||||
|
|
||||||
This will create configure script. Then run:
|
This will create configure script. Then run:
|
||||||
|
|
||||||
CXX='gcc -static-libgcc' CC='gcc -static-libgcc' ./configure --with-mysql=mysql-5.1.40
|
CXX='gcc -static-libgcc' CC='gcc -static-libgcc' ./configure --with-mysql=mysql-5.1.40
|
||||||
|
|
||||||
|
|
||||||
==== MySQL 5.5 ======
|
==== MySQL 5.5 ======
|
||||||
|
|
||||||
Extract MySQL 5.5 source code
|
Extract MySQL 5.5 source code
|
||||||
|
|
||||||
go to mysql-src dir and run:
|
go to mysql-src dir and run:
|
||||||
|
|
||||||
cd mysql-5.5.8
|
cd mysql-5.5.8
|
||||||
cmake .
|
cmake .
|
||||||
make
|
make
|
||||||
|
|
||||||
back to working dir and run:
|
back to working dir and run:
|
||||||
|
|
||||||
CXX='gcc -static-libgcc' CC='gcc -static-libgcc' ./configure --with-mysql=mysql-5.5.8 --with-mysql-libservices=mysql-5.5.8/libservices/libmysqlservices.a
|
CXX='gcc -static-libgcc' CC='gcc -static-libgcc' ./configure --with-mysql=mysql-5.5.8 --with-mysql-libservices=mysql-5.5.8/libservices/libmysqlservices.a
|
||||||
make
|
make
|
||||||
|
|
||||||
==== Compiling with make =====
|
==== Compiling with make =====
|
||||||
|
|
||||||
Go to top source dir and run:
|
Go to top source dir and run:
|
||||||
|
|
||||||
make
|
make
|
||||||
|
|
||||||
Plugin will be compiled at:
|
Plugin will be compiled at:
|
||||||
|
|
||||||
src/.libs/libaudit_plugin.so
|
src/.libs/libaudit_plugin.so
|
||||||
|
|
||||||
Some documentation about configure command for mysql:
|
Some documentation about configure command for mysql:
|
||||||
|
|
||||||
http://dev.mysql.com/doc/refman/5.1/en/source-configuration-options.html
|
http://dev.mysql.com/doc/refman/5.1/en/source-configuration-options.html
|
||||||
|
|
||||||
|
|
|
@ -213,8 +213,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
static const size_t MAX_AUDIT_HANDLERS_NUM = 4;
|
static const size_t MAX_AUDIT_HANDLERS_NUM = 4;
|
||||||
static const size_t BSON_FILE_HANDLER = 1;
|
static const size_t JSON_FILE_HANDLER = 1;
|
||||||
static const size_t BSON_SOCKET_HANDLER = 3;
|
static const size_t JSON_SOCKET_HANDLER = 3;
|
||||||
|
|
||||||
static Audit_handler * m_audit_handler_list[];
|
static Audit_handler * m_audit_handler_list[];
|
||||||
|
|
||||||
|
@ -277,6 +277,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_enable(bool val);
|
void set_enable(bool val);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* will close and start the handler
|
||||||
|
*/
|
||||||
|
void flush();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will get relevant shared lock and call internal method of handler
|
* Will get relevant shared lock and call internal method of handler
|
||||||
|
|
|
@ -123,6 +123,22 @@ void Audit_handler::set_enable(bool val)
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Audit_handler::flush()
|
||||||
|
{
|
||||||
|
lock_exclusive();
|
||||||
|
if (!m_enabled) //if not running we don't flush
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//call the cleanup of the handler
|
||||||
|
handler_stop();
|
||||||
|
//call the startup of the handler
|
||||||
|
handler_start();
|
||||||
|
sql_print_information("%s Log flush complete.", AUDIT_LOG_PREFIX);
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void Audit_handler::log_audit(ThdSesData *pThdData)
|
void Audit_handler::log_audit(ThdSesData *pThdData)
|
||||||
{
|
{
|
||||||
lock_shared();
|
lock_shared();
|
||||||
|
|
|
@ -501,6 +501,7 @@ static Audit_json_formatter json_formatter;
|
||||||
|
|
||||||
//flags to hold if audit handlers are enabled
|
//flags to hold if audit handlers are enabled
|
||||||
static my_bool json_file_handler_enable = FALSE;
|
static my_bool json_file_handler_enable = FALSE;
|
||||||
|
static my_bool json_file_handler_flush = FALSE;
|
||||||
static my_bool json_socket_handler_enable = FALSE;
|
static my_bool json_socket_handler_enable = FALSE;
|
||||||
static my_bool uninstall_plugin_enable = FALSE;
|
static my_bool uninstall_plugin_enable = FALSE;
|
||||||
static my_bool validate_checksum_enable = FALSE;
|
static my_bool validate_checksum_enable = FALSE;
|
||||||
|
@ -1403,9 +1404,9 @@ static int audit_plugin_init(void *p)
|
||||||
//enable according to what we have in *file_handler_enable (this is set accordingly by sysvar functionality)
|
//enable according to what we have in *file_handler_enable (this is set accordingly by sysvar functionality)
|
||||||
json_file_handler.set_enable(json_file_handler_enable);
|
json_file_handler.set_enable(json_file_handler_enable);
|
||||||
json_socket_handler.set_enable(json_socket_handler_enable);
|
json_socket_handler.set_enable(json_socket_handler_enable);
|
||||||
Audit_handler::m_audit_handler_list[Audit_handler::BSON_FILE_HANDLER]
|
Audit_handler::m_audit_handler_list[Audit_handler::JSON_FILE_HANDLER]
|
||||||
= &json_file_handler;
|
= &json_file_handler;
|
||||||
Audit_handler::m_audit_handler_list[Audit_handler::BSON_SOCKET_HANDLER]
|
Audit_handler::m_audit_handler_list[Audit_handler::JSON_SOCKET_HANDLER]
|
||||||
= &json_socket_handler;
|
= &json_socket_handler;
|
||||||
|
|
||||||
//hot patch functions
|
//hot patch functions
|
||||||
|
@ -1600,6 +1601,20 @@ static void json_log_file_enable(THD *thd, struct st_mysql_sys_var *var,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void json_log_file_flush(THD *thd, struct st_mysql_sys_var *var,
|
||||||
|
void *tgt, const void *save)
|
||||||
|
{
|
||||||
|
//always set to false. as we just flush if set to true and leave at 0
|
||||||
|
json_file_handler_flush = FALSE;
|
||||||
|
my_bool val = *(my_bool *) save ? TRUE : FALSE;
|
||||||
|
if(val && json_file_handler.is_init())
|
||||||
|
{
|
||||||
|
json_file_handler.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void json_log_socket_enable(THD *thd, struct st_mysql_sys_var *var,
|
static void json_log_socket_enable(THD *thd, struct st_mysql_sys_var *var,
|
||||||
void *tgt, const void *save)
|
void *tgt, const void *save)
|
||||||
|
@ -1651,6 +1666,10 @@ static MYSQL_SYSVAR_UINT(json_file_sync, json_file_handler.m_sync_period,
|
||||||
static MYSQL_SYSVAR_BOOL(json_file, json_file_handler_enable,
|
static MYSQL_SYSVAR_BOOL(json_file, json_file_handler_enable,
|
||||||
PLUGIN_VAR_RQCMDARG,
|
PLUGIN_VAR_RQCMDARG,
|
||||||
"AUDIT plugin json log file Enable|Disable", NULL, json_log_file_enable, 0);
|
"AUDIT plugin json log file Enable|Disable", NULL, json_log_file_enable, 0);
|
||||||
|
|
||||||
|
static MYSQL_SYSVAR_BOOL(json_file_flush, json_file_handler_flush,
|
||||||
|
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_NOCMDOPT,
|
||||||
|
"AUDIT plugin json log file flush. Set to ON to perform a flush of the log.", NULL, json_log_file_flush, 0);
|
||||||
|
|
||||||
|
|
||||||
static MYSQL_SYSVAR_STR(json_socket_name, json_socket_handler.m_sockname,
|
static MYSQL_SYSVAR_STR(json_socket_name, json_socket_handler.m_sockname,
|
||||||
|
@ -1706,6 +1725,7 @@ static struct st_mysql_sys_var* audit_system_variables[] =
|
||||||
MYSQL_SYSVAR(json_log_file),
|
MYSQL_SYSVAR(json_log_file),
|
||||||
MYSQL_SYSVAR(json_file_sync),
|
MYSQL_SYSVAR(json_file_sync),
|
||||||
MYSQL_SYSVAR(json_file),
|
MYSQL_SYSVAR(json_file),
|
||||||
|
MYSQL_SYSVAR(json_file_flush),
|
||||||
MYSQL_SYSVAR(uninstall_plugin),
|
MYSQL_SYSVAR(uninstall_plugin),
|
||||||
MYSQL_SYSVAR(validate_checksum),
|
MYSQL_SYSVAR(validate_checksum),
|
||||||
MYSQL_SYSVAR(json_socket_name),
|
MYSQL_SYSVAR(json_socket_name),
|
||||||
|
|
Loading…
Reference in New Issue