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

Function fill_schema_table_privileges

phx_percona/percona/sql/sql_acl.cc:9286–9367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9284
9285
9286int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, Item *cond)
9287{
9288#ifndef NO_EMBEDDED_ACCESS_CHECKS
9289 int error= 0;
9290 uint index;
9291 char buff[100];
9292 TABLE *table= tables->table;
9293 bool no_global_access= check_access(thd, SELECT_ACL, "mysql",
9294 NULL, NULL, 1, 1);
9295 char *curr_host= thd->security_ctx->priv_host_name();
9296 DBUG_ENTER("fill_schema_table_privileges");
9297
9298 mysql_rwlock_rdlock(&LOCK_grant);
9299
9300 for (index=0 ; index < column_priv_hash.records ; index++)
9301 {
9302 const char *user, *host, *is_grantable= "YES";
9303 GRANT_TABLE *grant_table= (GRANT_TABLE*) my_hash_element(&column_priv_hash,
9304 index);
9305 if (!(user=grant_table->user))
9306 user= "";
9307 if (!(host= grant_table->host.get_host()))
9308 host= "";
9309
9310 if (no_global_access &&
9311 (strcmp(thd->security_ctx->priv_user, user) ||
9312 my_strcasecmp(system_charset_info, curr_host, host)))
9313 continue;
9314
9315 ulong table_access= grant_table->privs;
9316 if (table_access)
9317 {
9318 ulong test_access= table_access & ~GRANT_ACL;
9319 /*
9320 We should skip 'usage' privilege on table if
9321 we have any privileges on column(s) of this table
9322 */
9323 if (!test_access && grant_table->cols)
9324 continue;
9325 if (!(table_access & GRANT_ACL))
9326 is_grantable= "NO";
9327
9328 strxmov(buff, "'", user, "'@'", host, "'", NullS);
9329 if (!test_access)
9330 {
9331 if (update_schema_privilege(thd, table, buff, grant_table->db,
9332 grant_table->tname, 0, 0,
9333 STRING_WITH_LEN("USAGE"), is_grantable))
9334 {
9335 error= 1;
9336 goto err;
9337 }
9338 }
9339 else
9340 {
9341 ulong j;
9342 int cnt;
9343 for (cnt= 0, j= SELECT_ACL; j <= TABLE_ACLS; cnt++, j<<= 1)

Callers

nothing calls this directly

Calls 2

update_schema_privilegeFunction · 0.85
get_hostMethod · 0.80

Tested by

no test coverage detected