Changed queries to more closely match actual queries.

This commit is contained in:
Markus Makela 2015-08-27 10:44:03 +03:00
parent b232c49742
commit cb2b465510
2 changed files with 36 additions and 29 deletions

View File

@ -2376,46 +2376,43 @@ void valid_service_permissions(SERVICE* service)
return;
}
if(mysql_query(mysql,"select * from mysql.user limit 1") != 0)
if(mysql_query(mysql,"SELECT user, host, password,Select_priv FROM mysql.user limit 1") != 0)
{
skygw_log_write(LE,"[%s] Error: Failed to query from mysql.user table. MySQL error message: %s",service->name,mysql_error(mysql));
mysql_close(mysql);
if(mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
{
skygw_log_write(LE,"[%s] Error: User '%s' is missing SELECT privileges on mysql.user table. MySQL error message: %s",
service->name,user,mysql_error(mysql));
}
else
{
skygw_log_write(LE,"[%s] Error: Failed to query from mysql.user table. MySQL error message: %s",
service->name,mysql_error(mysql));
}
mysql_close(mysql);
free(dpasswd);
return;
}
mysql_free_result(mysql_use_result(mysql));
if(mysql_query(mysql,"select * from mysql.db limit 1") != 0)
if(mysql_query(mysql,"SELECT user, host, db FROM mysql.db limit 1") != 0)
{
skygw_log_write(LM|LE,"The user '%s' for service '%s' does not have"
" SELECT permissions on the mysql.db table. MaxScale will not use the database in authentication. MySQL error message: %s",
user,service->name,mysql_error(mysql));
mysql_close(mysql);
if(mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
{
skygw_log_write(LE,"[%s] Error: User '%s' is missing SELECT privileges on mysql.db table. MySQL error message: %s",
service->name,user,mysql_error(mysql));
}
else
{
skygw_log_write(LE,"[%s] Error: Failed to query from mysql.user table. MySQL error message: %s",
service->name,mysql_error(mysql));
}
mysql_close(mysql);
free(dpasswd);
return;
}
else
{
mysql_free_result(mysql_use_result(mysql));
}
if(mysql_query(mysql,LOAD_MYSQL_DATABASE_NAMES) != 0)
{
skygw_log_write(LE,"[%s] Error: Failed to query for SHOW DATABASES permissions. MySQL error message: %s.",service->name,mysql_error(mysql));
}
else
{
res = mysql_use_result(mysql);
if(mysql_num_rows(res) == 0)
{
skygw_log_write(LM|LE,"The user '%s' for service '%s' does not have"
" SHOW DATABASES permissions. MaxScale will not use the database in authentication.",
user,service->name);
}
mysql_free_result(res);
}
mysql_free_result(mysql_use_result(mysql));
mysql_close(mysql);
free(dpasswd);
}

View File

@ -41,6 +41,7 @@
#include <skygw_utils.h>
#include <log_manager.h>
#include <secrets.h>
#include <mysql/mysqld_error.h>
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
@ -496,7 +497,16 @@ void valid_monitor_permissions(MONITOR* monitor)
if(mysql_query(mysql,"show slave status") != 0)
{
skygw_log_write(LE,"[%s] Error: Monitor failed to query for slave status. MySQL error message: %s",monitor->name,mysql_error(mysql));
if(mysql_errno(mysql) == ER_SPECIFIC_ACCESS_DENIED_ERROR)
{
skygw_log_write(LE,"[%s] Error: User '%s' is missing REPLICATION CLIENT privileges. MySQL error message: %s",
monitor->name,mysql_error(mysql));
}
else
{
skygw_log_write(LE,"[%s] Error: Monitor failed to query for slave status. MySQL error message: %s",
monitor->name,mysql_error(mysql));
}
mysql_close(mysql);
free(dpasswd);
return;