Added optional stripping of escape characters from database names when laoding users.
This commit is contained in:
@ -279,6 +279,7 @@ int error_count = 0;
|
||||
char *auth;
|
||||
char *enable_root_user;
|
||||
char *auth_all_servers;
|
||||
char *strip_db_esc;
|
||||
char *weightby;
|
||||
char *version_string;
|
||||
bool is_rwsplit = false;
|
||||
@ -294,6 +295,9 @@ int error_count = 0;
|
||||
auth_all_servers = config_get_value(
|
||||
obj->parameters,
|
||||
"auth_all_servers");
|
||||
strip_db_esc = config_get_value(
|
||||
obj->parameters,
|
||||
"strip_db_esc");
|
||||
allow_localhost_match_wildcard_host =
|
||||
config_get_value(obj->parameters,
|
||||
"localhost_match_wildcard_host");
|
||||
@ -359,6 +363,9 @@ int error_count = 0;
|
||||
if(auth_all_servers)
|
||||
serviceAuthAllServers(obj->element,
|
||||
config_truth_value(auth_all_servers));
|
||||
if(strip_db_esc)
|
||||
serviceStripDbEsc(obj->element,
|
||||
config_truth_value(strip_db_esc));
|
||||
if (weightby)
|
||||
serviceWeightBy(obj->element, weightby);
|
||||
|
||||
@ -1359,6 +1366,7 @@ SERVER *server;
|
||||
char *auth;
|
||||
char *enable_root_user;
|
||||
char* auth_all_servers;
|
||||
char* strip_db_esc;
|
||||
char* max_slave_conn_str;
|
||||
char* max_slave_rlag_str;
|
||||
char *version_string;
|
||||
@ -1372,7 +1380,7 @@ SERVER *server;
|
||||
"passwd");
|
||||
|
||||
auth_all_servers = config_get_value(obj->parameters, "auth_all_servers");
|
||||
|
||||
strip_db_esc = config_get_value(obj->parameters, "strip_db_esc");
|
||||
version_string = config_get_value(obj->parameters, "version_string");
|
||||
|
||||
allow_localhost_match_wildcard_host =
|
||||
@ -1396,6 +1404,8 @@ SERVER *server;
|
||||
serviceEnableRootUser(service, atoi(enable_root_user));
|
||||
if(auth_all_servers)
|
||||
serviceAuthAllServers(service, atoi(auth_all_servers));
|
||||
if(strip_db_esc)
|
||||
serviceStripDbEsc(service, atoi(strip_db_esc));
|
||||
if (allow_localhost_match_wildcard_host)
|
||||
serviceEnableLocalhostMatchWildcardHost(
|
||||
service,
|
||||
@ -1505,10 +1515,17 @@ SERVER *server;
|
||||
char *enable_root_user;
|
||||
char *allow_localhost_match_wildcard_host;
|
||||
char *auth_all_servers;
|
||||
|
||||
char *strip_db_esc;
|
||||
enable_root_user =
|
||||
config_get_value(obj->parameters,
|
||||
"enable_root_user");
|
||||
|
||||
auth_all_servers =
|
||||
config_get_value(obj->parameters,
|
||||
"auth_all_servers");
|
||||
strip_db_esc =
|
||||
config_get_value(obj->parameters,
|
||||
"strip_db_esc");
|
||||
allow_localhost_match_wildcard_host =
|
||||
config_get_value(obj->parameters,
|
||||
"localhost_match_wildcard_host");
|
||||
@ -1530,6 +1547,8 @@ SERVER *server;
|
||||
atoi(enable_root_user));
|
||||
if(auth_all_servers)
|
||||
serviceAuthAllServers(obj->element, atoi(auth_all_servers));
|
||||
if(strip_db_esc)
|
||||
serviceStripDbEsc(obj->element, atoi(strip_db_esc));
|
||||
|
||||
if (allow_localhost_match_wildcard_host)
|
||||
serviceEnableLocalhostMatchWildcardHost(
|
||||
@ -1755,6 +1774,7 @@ static char *service_params[] =
|
||||
"passwd",
|
||||
"enable_root_user",
|
||||
"auth_all_servers",
|
||||
"strip_db_esc",
|
||||
"localhost_match_wildcard_host",
|
||||
"max_slave_connections",
|
||||
"max_slave_replication_lag",
|
||||
|
@ -274,7 +274,7 @@ int add_mysql_users_with_host_ipv4(USERS *users, char *user, char *host, char *p
|
||||
} else {
|
||||
if (strcmp(anydb, "N") == 0) {
|
||||
if (db != NULL)
|
||||
key.resource = strdup(db);
|
||||
key.resource = strdup(db);
|
||||
else
|
||||
key.resource = NULL;
|
||||
} else {
|
||||
@ -428,7 +428,7 @@ getDatabases(SERVICE *service, MYSQL *con)
|
||||
/* insert key and value "" */
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
skygw_log_write(LOGFILE_DEBUG,"%s: Adding database %s to the resouce hash.",service->name,row[0]);
|
||||
resource_add(service->resources, row[0], "");
|
||||
resource_add(service->resources, row[0], "");
|
||||
}
|
||||
|
||||
mysql_free_result(result);
|
||||
@ -460,6 +460,7 @@ getUsers(SERVICE *service, USERS *users)
|
||||
unsigned char hash[SHA_DIGEST_LENGTH]="";
|
||||
char *users_data = NULL;
|
||||
char *final_data = NULL;
|
||||
char dbnm[MYSQL_DATABASE_MAXLEN+1];
|
||||
int nusers = -1;
|
||||
int users_data_row_len = MYSQL_USER_MAXLEN +
|
||||
MYSQL_HOST_MAXLEN +
|
||||
@ -796,8 +797,17 @@ getUsers(SERVICE *service, USERS *users)
|
||||
|
||||
if (db_grants) {
|
||||
/* we have dbgrants, store them */
|
||||
rc = add_mysql_users_with_host_ipv4(users, row[0], row[1], password, row[4], row[5]);
|
||||
skygw_log_write(LOGFILE_DEBUG,"%s: Adding user:%s host:%s anydb:%s db:%s.",service->name,row[0],row[1],row[4],row[5]);
|
||||
if(row[5]){
|
||||
strcpy(dbnm,row[5]);
|
||||
if(service->strip_db_esc) {
|
||||
strip_escape_chars(dbnm);
|
||||
}
|
||||
}
|
||||
else {
|
||||
*dbnm = 0;
|
||||
}
|
||||
rc = add_mysql_users_with_host_ipv4(users, row[0], row[1], password, row[4], dbnm);
|
||||
skygw_log_write(LOGFILE_DEBUG,"%s: Adding user:%s host:%s anydb:%s db:%s.",service->name,row[0],row[1],row[4],dbnm);
|
||||
} else {
|
||||
/* we don't have dbgrants, simply set ANY DB for the user */
|
||||
rc = add_mysql_users_with_host_ipv4(users, row[0], row[1], password, "Y", NULL);
|
||||
|
@ -822,6 +822,23 @@ serviceAuthAllServers(SERVICE *service, int action)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to strip escape characters from the name of the database the client
|
||||
* is connecting to.
|
||||
* @param service Service to configure
|
||||
* @param action 0 for disabled, 1 for enabled
|
||||
* @return 1 if successful, 0 on error
|
||||
*/
|
||||
int serviceStripDbEsc(SERVICE* service, int action)
|
||||
{
|
||||
if (action != 0 && action != 1)
|
||||
return 0;
|
||||
|
||||
service->strip_db_esc = action;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim whitespace from the from an rear of a string
|
||||
*
|
||||
|
Reference in New Issue
Block a user