diff --git a/server/core/config.c b/server/core/config.c index f86f97949..c0113d001 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -92,7 +92,7 @@ static void global_defaults(); static void feedback_defaults(); static void check_config_objects(CONFIG_CONTEXT *context); int config_truth_value(char *str); -int isInternalService(char *router); +bool isInternalService(char *router); int config_get_ifaddr(unsigned char *output); int config_get_release_string(char* release); FEEDBACK_CONF * config_get_feedback_data(); @@ -898,7 +898,7 @@ process_config_context(CONFIG_CONTEXT *context) s = strtok_r(NULL, ",", &lasts); } } - else if (servers == NULL && isInternalService(router) == 0) + else if (servers == NULL && !isInternalService(router)) { LOGIF(LE, (skygw_log_write_flush( LOGFILE_ERROR, @@ -2230,18 +2230,16 @@ static char *InternalRouters[] = { * @param router The router name * @return Non-zero if the router is in the InternalRouters table */ -int +bool isInternalService(char *router) { -int i; - if (router) { - for (i = 0; InternalRouters[i]; i++) + for (int i = 0; InternalRouters[i]; i++) if (strcmp(router, InternalRouters[i]) == 0) - return 1; + return true; } - return 0; + return false; } /** * Get the MAC address of first network interface diff --git a/server/core/dbusers.c b/server/core/dbusers.c index e8f38ab13..8079994c1 100644 --- a/server/core/dbusers.c +++ b/server/core/dbusers.c @@ -2387,7 +2387,6 @@ bool check_service_permissions(SERVICE* service) 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)); - rval = false; } else { @@ -2395,6 +2394,7 @@ bool check_service_permissions(SERVICE* service) " MySQL error message: %s", service->name,mysql_error(mysql)); } + rval = false; } else { @@ -2405,7 +2405,7 @@ bool check_service_permissions(SERVICE* service) service->name,mysql_error(mysql)); mysql_close(mysql); free(dpasswd); - return rval; + return false; } mysql_free_result(res); @@ -2416,13 +2416,13 @@ bool check_service_permissions(SERVICE* service) { 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)); - rval = false; } else { skygw_log_write(LE,"%s: Error: Failed to query from mysql.db table. MySQL error message: %s", service->name,mysql_error(mysql)); } + rval = false; } else { @@ -2430,6 +2430,7 @@ bool check_service_permissions(SERVICE* service) { skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for permissions to the mysql.db table: %s", service->name,mysql_error(mysql)); + rval = false; } else { diff --git a/server/core/monitor.c b/server/core/monitor.c index 52d4c5f28..ef782ed47 100644 --- a/server/core/monitor.c +++ b/server/core/monitor.c @@ -493,7 +493,7 @@ bool check_monitor_permissions(MONITOR* monitor) server->port); mysql_close(mysql); free(dpasswd); - return true; + return false; } if(mysql_query(mysql,"show slave status") != 0) @@ -502,13 +502,13 @@ bool check_monitor_permissions(MONITOR* monitor) { skygw_log_write(LE,"%s: Error: User '%s' is missing REPLICATION CLIENT privileges. MySQL error message: %s", monitor->name,user,mysql_error(mysql)); - rval = false; } else { skygw_log_write(LE,"%s: Error: Monitor failed to query for slave status. MySQL error message: %s", monitor->name,mysql_error(mysql)); } + rval = false; } else { @@ -516,11 +516,12 @@ bool check_monitor_permissions(MONITOR* monitor) { skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for REPLICATION CLIENT permissions: %s", monitor->name,mysql_error(mysql)); - free(dpasswd); - mysql_close(mysql); - return rval; + rval = false; + } + else + { + mysql_free_result(res); } - mysql_free_result(res); } mysql_close(mysql); free(dpasswd); diff --git a/server/include/maxconfig.h b/server/include/maxconfig.h index 58d9a7ac5..5052d50c9 100644 --- a/server/include/maxconfig.h +++ b/server/include/maxconfig.h @@ -146,5 +146,5 @@ void config_enable_feedback_task(void); void config_disable_feedback_task(void); unsigned long config_get_gateway_id(void); GATEWAY_CONF* config_get_global_options(); -int isInternalService(char *router); +bool isInternalService(char *router); #endif