Merge lp:~sergei.glushchenko/percona-server/5.6-ps-blueprint-audit-log-streaming into lp:percona-server/5.6

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 642
Proposed branch: lp:~sergei.glushchenko/percona-server/5.6-ps-blueprint-audit-log-streaming
Merge into: lp:percona-server/5.6
Prerequisite: lp:~sergei.glushchenko/percona-server/5.6-ps-bug1320879
Diff against target: 1903 lines (+1114/-481)
25 files modified
mysql-test/r/audit_log.result (+0/-304)
mysql-test/r/audit_log_csv.result (+84/-0)
mysql-test/r/audit_log_json.result (+84/-0)
mysql-test/r/audit_log_new.result (+84/-0)
mysql-test/r/audit_log_old.result (+84/-0)
mysql-test/r/audit_log_syslog.result (+83/-0)
mysql-test/t/audit_log-master.opt (+0/-4)
mysql-test/t/audit_log.test (+0/-77)
mysql-test/t/audit_log_csv-master.opt (+5/-0)
mysql-test/t/audit_log_csv.test (+20/-0)
mysql-test/t/audit_log_json-master.opt (+5/-0)
mysql-test/t/audit_log_json.test (+18/-0)
mysql-test/t/audit_log_new-master.opt (+6/-0)
mysql-test/t/audit_log_new.test (+15/-0)
mysql-test/t/audit_log_old-master.opt (+5/-0)
mysql-test/t/audit_log_old.test (+15/-0)
mysql-test/t/audit_log_syslog-master.opt (+7/-0)
mysql-test/t/audit_log_syslog.test (+3/-0)
plugin/audit_log/CMakeLists.txt (+2/-1)
plugin/audit_log/audit_file.c (+200/-0)
plugin/audit_log/audit_handler.h (+116/-0)
plugin/audit_log/audit_log.c (+174/-91)
plugin/audit_log/audit_syslog.c (+91/-0)
plugin/audit_log/buffer.h (+11/-2)
plugin/audit_log/logger.h (+2/-2)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-server/5.6-ps-blueprint-audit-log-streaming
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+222603@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

See the 5.5 comments.

Is this an automerge from 5.5? If not, what are the differences?

review: Needs Fixing
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

GCA been taken, lp:~sergei.glushchenko/percona-server/5.5-ps-bug1320879 (which is already in 5.5 trunk) been merged into 5.5 branch. Then feature implemented in 5.5. After that 5.5 branch been merged into 5.6 branch. After this MP been created. No idea why LP shows that many revisions... I did try to merge this branch to branch based on lp:percona-server/5.6 and it merged without any conflicts touching only necessary files.

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Is this an automerge from 5.5? If not, what are the differences?

review: Needs Information
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

An automerge as discussed on IRC.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file 'mysql-test/r/audit_log.result'
--- mysql-test/r/audit_log.result 2014-05-23 16:14:27 +0000
+++ mysql-test/r/audit_log.result 1970-01-01 00:00:00 +0000
@@ -1,304 +0,0 @@
1CREATE TABLE t1 (c1 INT, c2 CHAR(20));
2CREATE TABLE t1
3(c1 INT,
4c2 CHAR(20));
5ERROR 42S01: Table 't1' already exists
6INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
7SELECT * FROM t1;
8c1 c2
91 a
102 b
113 c
12SELECT * FROM t2;
13ERROR 42S02: Table 'test.t2' doesn't exist
14DROP TABLE t1;
15PREPARE stmt1 FROM 'SELECT 1';
16EXECUTE stmt1;
171
181
19SHOW STATUS LIKE 'audit_log%';
20Variable_name Value
21DEALLOCATE PREPARE stmt1;
22show variables like 'audit_log%';
23Variable_name Value
24audit_log_buffer_size 4096
25audit_log_file test_audit.log
26audit_log_flush OFF
27audit_log_format OLD
28audit_log_policy ALL
29audit_log_rotate_on_size 0
30audit_log_rotations 0
31audit_log_strategy ASYNCHRONOUS
32connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
33ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
34create table t1 (id int);
35create table t2 (id int);
36insert into t1 values (1), (2);
37insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2);
38select * from t1;
39id
401
412
42alter table t1 rename renamed_t1;
43select * from t_doesnt_exist;
44ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
45syntax_error_query;
46ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1
47drop table renamed_t1, t2;
48show variables like 'audit_log%';
49Variable_name Value
50audit_log_buffer_size 4096
51audit_log_file test_audit.log
52audit_log_flush OFF
53audit_log_format OLD
54audit_log_policy ALL
55audit_log_rotate_on_size 0
56audit_log_rotations 0
57audit_log_strategy ASYNCHRONOUS
58create database sa_db;
59create table t1 (id2 int);
60insert into t1 values (1), (2);
61select * from t1;
62id2
631
642
65drop table t1;
66use sa_db;
67create table sa_t1(id int);
68insert into sa_t1 values (1), (2);
69drop table sa_t1;
70drop database sa_db;
71create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
72drop user 'jeffrey'@'localhost';
73select '&;&&&""""<><<>>>>';
74&;&&&""""<><<>>>>
75&;&&&""""<><<>>>>
76set global audit_log_flush= ON;
77CREATE TABLE t1 (c1 INT, c2 CHAR(20));
78CREATE TABLE t1
79(c1 INT,
80c2 CHAR(20));
81ERROR 42S01: Table 't1' already exists
82INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
83SELECT * FROM t1;
84c1 c2
851 a
862 b
873 c
88SELECT * FROM t2;
89ERROR 42S02: Table 'test.t2' doesn't exist
90DROP TABLE t1;
91PREPARE stmt1 FROM 'SELECT 1';
92EXECUTE stmt1;
931
941
95SHOW STATUS LIKE 'audit_log%';
96Variable_name Value
97DEALLOCATE PREPARE stmt1;
98show variables like 'audit_log%';
99Variable_name Value
100audit_log_buffer_size 4096
101audit_log_file test_audit.log
102audit_log_flush OFF
103audit_log_format NEW
104audit_log_policy LOGINS
105audit_log_rotate_on_size 0
106audit_log_rotations 0
107audit_log_strategy SEMISYNCHRONOUS
108connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
109ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
110create table t1 (id int);
111create table t2 (id int);
112insert into t1 values (1), (2);
113insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2);
114select * from t1;
115id
1161
1172
118alter table t1 rename renamed_t1;
119select * from t_doesnt_exist;
120ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
121syntax_error_query;
122ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1
123drop table renamed_t1, t2;
124show variables like 'audit_log%';
125Variable_name Value
126audit_log_buffer_size 4096
127audit_log_file test_audit.log
128audit_log_flush OFF
129audit_log_format NEW
130audit_log_policy LOGINS
131audit_log_rotate_on_size 0
132audit_log_rotations 0
133audit_log_strategy SEMISYNCHRONOUS
134create database sa_db;
135create table t1 (id2 int);
136insert into t1 values (1), (2);
137select * from t1;
138id2
1391
1402
141drop table t1;
142use sa_db;
143create table sa_t1(id int);
144insert into sa_t1 values (1), (2);
145drop table sa_t1;
146drop database sa_db;
147create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
148drop user 'jeffrey'@'localhost';
149select '&;&&&""""<><<>>>>';
150&;&&&""""<><<>>>>
151&;&&&""""<><<>>>>
152set global audit_log_flush= ON;
153CREATE TABLE t1 (c1 INT, c2 CHAR(20));
154CREATE TABLE t1
155(c1 INT,
156c2 CHAR(20));
157ERROR 42S01: Table 't1' already exists
158INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
159SELECT * FROM t1;
160c1 c2
1611 a
1622 b
1633 c
164SELECT * FROM t2;
165ERROR 42S02: Table 'test.t2' doesn't exist
166DROP TABLE t1;
167PREPARE stmt1 FROM 'SELECT 1';
168EXECUTE stmt1;
1691
1701
171SHOW STATUS LIKE 'audit_log%';
172Variable_name Value
173DEALLOCATE PREPARE stmt1;
174show variables like 'audit_log%';
175Variable_name Value
176audit_log_buffer_size 4096
177audit_log_file test_audit.log
178audit_log_flush OFF
179audit_log_format JSON
180audit_log_policy ALL
181audit_log_rotate_on_size 0
182audit_log_rotations 0
183audit_log_strategy SEMISYNCHRONOUS
184connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
185ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
186create table t1 (id int);
187create table t2 (id int);
188insert into t1 values (1), (2);
189insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2);
190select * from t1;
191id
1921
1932
194alter table t1 rename renamed_t1;
195select * from t_doesnt_exist;
196ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
197syntax_error_query;
198ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1
199drop table renamed_t1, t2;
200show variables like 'audit_log%';
201Variable_name Value
202audit_log_buffer_size 4096
203audit_log_file test_audit.log
204audit_log_flush OFF
205audit_log_format JSON
206audit_log_policy ALL
207audit_log_rotate_on_size 0
208audit_log_rotations 0
209audit_log_strategy SEMISYNCHRONOUS
210create database sa_db;
211create table t1 (id2 int);
212insert into t1 values (1), (2);
213select * from t1;
214id2
2151
2162
217drop table t1;
218use sa_db;
219create table sa_t1(id int);
220insert into sa_t1 values (1), (2);
221drop table sa_t1;
222drop database sa_db;
223create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
224drop user 'jeffrey'@'localhost';
225select '&;&&&""""<><<>>>>';
226&;&&&""""<><<>>>>
227&;&&&""""<><<>>>>
228set global audit_log_flush= ON;
229CREATE TABLE t1 (c1 INT, c2 CHAR(20));
230CREATE TABLE t1
231(c1 INT,
232c2 CHAR(20));
233ERROR 42S01: Table 't1' already exists
234INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
235SELECT * FROM t1;
236c1 c2
2371 a
2382 b
2393 c
240SELECT * FROM t2;
241ERROR 42S02: Table 'test.t2' doesn't exist
242DROP TABLE t1;
243PREPARE stmt1 FROM 'SELECT 1';
244EXECUTE stmt1;
2451
2461
247SHOW STATUS LIKE 'audit_log%';
248Variable_name Value
249DEALLOCATE PREPARE stmt1;
250show variables like 'audit_log%';
251Variable_name Value
252audit_log_buffer_size 4096
253audit_log_file test_audit.log
254audit_log_flush OFF
255audit_log_format CSV
256audit_log_policy ALL
257audit_log_rotate_on_size 0
258audit_log_rotations 0
259audit_log_strategy SEMISYNCHRONOUS
260connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
261ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
262create table t1 (id int);
263create table t2 (id int);
264insert into t1 values (1), (2);
265insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2);
266select * from t1;
267id
2681
2692
270alter table t1 rename renamed_t1;
271select * from t_doesnt_exist;
272ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
273syntax_error_query;
274ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1
275drop table renamed_t1, t2;
276show variables like 'audit_log%';
277Variable_name Value
278audit_log_buffer_size 4096
279audit_log_file test_audit.log
280audit_log_flush OFF
281audit_log_format CSV
282audit_log_policy ALL
283audit_log_rotate_on_size 0
284audit_log_rotations 0
285audit_log_strategy SEMISYNCHRONOUS
286create database sa_db;
287create table t1 (id2 int);
288insert into t1 values (1), (2);
289select * from t1;
290id2
2911
2922
293drop table t1;
294use sa_db;
295create table sa_t1(id int);
296insert into sa_t1 values (1), (2);
297drop table sa_t1;
298drop database sa_db;
299create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
300drop user 'jeffrey'@'localhost';
301select '&;&&&""""<><<>>>>';
302&;&&&""""<><<>>>>
303&;&&&""""<><<>>>>
304set global audit_log_flush= ON;
3050
=== added file 'mysql-test/r/audit_log_csv.result'
--- mysql-test/r/audit_log_csv.result 1970-01-01 00:00:00 +0000
+++ mysql-test/r/audit_log_csv.result 2014-07-30 17:21:31 +0000
@@ -0,0 +1,84 @@
1CREATE TABLE t1 (c1 INT, c2 CHAR(20));
2CREATE TABLE t1
3(c1 INT,
4c2 CHAR(20));
5ERROR 42S01: Table 't1' already exists
6INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
7SELECT * FROM t1;
8c1 c2
91 a
102 b
113 c
12SELECT * FROM t2;
13ERROR 42S02: Table 'test.t2' doesn't exist
14DROP TABLE t1;
15PREPARE stmt1 FROM 'SELECT 1';
16EXECUTE stmt1;
171
181
19SHOW STATUS LIKE 'audit_log%';
20Variable_name Value
21DEALLOCATE PREPARE stmt1;
22show variables like 'audit_log%';
23Variable_name Value
24audit_log_buffer_size 1048576
25audit_log_file test_audit.log
26audit_log_flush OFF
27audit_log_format CSV
28audit_log_handler FILE
29audit_log_policy ALL
30audit_log_rotate_on_size 0
31audit_log_rotations 0
32audit_log_strategy SEMISYNCHRONOUS
33audit_log_syslog_facility LOG_USER
34audit_log_syslog_ident percona-audit
35audit_log_syslog_priority LOG_INFO
36connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
37ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
38create table t1 (id int);
39create table t2 (id int);
40insert into t1 values (1), (2);
41insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2);
42select * from t1;
43id
441
452
46alter table t1 rename renamed_t1;
47select * from t_doesnt_exist;
48ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
49syntax_error_query;
50ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1
51drop table renamed_t1, t2;
52show variables like 'audit_log%';
53Variable_name Value
54audit_log_buffer_size 1048576
55audit_log_file test_audit.log
56audit_log_flush OFF
57audit_log_format CSV
58audit_log_handler FILE
59audit_log_policy ALL
60audit_log_rotate_on_size 0
61audit_log_rotations 0
62audit_log_strategy SEMISYNCHRONOUS
63audit_log_syslog_facility LOG_USER
64audit_log_syslog_ident percona-audit
65audit_log_syslog_priority LOG_INFO
66create database sa_db;
67create table t1 (id2 int);
68insert into t1 values (1), (2);
69select * from t1;
70id2
711
722
73drop table t1;
74use sa_db;
75create table sa_t1(id int);
76insert into sa_t1 values (1), (2);
77drop table sa_t1;
78drop database sa_db;
79create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
80drop user 'jeffrey'@'localhost';
81select '&;&&&""""<><<>>>>';
82&;&&&""""<><<>>>>
83&;&&&""""<><<>>>>
84set global audit_log_flush= ON;
085
=== added file 'mysql-test/r/audit_log_json.result'
--- mysql-test/r/audit_log_json.result 1970-01-01 00:00:00 +0000
+++ mysql-test/r/audit_log_json.result 2014-07-30 17:21:31 +0000
@@ -0,0 +1,84 @@
1CREATE TABLE t1 (c1 INT, c2 CHAR(20));
2CREATE TABLE t1
3(c1 INT,
4c2 CHAR(20));
5ERROR 42S01: Table 't1' already exists
6INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
7SELECT * FROM t1;
8c1 c2
91 a
102 b
113 c
12SELECT * FROM t2;
13ERROR 42S02: Table 'test.t2' doesn't exist
14DROP TABLE t1;
15PREPARE stmt1 FROM 'SELECT 1';
16EXECUTE stmt1;
171
181
19SHOW STATUS LIKE 'audit_log%';
20Variable_name Value
21DEALLOCATE PREPARE stmt1;
22show variables like 'audit_log%';
23Variable_name Value
24audit_log_buffer_size 1048576
25audit_log_file test_audit.log
26audit_log_flush OFF
27audit_log_format JSON
28audit_log_handler FILE
29audit_log_policy ALL
30audit_log_rotate_on_size 0
31audit_log_rotations 0
32audit_log_strategy SEMISYNCHRONOUS
33audit_log_syslog_facility LOG_USER
34audit_log_syslog_ident percona-audit
35audit_log_syslog_priority LOG_INFO
36connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
37ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
38create table t1 (id int);
39create table t2 (id int);
40insert into t1 values (1), (2);
41insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2);
42select * from t1;
43id
441
452
46alter table t1 rename renamed_t1;
47select * from t_doesnt_exist;
48ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
49syntax_error_query;
50ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1
51drop table renamed_t1, t2;
52show variables like 'audit_log%';
53Variable_name Value
54audit_log_buffer_size 1048576
55audit_log_file test_audit.log
56audit_log_flush OFF
57audit_log_format JSON
58audit_log_handler FILE
59audit_log_policy ALL
60audit_log_rotate_on_size 0
61audit_log_rotations 0
62audit_log_strategy SEMISYNCHRONOUS
63audit_log_syslog_facility LOG_USER
64audit_log_syslog_ident percona-audit
65audit_log_syslog_priority LOG_INFO
66create database sa_db;
67create table t1 (id2 int);
68insert into t1 values (1), (2);
69select * from t1;
70id2
711
722
73drop table t1;
74use sa_db;
75create table sa_t1(id int);
76insert into sa_t1 values (1), (2);
77drop table sa_t1;
78drop database sa_db;
79create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
80drop user 'jeffrey'@'localhost';
81select '&;&&&""""<><<>>>>';
82&;&&&""""<><<>>>>
83&;&&&""""<><<>>>>
84set global audit_log_flush= ON;
085
=== added file 'mysql-test/r/audit_log_new.result'
--- mysql-test/r/audit_log_new.result 1970-01-01 00:00:00 +0000
+++ mysql-test/r/audit_log_new.result 2014-07-30 17:21:31 +0000
@@ -0,0 +1,84 @@
1CREATE TABLE t1 (c1 INT, c2 CHAR(20));
2CREATE TABLE t1
3(c1 INT,
4c2 CHAR(20));
5ERROR 42S01: Table 't1' already exists
6INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
7SELECT * FROM t1;
8c1 c2
91 a
102 b
113 c
12SELECT * FROM t2;
13ERROR 42S02: Table 'test.t2' doesn't exist
14DROP TABLE t1;
15PREPARE stmt1 FROM 'SELECT 1';
16EXECUTE stmt1;
171
181
19SHOW STATUS LIKE 'audit_log%';
20Variable_name Value
21DEALLOCATE PREPARE stmt1;
22show variables like 'audit_log%';
23Variable_name Value
24audit_log_buffer_size 1048576
25audit_log_file test_audit.log
26audit_log_flush OFF
27audit_log_format NEW
28audit_log_handler FILE
29audit_log_policy LOGINS
30audit_log_rotate_on_size 0
31audit_log_rotations 0
32audit_log_strategy SEMISYNCHRONOUS
33audit_log_syslog_facility LOG_USER
34audit_log_syslog_ident percona-audit
35audit_log_syslog_priority LOG_INFO
36connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
37ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
38create table t1 (id int);
39create table t2 (id int);
40insert into t1 values (1), (2);
41insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2);
42select * from t1;
43id
441
452
46alter table t1 rename renamed_t1;
47select * from t_doesnt_exist;
48ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
49syntax_error_query;
50ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1
51drop table renamed_t1, t2;
52show variables like 'audit_log%';
53Variable_name Value
54audit_log_buffer_size 1048576
55audit_log_file test_audit.log
56audit_log_flush OFF
57audit_log_format NEW
58audit_log_handler FILE
59audit_log_policy LOGINS
60audit_log_rotate_on_size 0
61audit_log_rotations 0
62audit_log_strategy SEMISYNCHRONOUS
63audit_log_syslog_facility LOG_USER
64audit_log_syslog_ident percona-audit
65audit_log_syslog_priority LOG_INFO
66create database sa_db;
67create table t1 (id2 int);
68insert into t1 values (1), (2);
69select * from t1;
70id2
711
722
73drop table t1;
74use sa_db;
75create table sa_t1(id int);
76insert into sa_t1 values (1), (2);
77drop table sa_t1;
78drop database sa_db;
79create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
80drop user 'jeffrey'@'localhost';
81select '&;&&&""""<><<>>>>';
82&;&&&""""<><<>>>>
83&;&&&""""<><<>>>>
84set global audit_log_flush= ON;
085
=== added file 'mysql-test/r/audit_log_old.result'
--- mysql-test/r/audit_log_old.result 1970-01-01 00:00:00 +0000
+++ mysql-test/r/audit_log_old.result 2014-07-30 17:21:31 +0000
@@ -0,0 +1,84 @@
1CREATE TABLE t1 (c1 INT, c2 CHAR(20));
2CREATE TABLE t1
3(c1 INT,
4c2 CHAR(20));
5ERROR 42S01: Table 't1' already exists
6INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
7SELECT * FROM t1;
8c1 c2
91 a
102 b
113 c
12SELECT * FROM t2;
13ERROR 42S02: Table 'test.t2' doesn't exist
14DROP TABLE t1;
15PREPARE stmt1 FROM 'SELECT 1';
16EXECUTE stmt1;
171
181
19SHOW STATUS LIKE 'audit_log%';
20Variable_name Value
21DEALLOCATE PREPARE stmt1;
22show variables like 'audit_log%';
23Variable_name Value
24audit_log_buffer_size 4096
25audit_log_file test_audit.log
26audit_log_flush OFF
27audit_log_format OLD
28audit_log_handler FILE
29audit_log_policy ALL
30audit_log_rotate_on_size 0
31audit_log_rotations 0
32audit_log_strategy ASYNCHRONOUS
33audit_log_syslog_facility LOG_USER
34audit_log_syslog_ident percona-audit
35audit_log_syslog_priority LOG_INFO
36connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
37ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
38create table t1 (id int);
39create table t2 (id int);
40insert into t1 values (1), (2);
41insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2);
42select * from t1;
43id
441
452
46alter table t1 rename renamed_t1;
47select * from t_doesnt_exist;
48ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
49syntax_error_query;
50ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1
51drop table renamed_t1, t2;
52show variables like 'audit_log%';
53Variable_name Value
54audit_log_buffer_size 4096
55audit_log_file test_audit.log
56audit_log_flush OFF
57audit_log_format OLD
58audit_log_handler FILE
59audit_log_policy ALL
60audit_log_rotate_on_size 0
61audit_log_rotations 0
62audit_log_strategy ASYNCHRONOUS
63audit_log_syslog_facility LOG_USER
64audit_log_syslog_ident percona-audit
65audit_log_syslog_priority LOG_INFO
66create database sa_db;
67create table t1 (id2 int);
68insert into t1 values (1), (2);
69select * from t1;
70id2
711
722
73drop table t1;
74use sa_db;
75create table sa_t1(id int);
76insert into sa_t1 values (1), (2);
77drop table sa_t1;
78drop database sa_db;
79create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
80drop user 'jeffrey'@'localhost';
81select '&;&&&""""<><<>>>>';
82&;&&&""""<><<>>>>
83&;&&&""""<><<>>>>
84set global audit_log_flush= ON;
085
=== added file 'mysql-test/r/audit_log_syslog.result'
--- mysql-test/r/audit_log_syslog.result 1970-01-01 00:00:00 +0000
+++ mysql-test/r/audit_log_syslog.result 2014-07-30 17:21:31 +0000
@@ -0,0 +1,83 @@
1CREATE TABLE t1 (c1 INT, c2 CHAR(20));
2CREATE TABLE t1
3(c1 INT,
4c2 CHAR(20));
5ERROR 42S01: Table 't1' already exists
6INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
7SELECT * FROM t1;
8c1 c2
91 a
102 b
113 c
12SELECT * FROM t2;
13ERROR 42S02: Table 'test.t2' doesn't exist
14DROP TABLE t1;
15PREPARE stmt1 FROM 'SELECT 1';
16EXECUTE stmt1;
171
181
19SHOW STATUS LIKE 'audit_log%';
20Variable_name Value
21DEALLOCATE PREPARE stmt1;
22show variables like 'audit_log%';
23Variable_name Value
24audit_log_buffer_size 1048576
25audit_log_file audit.log
26audit_log_flush OFF
27audit_log_format CSV
28audit_log_handler SYSLOG
29audit_log_policy ALL
30audit_log_rotate_on_size 0
31audit_log_rotations 0
32audit_log_strategy ASYNCHRONOUS
33audit_log_syslog_facility LOG_AUTH
34audit_log_syslog_ident test_audit
35audit_log_syslog_priority LOG_INFO
36connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
37ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
38create table t1 (id int);
39create table t2 (id int);
40insert into t1 values (1), (2);
41insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2);
42select * from t1;
43id
441
452
46alter table t1 rename renamed_t1;
47select * from t_doesnt_exist;
48ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
49syntax_error_query;
50ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1
51drop table renamed_t1, t2;
52show variables like 'audit_log%';
53Variable_name Value
54audit_log_buffer_size 1048576
55audit_log_file audit.log
56audit_log_flush OFF
57audit_log_format CSV
58audit_log_handler SYSLOG
59audit_log_policy ALL
60audit_log_rotate_on_size 0
61audit_log_rotations 0
62audit_log_strategy ASYNCHRONOUS
63audit_log_syslog_facility LOG_AUTH
64audit_log_syslog_ident test_audit
65audit_log_syslog_priority LOG_INFO
66create database sa_db;
67create table t1 (id2 int);
68insert into t1 values (1), (2);
69select * from t1;
70id2
711
722
73drop table t1;
74use sa_db;
75create table sa_t1(id int);
76insert into sa_t1 values (1), (2);
77drop table sa_t1;
78drop database sa_db;
79create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
80drop user 'jeffrey'@'localhost';
81select '&;&&&""""<><<>>>>';
82&;&&&""""<><<>>>>
83&;&&&""""<><<>>>>
084
=== removed file 'mysql-test/t/audit_log-master.opt'
--- mysql-test/t/audit_log-master.opt 2014-04-21 12:07:45 +0000
+++ mysql-test/t/audit_log-master.opt 1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
1$AUDIT_LOG_OPT
2$AUDIT_LOG_LOAD
3--audit_log_file=test_audit.log
4--audit_log_buffer_size=4096
50
=== removed file 'mysql-test/t/audit_log.test'
--- mysql-test/t/audit_log.test 2014-05-23 16:14:27 +0000
+++ mysql-test/t/audit_log.test 1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
1--source include/not_embedded.inc
2
3let $MYSQLD_DATADIR= `select @@datadir`;
4let MYSQLD_DATADIR= $MYSQLD_DATADIR;
5
6--source include/audit_log_events.inc
7
8--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_old.log
9set global audit_log_flush= ON;
10perl;
11 eval "use XML::Parser; 1" or exit 0;
12 $p = new XML::Parser;
13 $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_old.log');
14EOF
15--remove_file $MYSQLD_DATADIR/test_audit.log
16
17--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
18--shutdown_server
19--source include/wait_until_disconnected.inc
20--enable_reconnect
21--exec echo "restart: --audit_log_policy=LOGINS --audit-log-format=NEW --audit_log_strategy=SEMISYNCHRONOUS" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
22--source include/wait_until_connected_again.inc
23
24--source include/audit_log_events.inc
25
26--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_new.log
27set global audit_log_flush= ON;
28perl;
29 eval "use XML::Parser; 1" or exit 0;
30 $p = new XML::Parser;
31 $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_new.log');
32EOF
33--remove_file $MYSQLD_DATADIR/test_audit.log
34
35--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
36--shutdown_server
37--source include/wait_until_disconnected.inc
38--enable_reconnect
39--exec echo "restart: --audit-log-format=JSON --audit_log_strategy=SEMISYNCHRONOUS" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
40--source include/wait_until_connected_again.inc
41
42--source include/audit_log_events.inc
43
44--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_json.log
45set global audit_log_flush= ON;
46perl;
47 eval "use JSON qw(decode_json); 1" or exit 0;
48 open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_json.log' or die "Could not open log: $!";
49 while (my $line = <$file>) {
50 decode_json($line);
51 }
52 close $file;
53EOF
54--remove_file $MYSQLD_DATADIR/test_audit.log
55
56--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
57--shutdown_server
58--source include/wait_until_disconnected.inc
59--enable_reconnect
60--exec echo "restart: --audit-log-format=CSV --audit_log_strategy=SEMISYNCHRONOUS" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
61--source include/wait_until_connected_again.inc
62
63--source include/audit_log_events.inc
64
65--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_csv.log
66set global audit_log_flush= ON;
67perl;
68 eval "use Text::CSV; 1" or exit 0;
69 my $p = Text::CSV->new({ binary => 1, auto_diag => 1, sep_char => ',' });
70 open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_csv.log' or die "Could not open log: $!";
71 while ($p->getline($file)) {};
72 if (not $p->eof) {
73 die "CSV parse error " . $p->error_diag();
74 }
75 close $file;
76EOF
77--remove_file $MYSQLD_DATADIR/test_audit.log
780
=== added file 'mysql-test/t/audit_log_csv-master.opt'
--- mysql-test/t/audit_log_csv-master.opt 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_csv-master.opt 2014-07-30 17:21:31 +0000
@@ -0,0 +1,5 @@
1$AUDIT_LOG_OPT
2$AUDIT_LOG_LOAD
3--audit_log_file=test_audit.log
4--audit-log-format=CSV
5--audit_log_strategy=SEMISYNCHRONOUS
06
=== added file 'mysql-test/t/audit_log_csv.test'
--- mysql-test/t/audit_log_csv.test 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_csv.test 2014-07-30 17:21:31 +0000
@@ -0,0 +1,20 @@
1--source include/not_embedded.inc
2
3let $MYSQLD_DATADIR= `select @@datadir`;
4let MYSQLD_DATADIR= $MYSQLD_DATADIR;
5
6--source include/audit_log_events.inc
7
8--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_csv.log
9set global audit_log_flush= ON;
10perl;
11 eval "use Text::CSV; 1" or exit 0;
12 my $p = Text::CSV->new({ binary => 1, auto_diag => 1, sep_char => ',' });
13 open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_csv.log' or die "Could not open log: $!";
14 while ($p->getline($file)) {};
15 if (not $p->eof) {
16 die "CSV parse error " . $p->error_diag();
17 }
18 close $file;
19EOF
20--remove_file $MYSQLD_DATADIR/test_audit.log
021
=== added file 'mysql-test/t/audit_log_json-master.opt'
--- mysql-test/t/audit_log_json-master.opt 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_json-master.opt 2014-07-30 17:21:31 +0000
@@ -0,0 +1,5 @@
1$AUDIT_LOG_OPT
2$AUDIT_LOG_LOAD
3--audit_log_file=test_audit.log
4--audit-log-format=JSON
5--audit_log_strategy=SEMISYNCHRONOUS
06
=== added file 'mysql-test/t/audit_log_json.test'
--- mysql-test/t/audit_log_json.test 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_json.test 2014-07-30 17:21:31 +0000
@@ -0,0 +1,18 @@
1--source include/not_embedded.inc
2
3let $MYSQLD_DATADIR= `select @@datadir`;
4let MYSQLD_DATADIR= $MYSQLD_DATADIR;
5
6--source include/audit_log_events.inc
7
8--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_json.log
9set global audit_log_flush= ON;
10perl;
11 eval "use JSON qw(decode_json); 1" or exit 0;
12 open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_json.log' or die "Could not open log: $!";
13 while (my $line = <$file>) {
14 decode_json($line);
15 }
16 close $file;
17EOF
18--remove_file $MYSQLD_DATADIR/test_audit.log
019
=== added file 'mysql-test/t/audit_log_new-master.opt'
--- mysql-test/t/audit_log_new-master.opt 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_new-master.opt 2014-07-30 17:21:31 +0000
@@ -0,0 +1,6 @@
1$AUDIT_LOG_OPT
2$AUDIT_LOG_LOAD
3--audit_log_file=test_audit.log
4--audit_log_policy=LOGINS
5--audit-log-format=NEW
6--audit_log_strategy=SEMISYNCHRONOUS
07
=== added file 'mysql-test/t/audit_log_new.test'
--- mysql-test/t/audit_log_new.test 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_new.test 2014-07-30 17:21:31 +0000
@@ -0,0 +1,15 @@
1--source include/not_embedded.inc
2
3let $MYSQLD_DATADIR= `select @@datadir`;
4let MYSQLD_DATADIR= $MYSQLD_DATADIR;
5
6--source include/audit_log_events.inc
7
8--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_new.log
9set global audit_log_flush= ON;
10perl;
11 eval "use XML::Parser; 1" or exit 0;
12 $p = new XML::Parser;
13 $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_new.log');
14EOF
15--remove_file $MYSQLD_DATADIR/test_audit.log
016
=== added file 'mysql-test/t/audit_log_old-master.opt'
--- mysql-test/t/audit_log_old-master.opt 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_old-master.opt 2014-07-30 17:21:31 +0000
@@ -0,0 +1,5 @@
1$AUDIT_LOG_OPT
2$AUDIT_LOG_LOAD
3--audit_log_file=test_audit.log
4--audit_log_buffer_size=4096
5--audit_log_strategy=ASYNCHRONOUS
06
=== added file 'mysql-test/t/audit_log_old.test'
--- mysql-test/t/audit_log_old.test 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_old.test 2014-07-30 17:21:31 +0000
@@ -0,0 +1,15 @@
1--source include/not_embedded.inc
2
3let $MYSQLD_DATADIR= `select @@datadir`;
4let MYSQLD_DATADIR= $MYSQLD_DATADIR;
5
6--source include/audit_log_events.inc
7
8--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_old.log
9set global audit_log_flush= ON;
10perl;
11 eval "use XML::Parser; 1" or exit 0;
12 $p = new XML::Parser;
13 $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_old.log');
14EOF
15--remove_file $MYSQLD_DATADIR/test_audit.log
016
=== added file 'mysql-test/t/audit_log_syslog-master.opt'
--- mysql-test/t/audit_log_syslog-master.opt 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_syslog-master.opt 2014-07-30 17:21:31 +0000
@@ -0,0 +1,7 @@
1$AUDIT_LOG_OPT
2$AUDIT_LOG_LOAD
3--audit-log-format=CSV
4--audit_log_handler=SYSLOG
5--audit_log_syslog_ident=test_audit
6--audit_log_syslog_facility=LOG_AUTH
7--audit_log_syslog_priority=LOG_INFO
08
=== added file 'mysql-test/t/audit_log_syslog.test'
--- mysql-test/t/audit_log_syslog.test 1970-01-01 00:00:00 +0000
+++ mysql-test/t/audit_log_syslog.test 2014-07-30 17:21:31 +0000
@@ -0,0 +1,3 @@
1--source include/not_embedded.inc
2
3--source include/audit_log_events.inc
04
=== modified file 'plugin/audit_log/CMakeLists.txt'
--- plugin/audit_log/CMakeLists.txt 2014-04-21 12:07:45 +0000
+++ plugin/audit_log/CMakeLists.txt 2014-07-30 17:21:31 +0000
@@ -13,5 +13,6 @@
13# along with this program; if not, write to the Free Software13# along with this program; if not, write to the Free Software
14# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA14# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1515
16MYSQL_ADD_PLUGIN(audit_log audit_log.c file_logger.c buffer.c16MYSQL_ADD_PLUGIN(audit_log audit_log.c file_logger.c buffer.c audit_file.c
17 audit_syslog.c
17 MODULE_ONLY MODULE_OUTPUT_NAME "audit_log")18 MODULE_ONLY MODULE_OUTPUT_NAME "audit_log")
1819
=== added file 'plugin/audit_log/audit_file.c'
--- plugin/audit_log/audit_file.c 1970-01-01 00:00:00 +0000
+++ plugin/audit_log/audit_file.c 2014-07-30 17:21:31 +0000
@@ -0,0 +1,200 @@
1/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved.
2
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; version 2 of
6 the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17#include "audit_handler.h"
18#include "buffer.h"
19
20typedef struct audit_handler_file_data_struct audit_handler_file_data_t;
21
22struct audit_handler_file_data_struct
23{
24 size_t struct_size;
25 LOGGER_HANDLE *logger;
26 logger_prolog_func_t header;
27 logger_epilog_func_t footer;
28 my_bool sync_on_write;
29 my_bool use_buffer;
30 audit_log_buffer_t *buffer;
31};
32
33static
34int audit_handler_file_write(audit_handler_t *handler,
35 const char *buf, size_t len);
36static
37int audit_handler_file_flush(audit_handler_t *handler);
38static
39int audit_handler_file_close(audit_handler_t *handler);
40static
41int audit_handler_file_write_nobuf(LOGGER_HANDLE *logger,
42 const char *buf, size_t len);
43static
44int audit_handler_file_write_buf(audit_log_buffer_t *buffer,
45 const char *buf, size_t len);
46static
47void audit_handler_file_set_option(audit_handler_t *handler,
48 audit_handler_option_t opt, void *val);
49
50static
51int write_callback(void *data, const char *buf, size_t len)
52{
53 audit_handler_t *handler= (audit_handler_t *) data;
54 audit_handler_file_data_t *hdata= (audit_handler_file_data_t*) handler->data;
55
56 DBUG_ASSERT(hdata->struct_size == sizeof(audit_handler_file_data_t));
57
58 return audit_handler_file_write_nobuf(hdata->logger, buf, len);
59}
60
61
62audit_handler_t *audit_handler_file_open(audit_handler_file_config_t *opts)
63{
64 audit_handler_t *handler= (audit_handler_t*)
65 calloc(sizeof(audit_handler_t) + sizeof(audit_handler_file_data_t), 1);
66 if (handler != NULL)
67 {
68 audit_handler_file_data_t *data= (audit_handler_file_data_t*) (handler + 1);
69 data->struct_size= sizeof(audit_handler_file_data_t);
70 data->footer= opts->footer;
71 data->header= opts->header;
72 data->sync_on_write= opts->sync_on_write;
73 data->use_buffer= opts->use_buffer;
74 if (data->use_buffer)
75 {
76 data->buffer= audit_log_buffer_init(opts->buffer_size,
77 opts->can_drop_data,
78 write_callback, handler);
79 if (data->buffer == NULL)
80 goto error;
81 }
82 data->logger= logger_open(opts->name, opts->rotate_on_size,
83 opts->rotate_on_size ? opts->rotations : 0,
84 !opts->use_buffer, opts->header);
85 if (data->logger == NULL)
86 {
87 goto error;
88 }
89 handler->data= data;
90 handler->write= audit_handler_file_write;
91 handler->flush= audit_handler_file_flush;
92 handler->close= audit_handler_file_close;
93 handler->set_option= audit_handler_file_set_option;
94 goto success;
95error:
96 if (data->use_buffer)
97 {
98 free(data->buffer);
99 }
100 free(handler);
101 handler= NULL;
102 }
103success:
104 return handler;
105}
106
107static
108int audit_handler_file_write_nobuf(LOGGER_HANDLE *logger,
109 const char *buf, size_t len)
110{
111 return logger_write(logger, buf, len);
112}
113
114static
115int audit_handler_file_write_buf(audit_log_buffer_t *buffer,
116 const char *buf, size_t len)
117{
118 return audit_log_buffer_write(buffer, buf, len);
119}
120
121static
122int audit_handler_file_write(audit_handler_t *handler,
123 const char *buf, size_t len)
124{
125 audit_handler_file_data_t *data= (audit_handler_file_data_t*) handler->data;
126 int res;
127
128 DBUG_ASSERT(data->struct_size == sizeof(audit_handler_file_data_t));
129
130 if (data->use_buffer)
131 {
132 DBUG_ASSERT(data->buffer);
133 res= audit_handler_file_write_buf(data->buffer, buf, len);
134 }
135 else
136 {
137 DBUG_ASSERT(data->logger);
138 res= audit_handler_file_write_nobuf(data->logger, buf, len);
139
140 if (data->sync_on_write)
141 {
142 logger_sync(data->logger);
143 }
144 }
145
146 return res;
147}
148
149static
150int audit_handler_file_flush(audit_handler_t *handler)
151{
152 audit_handler_file_data_t *data= (audit_handler_file_data_t*) handler->data;
153 LOGGER_HANDLE* logger;
154
155 DBUG_ASSERT(data->struct_size == sizeof(audit_handler_file_data_t));
156
157 logger= data->logger;
158
159 return logger_reopen(logger, data->header, data->footer);
160}
161
162static
163int audit_handler_file_close(audit_handler_t *handler)
164{
165 audit_handler_file_data_t *data= (audit_handler_file_data_t*) handler->data;
166 int res;
167 LOGGER_HANDLE* logger;
168
169 DBUG_ASSERT(data->struct_size == sizeof(audit_handler_file_data_t));
170
171 logger= data->logger;
172
173 if (data->use_buffer)
174 {
175 audit_log_buffer_shutdown(data->buffer);
176 }
177
178 res= logger_close(logger, data->footer);
179
180 free(handler);
181
182 return res;
183}
184
185static
186void audit_handler_file_set_option(audit_handler_t *handler,
187 audit_handler_option_t opt, void *val)
188{
189 audit_handler_file_data_t *data= (audit_handler_file_data_t*) handler->data;
190
191 switch (opt)
192 {
193 case OPT_ROTATIONS:
194 logger_set_size_limit(data->logger, *(ulonglong*)(val));
195 break;
196 case OPT_ROTATE_ON_SIZE:
197 logger_set_rotations(data->logger, *(ulonglong*)(val));
198 break;
199 }
200}
0201
=== added file 'plugin/audit_log/audit_handler.h'
--- plugin/audit_log/audit_handler.h 1970-01-01 00:00:00 +0000
+++ plugin/audit_log/audit_handler.h 2014-07-30 17:21:31 +0000
@@ -0,0 +1,116 @@
1/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved.
2
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; version 2 of
6 the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17
18#ifndef AUDIT_HANDLER_INCLUDED
19#define AUDIT_HANDLER_INCLUDED
20
21#include <my_global.h>
22
23#include "logger.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29typedef struct audit_handler_struct audit_handler_t;
30typedef struct audit_handler_file_config_struct audit_handler_file_config_t;
31typedef struct audit_handler_syslog_config_struct audit_handler_syslog_config_t;
32typedef struct audit_handler_buffered_struct audit_handler_buffered_t;
33typedef void * audit_handler_data_t;
34
35
36typedef enum { OPT_ROTATE_ON_SIZE, OPT_ROTATIONS } audit_handler_option_t;
37
38struct audit_handler_struct
39{
40 int (*write)(audit_handler_t *, const char *, size_t);
41 int (*flush)(audit_handler_t *);
42 int (*close)(audit_handler_t *);
43 void (*set_option)(audit_handler_t *, audit_handler_option_t, void *);
44 audit_handler_data_t data;
45};
46
47struct audit_handler_file_config_struct
48{
49 const char *name;
50 size_t rotate_on_size;
51 size_t rotations;
52 my_bool sync_on_write;
53 my_bool use_buffer;
54 size_t buffer_size;
55 my_bool can_drop_data;
56 logger_prolog_func_t header;
57 logger_epilog_func_t footer;
58};
59
60struct audit_handler_syslog_config_struct
61{
62 const char *ident;
63 int facility;
64 int priority;
65 logger_prolog_func_t header;
66 logger_epilog_func_t footer;
67};
68
69static inline
70int audit_handler_write(audit_handler_t *handler, const char *buf, size_t len)
71{
72 if (handler->write != NULL)
73 {
74 return handler->write(handler, buf, len);
75 }
76 return len;
77}
78
79static inline
80int audit_handler_flush(audit_handler_t *handler)
81{
82 if (handler->flush != NULL)
83 {
84 return handler->flush(handler);
85 }
86 return 0;
87}
88
89static inline
90int audit_handler_close(audit_handler_t *handler)
91{
92 if (handler->close != NULL)
93 {
94 return handler->close(handler);
95 }
96 return 0;
97}
98
99static inline
100void audit_handler_set_option(audit_handler_t *handler,
101 audit_handler_option_t opt, void *val)
102{
103 if (handler->set_option != NULL)
104 {
105 handler->set_option(handler, opt, val);
106 }
107}
108
109audit_handler_t *audit_handler_file_open(audit_handler_file_config_t *opts);
110audit_handler_t *audit_handler_syslog_open(audit_handler_syslog_config_t *opts);
111
112#ifdef __cplusplus
113}
114#endif
115
116#endif
0117
=== modified file 'plugin/audit_log/audit_log.c'
--- plugin/audit_log/audit_log.c 2014-05-23 16:14:27 +0000
+++ plugin/audit_log/audit_log.c 2014-07-30 17:21:31 +0000
@@ -25,22 +25,24 @@
25#include <mysql_version.h>25#include <mysql_version.h>
26#include <mysql_com.h>26#include <mysql_com.h>
27#include <my_pthread.h>27#include <my_pthread.h>
28#include <syslog.h>
2829
29#include "logger.h"30#include "logger.h"
30#include "buffer.h"31#include "buffer.h"
32#include "audit_handler.h"
3133
32#define PLUGIN_VERSION 0x000134#define PLUGIN_VERSION 0x0002
3335
3436
35enum audit_log_policy_t { ALL, NONE, LOGINS, QUERIES };37enum audit_log_policy_t { ALL, NONE, LOGINS, QUERIES };
36enum audit_log_strategy_t38enum audit_log_strategy_t
37 { ASYNCHRONOUS, PERFORMANCE, SEMISYNCHRONOUS, SYNCHRONOUS };39 { ASYNCHRONOUS, PERFORMANCE, SEMISYNCHRONOUS, SYNCHRONOUS };
38enum audit_log_format_t { OLD, NEW, JSON, CSV };40enum audit_log_format_t { OLD, NEW, JSON, CSV };
41enum audit_log_handler_t { HANDLER_FILE, HANDLER_SYSLOG };
3942
40typedef void (*escape_buf_func_t)(const char *, size_t *, char *, size_t *);43typedef void (*escape_buf_func_t)(const char *, size_t *, char *, size_t *);
4144
42static LOGGER_HANDLE *audit_file_logger= NULL;45static audit_handler_t *log_handler= NULL;
43static audit_log_buffer_t *audit_log_buffer= NULL;
44static ulonglong record_id= 0;46static ulonglong record_id= 0;
45static time_t log_file_time= 0;47static time_t log_file_time= 0;
46char *audit_log_file;48char *audit_log_file;
@@ -52,6 +54,43 @@
52ulonglong audit_log_rotations= 0;54ulonglong audit_log_rotations= 0;
53char audit_log_flush= FALSE;55char audit_log_flush= FALSE;
54ulong audit_log_format= OLD;56ulong audit_log_format= OLD;
57ulong audit_log_handler= HANDLER_FILE;
58char *audit_log_syslog_ident;
59char default_audit_log_syslog_ident[] = "percona-audit";
60ulong audit_log_syslog_facility= 0;
61ulong audit_log_syslog_priority= 0;
62
63
64static int audit_log_syslog_facility_codes[]=
65 { LOG_USER, LOG_AUTHPRIV, LOG_CRON, LOG_DAEMON, LOG_FTP,
66 LOG_KERN, LOG_LPR, LOG_MAIL, LOG_NEWS,
67#if (defined LOG_SECURITY)
68 LOG_SECURITY,
69#endif
70 LOG_SYSLOG, LOG_AUTH, LOG_UUCP, LOG_LOCAL0, LOG_LOCAL1,
71 LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6,
72 LOG_LOCAL7, 0};
73
74
75static const char *audit_log_syslog_facility_names[]=
76 { "LOG_USER", "LOG_AUTHPRIV", "LOG_CRON", "LOG_DAEMON", "LOG_FTP",
77 "LOG_KERN", "LOG_LPR", "LOG_MAIL", "LOG_NEWS",
78#if (defined LOG_SECURITY)
79 "LOG_SECURITY",
80#endif
81 "LOG_SYSLOG", "LOG_AUTH", "LOG_UUCP", "LOG_LOCAL0", "LOG_LOCAL1",
82 "LOG_LOCAL2", "LOG_LOCAL3", "LOG_LOCAL4", "LOG_LOCAL5", "LOG_LOCAL6",
83 "LOG_LOCAL7", 0 };
84
85
86static const int audit_log_syslog_priority_codes[]=
87 { LOG_INFO, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING,
88 LOG_NOTICE, LOG_EMERG, LOG_DEBUG, 0 };
89
90
91static const char *audit_log_syslog_priority_names[]=
92 { "LOG_INFO", "LOG_ALERT", "LOG_CRIT", "LOG_ERR", "LOG_WARNING",
93 "LOG_NOTICE", "LOG_EMERG", "LOG_DEBUG", 0 };
5594
5695
57static96static
@@ -228,14 +267,15 @@
228 return out;267 return out;
229}268}
230269
270
231static271static
232void logger_write_safe(LOGGER_HANDLE *log, const char *buffer, size_t size)272void audit_log_write(const char *buf, size_t len)
233{273{
234 static int write_error= 0;274 static int write_error= 0;
235275
236 if (log != NULL)276 if (log_handler != NULL)
237 {277 {
238 if (logger_write(log, buffer, size) < 0)278 if (audit_handler_write(log_handler, buf, len) < 0)
239 {279 {
240 if (!write_error)280 if (!write_error)
241 {281 {
@@ -253,44 +293,6 @@
253}293}
254294
255295
256static
257void logger_write_safe_void(void *log, const char *buffer, size_t size)
258{
259 logger_write_safe((LOGGER_HANDLE *)log, buffer, size);
260}
261
262
263static
264void audit_log_write_without_buffer(const char *buf, size_t len)
265{
266 logger_write_safe(audit_file_logger, buf, len);
267 if (audit_log_strategy == SYNCHRONOUS && audit_file_logger != NULL)
268 {
269 logger_sync(audit_file_logger);
270 }
271}
272
273
274static
275void audit_log_write(const char *buf, size_t len)
276{
277 switch (audit_log_strategy)
278 {
279 case ASYNCHRONOUS:
280 case PERFORMANCE:
281 if (audit_log_buffer != NULL)
282 audit_log_buffer_write(audit_log_buffer, buf, len);
283 break;
284 case SEMISYNCHRONOUS:
285 case SYNCHRONOUS:
286 audit_log_write_without_buffer(buf, len);
287 break;
288 default:
289 DBUG_ASSERT(0);
290 }
291}
292
293
294296
295/* Defined in MySQL server */297/* Defined in MySQL server */
296extern int orig_argc;298extern int orig_argc;
@@ -541,6 +543,11 @@
541543
542 init_record_id(stat->st_size);544 init_record_id(stat->st_size);
543545
546 if (buf == NULL)
547 {
548 return 0;
549 }
550
544 return my_snprintf(buf, buflen, format_string[audit_log_format]);551 return my_snprintf(buf, buflen, format_string[audit_log_format]);
545}552}
546553
@@ -554,22 +561,56 @@
554 "",561 "",
555 "" };562 "" };
556563
564 if (buf == NULL)
565 {
566 return 0;
567 }
568
557 return my_snprintf(buf, buflen, format_string[audit_log_format]);569 return my_snprintf(buf, buflen, format_string[audit_log_format]);
558}570}
559571
560static572static
561int init_new_log_file()573int init_new_log_file()
562{574{
563 audit_file_logger= logger_open(audit_log_file, audit_log_rotate_on_size,575 if (audit_log_handler == HANDLER_FILE)
564 audit_log_rotate_on_size ? audit_log_rotations : 0,576 {
565 audit_log_strategy >= SEMISYNCHRONOUS,577 audit_handler_file_config_t opts;
566 audit_log_header);578 opts.name= audit_log_file;
567 if (audit_file_logger == NULL)579 opts.rotate_on_size= audit_log_rotate_on_size;
568 {580 opts.rotations= audit_log_rotations;
569 fprintf_timestamp(stderr);581 opts.sync_on_write= audit_log_strategy == SYNCHRONOUS;
570 fprintf(stderr, "Cannot open file %s. ", audit_log_file);582 opts.use_buffer= audit_log_strategy < SEMISYNCHRONOUS;
571 perror("Error: ");583 opts.buffer_size= audit_log_buffer_size;
572 return(1);584 opts.can_drop_data= audit_log_strategy == PERFORMANCE;
585 opts.header= audit_log_header;
586 opts.footer= audit_log_footer;
587
588 log_handler= audit_handler_file_open(&opts);
589 if (log_handler == NULL)
590 {
591 fprintf_timestamp(stderr);
592 fprintf(stderr, "Cannot open file %s. ", audit_log_file);
593 perror("Error: ");
594 return(1);
595 }
596 }
597 else
598 {
599 audit_handler_syslog_config_t opts;
600 opts.facility= audit_log_syslog_facility_codes[audit_log_syslog_facility];
601 opts.ident= audit_log_syslog_ident;
602 opts.priority= audit_log_syslog_priority_codes[audit_log_syslog_priority];
603 opts.header= audit_log_header;
604 opts.footer= audit_log_footer;
605
606 log_handler= audit_handler_syslog_open(&opts);
607 if (log_handler == NULL)
608 {
609 fprintf_timestamp(stderr);
610 fprintf(stderr, "Cannot open syslog. ");
611 perror("Error: ");
612 return(1);
613 }
573 }614 }
574615
575 return(0);616 return(0);
@@ -579,12 +620,15 @@
579static620static
580int reopen_log_file()621int reopen_log_file()
581{622{
582 if (logger_reopen(audit_file_logger, audit_log_header, audit_log_footer))623 if (log_handler != NULL)
583 {624 {
584 fprintf_timestamp(stderr);625 if (audit_handler_flush(log_handler))
585 fprintf(stderr, "Cannot open file %s. ", audit_log_file);626 {
586 perror("Error: ");627 fprintf_timestamp(stderr);
587 return(1);628 fprintf(stderr, "Cannot open file %s. ", audit_log_file);
629 perror("Error: ");
630 return(1);
631 }
588 }632 }
589633
590 return(0);634 return(0);
@@ -592,14 +636,6 @@
592636
593637
594static638static
595void close_log_file()
596{
597 if (audit_file_logger != NULL)
598 logger_close(audit_file_logger, audit_log_footer);
599}
600
601
602static
603int audit_log_plugin_init(void *arg __attribute__((unused)))639int audit_log_plugin_init(void *arg __attribute__((unused)))
604{640{
605 char buf[1024];641 char buf[1024];
@@ -610,13 +646,6 @@
610 if (init_new_log_file())646 if (init_new_log_file())
611 return(1);647 return(1);
612648
613 if (audit_log_strategy < SEMISYNCHRONOUS)
614 {
615 audit_log_buffer= audit_log_buffer_init(audit_log_buffer_size,
616 audit_log_strategy == PERFORMANCE, logger_write_safe_void,
617 audit_file_logger);
618 }
619
620 len= audit_log_audit_record(buf, sizeof(buf), "Audit", time(NULL));649 len= audit_log_audit_record(buf, sizeof(buf), "Audit", time(NULL));
621 audit_log_write(buf, len);650 audit_log_write(buf, len);
622651
@@ -633,9 +662,7 @@
633 len= audit_log_audit_record(buf, sizeof(buf), "NoAudit", time(NULL));662 len= audit_log_audit_record(buf, sizeof(buf), "NoAudit", time(NULL));
634 audit_log_write(buf, len);663 audit_log_write(buf, len);
635664
636 if (audit_log_buffer != NULL)665 audit_handler_close(log_handler);
637 audit_log_buffer_shutdown(audit_log_buffer);
638 close_log_file();
639666
640 return(0);667 return(0);
641}668}
@@ -729,8 +756,8 @@
729756
730static TYPELIB audit_log_policy_typelib=757static TYPELIB audit_log_policy_typelib=
731{758{
732 array_elements(audit_log_policy_names) - 1, "audit_log_policy_typelib",759 array_elements(audit_log_policy_names) - 1, "audit_log_policy_typelib",
733 audit_log_policy_names, NULL760 audit_log_policy_names, NULL
734};761};
735762
736static MYSQL_SYSVAR_ENUM(policy, audit_log_policy, PLUGIN_VAR_RQCMDARG,763static MYSQL_SYSVAR_ENUM(policy, audit_log_policy, PLUGIN_VAR_RQCMDARG,
@@ -742,21 +769,22 @@
742 { "ASYNCHRONOUS", "PERFORMANCE", "SEMISYNCHRONOUS", "SYNCHRONOUS", 0 };769 { "ASYNCHRONOUS", "PERFORMANCE", "SEMISYNCHRONOUS", "SYNCHRONOUS", 0 };
743static TYPELIB audit_log_strategy_typelib=770static TYPELIB audit_log_strategy_typelib=
744{771{
745 array_elements(audit_log_strategy_names) - 1, "audit_log_strategy_typelib",772 array_elements(audit_log_strategy_names) - 1, "audit_log_strategy_typelib",
746 audit_log_strategy_names, NULL773 audit_log_strategy_names, NULL
747};774};
748775
749static MYSQL_SYSVAR_ENUM(strategy, audit_log_strategy,776static MYSQL_SYSVAR_ENUM(strategy, audit_log_strategy,
750 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,777 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
751 "The logging method used by the audit log plugin.", NULL, NULL,778 "The logging method used by the audit log plugin, "
779 "if FILE handler is used.", NULL, NULL,
752 ASYNCHRONOUS, &audit_log_strategy_typelib);780 ASYNCHRONOUS, &audit_log_strategy_typelib);
753781
754static const char *audit_log_format_names[]=782static const char *audit_log_format_names[]=
755 { "OLD", "NEW", "JSON", "CSV", 0 };783 { "OLD", "NEW", "JSON", "CSV", 0 };
756static TYPELIB audit_log_format_typelib=784static TYPELIB audit_log_format_typelib=
757{785{
758 array_elements(audit_log_format_names) - 1, "audit_log_format_typelib",786 array_elements(audit_log_format_names) - 1, "audit_log_format_typelib",
759 audit_log_format_names, NULL787 audit_log_format_names, NULL
760};788};
761789
762static MYSQL_SYSVAR_ENUM(format, audit_log_format,790static MYSQL_SYSVAR_ENUM(format, audit_log_format,
@@ -764,9 +792,23 @@
764 "The audit log file format.", NULL, NULL,792 "The audit log file format.", NULL, NULL,
765 ASYNCHRONOUS, &audit_log_format_typelib);793 ASYNCHRONOUS, &audit_log_format_typelib);
766794
795static const char *audit_log_handler_names[]=
796 { "FILE", "SYSLOG", 0 };
797static TYPELIB audit_log_handler_typelib=
798{
799 array_elements(audit_log_handler_names) - 1, "audit_log_handler_typelib",
800 audit_log_handler_names, NULL
801};
802
803static MYSQL_SYSVAR_ENUM(handler, audit_log_handler,
804 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
805 "The audit log handler.", NULL, NULL,
806 HANDLER_FILE, &audit_log_handler_typelib);
807
767static MYSQL_SYSVAR_ULONGLONG(buffer_size, audit_log_buffer_size,808static MYSQL_SYSVAR_ULONGLONG(buffer_size, audit_log_buffer_size,
768 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,809 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
769 "The size of the buffer for asynchronous logging.",810 "The size of the buffer for asynchronous logging, "
811 "if FILE handler is used.",
770 NULL, NULL, 1048576UL, 4096UL, ULONGLONG_MAX, 4096UL);812 NULL, NULL, 1048576UL, 4096UL, ULONGLONG_MAX, 4096UL);
771813
772static814static
@@ -778,13 +820,15 @@
778{820{
779 ulonglong new_val= *(ulonglong *)(save);821 ulonglong new_val= *(ulonglong *)(save);
780822
781 if (audit_file_logger)823 if (log_handler != NULL)
782 logger_set_size_limit(audit_file_logger, new_val);824 audit_handler_set_option(log_handler, OPT_ROTATE_ON_SIZE, &new_val);
825
826 audit_log_rotate_on_size= new_val;
783}827}
784828
785static MYSQL_SYSVAR_ULONGLONG(rotate_on_size, audit_log_rotate_on_size,829static MYSQL_SYSVAR_ULONGLONG(rotate_on_size, audit_log_rotate_on_size,
786 PLUGIN_VAR_RQCMDARG,830 PLUGIN_VAR_RQCMDARG,
787 "Maximum size of the log to start the rotation.",831 "Maximum size of the log to start the rotation, if FILE handler is used.",
788 NULL, audit_log_rotate_on_size_update, 0UL, 0UL, ULONGLONG_MAX, 4096UL);832 NULL, audit_log_rotate_on_size_update, 0UL, 0UL, ULONGLONG_MAX, 4096UL);
789833
790static834static
@@ -796,13 +840,15 @@
796{840{
797 ulonglong new_val= *(ulonglong *)(save);841 ulonglong new_val= *(ulonglong *)(save);
798842
799 if (audit_file_logger)843 if (log_handler != NULL)
800 logger_set_rotations(audit_file_logger, new_val);844 audit_handler_set_option(log_handler, OPT_ROTATIONS, &new_val);
845
846 audit_log_rotations= new_val;
801}847}
802848
803static MYSQL_SYSVAR_ULONGLONG(rotations, audit_log_rotations,849static MYSQL_SYSVAR_ULONGLONG(rotations, audit_log_rotations,
804 PLUGIN_VAR_RQCMDARG,850 PLUGIN_VAR_RQCMDARG,
805 "Maximum number of rotations to keep.",851 "Maximum number of rotations to keep, if FILE handler is used.",
806 NULL, audit_log_rotations_update, 0UL, 0UL, 999UL, 1UL);852 NULL, audit_log_rotations_update, 0UL, 0UL, 999UL, 1UL);
807853
808static854static
@@ -826,6 +872,39 @@
826 PLUGIN_VAR_OPCMDARG, "Flush the log file.", NULL,872 PLUGIN_VAR_OPCMDARG, "Flush the log file.", NULL,
827 audit_log_flush_update, 0);873 audit_log_flush_update, 0);
828874
875static MYSQL_SYSVAR_STR(syslog_ident, audit_log_syslog_ident,
876 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
877 "The string that will be prepended to each log message, "
878 "if SYSLOG handler is used.",
879 NULL, NULL, default_audit_log_syslog_ident);
880
881static TYPELIB audit_log_syslog_facility_typelib=
882{
883 array_elements(audit_log_syslog_facility_names) - 1,
884 "audit_log_syslog_facility_typelib",
885 audit_log_syslog_facility_names, NULL
886};
887
888static MYSQL_SYSVAR_ENUM(syslog_facility, audit_log_syslog_facility,
889 PLUGIN_VAR_RQCMDARG,
890 "The syslog facility to assign to messages, if SYSLOG handler is used.",
891 NULL, NULL, 0,
892 &audit_log_syslog_facility_typelib);
893
894static TYPELIB audit_log_syslog_priority_typelib=
895{
896 array_elements(audit_log_syslog_priority_names) - 1,
897 "audit_log_syslog_priority_typelib",
898 audit_log_syslog_priority_names, NULL
899};
900
901static MYSQL_SYSVAR_ENUM(syslog_priority, audit_log_syslog_priority,
902 PLUGIN_VAR_RQCMDARG,
903 "Priority to be assigned to all messages written to syslog.",
904 NULL, NULL, 0,
905 &audit_log_syslog_priority_typelib);
906
907
829static struct st_mysql_sys_var* audit_log_system_variables[] =908static struct st_mysql_sys_var* audit_log_system_variables[] =
830{909{
831 MYSQL_SYSVAR(file),910 MYSQL_SYSVAR(file),
@@ -836,6 +915,10 @@
836 MYSQL_SYSVAR(rotate_on_size),915 MYSQL_SYSVAR(rotate_on_size),
837 MYSQL_SYSVAR(rotations),916 MYSQL_SYSVAR(rotations),
838 MYSQL_SYSVAR(flush),917 MYSQL_SYSVAR(flush),
918 MYSQL_SYSVAR(handler),
919 MYSQL_SYSVAR(syslog_ident),
920 MYSQL_SYSVAR(syslog_priority),
921 MYSQL_SYSVAR(syslog_facility),
839 NULL922 NULL
840};923};
841924
842925
=== added file 'plugin/audit_log/audit_syslog.c'
--- plugin/audit_log/audit_syslog.c 1970-01-01 00:00:00 +0000
+++ plugin/audit_log/audit_syslog.c 2014-07-30 17:21:31 +0000
@@ -0,0 +1,91 @@
1/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved.
2
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; version 2 of
6 the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17#include <syslog.h>
18#include <string.h>
19#include "audit_handler.h"
20
21typedef struct audit_handler_syslog_data_struct audit_handler_syslog_data_t;
22
23struct audit_handler_syslog_data_struct
24{
25 size_t struct_size;
26 int priority;
27 logger_prolog_func_t header;
28 logger_epilog_func_t footer;
29};
30
31int audit_handler_syslog_write(audit_handler_t *handler,
32 const char *buf, size_t len);
33int audit_handler_syslog_flush(audit_handler_t *handler);
34int audit_handler_syslog_close(audit_handler_t *handler);
35
36
37audit_handler_t *audit_handler_syslog_open(audit_handler_syslog_config_t *opts)
38{
39 audit_handler_t *handler= (audit_handler_t*)
40 calloc(sizeof(audit_handler_t) + sizeof(audit_handler_syslog_data_t), 1);
41 if (handler != NULL)
42 {
43 audit_handler_syslog_data_t *data=
44 (audit_handler_syslog_data_t*) (handler + 1);
45 MY_STAT stat_arg;
46
47 data->struct_size= sizeof(audit_handler_syslog_data_t);
48 data->priority= opts->priority;
49 data->header= opts->header;
50 data->footer= opts->footer;
51 openlog(opts->ident, 0, opts->facility);
52 memset(&stat_arg, 0, sizeof(stat_arg));
53 opts->header(&stat_arg, NULL, 0);
54 handler->data= data;
55 handler->write= audit_handler_syslog_write;
56 handler->flush= audit_handler_syslog_flush;
57 handler->close= audit_handler_syslog_close;
58 }
59 return handler;
60}
61
62int audit_handler_syslog_write(audit_handler_t *handler,
63 const char *buf, size_t len)
64{
65 audit_handler_syslog_data_t *data=
66 (audit_handler_syslog_data_t*) handler->data;
67 DBUG_ASSERT(data->struct_size == sizeof(audit_handler_syslog_data_t));
68 syslog(data->priority, "%s", buf);
69 return len;
70}
71
72int audit_handler_syslog_flush(audit_handler_t *handler)
73{
74 audit_handler_syslog_data_t *data=
75 (audit_handler_syslog_data_t*) handler->data;
76 MY_STAT stat_arg;
77 memset(&stat_arg, 0, sizeof(stat_arg));
78 data->header(&stat_arg, NULL, 0);
79 data->footer(NULL, 0);
80 return 0;
81}
82
83int audit_handler_syslog_close(audit_handler_t *handler)
84{
85 audit_handler_syslog_data_t *data=
86 (audit_handler_syslog_data_t*) handler->data;
87 data->footer(NULL, 0);
88 closelog();
89 free(handler);
90 return 0;
91}
092
=== modified file 'plugin/audit_log/buffer.h'
--- plugin/audit_log/buffer.h 2014-04-21 12:07:45 +0000
+++ plugin/audit_log/buffer.h 2014-07-30 17:21:31 +0000
@@ -20,13 +20,22 @@
2020
21#include <string.h> // for size_t21#include <string.h> // for size_t
2222
23#ifdef __cplusplus
24extern "C" {
25#endif
26
23typedef struct audit_log_buffer audit_log_buffer_t;27typedef struct audit_log_buffer audit_log_buffer_t;
2428
25typedef void (*audit_log_write_func)(void *data, const char *buf, size_t len);29typedef int (*audit_log_write_func)(void *data, const char *buf, size_t len);
2630
27audit_log_buffer_t *audit_log_buffer_init(size_t size, int drop_if_full,31audit_log_buffer_t *audit_log_buffer_init(size_t size, int drop_if_full,
28 audit_log_write_func write_func, void *data);32 audit_log_write_func write_func, void *data);
29void audit_log_buffer_shutdown(audit_log_buffer_t *log);33void audit_log_buffer_shutdown(audit_log_buffer_t *log);
30int audit_log_buffer_write(audit_log_buffer_t *log, const char *buf, size_t len);34int audit_log_buffer_write(audit_log_buffer_t *log,
35 const char *buf, size_t len);
36
37#ifdef __cplusplus
38}
39#endif
3140
32#endif41#endif
3342
=== modified file 'plugin/audit_log/logger.h'
--- plugin/audit_log/logger.h 2014-05-23 16:14:27 +0000
+++ plugin/audit_log/logger.h 2014-07-30 17:21:31 +0000
@@ -60,8 +60,8 @@
60#endif60#endif
6161
62typedef struct logger_handle_st LOGGER_HANDLE;62typedef struct logger_handle_st LOGGER_HANDLE;
63typedef size_t (logger_prolog_func_t)(MY_STAT *, char *buf, size_t buflen);63typedef size_t (*logger_prolog_func_t)(MY_STAT *, char *buf, size_t buflen);
64typedef size_t (logger_epilog_func_t)(char *buf, size_t buflen);64typedef size_t (*logger_epilog_func_t)(char *buf, size_t buflen);
6565
66void logger_init_mutexes();66void logger_init_mutexes();
67LOGGER_HANDLE *logger_open(const char *path,67LOGGER_HANDLE *logger_open(const char *path,

Subscribers

People subscribed via source and target branches