| 9206 | |
| 9207 | |
| 9208 | int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, Item *cond) |
| 9209 | { |
| 9210 | #ifndef NO_EMBEDDED_ACCESS_CHECKS |
| 9211 | int error= 0; |
| 9212 | uint counter; |
| 9213 | ACL_DB *acl_db; |
| 9214 | ulong want_access; |
| 9215 | char buff[100]; |
| 9216 | TABLE *table= tables->table; |
| 9217 | bool no_global_access= check_access(thd, SELECT_ACL, "mysql", |
| 9218 | NULL, NULL, 1, 1); |
| 9219 | char *curr_host= thd->security_ctx->priv_host_name(); |
| 9220 | DBUG_ENTER("fill_schema_schema_privileges"); |
| 9221 | |
| 9222 | if (!initialized) |
| 9223 | DBUG_RETURN(0); |
| 9224 | mysql_mutex_lock(&acl_cache->lock); |
| 9225 | |
| 9226 | for (counter=0 ; counter < acl_dbs.elements ; counter++) |
| 9227 | { |
| 9228 | const char *user, *host, *is_grantable="YES"; |
| 9229 | |
| 9230 | acl_db=dynamic_element(&acl_dbs,counter,ACL_DB*); |
| 9231 | if (!(user=acl_db->user)) |
| 9232 | user= ""; |
| 9233 | if (!(host=acl_db->host.get_host())) |
| 9234 | host= ""; |
| 9235 | |
| 9236 | if (no_global_access && |
| 9237 | (strcmp(thd->security_ctx->priv_user, user) || |
| 9238 | my_strcasecmp(system_charset_info, curr_host, host))) |
| 9239 | continue; |
| 9240 | |
| 9241 | want_access=acl_db->access; |
| 9242 | if (want_access) |
| 9243 | { |
| 9244 | if (!(want_access & GRANT_ACL)) |
| 9245 | { |
| 9246 | is_grantable= "NO"; |
| 9247 | } |
| 9248 | strxmov(buff,"'",user,"'@'",host,"'",NullS); |
| 9249 | if (!(want_access & ~GRANT_ACL)) |
| 9250 | { |
| 9251 | if (update_schema_privilege(thd, table, buff, acl_db->db, 0, 0, |
| 9252 | 0, STRING_WITH_LEN("USAGE"), is_grantable)) |
| 9253 | { |
| 9254 | error= 1; |
| 9255 | goto err; |
| 9256 | } |
| 9257 | } |
| 9258 | else |
| 9259 | { |
| 9260 | int cnt; |
| 9261 | ulong j,test_access= want_access & ~GRANT_ACL; |
| 9262 | for (cnt=0, j = SELECT_ACL; j <= DB_ACLS; cnt++,j <<= 1) |
| 9263 | if (test_access & j) |
| 9264 | { |
| 9265 | if (update_schema_privilege(thd, table, buff, acl_db->db, 0, 0, 0, |
nothing calls this directly
no test coverage detected