2004-07-08 18:54:07 +05:00
|
|
|
SET NAMES binary;
|
|
|
|
|
2003-07-22 22:00:51 +02:00
|
|
|
#
|
|
|
|
# GRANT tests that require several connections
|
|
|
|
# (usually it's GRANT, reconnect as another user, try something)
|
|
|
|
#
|
|
|
|
|
|
|
|
|
2004-10-20 16:04:43 +04:00
|
|
|
# prepare playground before tests
|
|
|
|
--disable_warnings
|
|
|
|
drop database if exists mysqltest;
|
|
|
|
--enable_warnings
|
|
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.tables_priv where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.columns_priv where user like 'mysqltest\_%';
|
|
|
|
flush privileges;
|
|
|
|
|
|
|
|
|
2003-07-22 22:00:51 +02:00
|
|
|
#
|
|
|
|
# wild_compare fun
|
|
|
|
#
|
|
|
|
|
|
|
|
grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
|
|
|
|
connect (user1,localhost,mysqltest_1,,);
|
|
|
|
connection user1;
|
|
|
|
select current_user();
|
2004-04-05 17:55:26 +05:00
|
|
|
select current_user;
|
2003-07-22 22:21:23 +02:00
|
|
|
grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
|
2003-07-22 22:00:51 +02:00
|
|
|
--error 1044
|
2003-07-22 22:21:23 +02:00
|
|
|
grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
|
2003-07-22 22:00:51 +02:00
|
|
|
disconnect user1;
|
2003-07-28 16:58:51 +02:00
|
|
|
connection default;
|
2003-07-22 22:21:23 +02:00
|
|
|
show grants for mysqltest_1@localhost;
|
|
|
|
show grants for mysqltest_2@localhost;
|
|
|
|
--error 1141
|
|
|
|
show grants for mysqltest_3@localhost;
|
2003-07-22 22:00:51 +02:00
|
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
|
|
|
flush privileges;
|
|
|
|
|
2004-10-20 16:04:43 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug #6173: One can circumvent missing UPDATE privilege if he has SELECT
|
|
|
|
# and INSERT privilege for table with primary key
|
|
|
|
#
|
|
|
|
create database mysqltest;
|
|
|
|
grant INSERT, SELECT on mysqltest.* to mysqltest_1@localhost;
|
|
|
|
flush privileges;
|
|
|
|
use mysqltest;
|
|
|
|
create table t1 (id int primary key, data varchar(255));
|
|
|
|
|
|
|
|
connect (mrbad, localhost, mysqltest_1,,);
|
|
|
|
connection mrbad;
|
|
|
|
show grants for current_user();
|
|
|
|
use mysqltest;
|
|
|
|
insert into t1 values (1, 'I can''t change it!');
|
|
|
|
--error 1044
|
|
|
|
update t1 set data='I can change it!' where id = 1;
|
|
|
|
# This should not be allowed since it too require UPDATE privilege.
|
|
|
|
--error 1044
|
|
|
|
insert into t1 values (1, 'XXX') on duplicate key update data= 'I can change it!';
|
|
|
|
select * from t1;
|
|
|
|
|
|
|
|
connection default;
|
|
|
|
drop table t1;
|
|
|
|
drop database mysqltest;
|
|
|
|
use test;
|
|
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
|
|
|
flush privileges;
|