mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Added implementation for DYNAMIC_ARRAY in ACL_USER
TODO: Memory allocated for the array is never freed
This commit is contained in:
committed by
Sergei Golubchik
parent
69a3deb58e
commit
9e7228dc4a
@@ -230,6 +230,7 @@ public:
|
|||||||
if the instance of the class represents a user, or a user if the
|
if the instance of the class represents a user, or a user if the
|
||||||
instance of the class represents a role.
|
instance of the class represents a role.
|
||||||
*/
|
*/
|
||||||
|
//TODO this array does not get freed automatically when acl_users is freed
|
||||||
DYNAMIC_ARRAY role_grants;
|
DYNAMIC_ARRAY role_grants;
|
||||||
|
|
||||||
ACL_USER *copy(MEM_ROOT *root)
|
ACL_USER *copy(MEM_ROOT *root)
|
||||||
@@ -597,10 +598,8 @@ enum enum_acl_lists
|
|||||||
|
|
||||||
typedef struct st_role_grant
|
typedef struct st_role_grant
|
||||||
{
|
{
|
||||||
char *user_username;
|
char *username;
|
||||||
char *user_hostname;
|
char *hostname;
|
||||||
char *role_username;
|
|
||||||
char *role_hostname;
|
|
||||||
} ROLE_GRANT_PAIR;
|
} ROLE_GRANT_PAIR;
|
||||||
/*
|
/*
|
||||||
Convert scrambled password to binary form, according to scramble type,
|
Convert scrambled password to binary form, according to scramble type,
|
||||||
@@ -1054,6 +1053,10 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
|
|||||||
user.access|= SUPER_ACL | EXECUTE_ACL;
|
user.access|= SUPER_ACL | EXECUTE_ACL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void) my_init_dynamic_array(&user.role_grants,sizeof(ROLE_GRANT_PAIR),
|
||||||
|
50, 100, MYF(0));
|
||||||
|
|
||||||
if (is_role) {
|
if (is_role) {
|
||||||
sql_print_information("Found role %s", user.user.str);
|
sql_print_information("Found role %s", user.user.str);
|
||||||
my_hash_insert(&acl_roles, (uchar*) user.copy(&mem));
|
my_hash_insert(&acl_roles, (uchar*) user.copy(&mem));
|
||||||
@@ -1188,32 +1191,31 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
|
|||||||
if (!initialized)
|
if (!initialized)
|
||||||
mysql_mutex_lock(&acl_cache->lock);
|
mysql_mutex_lock(&acl_cache->lock);
|
||||||
|
|
||||||
/* (void) my_init_dynamic_array(&role_grants,sizeof(ROLE_GRANT_PAIR), 50, 100,
|
|
||||||
MYF(0));
|
|
||||||
*/
|
|
||||||
while (!(read_record_info.read_record(&read_record_info)))
|
while (!(read_record_info.read_record(&read_record_info)))
|
||||||
{
|
{
|
||||||
ROLE_GRANT_PAIR p;
|
ROLE_GRANT_PAIR role_ref;
|
||||||
p.user_hostname= get_field(&mem, table->field[0]);
|
ROLE_GRANT_PAIR user_ref;
|
||||||
p.user_username= get_field(&mem, table->field[1]);
|
user_ref.hostname= get_field(&mem, table->field[0]);
|
||||||
p.role_hostname= get_field(&mem, table->field[2]);
|
user_ref.username= get_field(&mem, table->field[1]);
|
||||||
p.role_username= get_field(&mem, table->field[3]);
|
role_ref.hostname= get_field(&mem, table->field[2]);
|
||||||
ACL_USER *user= find_acl_user((p.user_hostname) ? p.user_hostname: "",
|
role_ref.username= get_field(&mem, table->field[3]);
|
||||||
(p.user_username) ? p.user_username: "",
|
ACL_USER *user= find_acl_user((user_ref.hostname) ? user_ref.hostname: "",
|
||||||
|
(user_ref.username) ? user_ref.username: "",
|
||||||
TRUE);
|
TRUE);
|
||||||
ACL_USER *role= find_acl_role(p.role_username ? p.role_username: "");
|
ACL_USER *role= find_acl_role(role_ref.username ? role_ref.username: "");
|
||||||
if (user == NULL || role == NULL)
|
if (user == NULL || role == NULL)
|
||||||
{
|
{
|
||||||
sql_print_error("Invalid roles_mapping table entry '%s@%s', '%s@%s'",
|
sql_print_error("Invalid roles_mapping table entry '%s@%s', '%s@%s'",
|
||||||
p.user_username ? p.user_username : "",
|
user_ref.username ? user_ref.username : "",
|
||||||
p.user_hostname ? p.user_hostname : "",
|
user_ref.hostname ? user_ref.hostname : "",
|
||||||
p.role_username ? p.role_username : "",
|
role_ref.username ? role_ref.username : "",
|
||||||
p.role_hostname ? p.role_hostname : "",
|
role_ref.hostname ? role_ref.hostname : "",
|
||||||
user, role);
|
user, role);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// push_dynamic(&role_grants, (uchar*) &p);
|
push_dynamic(&user->role_grants, (uchar*) &role_ref);
|
||||||
|
push_dynamic(&role->role_grants, (uchar*) &user_ref);
|
||||||
sql_print_information("Found user %s@%s having role granted %s@%s\n",
|
sql_print_information("Found user %s@%s having role granted %s@%s\n",
|
||||||
user->user.str, user->host.hostname,
|
user->user.str, user->host.hostname,
|
||||||
role->user.str, role->host.hostname);
|
role->user.str, role->host.hostname);
|
||||||
|
Reference in New Issue
Block a user