Bug #79091 MYSQL_AUDIT_SERVER_STARTUP_CLASS event termination should improve diagnostics
Submitted: 3 Nov 2015 9:45 Modified: 24 Feb 2016 23:17
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Security: Audit Severity:S3 (Non-critical)
Version:5.7.9 OS:Any
Assigned to: CPU Architecture:Any
Tags: plugin api

[3 Nov 2015 9:45] Laurynas Biveinis
Description:
If an audit plugin chooses to terminate server startup by returning non-zero from a MYSQL_AUDIT_SERVER_STARTUP_CLASS handler, it results in very non-intuitive diagnostics in the error log:
...
2015-11-03T09:38:59.276726Z 0 [ERROR] Aborting
...

How to repeat:
Apply

--- mysql-server/plugin/audit_null/audit_null.c	2015-11-03 10:46:59.000000000 +0200
+++ mysql-5.7.9/plugin/audit_null/audit_null.c	2015-11-03 11:43:16.000000000 +0200
@@ -481,6 +481,7 @@ static int audit_null_notify(MYSQL_THD t
     /* const struct mysql_event_server_startup *event_startup=
        (const struct mysql_event_server_startup *) event; */
     number_of_calls_server_startup++;
+    return 1;
   }
   else if (event_class == MYSQL_AUDIT_SERVER_SHUTDOWN_CLASS)
   {

Then use the following MTR:

foo-master.opt:
$AUDIT_NULL_OPT

foo.test:

--source include/have_null_audit_plugin.inc
--source include/not_embedded.inc

connection default;
let $expected_extension= so;
if(`SELECT CONVERT(@@version_compile_os USING latin1)
           IN ("Win32","Win64","Windows")`)
{
   let $expected_extension= dll;
}
--replace_result $expected_extension <expected_extension>
eval INSTALL PLUGIN null_audit SONAME 'adt_null.$expected_extension';

SHOW PLUGINS;

--source include/restart_mysqld.inc

SHOW PLUGINS;

eval UNINSTALL PLUGIN null_audit;

Check the error log after the testcase fails.

Suggested fix:
The diagnostics in this case should tell at least the plugin name that chose to terminate server startup
[3 Nov 2015 10:57] MySQL Verification Team
Hello Laurynas,
 
Thank you for the report.

// with the patch

2015-11-03T10:10:54.467676Z 0 [Note] InnoDB: 5.7.9 started; log sequence number 1350543
2015-11-03T10:10:54.467991Z 0 [Note] InnoDB: Loading buffer pool(s) from /export/umesh/server/source/bugs/mysql-5.7.9/mysql-test/var/mysqld.1/data/ib_buffer_pool
2015-11-03T10:10:54.468063Z 0 [Note] InnoDB: not started
2015-11-03T10:10:54.471524Z 0 [Note] Plugin 'FEDERATED' is disabled.
2015-11-03T10:10:54.475721Z 0 [Note] InnoDB: Buffer pool(s) load completed at 151103 13:10:54
2015-11-03T10:10:54.481109Z 0 [Warning] unknown variable 'loose-sha256_password_auto_generate_rsa_keys=0'
2015-11-03T10:10:54.487456Z 0 [ERROR] Aborting

Thanks,
Umesh
[24 Feb 2016 23:17] Paul DuBois
Noted in 5.7.12, 5.8.0 changelogs.

Diagnostic messages were improved for the case when the
MYSQL_AUDIT_GENERAL_CLASS handler returned nonzero.