MXS-2496: Fix SHOW DATABASES grant check
The code expected that the grant was given to the actual user, not a role.
This commit is contained in:
parent
bb706394f6
commit
b294acf276
@ -815,23 +815,28 @@ static bool check_server_permissions(SERVICE* service,
|
||||
}
|
||||
|
||||
// Check whether the current user has the SHOW DATABASES privilege
|
||||
if (mxs_mysql_query(mysql,
|
||||
"SELECT show_db_priv FROM mysql.user "
|
||||
"WHERE CONCAT(user, '@', host) = CURRENT_USER()") == 0)
|
||||
if (mxs_mysql_query(mysql, "SHOW GRANTS") == 0)
|
||||
{
|
||||
MYSQL_RES* res = mysql_use_result(mysql);
|
||||
if (res)
|
||||
if (MYSQL_RES* res = mysql_use_result(mysql))
|
||||
{
|
||||
MYSQL_ROW row = mysql_fetch_row(res);
|
||||
bool found = false;
|
||||
|
||||
if (row && strcasecmp(row[0], "Y") != 0)
|
||||
for (MYSQL_ROW row = mysql_fetch_row(res); row; row = mysql_fetch_row(res))
|
||||
{
|
||||
if (strcasestr(row[0], "SHOW DATABASES"))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
MXS_WARNING("[%s] User '%s' is missing the SHOW DATABASES privilege. "
|
||||
"This means that MaxScale cannot see all databases and authentication can fail.",
|
||||
service->name,
|
||||
user);
|
||||
}
|
||||
|
||||
mysql_free_result(res);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user