Check SHOW DATABASES privilege on startup

MySQLAuth requires the SHOW DATABASES privilege to see all the databases
so it should be checked that the current user has the permission. A
missing permission will cause errors that are hard to resolve.
This commit is contained in:
Markus Mäkelä 2018-02-22 10:06:29 +02:00
parent 8e31b30d19
commit 03eb30fbc6
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -627,6 +627,25 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
}
}
// 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)
{
MYSQL_RES* res = mysql_use_result(mysql);
if (res)
{
MYSQL_ROW row = mysql_fetch_row(res);
if (row && strcasecmp(row[0], "Y") != 0)
{
MXS_WARNING("[%s] User '%s' is missing the SHOW DATABASES privilege.",
service->name, user);
}
mysql_free_result(res);
}
}
mysql_close(mysql);
return rval;