mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
merged
This commit is contained in:
@ -121,7 +121,7 @@ create database mysqltest;
|
|||||||
create table mysqltest.t1 (a int,b int,c int);
|
create table mysqltest.t1 (a int,b int,c int);
|
||||||
grant all on mysqltest.t1 to mysqltest_1@localhost;
|
grant all on mysqltest.t1 to mysqltest_1@localhost;
|
||||||
alter table t1 rename t2;
|
alter table t1 rename t2;
|
||||||
ERROR 42000: insert command denied to user 'mysqltest_1'@'localhost' for table 't2'
|
ERROR 42000: INSERT,CREATE command denied to user: 'mysqltest_1@localhost' for table 't2'
|
||||||
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
|
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
|
||||||
delete from mysql.user where user=_binary'mysqltest_1';
|
delete from mysql.user where user=_binary'mysqltest_1';
|
||||||
drop database mysqltest;
|
drop database mysqltest;
|
||||||
|
@ -134,7 +134,7 @@ a b c a
|
|||||||
1 1 1 test.t1
|
1 1 1 test.t1
|
||||||
2 2 2 test.t1
|
2 2 2 test.t1
|
||||||
select * from t2;
|
select * from t2;
|
||||||
ERROR 42000: select command denied to user 'mysqltest_2'@'localhost' for table 't2'
|
ERROR 42000: SELECT command denied to user: 'mysqltest_2@localhost' for table 't2'
|
||||||
show status like "Qcache_queries_in_cache";
|
show status like "Qcache_queries_in_cache";
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Qcache_queries_in_cache 6
|
Qcache_queries_in_cache 6
|
||||||
@ -148,7 +148,7 @@ select "user3";
|
|||||||
user3
|
user3
|
||||||
user3
|
user3
|
||||||
select * from t1;
|
select * from t1;
|
||||||
ERROR 42000: select command denied to user 'mysqltest_3'@'localhost' for column 'b' in table 't1'
|
ERROR 42000: SELECT command denied to user: 'mysqltest_3@localhost' for column 'b' in table 't1'
|
||||||
select a from t1;
|
select a from t1;
|
||||||
a
|
a
|
||||||
1
|
1
|
||||||
@ -156,7 +156,7 @@ a
|
|||||||
select c from t1;
|
select c from t1;
|
||||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'
|
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'
|
||||||
select * from t2;
|
select * from t2;
|
||||||
ERROR 42000: select command denied to user 'mysqltest_3'@'localhost' for table 't2'
|
ERROR 42000: SELECT command denied to user: 'mysqltest_3@localhost' for table 't2'
|
||||||
select mysqltest.t1.c from test.t1,mysqltest.t1;
|
select mysqltest.t1.c from test.t1,mysqltest.t1;
|
||||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'
|
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'
|
||||||
show status like "Qcache_queries_in_cache";
|
show status like "Qcache_queries_in_cache";
|
||||||
|
101
sql/sql_acl.cc
101
sql/sql_acl.cc
@ -2256,39 +2256,58 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
|
|||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columns.elements && !revoke_grant)
|
if (!revoke_grant)
|
||||||
{
|
{
|
||||||
TABLE *table;
|
if (columns.elements && !revoke_grant)
|
||||||
class LEX_COLUMN *column;
|
{
|
||||||
List_iterator <LEX_COLUMN> column_iter(columns);
|
TABLE *table;
|
||||||
|
class LEX_COLUMN *column;
|
||||||
|
List_iterator <LEX_COLUMN> column_iter(columns);
|
||||||
|
|
||||||
if (!(table=open_ltable(thd,table_list,TL_READ)))
|
if (!(table=open_ltable(thd,table_list,TL_READ)))
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
while ((column = column_iter++))
|
while ((column = column_iter++))
|
||||||
{
|
|
||||||
uint unused_field_idx= NO_CACHED_FIELD_INDEX;
|
|
||||||
if (!find_field_in_table(thd,table,column->column.ptr(),
|
|
||||||
column->column.length(),0,0,
|
|
||||||
&unused_field_idx))
|
|
||||||
{
|
{
|
||||||
my_error(ER_BAD_FIELD_ERROR, MYF(0),
|
uint unused_field_idx= NO_CACHED_FIELD_INDEX;
|
||||||
column->column.c_ptr(), table_list->alias);
|
Field *f= find_field_in_table(thd,table,column->column.ptr(),
|
||||||
DBUG_RETURN(-1);
|
column->column.length(),1,0,&unused_field_idx);
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
my_error(ER_BAD_FIELD_ERROR, MYF(0),
|
||||||
|
column->column.c_ptr(), table_list->alias);
|
||||||
|
DBUG_RETURN(-1);
|
||||||
|
}
|
||||||
|
if (f == (Field*)-1)
|
||||||
|
{
|
||||||
|
DBUG_RETURN(-1);
|
||||||
|
}
|
||||||
|
column_priv|= column->rights;
|
||||||
}
|
}
|
||||||
column_priv|= column->rights;
|
close_thread_tables(thd);
|
||||||
}
|
}
|
||||||
close_thread_tables(thd);
|
else
|
||||||
}
|
|
||||||
else if (!(rights & CREATE_ACL) && !revoke_grant)
|
|
||||||
{
|
|
||||||
char buf[FN_REFLEN];
|
|
||||||
sprintf(buf,"%s/%s/%s.frm",mysql_data_home, table_list->db,
|
|
||||||
table_list->real_name);
|
|
||||||
fn_format(buf,buf,"","",4+16+32);
|
|
||||||
if (access(buf,F_OK))
|
|
||||||
{
|
{
|
||||||
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias);
|
if (!(rights & CREATE_ACL))
|
||||||
DBUG_RETURN(-1);
|
{
|
||||||
|
char buf[FN_REFLEN];
|
||||||
|
sprintf(buf,"%s/%s/%s.frm",mysql_data_home, table_list->db,
|
||||||
|
table_list->real_name);
|
||||||
|
fn_format(buf,buf,"","",4+16+32);
|
||||||
|
if (access(buf,F_OK))
|
||||||
|
{
|
||||||
|
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias);
|
||||||
|
DBUG_RETURN(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (table_list->grant.want_privilege)
|
||||||
|
{
|
||||||
|
char command[128];
|
||||||
|
get_privilege_desc(command, sizeof(command),
|
||||||
|
table_list->grant.want_privilege);
|
||||||
|
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
|
||||||
|
command, thd->priv_user, thd->host_or_ip, table_list->alias);
|
||||||
|
DBUG_RETURN(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2773,25 +2792,8 @@ err:
|
|||||||
rw_unlock(&LOCK_grant);
|
rw_unlock(&LOCK_grant);
|
||||||
if (!no_errors) // Not a silent skip of table
|
if (!no_errors) // Not a silent skip of table
|
||||||
{
|
{
|
||||||
const char *command="";
|
char command[128];
|
||||||
if (want_access & SELECT_ACL)
|
get_privilege_desc(command, sizeof(command), want_access);
|
||||||
command= "select";
|
|
||||||
else if (want_access & INSERT_ACL)
|
|
||||||
command= "insert";
|
|
||||||
else if (want_access & UPDATE_ACL)
|
|
||||||
command= "update";
|
|
||||||
else if (want_access & DELETE_ACL)
|
|
||||||
command= "delete";
|
|
||||||
else if (want_access & DROP_ACL)
|
|
||||||
command= "drop";
|
|
||||||
else if (want_access & CREATE_ACL)
|
|
||||||
command= "create";
|
|
||||||
else if (want_access & ALTER_ACL)
|
|
||||||
command= "alter";
|
|
||||||
else if (want_access & INDEX_ACL)
|
|
||||||
command= "index";
|
|
||||||
else if (want_access & GRANT_ACL)
|
|
||||||
command= "grant";
|
|
||||||
net_printf(thd,ER_TABLEACCESS_DENIED_ERROR,
|
net_printf(thd,ER_TABLEACCESS_DENIED_ERROR,
|
||||||
command,
|
command,
|
||||||
thd->priv_user,
|
thd->priv_user,
|
||||||
@ -2906,11 +2908,8 @@ bool check_grant_all_columns(THD *thd, ulong want_access, TABLE *table)
|
|||||||
err:
|
err:
|
||||||
rw_unlock(&LOCK_grant);
|
rw_unlock(&LOCK_grant);
|
||||||
err2:
|
err2:
|
||||||
const char *command= "";
|
char command[128];
|
||||||
if (want_access & SELECT_ACL)
|
get_privilege_desc(command, sizeof(command), want_access);
|
||||||
command= "select";
|
|
||||||
else if (want_access & INSERT_ACL)
|
|
||||||
command= "insert";
|
|
||||||
my_printf_error(ER_COLUMNACCESS_DENIED_ERROR,
|
my_printf_error(ER_COLUMNACCESS_DENIED_ERROR,
|
||||||
ER(ER_COLUMNACCESS_DENIED_ERROR),
|
ER(ER_COLUMNACCESS_DENIED_ERROR),
|
||||||
MYF(0),
|
MYF(0),
|
||||||
|
Reference in New Issue
Block a user