Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
1793646d
Commit
1793646d
authored
Jan 25, 2016
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '5.5' into 10.0
Conflicts: plugin/server_audit/server_audit.c
parents
74b1af19
9c9d10b4
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1338 additions
and
279 deletions
+1338
-279
cmake/libutils.cmake
cmake/libutils.cmake
+5
-0
mysql-test/suite/plugins/r/server_audit.result
mysql-test/suite/plugins/r/server_audit.result
+4
-1
mysql-test/suite/plugins/r/thread_pool_server_audit.result
mysql-test/suite/plugins/r/thread_pool_server_audit.result
+6
-3
mysys/file_logger.c
mysys/file_logger.c
+2
-0
plugin/server_audit/CMakeLists.txt
plugin/server_audit/CMakeLists.txt
+4
-1
plugin/server_audit/plugin_audit_v4.h
plugin/server_audit/plugin_audit_v4.h
+561
-0
plugin/server_audit/server_audit.c
plugin/server_audit/server_audit.c
+594
-274
plugin/server_audit/test_audit_v4.c
plugin/server_audit/test_audit_v4.c
+162
-0
No files found.
cmake/libutils.cmake
View file @
1793646d
...
...
@@ -87,6 +87,11 @@ MACRO(CREATE_EXPORT_FILE VAR TARGET API_FUNCTIONS)
ENDFOREACH
()
SET
(
CONTENT
"
${
CONTENT
}
(void *)0
\n
}
\;
"
)
CONFIGURE_FILE_CONTENT
(
${
CONTENT
}
${
EXPORTS
}
)
# Avoid "function redeclared as variable" error
# when using gcc/clang option -flto(link time optimization)
IF
(
"
${
CMAKE_C_FLAGS
}
${
CMAKE_CXX_FLAGS
}
"
MATCHES
" -flto"
)
SET_SOURCE_FILES_PROPERTIES
(
${
EXPORTS
}
PROPERTIES COMPILE_FLAGS
"-fno-lto"
)
ENDIF
()
SET
(
${
VAR
}
${
EXPORTS
}
)
ENDIF
()
ENDMACRO
()
...
...
mysql-test/suite/plugins/r/server_audit.result
View file @
1793646d
...
...
@@ -8,6 +8,7 @@ server_audit_file_rotate_now OFF
server_audit_file_rotate_size 1000000
server_audit_file_rotations 9
server_audit_incl_users
server_audit_loc_info
server_audit_logging OFF
server_audit_mode 0
server_audit_output_type file
...
...
@@ -71,6 +72,7 @@ server_audit_file_rotate_now OFF
server_audit_file_rotate_size 1000000
server_audit_file_rotations 9
server_audit_incl_users odin, root, dva, tri
server_audit_loc_info
server_audit_logging ON
server_audit_mode 0
server_audit_output_type file
...
...
@@ -216,6 +218,7 @@ server_audit_file_rotate_now OFF
server_audit_file_rotate_size 1000000
server_audit_file_rotations 9
server_audit_incl_users odin, root, dva, tri
server_audit_loc_info
server_audit_logging ON
server_audit_mode 1
server_audit_output_type file
...
...
@@ -289,7 +292,7 @@ TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,proc,
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc,
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event,
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0
TIME,HOSTNAME,root,localhost,ID,0,DISCONNECT,
sa_db
,,0
TIME,HOSTNAME,root,localhost,ID,0,DISCONNECT,,,0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'create database sa_db',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'use sa_db',0
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user,
...
...
mysql-test/suite/plugins/r/thread_pool_server_audit.result
View file @
1793646d
...
...
@@ -8,6 +8,7 @@ server_audit_file_rotate_now OFF
server_audit_file_rotate_size 1000000
server_audit_file_rotations 9
server_audit_incl_users
server_audit_loc_info
server_audit_logging OFF
server_audit_mode 0
server_audit_output_type file
...
...
@@ -71,6 +72,7 @@ server_audit_file_rotate_now OFF
server_audit_file_rotate_size 1000000
server_audit_file_rotations 9
server_audit_incl_users odin, root, dva, tri
server_audit_loc_info
server_audit_logging ON
server_audit_mode 0
server_audit_output_type file
...
...
@@ -216,6 +218,7 @@ server_audit_file_rotate_now OFF
server_audit_file_rotate_size 1000000
server_audit_file_rotations 9
server_audit_incl_users odin, root, dva, tri
server_audit_loc_info
server_audit_logging ON
server_audit_mode 1
server_audit_output_type file
...
...
@@ -229,9 +232,9 @@ Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_logging=on',0
TIME,HOSTNAME,root,localhost,ID,0,CONNECT,mysql,,0
TIME,HOSTNAME,
root,localhost,ID,0,DISCONNECT,mysql
,,0
TIME,HOSTNAME,
,,ID,0,DISCONNECT,
,,0
TIME,HOSTNAME,no_such_user,localhost,ID,0,FAILED_CONNECT,,,ID
TIME,HOSTNAME,
no_such_user,localhost
,ID,0,DISCONNECT,,,0
TIME,HOSTNAME,
,
,ID,0,DISCONNECT,,,0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_incl_users=\'odin, root, dva, tri\'',0
TIME,HOSTNAME,root,localhost,ID,ID,CREATE,test,t2,
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'create table t2 (id int)',0
...
...
@@ -289,7 +292,7 @@ TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,proc,
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc,
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event,
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0
TIME,HOSTNAME,
root,localhost,ID,0,DISCONNECT,sa_db
,,0
TIME,HOSTNAME,
,,ID,0,DISCONNECT,
,,0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'create database sa_db',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'use sa_db',0
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user,
...
...
mysys/file_logger.c
View file @
1793646d
...
...
@@ -14,11 +14,13 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef FLOGGER_SKIP_INCLUDES
#include "my_global.h"
#include <my_sys.h>
#include <m_string.h>
#include <mysql/service_logger.h>
#include <my_pthread.h>
#endif
/*FLOGGER_SKIP_INCLUDES*/
#ifndef flogger_mutex_init
#define flogger_mutex_init(A,B,C) mysql_mutex_init(A,B,C)
...
...
plugin/server_audit/CMakeLists.txt
View file @
1793646d
...
...
@@ -13,4 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MYSQL_ADD_PLUGIN
(
server_audit server_audit.c MODULE_ONLY
)
SET
(
SERVER_AUDIT_SOURCES
server_audit.c test_audit_v4.c plugin_audit_v4.h
)
MYSQL_ADD_PLUGIN
(
server_audit
${
SERVER_AUDIT_SOURCES
}
MODULE_ONLY
)
plugin/server_audit/plugin_audit_v4.h
0 → 100644
View file @
1793646d
This diff is collapsed.
Click to expand it.
plugin/server_audit/server_audit.c
View file @
1793646d
This diff is collapsed.
Click to expand it.
plugin/server_audit/test_audit_v4.c
0 → 100644
View file @
1793646d
#define PLUGIN_CONTEXT
#include <stdio.h>
typedef
void
*
MYSQL_THD
;
struct
st_mysql_const_lex_string
{
const
char
*
str
;
size_t
length
;
};
typedef
struct
st_mysql_const_lex_string
MYSQL_LEX_CSTRING
;
enum
enum_sql_command
{
SQLCOM_A
,
SQLCOM_B
};
enum
enum_server_command
{
SERVCOM_A
,
SERVCOM_B
};
#include "plugin_audit_v4.h"
extern
void
auditing
(
MYSQL_THD
thd
,
unsigned
int
event_class
,
const
void
*
ev
);
extern
int
get_db_mysql57
(
MYSQL_THD
thd
,
char
**
name
,
int
*
len
);
struct
mysql_event_general_302
{
unsigned
int
event_subclass
;
int
general_error_code
;
unsigned
long
general_thread_id
;
const
char
*
general_user
;
unsigned
int
general_user_length
;
const
char
*
general_command
;
unsigned
int
general_command_length
;
const
char
*
general_query
;
unsigned
int
general_query_length
;
struct
charset_info_st
*
general_charset
;
unsigned
long
long
general_time
;
unsigned
long
long
general_rows
;
unsigned
long
long
query_id
;
char
*
database
;
int
database_length
;
};
static
int
auditing_v4
(
MYSQL_THD
thd
,
mysql_event_class_t
class
,
const
void
*
ev
)
{
int
*
subclass
=
(
int
*
)
ev
;
struct
mysql_event_general_302
ev_302
;
int
subclass_v3
,
subclass_orig
;
if
(
class
!=
MYSQL_AUDIT_GENERAL_CLASS
&&
class
!=
MYSQL_AUDIT_CONNECTION_CLASS
)
return
0
;
subclass_orig
=
*
subclass
;
if
(
class
==
MYSQL_AUDIT_GENERAL_CLASS
)
{
struct
mysql_event_general
*
event
=
(
struct
mysql_event_general
*
)
ev
;
ev_302
.
general_error_code
=
event
->
general_error_code
;
ev_302
.
general_thread_id
=
event
->
general_thread_id
;
ev_302
.
general_user
=
event
->
general_user
.
str
;
ev_302
.
general_user_length
=
event
->
general_user
.
length
;
ev_302
.
general_command
=
event
->
general_command
.
str
;
ev_302
.
general_command_length
=
event
->
general_command
.
length
;
ev_302
.
general_query
=
event
->
general_query
.
str
;
ev_302
.
general_query_length
=
event
->
general_query
.
length
;
ev_302
.
general_charset
=
event
->
general_charset
;
ev_302
.
general_time
=
event
->
general_time
;
ev_302
.
general_rows
=
event
->
general_rows
;
if
(
get_db_mysql57
(
thd
,
&
ev_302
.
database
,
&
ev_302
.
database_length
))
{
ev_302
.
database
=
0
;
ev_302
.
database_length
=
0
;
}
ev
=
&
ev_302
;
switch
(
subclass_orig
)
{
case
MYSQL_AUDIT_GENERAL_LOG
:
subclass_v3
=
0
;
ev_302
.
event_subclass
=
0
;
break
;
case
MYSQL_AUDIT_GENERAL_ERROR
:
subclass_v3
=
1
;
ev_302
.
event_subclass
=
1
;
break
;
case
MYSQL_AUDIT_GENERAL_RESULT
:
subclass_v3
=
2
;
ev_302
.
event_subclass
=
2
;
break
;
case
MYSQL_AUDIT_GENERAL_STATUS
:
{
subclass_v3
=
3
;
ev_302
.
event_subclass
=
3
;
break
;
}
default:
return
0
;
}
}
else
/* if (class == MYSQL_AUDIT_CONNECTION_CLASS) */
{
switch
(
subclass_orig
)
{
case
MYSQL_AUDIT_CONNECTION_CONNECT
:
subclass_v3
=
0
;
break
;
case
MYSQL_AUDIT_CONNECTION_DISCONNECT
:
subclass_v3
=
1
;
break
;
default:
return
0
;
}
}
*
subclass
=
subclass_v3
;
auditing
(
thd
,
(
int
)
class
,
ev
);
*
subclass
=
subclass_orig
;
return
0
;
}
static
struct
st_mysql_audit
mysql_descriptor
=
{
MYSQL_AUDIT_INTERFACE_VERSION
,
NULL
,
auditing_v4
,
{
(
unsigned
long
)
MYSQL_AUDIT_GENERAL_ALL
,
(
unsigned
long
)
MYSQL_AUDIT_CONNECTION_ALL
,
(
unsigned
long
)
MYSQL_AUDIT_PARSE_ALL
,
0
,
/* This event class is currently not supported. */
0
,
/* This event class is currently not supported. */
(
unsigned
long
)
MYSQL_AUDIT_GLOBAL_VARIABLE_ALL
,
(
unsigned
long
)
MYSQL_AUDIT_SERVER_STARTUP_ALL
,
(
unsigned
long
)
MYSQL_AUDIT_SERVER_SHUTDOWN_ALL
,
(
unsigned
long
)
MYSQL_AUDIT_COMMAND_ALL
,
(
unsigned
long
)
MYSQL_AUDIT_QUERY_ALL
,
(
unsigned
long
)
MYSQL_AUDIT_STORED_PROGRAM_ALL
}
#ifdef WHEN_MYSQL_BUG_FIXED
/*
By this moment MySQL just sends no notifications at all
when we request only those we actually need.
So we have to request everything and filter them inside the
handling function.
*/
{
(
unsigned
long
)
MYSQL_AUDIT_GENERAL_ALL
,
(
unsigned
long
)
(
MYSQL_AUDIT_CONNECTION_CONNECT
|
MYSQL_AUDIT_CONNECTION_DISCONNECT
),
0
,
0
,
/* This event class is currently not supported. */
0
,
/* This event class is currently not supported. */
0
,
0
,
0
,
0
,
0
,
0
}
#endif
/*WHEN_MYSQL_BUG_FIXED*/
};
void
*
mysql_v4_descriptor
=
&
mysql_descriptor
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment