Commit bcd1520a authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

cleanup: check_grant_db doesn't need THD as parameter, only Security_ctx

parent d6370cb5
......@@ -3347,7 +3347,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table)
&thd->col_access, NULL, FALSE, FALSE))
return TRUE;
if (!thd->col_access && check_grant_db(thd, dst_db_name))
if (!thd->col_access && check_grant_db(thd->security_ctx, dst_db_name))
{
status_var_increment(thd->status_var.access_denied_errors);
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
......@@ -9561,10 +9561,8 @@ bool check_grant_all_columns(THD *thd, privilege_t want_access_arg,
}
static bool check_grant_db_routine(THD *thd, const char *db, HASH *hash)
static bool check_grant_db_routine(Security_context *sctx, const char *db, HASH *hash)
{
Security_context *sctx= thd->security_ctx;
for (uint idx= 0; idx < hash->records; ++idx)
{
GRANT_NAME *item= (GRANT_NAME*) my_hash_element(hash, idx);
......@@ -9593,9 +9591,8 @@ static bool check_grant_db_routine(THD *thd, const char *db, HASH *hash)
Return 1 if access is denied
*/
bool check_grant_db(THD *thd, const char *db)
bool check_grant_db(Security_context *sctx, const char *db)
{
Security_context *sctx= thd->security_ctx;
char helping [SAFE_NAME_LEN + USERNAME_LENGTH+2], *end;
char helping2 [SAFE_NAME_LEN + USERNAME_LENGTH+2], *tmp_db;
uint len, UNINIT_VAR(len2);
......@@ -9650,10 +9647,10 @@ bool check_grant_db(THD *thd, const char *db)
}
if (error)
error= check_grant_db_routine(thd, db, &proc_priv_hash) &&
check_grant_db_routine(thd, db, &func_priv_hash) &&
check_grant_db_routine(thd, db, &package_spec_priv_hash) &&
check_grant_db_routine(thd, db, &package_body_priv_hash);
error= check_grant_db_routine(sctx, db, &proc_priv_hash) &&
check_grant_db_routine(sctx, db, &func_priv_hash) &&
check_grant_db_routine(sctx, db, &package_spec_priv_hash) &&
check_grant_db_routine(sctx, db, &package_body_priv_hash);
mysql_rwlock_unlock(&LOCK_grant);
......
......@@ -100,7 +100,7 @@ bool check_column_grant_in_table_ref(THD *thd, TABLE_LIST * table_ref,
const char *name, size_t length, Field *fld);
bool check_grant_all_columns(THD *thd, privilege_t want_access,
Field_iterator_table_ref *fields);
bool check_grant_db(THD *thd,const char *db);
bool check_grant_db(Security_context *sctx, const char *db);
bool check_fk_parent_table_access(THD *thd,
HA_CREATE_INFO *create_info,
Alter_info *alter_info,
......
......@@ -1789,7 +1789,7 @@ uint mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name,
if (!force_switch &&
!(db_access & DB_ACLS) &&
check_grant_db(thd, new_db_file_name.str))
check_grant_db(thd->security_ctx, new_db_file_name.str))
{
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
sctx->priv_user,
......
......@@ -1409,7 +1409,7 @@ bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname,
db_access= acl_get_all3(sctx, dbname->str, FALSE) |
sctx->master_access;
if (!(db_access & DB_ACLS) && check_grant_db(thd,dbname->str))
if (!(db_access & DB_ACLS) && check_grant_db(sctx, dbname->str))
{
status_var_increment(thd->status_var.access_denied_errors);
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
......@@ -5314,7 +5314,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!(check_access(thd, SELECT_ACL, db_name->str,
&thd->col_access, NULL, 0, 1) ||
(!thd->col_access && check_grant_db(thd, db_name->str))) ||
(!thd->col_access && check_grant_db(sctx, db_name->str))) ||
sctx->master_access & (DB_ACLS | SHOW_DB_ACL) ||
acl_get_all3(sctx, db_name->str, false))
#endif
......@@ -5517,7 +5517,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (sctx->master_access & (DB_ACLS | SHOW_DB_ACL) ||
acl_get_all3(sctx, db_name->str, false) ||
!check_grant_db(thd, db_name->str))
!check_grant_db(sctx, db_name->str))
#endif
{
load_db_opt_by_name(thd, db_name->str, &create);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment