| 6382 | ****************************************************************************/ |
| 6383 | |
| 6384 | bool check_grant_routine(THD *thd, ulong want_access, |
| 6385 | TABLE_LIST *procs, bool is_proc, bool no_errors) |
| 6386 | { |
| 6387 | TABLE_LIST *table; |
| 6388 | Security_context *sctx= thd->security_ctx; |
| 6389 | char *user= sctx->priv_user; |
| 6390 | char *host= sctx->priv_host; |
| 6391 | DBUG_ENTER("check_grant_routine"); |
| 6392 | |
| 6393 | want_access&= ~sctx->master_access; |
| 6394 | if (!want_access) |
| 6395 | DBUG_RETURN(0); // ok |
| 6396 | |
| 6397 | mysql_rwlock_rdlock(&LOCK_grant); |
| 6398 | for (table= procs; table; table= table->next_global) |
| 6399 | { |
| 6400 | GRANT_NAME *grant_proc; |
| 6401 | if ((grant_proc= routine_hash_search(host, sctx->get_ip()->ptr(), table->db, |
| 6402 | user, table->table_name, is_proc, 0))) |
| 6403 | table->grant.privilege|= grant_proc->privs; |
| 6404 | |
| 6405 | if (want_access & ~table->grant.privilege) |
| 6406 | { |
| 6407 | want_access &= ~table->grant.privilege; |
| 6408 | goto err; |
| 6409 | } |
| 6410 | } |
| 6411 | mysql_rwlock_unlock(&LOCK_grant); |
| 6412 | DBUG_RETURN(0); |
| 6413 | err: |
| 6414 | mysql_rwlock_unlock(&LOCK_grant); |
| 6415 | if (!no_errors) |
| 6416 | { |
| 6417 | char buff[1024]; |
| 6418 | const char *command=""; |
| 6419 | if (table) |
| 6420 | strxmov(buff, table->db, ".", table->table_name, NullS); |
| 6421 | if (want_access & EXECUTE_ACL) |
| 6422 | command= "execute"; |
| 6423 | else if (want_access & ALTER_PROC_ACL) |
| 6424 | command= "alter routine"; |
| 6425 | else if (want_access & GRANT_ACL) |
| 6426 | command= "grant"; |
| 6427 | my_error(ER_PROCACCESS_DENIED_ERROR, MYF(0), |
| 6428 | command, user, host, table ? buff : "unknown"); |
| 6429 | } |
| 6430 | DBUG_RETURN(1); |
| 6431 | } |
| 6432 | |
| 6433 | |
| 6434 | /* |
nothing calls this directly
no test coverage detected