Bug #79092 my_message fails to abort MYSQL_AUDIT_SERVER_STARTUP_CLASS event
Submitted: 3 Nov 2015 9:52 Modified: 24 Feb 2016 23:18
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:52] Laurynas Biveinis
Description:
If MYSQL_AUDIT_SERVER_STARTUP_CLASS handler calls my_message, it does not result in server startup abort (as returning non-zero from the function does), and results in a non-standard format error log diagnostics:
...
2015-11-03T09:47:20.547387Z 0 [Warning] unknown variable 'loose-sha256_password_auto_generate_rsa_keys=0'
mysqld-debug: Aborting
2015-11-03T09:47:20.549250Z 0 [Note] InnoDB: Buffer pool(s) load completed at 151103 12:47:20
...

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:46:45.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++;
+    my_message(ER_AUDIT_API_ABORT, "Aborting", MYF(0));
   }
   else if (event_class == MYSQL_AUDIT_SERVER_SHUTDOWN_CLASS)
   {

Run same MTR as in bug 79091:

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

Suggested fix:
my_message diagnostics should be consistent with the diagnostics format and it should abort server startup.
[3 Nov 2015 11:03] MySQL Verification Team
Hello Laurynas,
 
Thank you for the report.

// with the patch

2015-11-03T11:01:46.656360Z 0 [Note] InnoDB: Buffer pool(s) load completed at 151103 14:01:46
2015-11-03T11:01:46.662304Z 0 [Warning] unknown variable 'loose-sha256_password_auto_generate_rsa_keys=0'
mysqld-debug: Aborting
2015-11-03T11:01:46.674946Z 0 [Warning] CA certificate /export/umesh/server/source/bugs/mysql-5.7.9/mysql-test/std_data/cacert.pem is self signed.
2015-11-03T11:01:46.695330Z 0 [Note] Server hostname (bind-address): '*'; port: 13000
2015-11-03T11:01:46.695419Z 0 [Note] IPv6 is available.
2015-11-03T11:01:46.695449Z 0 [Note]   - '::' resolves to '::';
2015-11-03T11:01:46.695523Z 0 [Note] Server socket created on IP: '::'.
2015-11-03T11:01:46.929317Z 0 [Note] Event Scheduler: Loaded 0 events
2015-11-03T11:01:46.930797Z 0 [Note] /export/umesh/server/source/bugs/mysql-5.7.9/sql/mysqld-debug: ready for connections.
Version: '5.7.9-debug-log'  socket: '/export/umesh/server/source/bugs/mysql-5.7.9/mysql-test/var/tmp/mysqld.1.sock'  port: 13000  MySQL Community Server (GPL)

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

Calling my_message() from the MYSQL_AUDIT_SERVER_STARTUP_CLASS
handler did not abort server startup as it should have.