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
1=== removed file 'mysql-test/r/audit_log.result'
2--- mysql-test/r/audit_log.result 2014-05-23 16:14:27 +0000
3+++ mysql-test/r/audit_log.result 1970-01-01 00:00:00 +0000
4@@ -1,304 +0,0 @@
5-CREATE TABLE t1 (c1 INT, c2 CHAR(20));
6-CREATE TABLE t1
7-(c1 INT,
8-c2 CHAR(20));
9-ERROR 42S01: Table 't1' already exists
10-INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
11-SELECT * FROM t1;
12-c1 c2
13-1 a
14-2 b
15-3 c
16-SELECT * FROM t2;
17-ERROR 42S02: Table 'test.t2' doesn't exist
18-DROP TABLE t1;
19-PREPARE stmt1 FROM 'SELECT 1';
20-EXECUTE stmt1;
21-1
22-1
23-SHOW STATUS LIKE 'audit_log%';
24-Variable_name Value
25-DEALLOCATE PREPARE stmt1;
26-show variables like 'audit_log%';
27-Variable_name Value
28-audit_log_buffer_size 4096
29-audit_log_file test_audit.log
30-audit_log_flush OFF
31-audit_log_format OLD
32-audit_log_policy ALL
33-audit_log_rotate_on_size 0
34-audit_log_rotations 0
35-audit_log_strategy ASYNCHRONOUS
36-connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
37-ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
38-create table t1 (id int);
39-create table t2 (id int);
40-insert into t1 values (1), (2);
41-insert 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);
42-select * from t1;
43-id
44-1
45-2
46-alter table t1 rename renamed_t1;
47-select * from t_doesnt_exist;
48-ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
49-syntax_error_query;
50-ERROR 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
51-drop table renamed_t1, t2;
52-show variables like 'audit_log%';
53-Variable_name Value
54-audit_log_buffer_size 4096
55-audit_log_file test_audit.log
56-audit_log_flush OFF
57-audit_log_format OLD
58-audit_log_policy ALL
59-audit_log_rotate_on_size 0
60-audit_log_rotations 0
61-audit_log_strategy ASYNCHRONOUS
62-create database sa_db;
63-create table t1 (id2 int);
64-insert into t1 values (1), (2);
65-select * from t1;
66-id2
67-1
68-2
69-drop table t1;
70-use sa_db;
71-create table sa_t1(id int);
72-insert into sa_t1 values (1), (2);
73-drop table sa_t1;
74-drop database sa_db;
75-create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
76-drop user 'jeffrey'@'localhost';
77-select '&;&&&""""<><<>>>>';
78-&;&&&""""<><<>>>>
79-&;&&&""""<><<>>>>
80-set global audit_log_flush= ON;
81-CREATE TABLE t1 (c1 INT, c2 CHAR(20));
82-CREATE TABLE t1
83-(c1 INT,
84-c2 CHAR(20));
85-ERROR 42S01: Table 't1' already exists
86-INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
87-SELECT * FROM t1;
88-c1 c2
89-1 a
90-2 b
91-3 c
92-SELECT * FROM t2;
93-ERROR 42S02: Table 'test.t2' doesn't exist
94-DROP TABLE t1;
95-PREPARE stmt1 FROM 'SELECT 1';
96-EXECUTE stmt1;
97-1
98-1
99-SHOW STATUS LIKE 'audit_log%';
100-Variable_name Value
101-DEALLOCATE PREPARE stmt1;
102-show variables like 'audit_log%';
103-Variable_name Value
104-audit_log_buffer_size 4096
105-audit_log_file test_audit.log
106-audit_log_flush OFF
107-audit_log_format NEW
108-audit_log_policy LOGINS
109-audit_log_rotate_on_size 0
110-audit_log_rotations 0
111-audit_log_strategy SEMISYNCHRONOUS
112-connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
113-ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
114-create table t1 (id int);
115-create table t2 (id int);
116-insert into t1 values (1), (2);
117-insert 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);
118-select * from t1;
119-id
120-1
121-2
122-alter table t1 rename renamed_t1;
123-select * from t_doesnt_exist;
124-ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
125-syntax_error_query;
126-ERROR 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
127-drop table renamed_t1, t2;
128-show variables like 'audit_log%';
129-Variable_name Value
130-audit_log_buffer_size 4096
131-audit_log_file test_audit.log
132-audit_log_flush OFF
133-audit_log_format NEW
134-audit_log_policy LOGINS
135-audit_log_rotate_on_size 0
136-audit_log_rotations 0
137-audit_log_strategy SEMISYNCHRONOUS
138-create database sa_db;
139-create table t1 (id2 int);
140-insert into t1 values (1), (2);
141-select * from t1;
142-id2
143-1
144-2
145-drop table t1;
146-use sa_db;
147-create table sa_t1(id int);
148-insert into sa_t1 values (1), (2);
149-drop table sa_t1;
150-drop database sa_db;
151-create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
152-drop user 'jeffrey'@'localhost';
153-select '&;&&&""""<><<>>>>';
154-&;&&&""""<><<>>>>
155-&;&&&""""<><<>>>>
156-set global audit_log_flush= ON;
157-CREATE TABLE t1 (c1 INT, c2 CHAR(20));
158-CREATE TABLE t1
159-(c1 INT,
160-c2 CHAR(20));
161-ERROR 42S01: Table 't1' already exists
162-INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
163-SELECT * FROM t1;
164-c1 c2
165-1 a
166-2 b
167-3 c
168-SELECT * FROM t2;
169-ERROR 42S02: Table 'test.t2' doesn't exist
170-DROP TABLE t1;
171-PREPARE stmt1 FROM 'SELECT 1';
172-EXECUTE stmt1;
173-1
174-1
175-SHOW STATUS LIKE 'audit_log%';
176-Variable_name Value
177-DEALLOCATE PREPARE stmt1;
178-show variables like 'audit_log%';
179-Variable_name Value
180-audit_log_buffer_size 4096
181-audit_log_file test_audit.log
182-audit_log_flush OFF
183-audit_log_format JSON
184-audit_log_policy ALL
185-audit_log_rotate_on_size 0
186-audit_log_rotations 0
187-audit_log_strategy SEMISYNCHRONOUS
188-connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
189-ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
190-create table t1 (id int);
191-create table t2 (id int);
192-insert into t1 values (1), (2);
193-insert 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);
194-select * from t1;
195-id
196-1
197-2
198-alter table t1 rename renamed_t1;
199-select * from t_doesnt_exist;
200-ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
201-syntax_error_query;
202-ERROR 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
203-drop table renamed_t1, t2;
204-show variables like 'audit_log%';
205-Variable_name Value
206-audit_log_buffer_size 4096
207-audit_log_file test_audit.log
208-audit_log_flush OFF
209-audit_log_format JSON
210-audit_log_policy ALL
211-audit_log_rotate_on_size 0
212-audit_log_rotations 0
213-audit_log_strategy SEMISYNCHRONOUS
214-create database sa_db;
215-create table t1 (id2 int);
216-insert into t1 values (1), (2);
217-select * from t1;
218-id2
219-1
220-2
221-drop table t1;
222-use sa_db;
223-create table sa_t1(id int);
224-insert into sa_t1 values (1), (2);
225-drop table sa_t1;
226-drop database sa_db;
227-create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
228-drop user 'jeffrey'@'localhost';
229-select '&;&&&""""<><<>>>>';
230-&;&&&""""<><<>>>>
231-&;&&&""""<><<>>>>
232-set global audit_log_flush= ON;
233-CREATE TABLE t1 (c1 INT, c2 CHAR(20));
234-CREATE TABLE t1
235-(c1 INT,
236-c2 CHAR(20));
237-ERROR 42S01: Table 't1' already exists
238-INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
239-SELECT * FROM t1;
240-c1 c2
241-1 a
242-2 b
243-3 c
244-SELECT * FROM t2;
245-ERROR 42S02: Table 'test.t2' doesn't exist
246-DROP TABLE t1;
247-PREPARE stmt1 FROM 'SELECT 1';
248-EXECUTE stmt1;
249-1
250-1
251-SHOW STATUS LIKE 'audit_log%';
252-Variable_name Value
253-DEALLOCATE PREPARE stmt1;
254-show variables like 'audit_log%';
255-Variable_name Value
256-audit_log_buffer_size 4096
257-audit_log_file test_audit.log
258-audit_log_flush OFF
259-audit_log_format CSV
260-audit_log_policy ALL
261-audit_log_rotate_on_size 0
262-audit_log_rotations 0
263-audit_log_strategy SEMISYNCHRONOUS
264-connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
265-ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
266-create table t1 (id int);
267-create table t2 (id int);
268-insert into t1 values (1), (2);
269-insert 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);
270-select * from t1;
271-id
272-1
273-2
274-alter table t1 rename renamed_t1;
275-select * from t_doesnt_exist;
276-ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
277-syntax_error_query;
278-ERROR 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
279-drop table renamed_t1, t2;
280-show variables like 'audit_log%';
281-Variable_name Value
282-audit_log_buffer_size 4096
283-audit_log_file test_audit.log
284-audit_log_flush OFF
285-audit_log_format CSV
286-audit_log_policy ALL
287-audit_log_rotate_on_size 0
288-audit_log_rotations 0
289-audit_log_strategy SEMISYNCHRONOUS
290-create database sa_db;
291-create table t1 (id2 int);
292-insert into t1 values (1), (2);
293-select * from t1;
294-id2
295-1
296-2
297-drop table t1;
298-use sa_db;
299-create table sa_t1(id int);
300-insert into sa_t1 values (1), (2);
301-drop table sa_t1;
302-drop database sa_db;
303-create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
304-drop user 'jeffrey'@'localhost';
305-select '&;&&&""""<><<>>>>';
306-&;&&&""""<><<>>>>
307-&;&&&""""<><<>>>>
308-set global audit_log_flush= ON;
309
310=== added file 'mysql-test/r/audit_log_csv.result'
311--- mysql-test/r/audit_log_csv.result 1970-01-01 00:00:00 +0000
312+++ mysql-test/r/audit_log_csv.result 2014-07-30 17:21:31 +0000
313@@ -0,0 +1,84 @@
314+CREATE TABLE t1 (c1 INT, c2 CHAR(20));
315+CREATE TABLE t1
316+(c1 INT,
317+c2 CHAR(20));
318+ERROR 42S01: Table 't1' already exists
319+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
320+SELECT * FROM t1;
321+c1 c2
322+1 a
323+2 b
324+3 c
325+SELECT * FROM t2;
326+ERROR 42S02: Table 'test.t2' doesn't exist
327+DROP TABLE t1;
328+PREPARE stmt1 FROM 'SELECT 1';
329+EXECUTE stmt1;
330+1
331+1
332+SHOW STATUS LIKE 'audit_log%';
333+Variable_name Value
334+DEALLOCATE PREPARE stmt1;
335+show variables like 'audit_log%';
336+Variable_name Value
337+audit_log_buffer_size 1048576
338+audit_log_file test_audit.log
339+audit_log_flush OFF
340+audit_log_format CSV
341+audit_log_handler FILE
342+audit_log_policy ALL
343+audit_log_rotate_on_size 0
344+audit_log_rotations 0
345+audit_log_strategy SEMISYNCHRONOUS
346+audit_log_syslog_facility LOG_USER
347+audit_log_syslog_ident percona-audit
348+audit_log_syslog_priority LOG_INFO
349+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
350+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
351+create table t1 (id int);
352+create table t2 (id int);
353+insert into t1 values (1), (2);
354+insert 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);
355+select * from t1;
356+id
357+1
358+2
359+alter table t1 rename renamed_t1;
360+select * from t_doesnt_exist;
361+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
362+syntax_error_query;
363+ERROR 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
364+drop table renamed_t1, t2;
365+show variables like 'audit_log%';
366+Variable_name Value
367+audit_log_buffer_size 1048576
368+audit_log_file test_audit.log
369+audit_log_flush OFF
370+audit_log_format CSV
371+audit_log_handler FILE
372+audit_log_policy ALL
373+audit_log_rotate_on_size 0
374+audit_log_rotations 0
375+audit_log_strategy SEMISYNCHRONOUS
376+audit_log_syslog_facility LOG_USER
377+audit_log_syslog_ident percona-audit
378+audit_log_syslog_priority LOG_INFO
379+create database sa_db;
380+create table t1 (id2 int);
381+insert into t1 values (1), (2);
382+select * from t1;
383+id2
384+1
385+2
386+drop table t1;
387+use sa_db;
388+create table sa_t1(id int);
389+insert into sa_t1 values (1), (2);
390+drop table sa_t1;
391+drop database sa_db;
392+create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
393+drop user 'jeffrey'@'localhost';
394+select '&;&&&""""<><<>>>>';
395+&;&&&""""<><<>>>>
396+&;&&&""""<><<>>>>
397+set global audit_log_flush= ON;
398
399=== added file 'mysql-test/r/audit_log_json.result'
400--- mysql-test/r/audit_log_json.result 1970-01-01 00:00:00 +0000
401+++ mysql-test/r/audit_log_json.result 2014-07-30 17:21:31 +0000
402@@ -0,0 +1,84 @@
403+CREATE TABLE t1 (c1 INT, c2 CHAR(20));
404+CREATE TABLE t1
405+(c1 INT,
406+c2 CHAR(20));
407+ERROR 42S01: Table 't1' already exists
408+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
409+SELECT * FROM t1;
410+c1 c2
411+1 a
412+2 b
413+3 c
414+SELECT * FROM t2;
415+ERROR 42S02: Table 'test.t2' doesn't exist
416+DROP TABLE t1;
417+PREPARE stmt1 FROM 'SELECT 1';
418+EXECUTE stmt1;
419+1
420+1
421+SHOW STATUS LIKE 'audit_log%';
422+Variable_name Value
423+DEALLOCATE PREPARE stmt1;
424+show variables like 'audit_log%';
425+Variable_name Value
426+audit_log_buffer_size 1048576
427+audit_log_file test_audit.log
428+audit_log_flush OFF
429+audit_log_format JSON
430+audit_log_handler FILE
431+audit_log_policy ALL
432+audit_log_rotate_on_size 0
433+audit_log_rotations 0
434+audit_log_strategy SEMISYNCHRONOUS
435+audit_log_syslog_facility LOG_USER
436+audit_log_syslog_ident percona-audit
437+audit_log_syslog_priority LOG_INFO
438+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
439+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
440+create table t1 (id int);
441+create table t2 (id int);
442+insert into t1 values (1), (2);
443+insert 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);
444+select * from t1;
445+id
446+1
447+2
448+alter table t1 rename renamed_t1;
449+select * from t_doesnt_exist;
450+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
451+syntax_error_query;
452+ERROR 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
453+drop table renamed_t1, t2;
454+show variables like 'audit_log%';
455+Variable_name Value
456+audit_log_buffer_size 1048576
457+audit_log_file test_audit.log
458+audit_log_flush OFF
459+audit_log_format JSON
460+audit_log_handler FILE
461+audit_log_policy ALL
462+audit_log_rotate_on_size 0
463+audit_log_rotations 0
464+audit_log_strategy SEMISYNCHRONOUS
465+audit_log_syslog_facility LOG_USER
466+audit_log_syslog_ident percona-audit
467+audit_log_syslog_priority LOG_INFO
468+create database sa_db;
469+create table t1 (id2 int);
470+insert into t1 values (1), (2);
471+select * from t1;
472+id2
473+1
474+2
475+drop table t1;
476+use sa_db;
477+create table sa_t1(id int);
478+insert into sa_t1 values (1), (2);
479+drop table sa_t1;
480+drop database sa_db;
481+create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
482+drop user 'jeffrey'@'localhost';
483+select '&;&&&""""<><<>>>>';
484+&;&&&""""<><<>>>>
485+&;&&&""""<><<>>>>
486+set global audit_log_flush= ON;
487
488=== added file 'mysql-test/r/audit_log_new.result'
489--- mysql-test/r/audit_log_new.result 1970-01-01 00:00:00 +0000
490+++ mysql-test/r/audit_log_new.result 2014-07-30 17:21:31 +0000
491@@ -0,0 +1,84 @@
492+CREATE TABLE t1 (c1 INT, c2 CHAR(20));
493+CREATE TABLE t1
494+(c1 INT,
495+c2 CHAR(20));
496+ERROR 42S01: Table 't1' already exists
497+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
498+SELECT * FROM t1;
499+c1 c2
500+1 a
501+2 b
502+3 c
503+SELECT * FROM t2;
504+ERROR 42S02: Table 'test.t2' doesn't exist
505+DROP TABLE t1;
506+PREPARE stmt1 FROM 'SELECT 1';
507+EXECUTE stmt1;
508+1
509+1
510+SHOW STATUS LIKE 'audit_log%';
511+Variable_name Value
512+DEALLOCATE PREPARE stmt1;
513+show variables like 'audit_log%';
514+Variable_name Value
515+audit_log_buffer_size 1048576
516+audit_log_file test_audit.log
517+audit_log_flush OFF
518+audit_log_format NEW
519+audit_log_handler FILE
520+audit_log_policy LOGINS
521+audit_log_rotate_on_size 0
522+audit_log_rotations 0
523+audit_log_strategy SEMISYNCHRONOUS
524+audit_log_syslog_facility LOG_USER
525+audit_log_syslog_ident percona-audit
526+audit_log_syslog_priority LOG_INFO
527+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
528+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
529+create table t1 (id int);
530+create table t2 (id int);
531+insert into t1 values (1), (2);
532+insert 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);
533+select * from t1;
534+id
535+1
536+2
537+alter table t1 rename renamed_t1;
538+select * from t_doesnt_exist;
539+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
540+syntax_error_query;
541+ERROR 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
542+drop table renamed_t1, t2;
543+show variables like 'audit_log%';
544+Variable_name Value
545+audit_log_buffer_size 1048576
546+audit_log_file test_audit.log
547+audit_log_flush OFF
548+audit_log_format NEW
549+audit_log_handler FILE
550+audit_log_policy LOGINS
551+audit_log_rotate_on_size 0
552+audit_log_rotations 0
553+audit_log_strategy SEMISYNCHRONOUS
554+audit_log_syslog_facility LOG_USER
555+audit_log_syslog_ident percona-audit
556+audit_log_syslog_priority LOG_INFO
557+create database sa_db;
558+create table t1 (id2 int);
559+insert into t1 values (1), (2);
560+select * from t1;
561+id2
562+1
563+2
564+drop table t1;
565+use sa_db;
566+create table sa_t1(id int);
567+insert into sa_t1 values (1), (2);
568+drop table sa_t1;
569+drop database sa_db;
570+create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
571+drop user 'jeffrey'@'localhost';
572+select '&;&&&""""<><<>>>>';
573+&;&&&""""<><<>>>>
574+&;&&&""""<><<>>>>
575+set global audit_log_flush= ON;
576
577=== added file 'mysql-test/r/audit_log_old.result'
578--- mysql-test/r/audit_log_old.result 1970-01-01 00:00:00 +0000
579+++ mysql-test/r/audit_log_old.result 2014-07-30 17:21:31 +0000
580@@ -0,0 +1,84 @@
581+CREATE TABLE t1 (c1 INT, c2 CHAR(20));
582+CREATE TABLE t1
583+(c1 INT,
584+c2 CHAR(20));
585+ERROR 42S01: Table 't1' already exists
586+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
587+SELECT * FROM t1;
588+c1 c2
589+1 a
590+2 b
591+3 c
592+SELECT * FROM t2;
593+ERROR 42S02: Table 'test.t2' doesn't exist
594+DROP TABLE t1;
595+PREPARE stmt1 FROM 'SELECT 1';
596+EXECUTE stmt1;
597+1
598+1
599+SHOW STATUS LIKE 'audit_log%';
600+Variable_name Value
601+DEALLOCATE PREPARE stmt1;
602+show variables like 'audit_log%';
603+Variable_name Value
604+audit_log_buffer_size 4096
605+audit_log_file test_audit.log
606+audit_log_flush OFF
607+audit_log_format OLD
608+audit_log_handler FILE
609+audit_log_policy ALL
610+audit_log_rotate_on_size 0
611+audit_log_rotations 0
612+audit_log_strategy ASYNCHRONOUS
613+audit_log_syslog_facility LOG_USER
614+audit_log_syslog_ident percona-audit
615+audit_log_syslog_priority LOG_INFO
616+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
617+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
618+create table t1 (id int);
619+create table t2 (id int);
620+insert into t1 values (1), (2);
621+insert 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);
622+select * from t1;
623+id
624+1
625+2
626+alter table t1 rename renamed_t1;
627+select * from t_doesnt_exist;
628+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
629+syntax_error_query;
630+ERROR 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
631+drop table renamed_t1, t2;
632+show variables like 'audit_log%';
633+Variable_name Value
634+audit_log_buffer_size 4096
635+audit_log_file test_audit.log
636+audit_log_flush OFF
637+audit_log_format OLD
638+audit_log_handler FILE
639+audit_log_policy ALL
640+audit_log_rotate_on_size 0
641+audit_log_rotations 0
642+audit_log_strategy ASYNCHRONOUS
643+audit_log_syslog_facility LOG_USER
644+audit_log_syslog_ident percona-audit
645+audit_log_syslog_priority LOG_INFO
646+create database sa_db;
647+create table t1 (id2 int);
648+insert into t1 values (1), (2);
649+select * from t1;
650+id2
651+1
652+2
653+drop table t1;
654+use sa_db;
655+create table sa_t1(id int);
656+insert into sa_t1 values (1), (2);
657+drop table sa_t1;
658+drop database sa_db;
659+create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
660+drop user 'jeffrey'@'localhost';
661+select '&;&&&""""<><<>>>>';
662+&;&&&""""<><<>>>>
663+&;&&&""""<><<>>>>
664+set global audit_log_flush= ON;
665
666=== added file 'mysql-test/r/audit_log_syslog.result'
667--- mysql-test/r/audit_log_syslog.result 1970-01-01 00:00:00 +0000
668+++ mysql-test/r/audit_log_syslog.result 2014-07-30 17:21:31 +0000
669@@ -0,0 +1,83 @@
670+CREATE TABLE t1 (c1 INT, c2 CHAR(20));
671+CREATE TABLE t1
672+(c1 INT,
673+c2 CHAR(20));
674+ERROR 42S01: Table 't1' already exists
675+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
676+SELECT * FROM t1;
677+c1 c2
678+1 a
679+2 b
680+3 c
681+SELECT * FROM t2;
682+ERROR 42S02: Table 'test.t2' doesn't exist
683+DROP TABLE t1;
684+PREPARE stmt1 FROM 'SELECT 1';
685+EXECUTE stmt1;
686+1
687+1
688+SHOW STATUS LIKE 'audit_log%';
689+Variable_name Value
690+DEALLOCATE PREPARE stmt1;
691+show variables like 'audit_log%';
692+Variable_name Value
693+audit_log_buffer_size 1048576
694+audit_log_file audit.log
695+audit_log_flush OFF
696+audit_log_format CSV
697+audit_log_handler SYSLOG
698+audit_log_policy ALL
699+audit_log_rotate_on_size 0
700+audit_log_rotations 0
701+audit_log_strategy ASYNCHRONOUS
702+audit_log_syslog_facility LOG_AUTH
703+audit_log_syslog_ident test_audit
704+audit_log_syslog_priority LOG_INFO
705+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET);
706+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO)
707+create table t1 (id int);
708+create table t2 (id int);
709+insert into t1 values (1), (2);
710+insert 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);
711+select * from t1;
712+id
713+1
714+2
715+alter table t1 rename renamed_t1;
716+select * from t_doesnt_exist;
717+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
718+syntax_error_query;
719+ERROR 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
720+drop table renamed_t1, t2;
721+show variables like 'audit_log%';
722+Variable_name Value
723+audit_log_buffer_size 1048576
724+audit_log_file audit.log
725+audit_log_flush OFF
726+audit_log_format CSV
727+audit_log_handler SYSLOG
728+audit_log_policy ALL
729+audit_log_rotate_on_size 0
730+audit_log_rotations 0
731+audit_log_strategy ASYNCHRONOUS
732+audit_log_syslog_facility LOG_AUTH
733+audit_log_syslog_ident test_audit
734+audit_log_syslog_priority LOG_INFO
735+create database sa_db;
736+create table t1 (id2 int);
737+insert into t1 values (1), (2);
738+select * from t1;
739+id2
740+1
741+2
742+drop table t1;
743+use sa_db;
744+create table sa_t1(id int);
745+insert into sa_t1 values (1), (2);
746+drop table sa_t1;
747+drop database sa_db;
748+create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
749+drop user 'jeffrey'@'localhost';
750+select '&;&&&""""<><<>>>>';
751+&;&&&""""<><<>>>>
752+&;&&&""""<><<>>>>
753
754=== removed file 'mysql-test/t/audit_log-master.opt'
755--- mysql-test/t/audit_log-master.opt 2014-04-21 12:07:45 +0000
756+++ mysql-test/t/audit_log-master.opt 1970-01-01 00:00:00 +0000
757@@ -1,4 +0,0 @@
758-$AUDIT_LOG_OPT
759-$AUDIT_LOG_LOAD
760---audit_log_file=test_audit.log
761---audit_log_buffer_size=4096
762
763=== removed file 'mysql-test/t/audit_log.test'
764--- mysql-test/t/audit_log.test 2014-05-23 16:14:27 +0000
765+++ mysql-test/t/audit_log.test 1970-01-01 00:00:00 +0000
766@@ -1,77 +0,0 @@
767---source include/not_embedded.inc
768-
769-let $MYSQLD_DATADIR= `select @@datadir`;
770-let MYSQLD_DATADIR= $MYSQLD_DATADIR;
771-
772---source include/audit_log_events.inc
773-
774---move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_old.log
775-set global audit_log_flush= ON;
776-perl;
777- eval "use XML::Parser; 1" or exit 0;
778- $p = new XML::Parser;
779- $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_old.log');
780-EOF
781---remove_file $MYSQLD_DATADIR/test_audit.log
782-
783---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
784---shutdown_server
785---source include/wait_until_disconnected.inc
786---enable_reconnect
787---exec echo "restart: --audit_log_policy=LOGINS --audit-log-format=NEW --audit_log_strategy=SEMISYNCHRONOUS" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
788---source include/wait_until_connected_again.inc
789-
790---source include/audit_log_events.inc
791-
792---move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_new.log
793-set global audit_log_flush= ON;
794-perl;
795- eval "use XML::Parser; 1" or exit 0;
796- $p = new XML::Parser;
797- $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_new.log');
798-EOF
799---remove_file $MYSQLD_DATADIR/test_audit.log
800-
801---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
802---shutdown_server
803---source include/wait_until_disconnected.inc
804---enable_reconnect
805---exec echo "restart: --audit-log-format=JSON --audit_log_strategy=SEMISYNCHRONOUS" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
806---source include/wait_until_connected_again.inc
807-
808---source include/audit_log_events.inc
809-
810---move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_json.log
811-set global audit_log_flush= ON;
812-perl;
813- eval "use JSON qw(decode_json); 1" or exit 0;
814- open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_json.log' or die "Could not open log: $!";
815- while (my $line = <$file>) {
816- decode_json($line);
817- }
818- close $file;
819-EOF
820---remove_file $MYSQLD_DATADIR/test_audit.log
821-
822---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
823---shutdown_server
824---source include/wait_until_disconnected.inc
825---enable_reconnect
826---exec echo "restart: --audit-log-format=CSV --audit_log_strategy=SEMISYNCHRONOUS" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
827---source include/wait_until_connected_again.inc
828-
829---source include/audit_log_events.inc
830-
831---move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_csv.log
832-set global audit_log_flush= ON;
833-perl;
834- eval "use Text::CSV; 1" or exit 0;
835- my $p = Text::CSV->new({ binary => 1, auto_diag => 1, sep_char => ',' });
836- open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_csv.log' or die "Could not open log: $!";
837- while ($p->getline($file)) {};
838- if (not $p->eof) {
839- die "CSV parse error " . $p->error_diag();
840- }
841- close $file;
842-EOF
843---remove_file $MYSQLD_DATADIR/test_audit.log
844
845=== added file 'mysql-test/t/audit_log_csv-master.opt'
846--- mysql-test/t/audit_log_csv-master.opt 1970-01-01 00:00:00 +0000
847+++ mysql-test/t/audit_log_csv-master.opt 2014-07-30 17:21:31 +0000
848@@ -0,0 +1,5 @@
849+$AUDIT_LOG_OPT
850+$AUDIT_LOG_LOAD
851+--audit_log_file=test_audit.log
852+--audit-log-format=CSV
853+--audit_log_strategy=SEMISYNCHRONOUS
854
855=== added file 'mysql-test/t/audit_log_csv.test'
856--- mysql-test/t/audit_log_csv.test 1970-01-01 00:00:00 +0000
857+++ mysql-test/t/audit_log_csv.test 2014-07-30 17:21:31 +0000
858@@ -0,0 +1,20 @@
859+--source include/not_embedded.inc
860+
861+let $MYSQLD_DATADIR= `select @@datadir`;
862+let MYSQLD_DATADIR= $MYSQLD_DATADIR;
863+
864+--source include/audit_log_events.inc
865+
866+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_csv.log
867+set global audit_log_flush= ON;
868+perl;
869+ eval "use Text::CSV; 1" or exit 0;
870+ my $p = Text::CSV->new({ binary => 1, auto_diag => 1, sep_char => ',' });
871+ open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_csv.log' or die "Could not open log: $!";
872+ while ($p->getline($file)) {};
873+ if (not $p->eof) {
874+ die "CSV parse error " . $p->error_diag();
875+ }
876+ close $file;
877+EOF
878+--remove_file $MYSQLD_DATADIR/test_audit.log
879
880=== added file 'mysql-test/t/audit_log_json-master.opt'
881--- mysql-test/t/audit_log_json-master.opt 1970-01-01 00:00:00 +0000
882+++ mysql-test/t/audit_log_json-master.opt 2014-07-30 17:21:31 +0000
883@@ -0,0 +1,5 @@
884+$AUDIT_LOG_OPT
885+$AUDIT_LOG_LOAD
886+--audit_log_file=test_audit.log
887+--audit-log-format=JSON
888+--audit_log_strategy=SEMISYNCHRONOUS
889
890=== added file 'mysql-test/t/audit_log_json.test'
891--- mysql-test/t/audit_log_json.test 1970-01-01 00:00:00 +0000
892+++ mysql-test/t/audit_log_json.test 2014-07-30 17:21:31 +0000
893@@ -0,0 +1,18 @@
894+--source include/not_embedded.inc
895+
896+let $MYSQLD_DATADIR= `select @@datadir`;
897+let MYSQLD_DATADIR= $MYSQLD_DATADIR;
898+
899+--source include/audit_log_events.inc
900+
901+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_json.log
902+set global audit_log_flush= ON;
903+perl;
904+ eval "use JSON qw(decode_json); 1" or exit 0;
905+ open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_json.log' or die "Could not open log: $!";
906+ while (my $line = <$file>) {
907+ decode_json($line);
908+ }
909+ close $file;
910+EOF
911+--remove_file $MYSQLD_DATADIR/test_audit.log
912
913=== added file 'mysql-test/t/audit_log_new-master.opt'
914--- mysql-test/t/audit_log_new-master.opt 1970-01-01 00:00:00 +0000
915+++ mysql-test/t/audit_log_new-master.opt 2014-07-30 17:21:31 +0000
916@@ -0,0 +1,6 @@
917+$AUDIT_LOG_OPT
918+$AUDIT_LOG_LOAD
919+--audit_log_file=test_audit.log
920+--audit_log_policy=LOGINS
921+--audit-log-format=NEW
922+--audit_log_strategy=SEMISYNCHRONOUS
923
924=== added file 'mysql-test/t/audit_log_new.test'
925--- mysql-test/t/audit_log_new.test 1970-01-01 00:00:00 +0000
926+++ mysql-test/t/audit_log_new.test 2014-07-30 17:21:31 +0000
927@@ -0,0 +1,15 @@
928+--source include/not_embedded.inc
929+
930+let $MYSQLD_DATADIR= `select @@datadir`;
931+let MYSQLD_DATADIR= $MYSQLD_DATADIR;
932+
933+--source include/audit_log_events.inc
934+
935+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_new.log
936+set global audit_log_flush= ON;
937+perl;
938+ eval "use XML::Parser; 1" or exit 0;
939+ $p = new XML::Parser;
940+ $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_new.log');
941+EOF
942+--remove_file $MYSQLD_DATADIR/test_audit.log
943
944=== added file 'mysql-test/t/audit_log_old-master.opt'
945--- mysql-test/t/audit_log_old-master.opt 1970-01-01 00:00:00 +0000
946+++ mysql-test/t/audit_log_old-master.opt 2014-07-30 17:21:31 +0000
947@@ -0,0 +1,5 @@
948+$AUDIT_LOG_OPT
949+$AUDIT_LOG_LOAD
950+--audit_log_file=test_audit.log
951+--audit_log_buffer_size=4096
952+--audit_log_strategy=ASYNCHRONOUS
953
954=== added file 'mysql-test/t/audit_log_old.test'
955--- mysql-test/t/audit_log_old.test 1970-01-01 00:00:00 +0000
956+++ mysql-test/t/audit_log_old.test 2014-07-30 17:21:31 +0000
957@@ -0,0 +1,15 @@
958+--source include/not_embedded.inc
959+
960+let $MYSQLD_DATADIR= `select @@datadir`;
961+let MYSQLD_DATADIR= $MYSQLD_DATADIR;
962+
963+--source include/audit_log_events.inc
964+
965+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_old.log
966+set global audit_log_flush= ON;
967+perl;
968+ eval "use XML::Parser; 1" or exit 0;
969+ $p = new XML::Parser;
970+ $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_old.log');
971+EOF
972+--remove_file $MYSQLD_DATADIR/test_audit.log
973
974=== added file 'mysql-test/t/audit_log_syslog-master.opt'
975--- mysql-test/t/audit_log_syslog-master.opt 1970-01-01 00:00:00 +0000
976+++ mysql-test/t/audit_log_syslog-master.opt 2014-07-30 17:21:31 +0000
977@@ -0,0 +1,7 @@
978+$AUDIT_LOG_OPT
979+$AUDIT_LOG_LOAD
980+--audit-log-format=CSV
981+--audit_log_handler=SYSLOG
982+--audit_log_syslog_ident=test_audit
983+--audit_log_syslog_facility=LOG_AUTH
984+--audit_log_syslog_priority=LOG_INFO
985
986=== added file 'mysql-test/t/audit_log_syslog.test'
987--- mysql-test/t/audit_log_syslog.test 1970-01-01 00:00:00 +0000
988+++ mysql-test/t/audit_log_syslog.test 2014-07-30 17:21:31 +0000
989@@ -0,0 +1,3 @@
990+--source include/not_embedded.inc
991+
992+--source include/audit_log_events.inc
993
994=== modified file 'plugin/audit_log/CMakeLists.txt'
995--- plugin/audit_log/CMakeLists.txt 2014-04-21 12:07:45 +0000
996+++ plugin/audit_log/CMakeLists.txt 2014-07-30 17:21:31 +0000
997@@ -13,5 +13,6 @@
998 # along with this program; if not, write to the Free Software
999 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1000
1001-MYSQL_ADD_PLUGIN(audit_log audit_log.c file_logger.c buffer.c
1002+MYSQL_ADD_PLUGIN(audit_log audit_log.c file_logger.c buffer.c audit_file.c
1003+ audit_syslog.c
1004 MODULE_ONLY MODULE_OUTPUT_NAME "audit_log")
1005
1006=== added file 'plugin/audit_log/audit_file.c'
1007--- plugin/audit_log/audit_file.c 1970-01-01 00:00:00 +0000
1008+++ plugin/audit_log/audit_file.c 2014-07-30 17:21:31 +0000
1009@@ -0,0 +1,200 @@
1010+/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved.
1011+
1012+ This program is free software; you can redistribute it and/or
1013+ modify it under the terms of the GNU General Public License
1014+ as published by the Free Software Foundation; version 2 of
1015+ the License.
1016+
1017+ This program is distributed in the hope that it will be useful,
1018+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1019+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1020+ GNU General Public License for more details.
1021+
1022+ You should have received a copy of the GNU General Public License
1023+ along with this program; if not, write to the Free Software
1024+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
1025+
1026+#include "audit_handler.h"
1027+#include "buffer.h"
1028+
1029+typedef struct audit_handler_file_data_struct audit_handler_file_data_t;
1030+
1031+struct audit_handler_file_data_struct
1032+{
1033+ size_t struct_size;
1034+ LOGGER_HANDLE *logger;
1035+ logger_prolog_func_t header;
1036+ logger_epilog_func_t footer;
1037+ my_bool sync_on_write;
1038+ my_bool use_buffer;
1039+ audit_log_buffer_t *buffer;
1040+};
1041+
1042+static
1043+int audit_handler_file_write(audit_handler_t *handler,
1044+ const char *buf, size_t len);
1045+static
1046+int audit_handler_file_flush(audit_handler_t *handler);
1047+static
1048+int audit_handler_file_close(audit_handler_t *handler);
1049+static
1050+int audit_handler_file_write_nobuf(LOGGER_HANDLE *logger,
1051+ const char *buf, size_t len);
1052+static
1053+int audit_handler_file_write_buf(audit_log_buffer_t *buffer,
1054+ const char *buf, size_t len);
1055+static
1056+void audit_handler_file_set_option(audit_handler_t *handler,
1057+ audit_handler_option_t opt, void *val);
1058+
1059+static
1060+int write_callback(void *data, const char *buf, size_t len)
1061+{
1062+ audit_handler_t *handler= (audit_handler_t *) data;
1063+ audit_handler_file_data_t *hdata= (audit_handler_file_data_t*) handler->data;
1064+
1065+ DBUG_ASSERT(hdata->struct_size == sizeof(audit_handler_file_data_t));
1066+
1067+ return audit_handler_file_write_nobuf(hdata->logger, buf, len);
1068+}
1069+
1070+
1071+audit_handler_t *audit_handler_file_open(audit_handler_file_config_t *opts)
1072+{
1073+ audit_handler_t *handler= (audit_handler_t*)
1074+ calloc(sizeof(audit_handler_t) + sizeof(audit_handler_file_data_t), 1);
1075+ if (handler != NULL)
1076+ {
1077+ audit_handler_file_data_t *data= (audit_handler_file_data_t*) (handler + 1);
1078+ data->struct_size= sizeof(audit_handler_file_data_t);
1079+ data->footer= opts->footer;
1080+ data->header= opts->header;
1081+ data->sync_on_write= opts->sync_on_write;
1082+ data->use_buffer= opts->use_buffer;
1083+ if (data->use_buffer)
1084+ {
1085+ data->buffer= audit_log_buffer_init(opts->buffer_size,
1086+ opts->can_drop_data,
1087+ write_callback, handler);
1088+ if (data->buffer == NULL)
1089+ goto error;
1090+ }
1091+ data->logger= logger_open(opts->name, opts->rotate_on_size,
1092+ opts->rotate_on_size ? opts->rotations : 0,
1093+ !opts->use_buffer, opts->header);
1094+ if (data->logger == NULL)
1095+ {
1096+ goto error;
1097+ }
1098+ handler->data= data;
1099+ handler->write= audit_handler_file_write;
1100+ handler->flush= audit_handler_file_flush;
1101+ handler->close= audit_handler_file_close;
1102+ handler->set_option= audit_handler_file_set_option;
1103+ goto success;
1104+error:
1105+ if (data->use_buffer)
1106+ {
1107+ free(data->buffer);
1108+ }
1109+ free(handler);
1110+ handler= NULL;
1111+ }
1112+success:
1113+ return handler;
1114+}
1115+
1116+static
1117+int audit_handler_file_write_nobuf(LOGGER_HANDLE *logger,
1118+ const char *buf, size_t len)
1119+{
1120+ return logger_write(logger, buf, len);
1121+}
1122+
1123+static
1124+int audit_handler_file_write_buf(audit_log_buffer_t *buffer,
1125+ const char *buf, size_t len)
1126+{
1127+ return audit_log_buffer_write(buffer, buf, len);
1128+}
1129+
1130+static
1131+int audit_handler_file_write(audit_handler_t *handler,
1132+ const char *buf, size_t len)
1133+{
1134+ audit_handler_file_data_t *data= (audit_handler_file_data_t*) handler->data;
1135+ int res;
1136+
1137+ DBUG_ASSERT(data->struct_size == sizeof(audit_handler_file_data_t));
1138+
1139+ if (data->use_buffer)
1140+ {
1141+ DBUG_ASSERT(data->buffer);
1142+ res= audit_handler_file_write_buf(data->buffer, buf, len);
1143+ }
1144+ else
1145+ {
1146+ DBUG_ASSERT(data->logger);
1147+ res= audit_handler_file_write_nobuf(data->logger, buf, len);
1148+
1149+ if (data->sync_on_write)
1150+ {
1151+ logger_sync(data->logger);
1152+ }
1153+ }
1154+
1155+ return res;
1156+}
1157+
1158+static
1159+int audit_handler_file_flush(audit_handler_t *handler)
1160+{
1161+ audit_handler_file_data_t *data= (audit_handler_file_data_t*) handler->data;
1162+ LOGGER_HANDLE* logger;
1163+
1164+ DBUG_ASSERT(data->struct_size == sizeof(audit_handler_file_data_t));
1165+
1166+ logger= data->logger;
1167+
1168+ return logger_reopen(logger, data->header, data->footer);
1169+}
1170+
1171+static
1172+int audit_handler_file_close(audit_handler_t *handler)
1173+{
1174+ audit_handler_file_data_t *data= (audit_handler_file_data_t*) handler->data;
1175+ int res;
1176+ LOGGER_HANDLE* logger;
1177+
1178+ DBUG_ASSERT(data->struct_size == sizeof(audit_handler_file_data_t));
1179+
1180+ logger= data->logger;
1181+
1182+ if (data->use_buffer)
1183+ {
1184+ audit_log_buffer_shutdown(data->buffer);
1185+ }
1186+
1187+ res= logger_close(logger, data->footer);
1188+
1189+ free(handler);
1190+
1191+ return res;
1192+}
1193+
1194+static
1195+void audit_handler_file_set_option(audit_handler_t *handler,
1196+ audit_handler_option_t opt, void *val)
1197+{
1198+ audit_handler_file_data_t *data= (audit_handler_file_data_t*) handler->data;
1199+
1200+ switch (opt)
1201+ {
1202+ case OPT_ROTATIONS:
1203+ logger_set_size_limit(data->logger, *(ulonglong*)(val));
1204+ break;
1205+ case OPT_ROTATE_ON_SIZE:
1206+ logger_set_rotations(data->logger, *(ulonglong*)(val));
1207+ break;
1208+ }
1209+}
1210
1211=== added file 'plugin/audit_log/audit_handler.h'
1212--- plugin/audit_log/audit_handler.h 1970-01-01 00:00:00 +0000
1213+++ plugin/audit_log/audit_handler.h 2014-07-30 17:21:31 +0000
1214@@ -0,0 +1,116 @@
1215+/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved.
1216+
1217+ This program is free software; you can redistribute it and/or
1218+ modify it under the terms of the GNU General Public License
1219+ as published by the Free Software Foundation; version 2 of
1220+ the License.
1221+
1222+ This program is distributed in the hope that it will be useful,
1223+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1224+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1225+ GNU General Public License for more details.
1226+
1227+ You should have received a copy of the GNU General Public License
1228+ along with this program; if not, write to the Free Software
1229+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
1230+
1231+
1232+#ifndef AUDIT_HANDLER_INCLUDED
1233+#define AUDIT_HANDLER_INCLUDED
1234+
1235+#include <my_global.h>
1236+
1237+#include "logger.h"
1238+
1239+#ifdef __cplusplus
1240+extern "C" {
1241+#endif
1242+
1243+typedef struct audit_handler_struct audit_handler_t;
1244+typedef struct audit_handler_file_config_struct audit_handler_file_config_t;
1245+typedef struct audit_handler_syslog_config_struct audit_handler_syslog_config_t;
1246+typedef struct audit_handler_buffered_struct audit_handler_buffered_t;
1247+typedef void * audit_handler_data_t;
1248+
1249+
1250+typedef enum { OPT_ROTATE_ON_SIZE, OPT_ROTATIONS } audit_handler_option_t;
1251+
1252+struct audit_handler_struct
1253+{
1254+ int (*write)(audit_handler_t *, const char *, size_t);
1255+ int (*flush)(audit_handler_t *);
1256+ int (*close)(audit_handler_t *);
1257+ void (*set_option)(audit_handler_t *, audit_handler_option_t, void *);
1258+ audit_handler_data_t data;
1259+};
1260+
1261+struct audit_handler_file_config_struct
1262+{
1263+ const char *name;
1264+ size_t rotate_on_size;
1265+ size_t rotations;
1266+ my_bool sync_on_write;
1267+ my_bool use_buffer;
1268+ size_t buffer_size;
1269+ my_bool can_drop_data;
1270+ logger_prolog_func_t header;
1271+ logger_epilog_func_t footer;
1272+};
1273+
1274+struct audit_handler_syslog_config_struct
1275+{
1276+ const char *ident;
1277+ int facility;
1278+ int priority;
1279+ logger_prolog_func_t header;
1280+ logger_epilog_func_t footer;
1281+};
1282+
1283+static inline
1284+int audit_handler_write(audit_handler_t *handler, const char *buf, size_t len)
1285+{
1286+ if (handler->write != NULL)
1287+ {
1288+ return handler->write(handler, buf, len);
1289+ }
1290+ return len;
1291+}
1292+
1293+static inline
1294+int audit_handler_flush(audit_handler_t *handler)
1295+{
1296+ if (handler->flush != NULL)
1297+ {
1298+ return handler->flush(handler);
1299+ }
1300+ return 0;
1301+}
1302+
1303+static inline
1304+int audit_handler_close(audit_handler_t *handler)
1305+{
1306+ if (handler->close != NULL)
1307+ {
1308+ return handler->close(handler);
1309+ }
1310+ return 0;
1311+}
1312+
1313+static inline
1314+void audit_handler_set_option(audit_handler_t *handler,
1315+ audit_handler_option_t opt, void *val)
1316+{
1317+ if (handler->set_option != NULL)
1318+ {
1319+ handler->set_option(handler, opt, val);
1320+ }
1321+}
1322+
1323+audit_handler_t *audit_handler_file_open(audit_handler_file_config_t *opts);
1324+audit_handler_t *audit_handler_syslog_open(audit_handler_syslog_config_t *opts);
1325+
1326+#ifdef __cplusplus
1327+}
1328+#endif
1329+
1330+#endif
1331
1332=== modified file 'plugin/audit_log/audit_log.c'
1333--- plugin/audit_log/audit_log.c 2014-05-23 16:14:27 +0000
1334+++ plugin/audit_log/audit_log.c 2014-07-30 17:21:31 +0000
1335@@ -25,22 +25,24 @@
1336 #include <mysql_version.h>
1337 #include <mysql_com.h>
1338 #include <my_pthread.h>
1339+#include <syslog.h>
1340
1341 #include "logger.h"
1342 #include "buffer.h"
1343+#include "audit_handler.h"
1344
1345-#define PLUGIN_VERSION 0x0001
1346+#define PLUGIN_VERSION 0x0002
1347
1348
1349 enum audit_log_policy_t { ALL, NONE, LOGINS, QUERIES };
1350 enum audit_log_strategy_t
1351 { ASYNCHRONOUS, PERFORMANCE, SEMISYNCHRONOUS, SYNCHRONOUS };
1352 enum audit_log_format_t { OLD, NEW, JSON, CSV };
1353+enum audit_log_handler_t { HANDLER_FILE, HANDLER_SYSLOG };
1354
1355 typedef void (*escape_buf_func_t)(const char *, size_t *, char *, size_t *);
1356
1357-static LOGGER_HANDLE *audit_file_logger= NULL;
1358-static audit_log_buffer_t *audit_log_buffer= NULL;
1359+static audit_handler_t *log_handler= NULL;
1360 static ulonglong record_id= 0;
1361 static time_t log_file_time= 0;
1362 char *audit_log_file;
1363@@ -52,6 +54,43 @@
1364 ulonglong audit_log_rotations= 0;
1365 char audit_log_flush= FALSE;
1366 ulong audit_log_format= OLD;
1367+ulong audit_log_handler= HANDLER_FILE;
1368+char *audit_log_syslog_ident;
1369+char default_audit_log_syslog_ident[] = "percona-audit";
1370+ulong audit_log_syslog_facility= 0;
1371+ulong audit_log_syslog_priority= 0;
1372+
1373+
1374+static int audit_log_syslog_facility_codes[]=
1375+ { LOG_USER, LOG_AUTHPRIV, LOG_CRON, LOG_DAEMON, LOG_FTP,
1376+ LOG_KERN, LOG_LPR, LOG_MAIL, LOG_NEWS,
1377+#if (defined LOG_SECURITY)
1378+ LOG_SECURITY,
1379+#endif
1380+ LOG_SYSLOG, LOG_AUTH, LOG_UUCP, LOG_LOCAL0, LOG_LOCAL1,
1381+ LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6,
1382+ LOG_LOCAL7, 0};
1383+
1384+
1385+static const char *audit_log_syslog_facility_names[]=
1386+ { "LOG_USER", "LOG_AUTHPRIV", "LOG_CRON", "LOG_DAEMON", "LOG_FTP",
1387+ "LOG_KERN", "LOG_LPR", "LOG_MAIL", "LOG_NEWS",
1388+#if (defined LOG_SECURITY)
1389+ "LOG_SECURITY",
1390+#endif
1391+ "LOG_SYSLOG", "LOG_AUTH", "LOG_UUCP", "LOG_LOCAL0", "LOG_LOCAL1",
1392+ "LOG_LOCAL2", "LOG_LOCAL3", "LOG_LOCAL4", "LOG_LOCAL5", "LOG_LOCAL6",
1393+ "LOG_LOCAL7", 0 };
1394+
1395+
1396+static const int audit_log_syslog_priority_codes[]=
1397+ { LOG_INFO, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING,
1398+ LOG_NOTICE, LOG_EMERG, LOG_DEBUG, 0 };
1399+
1400+
1401+static const char *audit_log_syslog_priority_names[]=
1402+ { "LOG_INFO", "LOG_ALERT", "LOG_CRIT", "LOG_ERR", "LOG_WARNING",
1403+ "LOG_NOTICE", "LOG_EMERG", "LOG_DEBUG", 0 };
1404
1405
1406 static
1407@@ -228,14 +267,15 @@
1408 return out;
1409 }
1410
1411+
1412 static
1413-void logger_write_safe(LOGGER_HANDLE *log, const char *buffer, size_t size)
1414+void audit_log_write(const char *buf, size_t len)
1415 {
1416 static int write_error= 0;
1417
1418- if (log != NULL)
1419+ if (log_handler != NULL)
1420 {
1421- if (logger_write(log, buffer, size) < 0)
1422+ if (audit_handler_write(log_handler, buf, len) < 0)
1423 {
1424 if (!write_error)
1425 {
1426@@ -253,44 +293,6 @@
1427 }
1428
1429
1430-static
1431-void logger_write_safe_void(void *log, const char *buffer, size_t size)
1432-{
1433- logger_write_safe((LOGGER_HANDLE *)log, buffer, size);
1434-}
1435-
1436-
1437-static
1438-void audit_log_write_without_buffer(const char *buf, size_t len)
1439-{
1440- logger_write_safe(audit_file_logger, buf, len);
1441- if (audit_log_strategy == SYNCHRONOUS && audit_file_logger != NULL)
1442- {
1443- logger_sync(audit_file_logger);
1444- }
1445-}
1446-
1447-
1448-static
1449-void audit_log_write(const char *buf, size_t len)
1450-{
1451- switch (audit_log_strategy)
1452- {
1453- case ASYNCHRONOUS:
1454- case PERFORMANCE:
1455- if (audit_log_buffer != NULL)
1456- audit_log_buffer_write(audit_log_buffer, buf, len);
1457- break;
1458- case SEMISYNCHRONOUS:
1459- case SYNCHRONOUS:
1460- audit_log_write_without_buffer(buf, len);
1461- break;
1462- default:
1463- DBUG_ASSERT(0);
1464- }
1465-}
1466-
1467-
1468
1469 /* Defined in MySQL server */
1470 extern int orig_argc;
1471@@ -541,6 +543,11 @@
1472
1473 init_record_id(stat->st_size);
1474
1475+ if (buf == NULL)
1476+ {
1477+ return 0;
1478+ }
1479+
1480 return my_snprintf(buf, buflen, format_string[audit_log_format]);
1481 }
1482
1483@@ -554,22 +561,56 @@
1484 "",
1485 "" };
1486
1487+ if (buf == NULL)
1488+ {
1489+ return 0;
1490+ }
1491+
1492 return my_snprintf(buf, buflen, format_string[audit_log_format]);
1493 }
1494
1495 static
1496 int init_new_log_file()
1497 {
1498- audit_file_logger= logger_open(audit_log_file, audit_log_rotate_on_size,
1499- audit_log_rotate_on_size ? audit_log_rotations : 0,
1500- audit_log_strategy >= SEMISYNCHRONOUS,
1501- audit_log_header);
1502- if (audit_file_logger == NULL)
1503- {
1504- fprintf_timestamp(stderr);
1505- fprintf(stderr, "Cannot open file %s. ", audit_log_file);
1506- perror("Error: ");
1507- return(1);
1508+ if (audit_log_handler == HANDLER_FILE)
1509+ {
1510+ audit_handler_file_config_t opts;
1511+ opts.name= audit_log_file;
1512+ opts.rotate_on_size= audit_log_rotate_on_size;
1513+ opts.rotations= audit_log_rotations;
1514+ opts.sync_on_write= audit_log_strategy == SYNCHRONOUS;
1515+ opts.use_buffer= audit_log_strategy < SEMISYNCHRONOUS;
1516+ opts.buffer_size= audit_log_buffer_size;
1517+ opts.can_drop_data= audit_log_strategy == PERFORMANCE;
1518+ opts.header= audit_log_header;
1519+ opts.footer= audit_log_footer;
1520+
1521+ log_handler= audit_handler_file_open(&opts);
1522+ if (log_handler == NULL)
1523+ {
1524+ fprintf_timestamp(stderr);
1525+ fprintf(stderr, "Cannot open file %s. ", audit_log_file);
1526+ perror("Error: ");
1527+ return(1);
1528+ }
1529+ }
1530+ else
1531+ {
1532+ audit_handler_syslog_config_t opts;
1533+ opts.facility= audit_log_syslog_facility_codes[audit_log_syslog_facility];
1534+ opts.ident= audit_log_syslog_ident;
1535+ opts.priority= audit_log_syslog_priority_codes[audit_log_syslog_priority];
1536+ opts.header= audit_log_header;
1537+ opts.footer= audit_log_footer;
1538+
1539+ log_handler= audit_handler_syslog_open(&opts);
1540+ if (log_handler == NULL)
1541+ {
1542+ fprintf_timestamp(stderr);
1543+ fprintf(stderr, "Cannot open syslog. ");
1544+ perror("Error: ");
1545+ return(1);
1546+ }
1547 }
1548
1549 return(0);
1550@@ -579,12 +620,15 @@
1551 static
1552 int reopen_log_file()
1553 {
1554- if (logger_reopen(audit_file_logger, audit_log_header, audit_log_footer))
1555+ if (log_handler != NULL)
1556 {
1557- fprintf_timestamp(stderr);
1558- fprintf(stderr, "Cannot open file %s. ", audit_log_file);
1559- perror("Error: ");
1560- return(1);
1561+ if (audit_handler_flush(log_handler))
1562+ {
1563+ fprintf_timestamp(stderr);
1564+ fprintf(stderr, "Cannot open file %s. ", audit_log_file);
1565+ perror("Error: ");
1566+ return(1);
1567+ }
1568 }
1569
1570 return(0);
1571@@ -592,14 +636,6 @@
1572
1573
1574 static
1575-void close_log_file()
1576-{
1577- if (audit_file_logger != NULL)
1578- logger_close(audit_file_logger, audit_log_footer);
1579-}
1580-
1581-
1582-static
1583 int audit_log_plugin_init(void *arg __attribute__((unused)))
1584 {
1585 char buf[1024];
1586@@ -610,13 +646,6 @@
1587 if (init_new_log_file())
1588 return(1);
1589
1590- if (audit_log_strategy < SEMISYNCHRONOUS)
1591- {
1592- audit_log_buffer= audit_log_buffer_init(audit_log_buffer_size,
1593- audit_log_strategy == PERFORMANCE, logger_write_safe_void,
1594- audit_file_logger);
1595- }
1596-
1597 len= audit_log_audit_record(buf, sizeof(buf), "Audit", time(NULL));
1598 audit_log_write(buf, len);
1599
1600@@ -633,9 +662,7 @@
1601 len= audit_log_audit_record(buf, sizeof(buf), "NoAudit", time(NULL));
1602 audit_log_write(buf, len);
1603
1604- if (audit_log_buffer != NULL)
1605- audit_log_buffer_shutdown(audit_log_buffer);
1606- close_log_file();
1607+ audit_handler_close(log_handler);
1608
1609 return(0);
1610 }
1611@@ -729,8 +756,8 @@
1612
1613 static TYPELIB audit_log_policy_typelib=
1614 {
1615- array_elements(audit_log_policy_names) - 1, "audit_log_policy_typelib",
1616- audit_log_policy_names, NULL
1617+ array_elements(audit_log_policy_names) - 1, "audit_log_policy_typelib",
1618+ audit_log_policy_names, NULL
1619 };
1620
1621 static MYSQL_SYSVAR_ENUM(policy, audit_log_policy, PLUGIN_VAR_RQCMDARG,
1622@@ -742,21 +769,22 @@
1623 { "ASYNCHRONOUS", "PERFORMANCE", "SEMISYNCHRONOUS", "SYNCHRONOUS", 0 };
1624 static TYPELIB audit_log_strategy_typelib=
1625 {
1626- array_elements(audit_log_strategy_names) - 1, "audit_log_strategy_typelib",
1627- audit_log_strategy_names, NULL
1628+ array_elements(audit_log_strategy_names) - 1, "audit_log_strategy_typelib",
1629+ audit_log_strategy_names, NULL
1630 };
1631
1632 static MYSQL_SYSVAR_ENUM(strategy, audit_log_strategy,
1633 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
1634- "The logging method used by the audit log plugin.", NULL, NULL,
1635+ "The logging method used by the audit log plugin, "
1636+ "if FILE handler is used.", NULL, NULL,
1637 ASYNCHRONOUS, &audit_log_strategy_typelib);
1638
1639 static const char *audit_log_format_names[]=
1640 { "OLD", "NEW", "JSON", "CSV", 0 };
1641 static TYPELIB audit_log_format_typelib=
1642 {
1643- array_elements(audit_log_format_names) - 1, "audit_log_format_typelib",
1644- audit_log_format_names, NULL
1645+ array_elements(audit_log_format_names) - 1, "audit_log_format_typelib",
1646+ audit_log_format_names, NULL
1647 };
1648
1649 static MYSQL_SYSVAR_ENUM(format, audit_log_format,
1650@@ -764,9 +792,23 @@
1651 "The audit log file format.", NULL, NULL,
1652 ASYNCHRONOUS, &audit_log_format_typelib);
1653
1654+static const char *audit_log_handler_names[]=
1655+ { "FILE", "SYSLOG", 0 };
1656+static TYPELIB audit_log_handler_typelib=
1657+{
1658+ array_elements(audit_log_handler_names) - 1, "audit_log_handler_typelib",
1659+ audit_log_handler_names, NULL
1660+};
1661+
1662+static MYSQL_SYSVAR_ENUM(handler, audit_log_handler,
1663+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
1664+ "The audit log handler.", NULL, NULL,
1665+ HANDLER_FILE, &audit_log_handler_typelib);
1666+
1667 static MYSQL_SYSVAR_ULONGLONG(buffer_size, audit_log_buffer_size,
1668 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
1669- "The size of the buffer for asynchronous logging.",
1670+ "The size of the buffer for asynchronous logging, "
1671+ "if FILE handler is used.",
1672 NULL, NULL, 1048576UL, 4096UL, ULONGLONG_MAX, 4096UL);
1673
1674 static
1675@@ -778,13 +820,15 @@
1676 {
1677 ulonglong new_val= *(ulonglong *)(save);
1678
1679- if (audit_file_logger)
1680- logger_set_size_limit(audit_file_logger, new_val);
1681+ if (log_handler != NULL)
1682+ audit_handler_set_option(log_handler, OPT_ROTATE_ON_SIZE, &new_val);
1683+
1684+ audit_log_rotate_on_size= new_val;
1685 }
1686
1687 static MYSQL_SYSVAR_ULONGLONG(rotate_on_size, audit_log_rotate_on_size,
1688 PLUGIN_VAR_RQCMDARG,
1689- "Maximum size of the log to start the rotation.",
1690+ "Maximum size of the log to start the rotation, if FILE handler is used.",
1691 NULL, audit_log_rotate_on_size_update, 0UL, 0UL, ULONGLONG_MAX, 4096UL);
1692
1693 static
1694@@ -796,13 +840,15 @@
1695 {
1696 ulonglong new_val= *(ulonglong *)(save);
1697
1698- if (audit_file_logger)
1699- logger_set_rotations(audit_file_logger, new_val);
1700+ if (log_handler != NULL)
1701+ audit_handler_set_option(log_handler, OPT_ROTATIONS, &new_val);
1702+
1703+ audit_log_rotations= new_val;
1704 }
1705
1706 static MYSQL_SYSVAR_ULONGLONG(rotations, audit_log_rotations,
1707 PLUGIN_VAR_RQCMDARG,
1708- "Maximum number of rotations to keep.",
1709+ "Maximum number of rotations to keep, if FILE handler is used.",
1710 NULL, audit_log_rotations_update, 0UL, 0UL, 999UL, 1UL);
1711
1712 static
1713@@ -826,6 +872,39 @@
1714 PLUGIN_VAR_OPCMDARG, "Flush the log file.", NULL,
1715 audit_log_flush_update, 0);
1716
1717+static MYSQL_SYSVAR_STR(syslog_ident, audit_log_syslog_ident,
1718+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
1719+ "The string that will be prepended to each log message, "
1720+ "if SYSLOG handler is used.",
1721+ NULL, NULL, default_audit_log_syslog_ident);
1722+
1723+static TYPELIB audit_log_syslog_facility_typelib=
1724+{
1725+ array_elements(audit_log_syslog_facility_names) - 1,
1726+ "audit_log_syslog_facility_typelib",
1727+ audit_log_syslog_facility_names, NULL
1728+};
1729+
1730+static MYSQL_SYSVAR_ENUM(syslog_facility, audit_log_syslog_facility,
1731+ PLUGIN_VAR_RQCMDARG,
1732+ "The syslog facility to assign to messages, if SYSLOG handler is used.",
1733+ NULL, NULL, 0,
1734+ &audit_log_syslog_facility_typelib);
1735+
1736+static TYPELIB audit_log_syslog_priority_typelib=
1737+{
1738+ array_elements(audit_log_syslog_priority_names) - 1,
1739+ "audit_log_syslog_priority_typelib",
1740+ audit_log_syslog_priority_names, NULL
1741+};
1742+
1743+static MYSQL_SYSVAR_ENUM(syslog_priority, audit_log_syslog_priority,
1744+ PLUGIN_VAR_RQCMDARG,
1745+ "Priority to be assigned to all messages written to syslog.",
1746+ NULL, NULL, 0,
1747+ &audit_log_syslog_priority_typelib);
1748+
1749+
1750 static struct st_mysql_sys_var* audit_log_system_variables[] =
1751 {
1752 MYSQL_SYSVAR(file),
1753@@ -836,6 +915,10 @@
1754 MYSQL_SYSVAR(rotate_on_size),
1755 MYSQL_SYSVAR(rotations),
1756 MYSQL_SYSVAR(flush),
1757+ MYSQL_SYSVAR(handler),
1758+ MYSQL_SYSVAR(syslog_ident),
1759+ MYSQL_SYSVAR(syslog_priority),
1760+ MYSQL_SYSVAR(syslog_facility),
1761 NULL
1762 };
1763
1764
1765=== added file 'plugin/audit_log/audit_syslog.c'
1766--- plugin/audit_log/audit_syslog.c 1970-01-01 00:00:00 +0000
1767+++ plugin/audit_log/audit_syslog.c 2014-07-30 17:21:31 +0000
1768@@ -0,0 +1,91 @@
1769+/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved.
1770+
1771+ This program is free software; you can redistribute it and/or
1772+ modify it under the terms of the GNU General Public License
1773+ as published by the Free Software Foundation; version 2 of
1774+ the License.
1775+
1776+ This program is distributed in the hope that it will be useful,
1777+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1778+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1779+ GNU General Public License for more details.
1780+
1781+ You should have received a copy of the GNU General Public License
1782+ along with this program; if not, write to the Free Software
1783+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
1784+
1785+#include <syslog.h>
1786+#include <string.h>
1787+#include "audit_handler.h"
1788+
1789+typedef struct audit_handler_syslog_data_struct audit_handler_syslog_data_t;
1790+
1791+struct audit_handler_syslog_data_struct
1792+{
1793+ size_t struct_size;
1794+ int priority;
1795+ logger_prolog_func_t header;
1796+ logger_epilog_func_t footer;
1797+};
1798+
1799+int audit_handler_syslog_write(audit_handler_t *handler,
1800+ const char *buf, size_t len);
1801+int audit_handler_syslog_flush(audit_handler_t *handler);
1802+int audit_handler_syslog_close(audit_handler_t *handler);
1803+
1804+
1805+audit_handler_t *audit_handler_syslog_open(audit_handler_syslog_config_t *opts)
1806+{
1807+ audit_handler_t *handler= (audit_handler_t*)
1808+ calloc(sizeof(audit_handler_t) + sizeof(audit_handler_syslog_data_t), 1);
1809+ if (handler != NULL)
1810+ {
1811+ audit_handler_syslog_data_t *data=
1812+ (audit_handler_syslog_data_t*) (handler + 1);
1813+ MY_STAT stat_arg;
1814+
1815+ data->struct_size= sizeof(audit_handler_syslog_data_t);
1816+ data->priority= opts->priority;
1817+ data->header= opts->header;
1818+ data->footer= opts->footer;
1819+ openlog(opts->ident, 0, opts->facility);
1820+ memset(&stat_arg, 0, sizeof(stat_arg));
1821+ opts->header(&stat_arg, NULL, 0);
1822+ handler->data= data;
1823+ handler->write= audit_handler_syslog_write;
1824+ handler->flush= audit_handler_syslog_flush;
1825+ handler->close= audit_handler_syslog_close;
1826+ }
1827+ return handler;
1828+}
1829+
1830+int audit_handler_syslog_write(audit_handler_t *handler,
1831+ const char *buf, size_t len)
1832+{
1833+ audit_handler_syslog_data_t *data=
1834+ (audit_handler_syslog_data_t*) handler->data;
1835+ DBUG_ASSERT(data->struct_size == sizeof(audit_handler_syslog_data_t));
1836+ syslog(data->priority, "%s", buf);
1837+ return len;
1838+}
1839+
1840+int audit_handler_syslog_flush(audit_handler_t *handler)
1841+{
1842+ audit_handler_syslog_data_t *data=
1843+ (audit_handler_syslog_data_t*) handler->data;
1844+ MY_STAT stat_arg;
1845+ memset(&stat_arg, 0, sizeof(stat_arg));
1846+ data->header(&stat_arg, NULL, 0);
1847+ data->footer(NULL, 0);
1848+ return 0;
1849+}
1850+
1851+int audit_handler_syslog_close(audit_handler_t *handler)
1852+{
1853+ audit_handler_syslog_data_t *data=
1854+ (audit_handler_syslog_data_t*) handler->data;
1855+ data->footer(NULL, 0);
1856+ closelog();
1857+ free(handler);
1858+ return 0;
1859+}
1860
1861=== modified file 'plugin/audit_log/buffer.h'
1862--- plugin/audit_log/buffer.h 2014-04-21 12:07:45 +0000
1863+++ plugin/audit_log/buffer.h 2014-07-30 17:21:31 +0000
1864@@ -20,13 +20,22 @@
1865
1866 #include <string.h> // for size_t
1867
1868+#ifdef __cplusplus
1869+extern "C" {
1870+#endif
1871+
1872 typedef struct audit_log_buffer audit_log_buffer_t;
1873
1874-typedef void (*audit_log_write_func)(void *data, const char *buf, size_t len);
1875+typedef int (*audit_log_write_func)(void *data, const char *buf, size_t len);
1876
1877 audit_log_buffer_t *audit_log_buffer_init(size_t size, int drop_if_full,
1878 audit_log_write_func write_func, void *data);
1879 void audit_log_buffer_shutdown(audit_log_buffer_t *log);
1880-int audit_log_buffer_write(audit_log_buffer_t *log, const char *buf, size_t len);
1881+int audit_log_buffer_write(audit_log_buffer_t *log,
1882+ const char *buf, size_t len);
1883+
1884+#ifdef __cplusplus
1885+}
1886+#endif
1887
1888 #endif
1889
1890=== modified file 'plugin/audit_log/logger.h'
1891--- plugin/audit_log/logger.h 2014-05-23 16:14:27 +0000
1892+++ plugin/audit_log/logger.h 2014-07-30 17:21:31 +0000
1893@@ -60,8 +60,8 @@
1894 #endif
1895
1896 typedef struct logger_handle_st LOGGER_HANDLE;
1897-typedef size_t (logger_prolog_func_t)(MY_STAT *, char *buf, size_t buflen);
1898-typedef size_t (logger_epilog_func_t)(char *buf, size_t buflen);
1899+typedef size_t (*logger_prolog_func_t)(MY_STAT *, char *buf, size_t buflen);
1900+typedef size_t (*logger_epilog_func_t)(char *buf, size_t buflen);
1901
1902 void logger_init_mutexes();
1903 LOGGER_HANDLE *logger_open(const char *path,

Subscribers

People subscribed via source and target branches