Fixed errors and added comments.

This commit is contained in:
Markus Makela 2015-08-27 16:12:46 +03:00
parent 525daf827a
commit 296bdc5df6
3 changed files with 26 additions and 20 deletions

View File

@ -2322,6 +2322,8 @@ int add_wildcard_users(USERS *users, char* name, char* host, char* password, cha
* SHOW DATABASES permissions. If permissions are not adequate, an error message
* is logged.
* @param service Service to inspect
* @return True if service permissions are correct. False if one or more permissions
* are missing or if an error occurred.
*/
bool check_service_permissions(SERVICE* service)
{
@ -2394,19 +2396,20 @@ bool check_service_permissions(SERVICE* service)
service->name,mysql_error(mysql));
}
}
if((res = mysql_use_result(mysql)) == NULL)
else
{
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for"
" permissions to the mysql.user table: %s",
if((res = mysql_use_result(mysql)) == NULL)
{
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for"
" permissions to the mysql.user table: %s",
service->name,mysql_error(mysql));
mysql_close(mysql);
free(dpasswd);
return rval;
mysql_close(mysql);
free(dpasswd);
return rval;
}
mysql_free_result(res);
}
mysql_free_result(res);
if(mysql_query(mysql,"SELECT user, host, db FROM mysql.db limit 1") != 0)
{
if(mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
@ -2421,17 +2424,18 @@ bool check_service_permissions(SERVICE* service)
service->name,mysql_error(mysql));
}
}
if((res = mysql_use_result(mysql)) == NULL)
{
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for permissions to the mysql.db table: %s",
service->name,mysql_error(mysql));
}
else
{
mysql_free_result(res);
if((res = mysql_use_result(mysql)) == NULL)
{
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for permissions to the mysql.db table: %s",
service->name,mysql_error(mysql));
}
else
{
mysql_free_result(res);
}
}
mysql_close(mysql);
free(dpasswd);
return rval;

View File

@ -455,6 +455,8 @@ int *data;
* Check if the monitor user has all required permissions to operate properly.
* this checks for REPLICATION CLIENT permissions
* @param service Monitor to inspect
* @return False if an error with monitor permissions was detected or if an
* error occurred. True if permissions are correct.
*/
bool check_monitor_permissions(MONITOR* monitor)
{
@ -499,7 +501,7 @@ bool check_monitor_permissions(MONITOR* monitor)
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));
monitor->name,user,mysql_error(mysql));
rval = false;
}
else

View File

@ -421,7 +421,7 @@ int listeners = 0;
if(!check_service_permissions(service))
{
skygw_log_write_flush(LE,
"%s: Inadequate user permissions for service. Service not started.",
"%s: Error: Inadequate user permissions for service. Service not started.",
service->name);
service->state = SERVICE_STATE_FAILED;
return 0;