From 10863265324a9a9fdf8ce771271af15b7e2f5a4a Mon Sep 17 00:00:00 2001 From: Platon Pronko Date: Fri, 19 May 2023 15:05:02 +0800 Subject: check_mysql: handle ER_ACCESS_DENIED_NO_PASSWORD_ERROR if ignore_auth=1 In some situations MySQL might return ER_ACCESS_DENIED_NO_PASSWORD_ERROR instead of ER_ACCESS_DENIED_ERROR. Semantically these errors are the same. --- plugins/check_mysql.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 6cfa70ed..91e150fb 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c @@ -138,7 +138,10 @@ main (int argc, char **argv) mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers); /* establish a connection to the server and error checking */ if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) { - if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR) + /* Depending on internally-selected auth plugin MySQL might return */ + /* ER_ACCESS_DENIED_NO_PASSWORD_ERROR or ER_ACCESS_DENIED_ERROR. */ + /* Semantically these errors are the same. */ + if (ignore_auth && (mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR || mysql_errno (&mysql) == ER_ACCESS_DENIED_NO_PASSWORD_ERROR)) { printf("MySQL OK - Version: %s (protocol %d)\n", mysql_get_server_info(&mysql), -- cgit v1.2.3-74-g34f1