MCPcopy Create free account
hub / github.com/Tencent/phxsql / fill_effective_table_privileges

Function fill_effective_table_privileges

phx_percona/percona/sql/sql_acl.cc:9464–9508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9462*/
9463
9464void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
9465 const char *db, const char *table)
9466{
9467 Security_context *sctx= thd->security_ctx;
9468 DBUG_ENTER("fill_effective_table_privileges");
9469 DBUG_PRINT("enter", ("Host: '%s', Ip: '%s', User: '%s', table: `%s`.`%s`",
9470 sctx->priv_host, (sctx->get_ip()->length() ?
9471 sctx->get_ip()->ptr() : "(NULL)"),
9472 sctx->priv_user,
9473 db, table));
9474 /* --skip-grants */
9475 if (!initialized)
9476 {
9477 DBUG_PRINT("info", ("skip grants"));
9478 grant->privilege= ~NO_ACCESS; // everything is allowed
9479 DBUG_PRINT("info", ("privilege 0x%lx", grant->privilege));
9480 DBUG_VOID_RETURN;
9481 }
9482
9483 /* global privileges */
9484 grant->privilege= sctx->master_access;
9485
9486 /* db privileges */
9487 grant->privilege|= acl_get(sctx->get_host()->ptr(), sctx->get_ip()->ptr(),
9488 sctx->priv_user, db, 0);
9489
9490 /* table privileges */
9491 mysql_rwlock_rdlock(&LOCK_grant);
9492 if (grant->version != grant_version)
9493 {
9494 grant->grant_table=
9495 table_hash_search(sctx->get_host()->ptr(), sctx->get_ip()->ptr(), db,
9496 sctx->priv_user,
9497 table, 0); /* purecov: inspected */
9498 grant->version= grant_version; /* purecov: inspected */
9499 }
9500 if (grant->grant_table != 0)
9501 {
9502 grant->privilege|= grant->grant_table->privs;
9503 }
9504 mysql_rwlock_unlock(&LOCK_grant);
9505
9506 DBUG_PRINT("info", ("privilege 0x%lx", grant->privilege));
9507 DBUG_VOID_RETURN;
9508}
9509
9510#else /* NO_EMBEDDED_ACCESS_CHECKS */
9511

Callers

nothing calls this directly

Calls 3

acl_getFunction · 0.85
table_hash_searchFunction · 0.85
get_hostMethod · 0.80

Tested by

no test coverage detected