Skip to content

Commit 953c9a9

Browse files
committed
WL#7254 Audit API extensions
- New event classes introduced (authorization, table access, command, server initialization and shutdown, global variable access, stored program execution). - Plugin's event handling function can abort further execution of the server enquiry that caused generation of the event. - Plugin allows to subscribe to the specific subclass. - Sec Context exposed as a Plugin Service. - Plugin implementation extended (null_plugin) to support event verification MTR: test_sec_context, audit_plugin_2
1 parent e554bbd commit 953c9a9

File tree

78 files changed

+4677
-792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4677
-792
lines changed

include/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sql_state.h
2323
SET(HEADERS_ABI
2424
mysql.h
2525
mysql_com.h
26+
my_command.h
2627
mysql_time.h
2728
my_list.h
2829
my_alloc.h

include/m_string.h

+8-6
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,17 @@ extern char *longlong10_to_str(longlong val,char *dst,int radix);
228228
/*
229229
LEX_STRING -- a pair of a C-string and its length.
230230
(it's part of the plugin API as a MYSQL_LEX_STRING)
231+
Ditto LEX_CSTRING/MYSQL_LEX_CSTRING.
231232
*/
232233

233234
#include <mysql/mysql_lex_string.h>
234235
typedef struct st_mysql_lex_string LEX_STRING;
236+
typedef struct st_mysql_const_lex_string LEX_CSTRING;
235237

236238
#define STRING_WITH_LEN(X) (X), ((sizeof(X) - 1))
237239
#define USTRING_WITH_LEN(X) ((uchar*) X), ((sizeof(X) - 1))
238240
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((sizeof(X) - 1))
239241

240-
struct st_mysql_const_lex_string
241-
{
242-
const char *str;
243-
size_t length;
244-
};
245-
typedef struct st_mysql_const_lex_string LEX_CSTRING;
246242

247243
/**
248244
Skip trailing space.
@@ -336,4 +332,10 @@ static inline void lex_string_set(LEX_STRING *lex_str, const char *c_str)
336332
lex_str->length= strlen(c_str);
337333
}
338334

335+
static inline void lex_cstring_set(LEX_CSTRING *lex_str, const char *c_str)
336+
{
337+
lex_str->str= c_str;
338+
lex_str->length= strlen(c_str);
339+
}
340+
339341
#endif

include/my_command.h

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15+
16+
#ifndef _mysql_command_h
17+
#define _mysql_command_h
18+
19+
/**
20+
@enum enum_server_command
21+
@brief You should add new commands to the end of this list, otherwise old
22+
servers won't be able to handle them as 'unsupported'.
23+
*/
24+
enum enum_server_command
25+
{
26+
COM_SLEEP,
27+
COM_QUIT,
28+
COM_INIT_DB,
29+
COM_QUERY,
30+
COM_FIELD_LIST,
31+
COM_CREATE_DB,
32+
COM_DROP_DB,
33+
COM_REFRESH,
34+
COM_SHUTDOWN,
35+
COM_STATISTICS,
36+
COM_PROCESS_INFO,
37+
COM_CONNECT,
38+
COM_PROCESS_KILL,
39+
COM_DEBUG,
40+
COM_PING,
41+
COM_TIME,
42+
COM_DELAYED_INSERT,
43+
COM_CHANGE_USER,
44+
COM_BINLOG_DUMP,
45+
COM_TABLE_DUMP,
46+
COM_CONNECT_OUT,
47+
COM_REGISTER_SLAVE,
48+
COM_STMT_PREPARE,
49+
COM_STMT_EXECUTE,
50+
COM_STMT_SEND_LONG_DATA,
51+
COM_STMT_CLOSE,
52+
COM_STMT_RESET,
53+
COM_SET_OPTION,
54+
COM_STMT_FETCH,
55+
COM_DAEMON,
56+
COM_BINLOG_DUMP_GTID,
57+
COM_RESET_CONNECTION,
58+
/* don't forget to update const char *command_name[] in sql_parse.cc */
59+
60+
/* Must be last */
61+
COM_END
62+
};
63+
64+
#endif /* _mysql_command_h */

include/my_sqlcommand.h

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15+
16+
#ifndef _mysql_sql_command_h
17+
#define _mysql_sql_command_h
18+
19+
/*
20+
@enum enum_sql_command
21+
@brief SQL Commands
22+
23+
SQL Command is resolved during SQL parsing and assigned to the Lex
24+
object, accessible from the THD.
25+
26+
When a command is added here, be sure it's also added in mysqld.cc
27+
in "struct show_var_st status_vars[]= {" ...
28+
29+
If the command returns a result set or is not allowed in stored
30+
functions or triggers, please also make sure that
31+
sp_get_flags_for_command (sp_head.cc) returns proper flags for the
32+
added SQLCOM_.
33+
*/
34+
enum enum_sql_command {
35+
SQLCOM_SELECT,
36+
SQLCOM_CREATE_TABLE,
37+
SQLCOM_CREATE_INDEX,
38+
SQLCOM_ALTER_TABLE,
39+
SQLCOM_UPDATE,
40+
SQLCOM_INSERT,
41+
SQLCOM_INSERT_SELECT,
42+
SQLCOM_DELETE,
43+
SQLCOM_TRUNCATE,
44+
SQLCOM_DROP_TABLE,
45+
SQLCOM_DROP_INDEX,
46+
SQLCOM_SHOW_DATABASES,
47+
SQLCOM_SHOW_TABLES,
48+
SQLCOM_SHOW_FIELDS,
49+
SQLCOM_SHOW_KEYS,
50+
SQLCOM_SHOW_VARIABLES,
51+
SQLCOM_SHOW_STATUS,
52+
SQLCOM_SHOW_ENGINE_LOGS,
53+
SQLCOM_SHOW_ENGINE_STATUS,
54+
SQLCOM_SHOW_ENGINE_MUTEX,
55+
SQLCOM_SHOW_PROCESSLIST,
56+
SQLCOM_SHOW_MASTER_STAT,
57+
SQLCOM_SHOW_SLAVE_STAT,
58+
SQLCOM_SHOW_GRANTS,
59+
SQLCOM_SHOW_CREATE,
60+
SQLCOM_SHOW_CHARSETS,
61+
SQLCOM_SHOW_COLLATIONS,
62+
SQLCOM_SHOW_CREATE_DB,
63+
SQLCOM_SHOW_TABLE_STATUS,
64+
SQLCOM_SHOW_TRIGGERS,
65+
SQLCOM_LOAD,
66+
SQLCOM_SET_OPTION,
67+
SQLCOM_LOCK_TABLES,
68+
SQLCOM_UNLOCK_TABLES,
69+
SQLCOM_GRANT,
70+
SQLCOM_CHANGE_DB,
71+
SQLCOM_CREATE_DB,
72+
SQLCOM_DROP_DB,
73+
SQLCOM_ALTER_DB,
74+
SQLCOM_REPAIR,
75+
SQLCOM_REPLACE,
76+
SQLCOM_REPLACE_SELECT,
77+
SQLCOM_CREATE_FUNCTION,
78+
SQLCOM_DROP_FUNCTION,
79+
SQLCOM_REVOKE,
80+
SQLCOM_OPTIMIZE,
81+
SQLCOM_CHECK,
82+
SQLCOM_ASSIGN_TO_KEYCACHE,
83+
SQLCOM_PRELOAD_KEYS,
84+
SQLCOM_FLUSH,
85+
SQLCOM_KILL,
86+
SQLCOM_ANALYZE,
87+
SQLCOM_ROLLBACK,
88+
SQLCOM_ROLLBACK_TO_SAVEPOINT,
89+
SQLCOM_COMMIT,
90+
SQLCOM_SAVEPOINT,
91+
SQLCOM_RELEASE_SAVEPOINT,
92+
SQLCOM_SLAVE_START,
93+
SQLCOM_SLAVE_STOP,
94+
SQLCOM_START_GROUP_REPLICATION,
95+
SQLCOM_STOP_GROUP_REPLICATION,
96+
SQLCOM_BEGIN,
97+
SQLCOM_CHANGE_MASTER,
98+
SQLCOM_CHANGE_REPLICATION_FILTER,
99+
SQLCOM_RENAME_TABLE,
100+
SQLCOM_RESET,
101+
SQLCOM_PURGE,
102+
SQLCOM_PURGE_BEFORE,
103+
SQLCOM_SHOW_BINLOGS,
104+
SQLCOM_SHOW_OPEN_TABLES,
105+
SQLCOM_HA_OPEN,
106+
SQLCOM_HA_CLOSE,
107+
SQLCOM_HA_READ,
108+
SQLCOM_SHOW_SLAVE_HOSTS,
109+
SQLCOM_DELETE_MULTI,
110+
SQLCOM_UPDATE_MULTI,
111+
SQLCOM_SHOW_BINLOG_EVENTS,
112+
SQLCOM_DO,
113+
SQLCOM_SHOW_WARNS,
114+
SQLCOM_EMPTY_QUERY,
115+
SQLCOM_SHOW_ERRORS,
116+
SQLCOM_SHOW_STORAGE_ENGINES,
117+
SQLCOM_SHOW_PRIVILEGES,
118+
SQLCOM_HELP,
119+
SQLCOM_CREATE_USER,
120+
SQLCOM_DROP_USER,
121+
SQLCOM_RENAME_USER,
122+
SQLCOM_REVOKE_ALL,
123+
SQLCOM_CHECKSUM,
124+
SQLCOM_CREATE_PROCEDURE,
125+
SQLCOM_CREATE_SPFUNCTION,
126+
SQLCOM_CALL,
127+
SQLCOM_DROP_PROCEDURE,
128+
SQLCOM_ALTER_PROCEDURE,
129+
SQLCOM_ALTER_FUNCTION,
130+
SQLCOM_SHOW_CREATE_PROC,
131+
SQLCOM_SHOW_CREATE_FUNC,
132+
SQLCOM_SHOW_STATUS_PROC,
133+
SQLCOM_SHOW_STATUS_FUNC,
134+
SQLCOM_PREPARE,
135+
SQLCOM_EXECUTE,
136+
SQLCOM_DEALLOCATE_PREPARE,
137+
SQLCOM_CREATE_VIEW,
138+
SQLCOM_DROP_VIEW,
139+
SQLCOM_CREATE_TRIGGER,
140+
SQLCOM_DROP_TRIGGER,
141+
SQLCOM_XA_START,
142+
SQLCOM_XA_END,
143+
SQLCOM_XA_PREPARE,
144+
SQLCOM_XA_COMMIT,
145+
SQLCOM_XA_ROLLBACK,
146+
SQLCOM_XA_RECOVER,
147+
SQLCOM_SHOW_PROC_CODE,
148+
SQLCOM_SHOW_FUNC_CODE,
149+
SQLCOM_ALTER_TABLESPACE,
150+
SQLCOM_INSTALL_PLUGIN,
151+
SQLCOM_UNINSTALL_PLUGIN,
152+
SQLCOM_BINLOG_BASE64_EVENT,
153+
SQLCOM_SHOW_PLUGINS,
154+
SQLCOM_CREATE_SERVER,
155+
SQLCOM_DROP_SERVER,
156+
SQLCOM_ALTER_SERVER,
157+
SQLCOM_CREATE_EVENT,
158+
SQLCOM_ALTER_EVENT,
159+
SQLCOM_DROP_EVENT,
160+
SQLCOM_SHOW_CREATE_EVENT,
161+
SQLCOM_SHOW_EVENTS,
162+
SQLCOM_SHOW_CREATE_TRIGGER,
163+
SQLCOM_ALTER_DB_UPGRADE,
164+
SQLCOM_SHOW_PROFILE,
165+
SQLCOM_SHOW_PROFILES,
166+
SQLCOM_SIGNAL,
167+
SQLCOM_RESIGNAL,
168+
SQLCOM_SHOW_RELAYLOG_EVENTS,
169+
SQLCOM_GET_DIAGNOSTICS,
170+
SQLCOM_ALTER_USER,
171+
SQLCOM_EXPLAIN_OTHER,
172+
SQLCOM_SHOW_CREATE_USER,
173+
/* This should be the last !!! */
174+
SQLCOM_END
175+
};
176+
177+
#endif /* _mysql_sql_command_h */

include/mysql.h.pp

+33-8
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,41 @@
2828
MYSQL_TYPE_STRING=254,
2929
MYSQL_TYPE_GEOMETRY=255
3030
} enum_field_types;
31+
#include "my_command.h"
3132
enum enum_server_command
3233
{
33-
COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
34-
COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
35-
COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING,
36-
COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
37-
COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
38-
COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
39-
COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_DAEMON,
40-
COM_BINLOG_DUMP_GTID, COM_RESET_CONNECTION,
34+
COM_SLEEP,
35+
COM_QUIT,
36+
COM_INIT_DB,
37+
COM_QUERY,
38+
COM_FIELD_LIST,
39+
COM_CREATE_DB,
40+
COM_DROP_DB,
41+
COM_REFRESH,
42+
COM_SHUTDOWN,
43+
COM_STATISTICS,
44+
COM_PROCESS_INFO,
45+
COM_CONNECT,
46+
COM_PROCESS_KILL,
47+
COM_DEBUG,
48+
COM_PING,
49+
COM_TIME,
50+
COM_DELAYED_INSERT,
51+
COM_CHANGE_USER,
52+
COM_BINLOG_DUMP,
53+
COM_TABLE_DUMP,
54+
COM_CONNECT_OUT,
55+
COM_REGISTER_SLAVE,
56+
COM_STMT_PREPARE,
57+
COM_STMT_EXECUTE,
58+
COM_STMT_SEND_LONG_DATA,
59+
COM_STMT_CLOSE,
60+
COM_STMT_RESET,
61+
COM_SET_OPTION,
62+
COM_STMT_FETCH,
63+
COM_DAEMON,
64+
COM_BINLOG_DUMP_GTID,
65+
COM_RESET_CONNECTION,
4166
COM_END
4267
};
4368
struct st_vio;

include/mysql/mysql_lex_string.h

+7
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,11 @@ struct st_mysql_lex_string
2323
};
2424
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
2525

26+
struct st_mysql_const_lex_string
27+
{
28+
const char *str;
29+
size_t length;
30+
};
31+
typedef struct st_mysql_const_lex_string MYSQL_LEX_CSTRING;
32+
2633
#endif // MYSQL_LEX_STRING_INCLUDED

0 commit comments

Comments
 (0)