| 9368 | |
| 9369 | |
| 9370 | int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, Item *cond) |
| 9371 | { |
| 9372 | #ifndef NO_EMBEDDED_ACCESS_CHECKS |
| 9373 | int error= 0; |
| 9374 | uint index; |
| 9375 | char buff[100]; |
| 9376 | TABLE *table= tables->table; |
| 9377 | bool no_global_access= check_access(thd, SELECT_ACL, "mysql", |
| 9378 | NULL, NULL, 1, 1); |
| 9379 | char *curr_host= thd->security_ctx->priv_host_name(); |
| 9380 | DBUG_ENTER("fill_schema_table_privileges"); |
| 9381 | |
| 9382 | mysql_rwlock_rdlock(&LOCK_grant); |
| 9383 | |
| 9384 | for (index=0 ; index < column_priv_hash.records ; index++) |
| 9385 | { |
| 9386 | const char *user, *host, *is_grantable= "YES"; |
| 9387 | GRANT_TABLE *grant_table= (GRANT_TABLE*) my_hash_element(&column_priv_hash, |
| 9388 | index); |
| 9389 | if (!(user=grant_table->user)) |
| 9390 | user= ""; |
| 9391 | if (!(host= grant_table->host.get_host())) |
| 9392 | host= ""; |
| 9393 | |
| 9394 | if (no_global_access && |
| 9395 | (strcmp(thd->security_ctx->priv_user, user) || |
| 9396 | my_strcasecmp(system_charset_info, curr_host, host))) |
| 9397 | continue; |
| 9398 | |
| 9399 | ulong table_access= grant_table->cols; |
| 9400 | if (table_access != 0) |
| 9401 | { |
| 9402 | if (!(grant_table->privs & GRANT_ACL)) |
| 9403 | is_grantable= "NO"; |
| 9404 | |
| 9405 | ulong test_access= table_access & ~GRANT_ACL; |
| 9406 | strxmov(buff, "'", user, "'@'", host, "'", NullS); |
| 9407 | if (!test_access) |
| 9408 | continue; |
| 9409 | else |
| 9410 | { |
| 9411 | ulong j; |
| 9412 | int cnt; |
| 9413 | for (cnt= 0, j= SELECT_ACL; j <= TABLE_ACLS; cnt++, j<<= 1) |
| 9414 | { |
| 9415 | if (test_access & j) |
| 9416 | { |
| 9417 | for (uint col_index=0 ; |
| 9418 | col_index < grant_table->hash_columns.records ; |
| 9419 | col_index++) |
| 9420 | { |
| 9421 | GRANT_COLUMN *grant_column = (GRANT_COLUMN*) |
| 9422 | my_hash_element(&grant_table->hash_columns,col_index); |
| 9423 | if ((grant_column->rights & j) && (table_access & j)) |
| 9424 | { |
| 9425 | if (update_schema_privilege(thd, table, buff, grant_table->db, |
| 9426 | grant_table->tname, |
| 9427 | grant_column->column, |
nothing calls this directly
no test coverage detected