MCPcopy Create free account
hub / github.com/MariaDB/server / update_role_mapping

Function update_role_mapping

sql/sql_acl.cc:5357–5383  ·  view source on GitHub ↗

Updates the acl_roles_mappings hash @param user user name of the grantee @param host host name of the grantee @param role role name to grant @param with_admin WITH ADMIN OPTION flag @param existing the entry in the acl_roles_mappings hash or NULL. it is never NULL if revoke_grant is true. it is NULL

Source from the content-addressed store, hash-verified

5355 @param revoke_grant true for REVOKE, false for GRANT
5356*/
5357static int
5358update_role_mapping(LEX_CSTRING *user, LEX_CSTRING *host, LEX_CSTRING *role,
5359 bool with_admin, ROLE_GRANT_PAIR *existing, bool revoke_grant)
5360{
5361 if (revoke_grant)
5362 {
5363 if (with_admin)
5364 {
5365 existing->with_admin= false;
5366 return 0;
5367 }
5368 return my_hash_delete(&acl_roles_mappings, (uchar*)existing);
5369 }
5370
5371 if (existing)
5372 {
5373 existing->with_admin|= with_admin;
5374 return 0;
5375 }
5376
5377 mysql_mutex_assert_owner(&acl_cache->lock);
5378 /* allocate a new entry that will go in the hash */
5379 ROLE_GRANT_PAIR *hash_entry= new (&acl_memroot) ROLE_GRANT_PAIR;
5380 if (hash_entry->init(&acl_memroot, *user, *host, *role, with_admin))
5381 return 1;
5382 return my_hash_insert(&acl_roles_mappings, (uchar*) hash_entry);
5383}
5384
5385static void
5386acl_update_proxy_user(ACL_PROXY_USER *new_value, bool is_revoke)

Callers 3

mysql_grant_roleFunction · 0.85
mysql_create_userFunction · 0.85
mysql_revoke_allFunction · 0.85

Calls 3

my_hash_deleteFunction · 0.85
my_hash_insertFunction · 0.85
initMethod · 0.45

Tested by

no test coverage detected