Adding d/p/23_check_mysql_fix_error_handling from upstream

This commit is contained in:
Jan Wagner 2023-05-31 16:38:05 +02:00
parent 01be8ce8fe
commit 85d9e03ea0
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,28 @@
From 10863265324a9a9fdf8ce771271af15b7e2f5a4a Mon Sep 17 00:00:00 2001
From: Platon Pronko <platon7pronko@gmail.com>
Date: Fri, 19 May 2023 15:05:02 +0800
Subject: [PATCH] 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 6cfa70edb..91e150fbd 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),

View file

@ -14,6 +14,7 @@
20_chech_nt_fix_encoding 20_chech_nt_fix_encoding
21_check_pgsql_extra_output 21_check_pgsql_extra_output
22_check_disk_avoid_mount 22_check_disk_avoid_mount
23_check_mysql_fix_error_handling
# feature patches # feature patches
30_check_radius_radcli_1.3.1_support 30_check_radius_radcli_1.3.1_support
31_checl_mailq_separate_submission_queue 31_checl_mailq_separate_submission_queue