Add offsets for MySQL 5.5.56.

Add offsets for MariaDB 5.5.56 and 10.1.23.
Add write timeout for sockets: audit_json_write_timeout variable.
pull/179/head
Aharon Robbins 2017-05-09 17:32:06 +03:00
parent cd9400da0e
commit f4a3411ccd
4 changed files with 51 additions and 2 deletions

View File

@ -899,7 +899,7 @@ class Audit_socket_handler: public Audit_io_handler {
public:
Audit_socket_handler() :
m_vio(NULL), m_connect_timeout(1)
m_vio(NULL), m_connect_timeout(1), m_write_timeout(0)
{
m_io_type = "socket";
}
@ -922,6 +922,8 @@ public:
void close();
int open(const char *io_dest, bool log_errors);
unsigned long m_write_timeout; // write timeout in microseconds
protected:
// override default assignment and copy to protect against creating additional instances
Audit_socket_handler & operator=(const Audit_socket_handler&);

View File

@ -27,6 +27,11 @@
#include <unistd.h>
#include "static_assert.h"
#if MYSQL_VERSION_ID < 50600
// for 5.5 and 5.1
void vio_timeout(Vio *vio,uint which, uint timeout);
#endif
// utility macro to log also with a date as a prefix
// FIXME: This is no longer used. Remove?
#define log_with_date(f, ...) do {\
@ -473,6 +478,21 @@ int Audit_socket_handler::open(const char *io_dest, bool log_errors)
close();
return -2;
}
if (m_write_timeout > 0)
{
int timeout = m_write_timeout / 1000; // milliseconds to seconds, integer dvision
if (timeout == 0)
{
timeout = 1; // round up to 1 second
}
// we don't check the result of this call since in earlier
// versions it returns void
//
// 1 as the 2nd argument means write timeout
vio_timeout((Vio*)m_vio, 1, timeout);
}
return 0;
}
@ -848,7 +868,12 @@ ssize_t Audit_json_formatter::event_format(ThdSesData *pThdData, IWriter *writer
(strcasestr(cmd, "select") != NULL && thd_row_count_func(thd) > 0))
{
// m_row_count_func will be -1 for most selects but can be > 0, e.g. select into file
rows = thd_row_count_func(thd);
// thd_row_count_func() returns signed valiue. Don't assign it to rows directly.
longlong row_count = thd_row_count_func(thd);
if (row_count > 0)
{
rows = row_count;
}
}
else
{

View File

@ -22,6 +22,8 @@
const ThdOffsets thd_offsets_arr[] =
{
/* +++ MYSQL 64 OFFSETS GO HERE +++ */
//offsets for: /mysqlrpm/5.5.56/usr/sbin/mysqld (5.5.56)
{"5.5.56","f5502b02ff60921421b535fbae6f582b", 6144, 6192, 3816, 4312, 88, 2592, 96, 0, 32, 104, 120, 6264, 4192, 0, 0, 0, 512, 0, 0, 6008, 6032, 6016},
//offsets for: /mysqlrpm/5.5.55/usr/sbin/mysqld (5.5.55)
{"5.5.55","863e03c6cdf67da35a98fa312de1f23b", 6144, 6192, 3816, 4312, 88, 2592, 96, 0, 32, 104, 120, 6264, 4192, 0, 0, 0, 512, 0, 0, 6008, 6032, 6016},
//offsets for: /mysqlrpm/5.7.18/usr/sbin/mysqld (5.7.18)
@ -439,6 +441,8 @@ const ThdOffsets thd_offsets_arr[] =
const ThdOffsets thd_offsets_arr[] =
{
/* +++ MYSQL 32 OFFSETS GO HERE +++ */
//offsets for: /mysqlrpm/5.5.56/usr/sbin/mysqld (5.5.56)
{"5.5.56","d6e5ef546ee6b8b592b82e2d28d36534", 3872, 3900, 2368, 2748, 44, 1656, 60, 0, 20, 64, 60, 3956, 2680, 0, 0, 0, 328, 0, 0, 3780, 3804, 3788},
//offsets for: /mysqlrpm/5.5.55/usr/sbin/mysqld (5.5.55)
{"5.5.55","9066eaea34ffce6ef0e0fa31c6554bf9", 3872, 3900, 2368, 2748, 44, 1656, 60, 0, 20, 64, 60, 3956, 2680, 0, 0, 0, 328, 0, 0, 3780, 3804, 3788},
//offsets for: /mysqlrpm/5.7.18/usr/sbin/mysqld (5.7.18)
@ -854,6 +858,10 @@ const ThdOffsets thd_offsets_arr[] =
const ThdOffsets thd_offsets_arr[] =
{
/* +++ MARIADB 64 OFFSETS GO HERE +++ */
//offsets for: /mariadb/10.1.23/bin/mysqld (10.1.23-MariaDB)
{"10.1.23-MariaDB","d7709a85d830039c438155fd2f87bf2e", 13648, 13712, 6424, 8032, 88, 2976, 8, 0, 16, 24, 152, 13804, 7800, 3136, 3144, 3148, 568, 0, 0, 13024, 13048, 13032},
//offsets for: /mariadb/5.5.56/bin/mysqld (5.5.56-MariaDB)
{"5.5.56-MariaDB","c411132cabf60fa72684f7adba29de12", 12032, 12096, 5800, 6904, 88, 2920, 8, 0, 16, 24, 152, 12168, 6784, 0, 0, 0, 536, 0, 0, 11888, 11912, 11896},
//offsets for: /mariadb/5.5.55/bin/mysqld (5.5.55-MariaDB)
{"5.5.55-MariaDB","eeca0909ae742f4670cb1edd0a6263df", 12032, 12096, 5800, 6904, 88, 2920, 8, 0, 16, 24, 152, 12168, 6784, 0, 0, 0, 536, 0, 0, 11888, 11912, 11896},
//offsets for: /mariadb/10.0.30/bin/mysqld (10.0.30-MariaDB)
@ -1019,6 +1027,10 @@ const ThdOffsets thd_offsets_arr[] =
const ThdOffsets thd_offsets_arr[] =
{
/* +++ MARIADB 32 OFFSETS GO HERE +++ */
//offsets for: /mariadb/10.1.23/bin/mysqld (10.1.23-MariaDB)
{"10.1.23-MariaDB","52b5e3c6545f67b346240cba2c7f0e14", 8504, 8540, 3848, 5308, 44, 1896, 4, 0, 8, 12, 84, 8616, 5176, 2604, 2608, 2612, 356, 0, 0, 8028, 8052, 8036},
//offsets for: /mariadb/5.5.56/bin/mysqld (5.5.56-MariaDB)
{"5.5.56-MariaDB","abd2635dee409c735021164498ebd5d8", 7276, 7312, 3460, 4468, 44, 1856, 4, 0, 8, 12, 84, 7372, 4400, 0, 0, 0, 340, 0, 0, 7176, 7200, 7184},
//offsets for: /mariadb/5.5.55/bin/mysqld (5.5.55-MariaDB)
{"5.5.55-MariaDB","a27a9e556367c414db72ef32da7c2626", 7276, 7312, 3460, 4468, 44, 1856, 4, 0, 8, 12, 84, 7372, 4400, 0, 0, 0, 340, 0, 0, 7176, 7200, 7184},
//offsets for: /mariadb/10.1.22/bin/mysqld (10.1.22-MariaDB)

View File

@ -120,6 +120,9 @@ static char json_socket_name_buff[1024] = {0};
// Define default port in case user configured out port and socket in my.cnf (bug 1151389)
#define MYSQL_DEFAULT_PORT 3306
// Default value for write timeout in microseconds
#define DEFAULT_WRITE_TIMEOUT 1000 // milliseconds --> 1 second - MySQL API uses seconds
/**
* The trampoline functions we use. Will be set to point to allocated mem.
*/
@ -2343,6 +2346,12 @@ static MYSQL_SYSVAR_STR(json_socket_name, json_socket_handler.m_io_dest,
"AUDIT plugin json log unix socket name",
NULL, json_socket_name_update, "");
static MYSQL_SYSVAR_ULONG(json_socket_write_timeout, json_socket_handler.m_write_timeout,
PLUGIN_VAR_RQCMDARG,
"AUDIT plugin json socket write timeout, in milliseconds (currently must be at least 1000)",
NULL, NULL, DEFAULT_WRITE_TIMEOUT,
0, UINT_MAX32, 0);
static MYSQL_SYSVAR_STR(offsets, offsets_string,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC,
"AUDIT plugin offsets. Comma separated list of offsets to use for extracting data",
@ -2476,6 +2485,7 @@ static struct st_mysql_sys_var* audit_system_variables[] =
MYSQL_SYSVAR(peer_is_uds),
MYSQL_SYSVAR(peer_info),
MYSQL_SYSVAR(before_after),
MYSQL_SYSVAR(json_socket_write_timeout),
NULL
};