Log unknown users and wrong passwords separately

If authentication fails due to a wrong password, a different error message
is logged. This should help resolve problems with user management.
This commit is contained in:
Markus Mäkelä
2018-07-03 16:35:17 +03:00
parent be7d31c6ff
commit 3f9a204116
2 changed files with 7 additions and 2 deletions

View File

@ -304,13 +304,17 @@ mysql_auth_authenticate(DCB *dcb)
}
else if (dcb->service->log_auth_warnings)
{
// Enough to hold the error message and the database name
char extra[256] = {};
// The default failure is a `User not found` one
char extra[256] = "User not found.";
if (auth_ret == MXS_AUTH_FAILED_DB)
{
snprintf(extra, sizeof(extra), "Unknown database: %s", client_data->db);
}
else if (auth_ret == MXS_AUTH_FAILED_WRONG_PASSWORD)
{
strcpy(extra, "Wrong password.");
}
if (dcb->path)
{