diff --git a/config/ac_mysql.m4 b/config/ac_mysql.m4 index 6852378..aca1fd2 100644 --- a/config/ac_mysql.m4 +++ b/config/ac_mysql.m4 @@ -33,7 +33,7 @@ dnl dnl table_id.h included from table.h included by mysql_inc.h is dnl in libbinlogevents/include. AC_DEFINE([MYSQL_SRC], [1], [Source directory for MySQL]) - MYSQL_INC="-I$withval/sql -I$withval/libbinlogevents/export -I$withval/libbinlogevents/include -I$withval/include -I$withval/regex -I$withval -I$withval/extra/rapidjson/include" + MYSQL_INC="-I$withval/sql -I$withval/libbinlogevents/export -I$withval/libbinlogevents/include -I$withval/include -I$withval/regex -I$withval -I$withval/extra/rapidjson/include -I$withval/wsrep-lib/include -I$withval/wsrep-lib/wsrep-API/v26" AC_MSG_RESULT(["$withval"]) ], [ diff --git a/configure.ac b/configure.ac index 2a98855..a988496 100644 --- a/configure.ac +++ b/configure.ac @@ -137,6 +137,19 @@ AC_SUBST(CPPFLAGS) AC_SUBST(CXXLAGS) AC_SUBST(CLAGS) +#mariadb-visibility section start +AC_ARG_ENABLE(mariadb-visibility, +[ --enable-mariadb-visibility, Enable symbol visibility for Mariadb, default:no ], +[case "${enableval}" in + yes) mariadb_visibility=yes ;; + no) mariadb_visibility=no ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-mariadb-visibility]) ;; +esac], +[ mariadb_visibility=no ] +) +AC_MSG_RESULT($mariadb_visibility) +AM_CONDITIONAL([ENABLE_MARIADB_SYMBOLS], [test "x$mariadb_visibility" = "xyes"]) +#mariadb-visibility section end AC_CONFIG_FILES([Makefile src/Makefile diff --git a/include/audit_handler.h b/include/audit_handler.h index acd0792..4f3b0cd 100644 --- a/include/audit_handler.h +++ b/include/audit_handler.h @@ -252,8 +252,14 @@ public: { if (! Audit_formatter::thd_offsets.db) // no offsets use compiled in header { -#if defined(MARIADB_BASE_VERSION) || MYSQL_VERSION_ID < 50709 +#if !defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID < 50709 return thd->db; +#elif defined(MARIADB_BASE_VERSION) +#if MYSQL_VERSION_ID >= 100504 + return thd->db.str; +#else + return thd->db; +#endif #else return thd->db().str; #endif @@ -395,7 +401,7 @@ public: } #endif - static inline const char * pfs_connect_attrs(void * pfs) + static inline const char * pfs_connect_attrs(const void * pfs) { if (! Audit_formatter::thd_offsets.pfs_connect_attrs || pfs == NULL) { @@ -407,7 +413,7 @@ public: return *pfs_pointer; } - static inline uint pfs_connect_attrs_length(void * pfs) + static inline uint pfs_connect_attrs_length(const void * pfs) { if (! Audit_formatter::thd_offsets.pfs_connect_attrs_length || pfs == NULL) { @@ -417,7 +423,7 @@ public: return *(uint *) (((unsigned char *) pfs) + Audit_formatter::thd_offsets.pfs_connect_attrs_length); } -static inline const CHARSET_INFO * pfs_connect_attrs_cs(void * pfs) +static inline const CHARSET_INFO * pfs_connect_attrs_cs(const void * pfs) { if (! Audit_formatter::thd_offsets.pfs_connect_attrs_cs || pfs == NULL) { @@ -572,12 +578,20 @@ static inline const CHARSET_INFO * pfs_connect_attrs_cs(void * pfs) // and it may return an invalid value for view_db static inline const char *table_get_db_name(TABLE_LIST *table) { +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100504 + return table->db.str; +#else return table->db; +#endif } static inline const char *table_get_name(TABLE_LIST *table) { +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100504 + return table->table_name.str; +#else return table->table_name; +#endif } static inline bool table_is_view(TABLE_LIST *table) diff --git a/include/mysql_inc.h b/include/mysql_inc.h index febbab8..510304a 100644 --- a/include/mysql_inc.h +++ b/include/mysql_inc.h @@ -31,13 +31,21 @@ #include #endif +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100504 +// From MariaDB 10.5 we include macro definitions for items like MY_GNUC_PREREQ +#include +#include +#endif + #include #include + #if !defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 80019 #include #include #include #endif + #if !defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 80000 using my_bool = bool; #if MYSQL_VERSION_ID < 80012 @@ -50,9 +58,12 @@ using my_bool = bool; #include #include #else +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID < 100504 #include +#endif typedef struct st_mysql_sys_var SYS_VAR; #endif + #include #include #include @@ -103,10 +114,11 @@ extern "C" char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int #endif #endif -//Define HAVE_SESS_CONNECT_ATTRS. We define it for mysql 5.6 and above -#if (!defined(MARIADB_BASE_VERSION)) && MYSQL_VERSION_ID >= 50600 +//Define HAVE_SESS_CONNECT_ATTRS. We define it for mysql 5.6 and above and MariaDB 10.0 and above +#if MYSQL_VERSION_ID >= 50600 #define HAVE_SESS_CONNECT_ATTRS 1 #endif +#include #if defined(MARIADB_BASE_VERSION) || MYSQL_VERSION_ID < 80000 @@ -169,7 +181,7 @@ static inline bool vio_socket_connect(MYSQL_VIO vio, struct sockaddr *addr, sock if (_vio_socket_connect_80020) return _vio_socket_connect_80020(vio, addr, len, false, timeout, nullptr); return true; } -static inline bool init() +static inline bool init_vio_socket_connect() { void* handle = dlopen(NULL, RTLD_LAZY); if (!handle) @@ -182,6 +194,57 @@ static inline bool init() } #endif #endif + +/*********************************************/ +/* PFS_thread::get_current_thread */ +/*********************************************/ +#if defined(HAVE_SESS_CONNECT_ATTRS) && defined(MARIADB_BASE_VERSION) +typedef const ::PFS_thread* (*pfs_thread_t)(); +extern pfs_thread_t _pfs_thread_get_current_thread; +extern PSI_v1* _psi_interface; +namespace PFS_thread { +static inline const ::PFS_thread* get_current_thread() +{ + // Try PFS_thread and PSI_hook when MariaDB + if (_pfs_thread_get_current_thread) return _pfs_thread_get_current_thread(); + if (_psi_interface) return (::PFS_thread*)_psi_interface->get_thread(); + return NULL; +} +} +static inline bool init_PFS_thread_get_current_thread() +{ + // obtain the PFS_thread::get_current_thread() address if it is exported + void* handle = dlopen(NULL, RTLD_LAZY); + if (handle) { + _pfs_thread_get_current_thread = (pfs_thread_t)dlsym(handle, "_ZN10PFS_thread18get_current_threadEv"); + dlclose(handle); + } + // obtain the PSI interface address + if (PSI_hook) + _psi_interface = (PSI_v1*)PSI_hook->get_interface(PSI_VERSION_1); + if (!_pfs_thread_get_current_thread && !_psi_interface) + sql_print_information("Failed to initialize Performance Schema. 'osuser' and 'appname' will not be avalilable."); + return true; +} +#elif defined(HAVE_SESS_CONNECT_ATTRS) +namespace PFS_thread { +static inline const ::PFS_thread* get_current_thread() +{ + // Use PFS_thread when MySQL + return ::PFS_thread::get_current_thread(); +} +} +#endif +static inline bool init() +{ +#if !defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 80000 + return init_vio_socket_connect(); +#elif defined(HAVE_SESS_CONNECT_ATTRS) && defined(MARIADB_BASE_VERSION) + return init_PFS_thread_get_current_thread(); +#else + return true; +#endif +} } #endif // MYSQL_INCL_H diff --git a/src/Makefile.am b/src/Makefile.am index b1ad255..97e02d1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,11 @@ pkgplugin_LTLIBRARIES = libaudit_plugin.la libaudit_plugin_la_DEPENDENCIESADD = pcre -libaudit_plugin_la_LDFLAGS = -module -Wl,--version-script=MySQLPlugin.map +if ENABLE_MARIADB_SYMBOLS +libaudit_plugin_la_LDFLAGS = -module -Wl,--version-script=MariadbPlugin.map +else +libaudit_plugin_la_LDFLAGS = -module -Wl,--version-script=MySQLPlugin.map +endif libaudit_plugin_la_SOURCES = hot_patch.cc audit_offsets.cc audit_plugin.cc audit_handler.cc md5.cc diff --git a/src/MariadbPlugin.map b/src/MariadbPlugin.map new file mode 100644 index 0000000..e4d2ee9 --- /dev/null +++ b/src/MariadbPlugin.map @@ -0,0 +1,13 @@ +{ + global: + _mysql_plugin_declarations_; + _mysql_plugin_interface_version_; + _mysql_sizeof_struct_st_plugin_; + _maria_plugin_declarations_; + _maria_plugin_interface_version_; + _maria_sizeof_struct_st_plugin_; + audit_plugin_so_init; + thd_alloc_service; + + local: *; +}; diff --git a/src/audit_handler.cc b/src/audit_handler.cc index f6a9b3d..edf90d4 100644 --- a/src/audit_handler.cc +++ b/src/audit_handler.cc @@ -759,9 +759,7 @@ static const char *replace_in_string(THD *thd, } #ifdef HAVE_SESS_CONNECT_ATTRS -#include - -#if defined(MARIADB_BASE_VERSION) || MYSQL_VERSION_ID < 80000 +#if MYSQL_VERSION_ID < 80000 //declare the function: parse_length_encoded_string from: storage/perfschema/table_session_connect.cc bool parse_length_encoded_string(const char **ptr, char *dest, uint dest_size, @@ -772,7 +770,7 @@ bool parse_length_encoded_string(const char **ptr, uint nchars_max); #else -// the function is not exported in MySQL 8 +// the function is not exported in MySQL 8 and neither in MariaDB /** Take a length encoded string @@ -801,8 +799,6 @@ static bool parse_length_encoded_string( ) { ulong copy_length, data_length; - const char *well_formed_error_pos = NULL, *cannot_convert_error_pos = NULL, - *from_end_pos = NULL; copy_length = data_length = net_field_length((uchar **)ptr); @@ -815,10 +811,35 @@ static bool parse_length_encoded_string( return true; } +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100504 + String_copier copier; + copy_length = copier.well_formed_copy( + &my_charset_utf8mb3_bin + , dest + , dest_size + , from_cs + , *ptr + , data_length + , nchars_max + ); +#elif defined(MARIADB_BASE_VERSION) && ( MYSQL_VERSION_ID >= 100104 && MYSQL_VERSION_ID < 100504 ) + String_copier copier; + copy_length = copier.well_formed_copy( + &my_charset_utf8_bin + , dest + , dest_size + , from_cs + , *ptr + , data_length + , nchars_max + ); +#else /* TODO: Migrate the data itself to UTF8MB4, this is still UTF8MB3 printed in a UTF8MB4 column. */ + const char *well_formed_error_pos = NULL, *cannot_convert_error_pos = NULL, + *from_end_pos = NULL; copy_length = well_formed_copy_nchars( &my_charset_utf8_bin , dest @@ -831,6 +852,7 @@ static bool parse_length_encoded_string( , &cannot_convert_error_pos , &from_end_pos ); + #endif *copied_len = copy_length; (*ptr) += data_length; @@ -843,7 +865,9 @@ static bool parse_length_encoded_string( */ static void log_session_connect_attrs(yajl_gen gen, THD *thd) { - PFS_thread * pfs = PFS_thread::get_current_thread(); + const PFS_thread * pfs = compat::PFS_thread::get_current_thread(); + if (!pfs) + return; const char * connect_attrs = Audit_formatter::pfs_connect_attrs(pfs); const uint connect_attrs_length = Audit_formatter::pfs_connect_attrs_length(pfs); const CHARSET_INFO *connect_attrs_cs = Audit_formatter::pfs_connect_attrs_cs(pfs); @@ -1058,7 +1082,11 @@ ssize_t Audit_json_formatter::event_format(ThdSesData *pThdData, IWriter *writer uint errors = 0; size_t len = copy_and_convert(to, to_amount, +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100504 + &my_charset_utf8mb3_general_ci, +#else &my_charset_utf8_general_ci, +#endif query, qlen, col_connection, & errors); diff --git a/src/audit_offsets.cc b/src/audit_offsets.cc index e99a23d..42f99d7 100644 --- a/src/audit_offsets.cc +++ b/src/audit_offsets.cc @@ -25,6 +25,10 @@ const ThdOffsets thd_offsets_arr[] = { /* +++ PERCONA 64 OFFSETS GO HERE +++ */ + //offsets for: /perconarpm/usr/sbin/mysqld (5.7.33-36) + {"5.7.33-36","732e230fdc4153d8dd2aa0acaf715c6e", 8360, 8424, 3928, 5088, 456, 360, 0, 32, 64, 160, 536, 8556, 4656, 3648, 3656, 3660, 6560, 2088, 8, 7592, 7632, 7616, 14328, 148, 672}, + //offsets for: /perconarpm/usr/sbin/mysqld (5.7.32-35) + {"5.7.32-35","02ad9d380df8a36c137ec75adbf97c71", 8360, 8424, 3928, 5088, 456, 360, 0, 32, 64, 160, 536, 8556, 4656, 3648, 3656, 3660, 6560, 2088, 8, 7592, 7632, 7616, 14328, 148, 672}, //offsets for: /perconarpm/usr/sbin/mysqld (5.7.31-34) {"5.7.31-34","6aacc4359af48e07145187bd8b590a43", 8360, 8424, 3928, 5088, 456, 360, 0, 32, 64, 160, 536, 8556, 4656, 3648, 3656, 3660, 6560, 2088, 8, 7592, 7632, 7616, 14328, 148, 672}, //offsets for: /perconarpm/usr/sbin/mysqld (5.7.30-33) @@ -65,33 +69,39 @@ const ThdOffsets thd_offsets_arr[] = const ThdOffsets thd_offsets_arr[] = { /* +++ MYSQL 64 OFFSETS GO HERE +++ */ + //offsets for: /mysqlrpm/5.6.51/usr/sbin/mysqld (5.6.51) + {"5.6.51","536e5cb3ca8ccf249ea2da764c1e19f8", 7000, 7048, 4008, 4528, 72, 2704, 96, 0, 32, 104, 136, 7136, 4400, 2800, 2808, 2812, 536, 0, 0, 6368, 6392, 6376, 13056, 548, 516}, + //offsets for: /mysqlrpm/5.7.33/usr/sbin/mysqld (5.7.33) + {"5.7.33","86c141ac1d66aad306e37da643a20902", 7824, 7872, 3632, 4792, 456, 360, 0, 32, 64, 160, 536, 7988, 4360, 3648, 3656, 3660, 6072, 2072, 8, 7056, 7096, 7080, 13472, 148, 672}, + //offsets for: /mysqlrpm/8.0.23/usr/sbin/mysqld (8.0.23) + {"8.0.23","01aa9b0074f1ed43fe5d4962ba505c5c", 8536, 8584, 4056, 5528, 520, 0, 0, 32, 64, 160, 600, 8700, 5160, 4208, 4216, 4220, 6832, 1616, 32, 7792, 7832, 7816, 11624, 140, 664, 320}, //offsets for: /mysqlrpm/5.6.50/usr/sbin/mysqld (5.6.50) {"5.6.50","7f4faea987f15f3f81235ec4b38d1f5e", 7000, 7048, 4008, 4528, 72, 2704, 96, 0, 32, 104, 136, 7136, 4400, 2800, 2808, 2812, 536, 0, 0, 6368, 6392, 6376, 13056, 548, 516}, //offsets for: /mysqlrpm/5.7.32/usr/sbin/mysqld (5.7.32) {"5.7.32","12356fea007b09247c10d0efb34b0a59", 7824, 7872, 3632, 4792, 456, 360, 0, 32, 64, 160, 536, 7988, 4360, 3648, 3656, 3660, 6072, 2072, 8, 7056, 7096, 7080, 13472, 148, 672}, - //offsets for: ./mysqld-8.0.22 (8.0.22) + //offsets for: /mysqlrpm/8.0.22/usr/sbin/mysqld (8.0.22) {"8.0.22","d33b22129504158cacdad5664d21a4a5", 8672, 8720, 4056, 5664, 520, 0, 0, 32, 64, 160, 600, 8836, 5296, 4208, 4216, 4220, 6968, 1600, 32, 7928, 7968, 7952, 11760, 140, 664, 320}, - //offsets for: ./mysqld-8.0.21 (8.0.21) + //offsets for: /mysqlrpm/8.0.21/usr/sbin/mysqld (8.0.21) {"8.0.21","93b401ddbe0484ac527524e8da26d02f", 8656, 8704, 4040, 5648, 520, 0, 0, 32, 64, 160, 600, 8820, 5280, 4200, 4208, 4212, 6952, 1592, 40, 7912, 7952, 7936, 11744, 140, 664, 328}, - //offsets for: ./mysqld-8.0.20 (8.0.20) + //offsets for: /mysqlrpm/8.0.20/usr/sbin/mysqld (8.0.20) {"8.0.20","d0cb4bd30cd1a325c24313d8edd4530b", 8656, 8704, 4040, 5648, 520, 0, 0, 32, 64, 160, 600, 8820, 5280, 4200, 4208, 4212, 6952, 1544, 40, 7912, 7952, 7936, 11744, 140, 664, 328}, - //offsets for: ./mysqld-8.0.19 (8.0.19) + //offsets for: /mysqlrpm/8.0.19/usr/sbin/mysqld (8.0.19) {"8.0.19","3e06dfd8490afdcd0075ef1395891ae8", 8632, 8680, 4016, 5624, 520, 0, 0, 32, 64, 160, 600, 8796, 5256, 4200, 4208, 4212, 6928, 1544, 40, 7888, 7928, 7912, 11696, 140, 664, 328}, - //offsets for: ./mysqld-8.0.18 (8.0.18) + //offsets for: /mysqlrpm/8.0.18/usr/sbin/mysqld (8.0.18) {"8.0.18","172a119d1acf6a743d155de9d9433124", 8608, 8656, 3992, 5600, 520, 0, 0, 32, 64, 160, 600, 8772, 5232, 4200, 4208, 4212, 6904, 1504, 40, 7864, 7904, 7888, 11672, 140, 664, 328}, - //offsets for: ./mysqld-8.0.17 (8.0.17) + //offsets for: /mysqlrpm/8.0.17/usr/sbin/mysqld (8.0.17) {"8.0.17","0feb95f129f62fa3350c6895d556e7d9", 8744, 8792, 3912, 5736, 520, 0, 0, 32, 64, 160, 600, 8908, 5368, 4200, 4208, 4212, 7040, 1456, 40, 8000, 8040, 8024, 11808, 140, 664, 328}, - //offsets for: ./mysqld-8.0.16 (8.0.16) + //offsets for: /mysqlrpm/8.0.16/usr/sbin/mysqld (8.0.16) {"8.0.16","ab69e3d19774ad65491dea8a722e6af1", 8360, 8408, 3912, 5352, 520, 0, 0, 32, 64, 160, 600, 8524, 4984, 4000, 4008, 4012, 6656, 1456, 40, 7616, 7656, 7640, 11416, 140, 664, 328}, - //offsets for: ./mysqld-8.0.15 (8.0.15) + //offsets for: /mysqlrpm/8.0.15/usr/sbin/mysqld (8.0.15) {"8.0.15","aa0a7deef2aaba81b081e4e498859af1", 8136, 8184, 3936, 5120, 520, 0, 0, 32, 64, 160, 600, 8300, 4752, 4000, 4008, 4012, 6424, 1424, 24, 7392, 7432, 7416, 11192, 140, 664, 328}, - //offsets for: ./mysqld-8.0.14 (8.0.14) + //offsets for: /mysqlrpm/8.0.14/usr/sbin/mysqld (8.0.14) {"8.0.14","649589cdd3e5b56f72790793a039e924", 8136, 8184, 3936, 5120, 520, 0, 0, 32, 64, 160, 600, 8300, 4752, 4000, 4008, 4012, 6424, 1424, 24, 7392, 7432, 7416, 11192, 140, 664, 328}, - //offsets for: ./mysqld-8.0.13 (8.0.13) + //offsets for: /mysqlrpm/8.0.13/usr/sbin/mysqld (8.0.13) {"8.0.13","665c9cb36af00034f1d3e8823e50f028", 8112, 8160, 3912, 5096, 520, 0, 0, 32, 64, 160, 600, 8276, 4728, 4000, 4008, 4012, 6400, 1424, 24, 7360, 7408, 7392, 11144, 140, 664, 328}, - //offsets for: ./mysqld-8.0.12 (8.0.12) + //offsets for: /mysqlrpm/8.0.12/usr/sbin/mysqld (8.0.12) {"8.0.12","261db244348c9750a6a08a12c36ecbbe", 8112, 8160, 3888, 5096, 520, 0, 0, 32, 64, 160, 600, 8276, 4728, 3992, 4000, 4004, 6400, 1416, 24, 7360, 7408, 7392, 11144, 140, 664, 328}, - //offsets for: ./mysqld-8.0.11 (8.0.11) + //offsets for: /mysqlrpm/8.0.11/usr/sbin/mysqld (8.0.11) {"8.0.11","1e42c35650057a8c339ddf498808ca89", 8080, 8128, 3888, 5064, 520, 0, 0, 32, 64, 160, 600, 8244, 4696, 3992, 4000, 4004, 6368, 1416, 24, 7328, 7376, 7360, 11112, 140, 664, 328}, //offsets for: /mysqlrpm/5.6.49/usr/sbin/mysqld (5.6.49) {"5.6.49","bd064dfd82d5e05499f6a77a87673919", 7000, 7048, 4008, 4528, 72, 2704, 96, 0, 32, 104, 136, 7136, 4400, 2800, 2808, 2812, 536, 0, 0, 6368, 6392, 6376, 13056, 548, 516}, @@ -410,6 +420,45 @@ const ThdOffsets thd_offsets_arr[] = const ThdOffsets thd_offsets_arr[] = { /* +++ MARIADB 64 OFFSETS GO HERE +++ */ + + //offsets for: /mariadbrpm/10.5.9/usr/sbin/mysqld (10.5.9-MariaDB) + {"10.5.9-MariaDB","725ac4b90ca420f615bd71956edad7a6", 15224, 15384, 7712, 9480, 88, 3504, 8, 0, 16, 24, 152, 15492, 9112, 5480, 5488, 5492, 632, 0, 0, 14480, 14504, 14488, 24024, 564, 8}, + //offsets for: /mariadb/10.5.9/bin/mysqld (10.5.9-MariaDB) + {"10.5.9-MariaDB","a6abda02a6438f3254829a007ef31a8d", 15224, 15384, 7712, 9480, 88, 3504, 8, 0, 16, 24, 152, 15492, 9112, 5480, 5488, 5492, 632, 0, 0, 14480, 14504, 14488, 24024, 564, 8}, + //offsets for: /mariadb/10.5.9/bin/mysqld (10.5.9-MariaDB) systemd + {"10.5.9-MariaDB","43c43dfad7fc3e3b7a26a59c2bff1fa8", 15224, 15384, 7712, 9480, 88, 3504, 8, 0, 16, 24, 152, 15492, 9112, 5480, 5488, 5492, 632, 0, 0, 14480, 14504, 14488, 24024, 564, 8}, + //offsets for: /mariadb/10.2.37/bin/mysqld (10.2.37-MariaDB) + {"10.2.37-MariaDB","2ae941e007e26f2f4a6108e359b6ee97", 13880, 13944, 6672, 8288, 88, 3208, 8, 0, 16, 24, 152, 14044, 8048, 2984, 2992, 2996, 608, 0, 0, 13256, 13280, 13264, 21216, 548, 516}, + //offsets for: /mariadbrpm/10.5.8/usr/sbin/mysqld (10.5.8-MariaDB) + {"10.5.8-MariaDB","6a40182f423179b5e55752c72834c25d", 15216, 15376, 7704, 9472, 88, 3504, 8, 0, 16, 24, 152, 15484, 9104, 5480, 5488, 5492, 632, 0, 0, 14472, 14496, 14480, 24016, 564, 8}, + //offsets for: /mariadbrpm/10.5.7/usr/sbin/mysqld (10.5.7-MariaDB) + {"10.5.7-MariaDB","9d929cd4fea6dc6f3b13588ac41559b2", 15216, 15376, 7704, 9472, 88, 3504, 8, 0, 16, 24, 152, 15484, 9104, 5480, 5488, 5492, 632, 0, 0, 14472, 14496, 14480, 24016, 564, 8}, + //offsets for: /mariadbrpm/10.5.6/usr/sbin/mysqld (10.5.6-MariaDB) + {"10.5.6-MariaDB","2047d965f6f9dbb9d69508a88ab6f5b3", 14824, 14984, 7312, 9080, 88, 3512, 8, 0, 16, 24, 152, 15092, 8712, 5480, 5488, 5492, 624, 0, 0, 14080, 14104, 14088, 23632, 564, 8}, + //offsets for: /mariadbrpm/10.5.5/usr/sbin/mysqld (10.5.5-MariaDB) + {"10.5.5-MariaDB","39d53533a39ff2fe11c1c5ed6773cd11", 14824, 14984, 7312, 9080, 88, 3512, 8, 0, 16, 24, 152, 15092, 8712, 5480, 5488, 5492, 624, 0, 0, 14080, 14104, 14088, 23632, 564, 8}, + //offsets for: /mariadbrpm/10.5.4/usr/sbin/mysqld (10.5.4-MariaDB) + {"10.5.4-MariaDB","3654c448ff5318de5870040cbf5c5b10", 14824, 14984, 7312, 9080, 88, 3512, 8, 0, 16, 24, 152, 15092, 8712, 5480, 5488, 5492, 624, 0, 0, 14080, 14104, 14088, 23632, 564, 8}, + //offsets for: /mariadb/10.5.8/bin/mysqld (10.5.8-MariaDB) systemd + {"10.5.8-MariaDB","a62479253a14b7a1ffd3bf75b3c98604", 15216, 15376, 7704, 9472, 88, 3504, 8, 0, 16, 24, 152, 15484, 9104, 5480, 5488, 5492, 632, 0, 0, 14472, 14496, 14480, 24016, 564, 8}, + //offsets for: /mariadb/10.5.7/bin/mysqld (10.5.7-MariaDB) systemd + {"10.5.7-MariaDB","8c6bfb8ef6c4c3107975f0071db319f2", 15216, 15376, 7704, 9472, 88, 3504, 8, 0, 16, 24, 152, 15484, 9104, 5480, 5488, 5492, 632, 0, 0, 14472, 14496, 14480, 24016, 564, 8}, + //offsets for: /mariadb/10.5.6/bin/mysqld (10.5.6-MariaDB) systemd + {"10.5.6-MariaDB","bace784d1ab7b882165972803dd66677", 14824, 14984, 7312, 9080, 88, 3512, 8, 0, 16, 24, 152, 15092, 8712, 5480, 5488, 5492, 624, 0, 0, 14080, 14104, 14088, 23632, 564, 8}, + //offsets for: /mariadb/10.5.5/bin/mysqld (10.5.5-MariaDB) systemd + {"10.5.5-MariaDB","8723bb0beff85d99d4966a556eeb8571", 14824, 14984, 7312, 9080, 88, 3512, 8, 0, 16, 24, 152, 15092, 8712, 5480, 5488, 5492, 624, 0, 0, 14080, 14104, 14088, 23632, 564, 8}, + //offsets for: /mariadb/10.5.4/bin/mysqld (10.5.4-MariaDB) systemd + {"10.5.4-MariaDB","706ce2652d5b6dd69c1e425b934e20f3", 14824, 14984, 7312, 9080, 88, 3512, 8, 0, 16, 24, 152, 15092, 8712, 5480, 5488, 5492, 624, 0, 0, 14080, 14104, 14088, 23632, 564, 8}, + //offsets for: /mariadb/10.5.8/bin/mysqld (10.5.8-MariaDB) + {"10.5.8-MariaDB","8daa247e5af6c32c49f1acfc6dbc5070", 15216, 15376, 7704, 9472, 88, 3504, 8, 0, 16, 24, 152, 15484, 9104, 5480, 5488, 5492, 632, 0, 0, 14472, 14496, 14480, 24016, 564, 8}, + //offsets for: /mariadb/10.5.7/bin/mysqld (10.5.7-MariaDB) + {"10.5.7-MariaDB","3d992f183a7faa381d9dd2a73b296f61", 15216, 15376, 7704, 9472, 88, 3504, 8, 0, 16, 24, 152, 15484, 9104, 5480, 5488, 5492, 632, 0, 0, 14472, 14496, 14480, 24016, 564, 8}, + //offsets for: /mariadb/10.5.6/bin/mysqld (10.5.6-MariaDB) + {"10.5.6-MariaDB","c2b3f23934cd4cb421a7e26ce68731bf", 14824, 14984, 7312, 9080, 88, 3512, 8, 0, 16, 24, 152, 15092, 8712, 5480, 5488, 5492, 624, 0, 0, 14080, 14104, 14088, 23632, 564, 8}, + //offsets for: /mariadb/10.5.5/bin/mysqld (10.5.5-MariaDB) + {"10.5.5-MariaDB","ede1dfe21489d98ef9c5b663b381fe8e", 14824, 14984, 7312, 9080, 88, 3512, 8, 0, 16, 24, 152, 15092, 8712, 5480, 5488, 5492, 624, 0, 0, 14080, 14104, 14088, 23632, 564, 8}, + //offsets for: /mariadb/10.5.4/bin/mysqld (10.5.4-MariaDB) + {"10.5.4-MariaDB","631e6eb51c07e3d20d41769b7f64c994", 14824, 14984, 7312, 9080, 88, 3512, 8, 0, 16, 24, 152, 15092, 8712, 5480, 5488, 5492, 624, 0, 0, 14080, 14104, 14088, 23632, 564, 8}, //offsets for: /mariadb/10.2.36/bin/mysqld (10.2.36-MariaDB) {"10.2.36-MariaDB","6ac5d544938762b31b4972d099c85933", 13880, 13944, 6672, 8288, 88, 3208, 8, 0, 16, 24, 152, 14044, 8048, 2984, 2992, 2996, 608, 0, 0, 13256, 13280, 13264, 21216, 548, 516}, //offsets for: /mariadb/10.2.35/bin/mysqld (10.2.35-MariaDB) @@ -747,6 +796,12 @@ const ThdOffsets thd_offsets_arr[] = const ThdOffsets thd_offsets_arr[] = { /* +++ MYSQL 32 OFFSETS GO HERE +++ */ + //offsets for: /mysqlrpm/5.6.51/usr/sbin/mysqld (5.6.51) + {"5.6.51","92b12b9c5531241950c85984b2a9f689", 4680, 4708, 2664, 3056, 36, 1748, 60, 0, 20, 64, 72, 4780, 2984, 2268, 2272, 2276, 348, 0, 0, 4208, 4232, 4216, 8664, 548, 516}, + //offsets for: /mysqlrpm/5.7.33/usr/sbin/mysqld (5.7.33) + {"5.7.33","b14a0d982dfbca2fd4b71e2a4183cee1", 5084, 5112, 2212, 3036, 296, 200, 0, 20, 40, 100, 340, 5196, 2776, 3108, 3112, 3116, 3720, 1152, 4, 4536, 4572, 4556, 9044, 80, 604}, + //offsets for: /mysqlrpm/8.0.23/usr/sbin/mysqld (8.0.23) + {"8.0.23","128b36f2904f96f3a672878dc3143281", 5680, 5708, 2492, 3640, 328, 0, 0, 20, 40, 100, 372, 5792, 3424, 3652, 3656, 3660, 4336, 920, 16, 5136, 5172, 5156, 8144, 72, 596, 172}, //offsets for: /mysqlrpm/5.6.50/usr/sbin/mysqld (5.6.50) {"5.6.50","faec9307821c607dbe7b4dd0e42e85fb", 4680, 4708, 2664, 3056, 36, 1748, 60, 0, 20, 64, 72, 4780, 2984, 2268, 2272, 2276, 348, 0, 0, 4208, 4232, 4216, 8664, 548, 516}, //offsets for: /mysqlrpm/5.7.32/usr/sbin/mysqld (5.7.32) @@ -1062,6 +1117,8 @@ const ThdOffsets thd_offsets_arr[] = const ThdOffsets thd_offsets_arr[] = { /* +++ MARIADB 32 OFFSETS GO HERE +++ */ + //offsets for: /mariadb/10.2.37/bin/mysqld (10.2.37-MariaDB) + {"10.2.37-MariaDB","f09c2b85d1f8989f71c7bebbc4b6088c", 8612, 8648, 3960, 5428, 44, 2032, 4, 0, 8, 12, 84, 8732, 5288, 2604, 2608, 2612, 376, 0, 0, 8136, 8160, 8144, 13464, 548, 516}, //offsets for: /mariadb/10.2.36/bin/mysqld (10.2.36-MariaDB) {"10.2.36-MariaDB","2360c1f90821d784efc03cc21d97bd97", 8616, 8652, 3964, 5432, 44, 2032, 4, 0, 8, 12, 84, 8736, 5292, 2604, 2608, 2612, 376, 0, 0, 8140, 8164, 8148, 13468, 548, 516}, //offsets for: /mariadb/10.2.35/bin/mysqld (10.2.35-MariaDB) diff --git a/src/audit_plugin.cc b/src/audit_plugin.cc index 44ca3e5..c5dafe9 100644 --- a/src/audit_plugin.cc +++ b/src/audit_plugin.cc @@ -2009,19 +2009,20 @@ static void record_objs_string_update_extended(THD *thd, SYS_VAR *var, void *tgt bool (*compat::_vio_socket_connect)(MYSQL_VIO vio, struct sockaddr *addr, socklen_t len, int timeout); bool (*compat::_vio_socket_connect_80016)(MYSQL_VIO vio, struct sockaddr *addr, socklen_t len, bool nonblocking, int timeout); bool (*compat::_vio_socket_connect_80020)(MYSQL_VIO vio, struct sockaddr *addr, socklen_t len, bool nonblocking, int timeout, bool *connect_done); +#elif defined(HAVE_SESS_CONNECT_ATTRS) && defined(MARIADB_BASE_VERSION) +compat::pfs_thread_t compat::_pfs_thread_get_current_thread; +PSI_v1* compat::_psi_interface; #endif static int audit_plugin_init(void *p) { DBUG_ENTER("audit_plugin_init"); -#if !defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID > 80000 const bool compat_init_ok = compat::init(); if (!compat_init_ok) { sql_print_error("%s unable to init compatibility layer. Aborting.", log_prefix); DBUG_RETURN(1); } -#endif #ifdef __x86_64__ const char * arch = "64bit"; @@ -2584,6 +2585,26 @@ mysql_declare_plugin(audit_plugin) } mysql_declare_plugin_end; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100504 +maria_declare_plugin(audit_plugin) +{ + plugin_type, /* the plugin type (see include/mysql/plugin.h) */ + &audit_plugin, /* pointer to type-specific plugin descriptor */ + PLUGIN_NAME, /* plugin name */ + "McAfee Inc", /* plugin author */ + "AUDIT plugin, creates a file mysql-audit.log to log activity", /* the plugin description */ + PLUGIN_LICENSE_GPL, /* the plugin license (see include/mysql/plugin.h) */ + audit_plugin_init, /* Pointer to plugin initialization function */ + audit_plugin_deinit, /* Pointer to plugin deinitialization function */ + 0x0100, /* Numeric version 0xAABB means AA.BB version */ + audit_status, /* Status variables */ + audit_system_variables, /* System variables */ + "1.0", /* String version representation */ + MariaDB_PLUGIN_MATURITY_STABLE /* Maturity (see include/mysql/plugin.h)*/ +} +maria_declare_plugin_end; +#endif + static inline void init_peer_info() { memset(peer_info_init_value, '0', sizeof(peer_info_init_value)-1);