Expand authentication failure log message

If the authentication failure was due to a missing database, this extra
information can be logged. This will help cases where users are using
databases that do not exist.
This commit is contained in:
Markus Mäkelä
2018-06-29 23:00:32 +03:00
parent d96a8b1773
commit ed068f4d93

View File

@ -304,15 +304,23 @@ mysql_auth_authenticate(DCB *dcb)
} }
else if (dcb->service->log_auth_warnings) else if (dcb->service->log_auth_warnings)
{ {
// Enough to hold the error message and the database name
char extra[256] = {};
if (auth_ret == MXS_AUTH_FAILED_DB)
{
snprintf(extra, sizeof(extra), "Unknown database: %s", client_data->db);
}
if (dcb->path) if (dcb->path)
{ {
MXS_WARNING("%s: login attempt for user '%s'@[%s]:%s, authentication failed.", MXS_WARNING("%s: login attempt for user '%s'@[%s]:%s, authentication failed. %s",
dcb->service->name, client_data->user, dcb->remote, dcb->path); dcb->service->name, client_data->user, dcb->remote, dcb->path, extra);
} }
else else
{ {
MXS_WARNING("%s: login attempt for user '%s'@[%s]:%d, authentication failed.", MXS_WARNING("%s: login attempt for user '%s'@[%s]:%d, authentication failed. %s",
dcb->service->name, client_data->user, dcb->remote, dcb_get_port(dcb)); dcb->service->name, client_data->user, dcb->remote, dcb_get_port(dcb), extra);
} }
if (is_localhost_address(&dcb->ip) && if (is_localhost_address(&dcb->ip) &&