diff options
author | Julius Goryavsky <julius.goryavsky@mariadb.com> | 2022-04-28 13:10:39 +0200 |
---|---|---|
committer | Julius Goryavsky <julius.goryavsky@mariadb.com> | 2022-05-09 07:55:41 +0200 |
commit | 35989d9cc1b36da5e558706c0253bc7b0bc0fdf0 (patch) | |
tree | 6586608f4a9fd547738ec87a450c54cff7f31213 | |
parent | 0c5d8b87307380d4b53c2267f9a8b56b9b948874 (diff) | |
download | mariadb-git-35989d9cc1b36da5e558706c0253bc7b0bc0fdf0.tar.gz |
MDEV-28281: Hashicorp: Key ID is not indicated in the log record
This commit adds an indication of the ID of the not found key
(and, when appropriate, also an indication of the version number
of the key) in the log file, making it easier to find errors.
-rw-r--r-- | plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc index f0508576f8b..eb851149d58 100644 --- a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc +++ b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc @@ -595,7 +595,9 @@ static int hex2buf (unsigned int max_length, unsigned char *dstbuf, } static int get_data (const std::string &response_str, - const char **js, int *js_len) + const char **js, int *js_len, + unsigned int key_id, + unsigned int key_version) { const char *response = response_str.c_str(); size_t response_len = response_str.size(); @@ -605,9 +607,18 @@ static int get_data (const std::string &response_str, */ if (response_len == 0) { - my_printf_error(ER_UNKNOWN_ERROR, PLUGIN_ERROR_HEADER - "Key not found", - ME_ERROR_LOG_ONLY | ME_NOTE); + if (key_version == ENCRYPTION_KEY_VERSION_INVALID) + { + my_printf_error(ER_UNKNOWN_ERROR, PLUGIN_ERROR_HEADER + "Key not found (key id: %u)", + ME_ERROR_LOG_ONLY | ME_NOTE, key_id); + } + else + { + my_printf_error(ER_UNKNOWN_ERROR, PLUGIN_ERROR_HEADER + "Key not found (key id: %u, key version: %u)", + ME_ERROR_LOG_ONLY | ME_NOTE, key_id, key_version); + } return 1; } if (json_get_object_key(response, response + response_len, "data", @@ -728,7 +739,8 @@ static unsigned int get_latest_version (unsigned int key_id) } const char *js; int js_len; - if (get_data(response_str, &js, &js_len)) + if (get_data(response_str, &js, &js_len, key_id, + ENCRYPTION_KEY_VERSION_INVALID)) { return ENCRYPTION_KEY_VERSION_INVALID; } @@ -809,7 +821,7 @@ static unsigned int get_key_from_vault (unsigned int key_id, } const char *js; int js_len; - if (get_data(response_str, &js, &js_len)) + if (get_data(response_str, &js, &js_len, key_id, key_version)) { return ENCRYPTION_KEY_VERSION_INVALID; } |