mariadb/mysql-test/main/long_host.test
Oleksandr Byelkin a3099a3b4a MDEV-24312 master_host has 60 character limit, increase to 255 bytes
Also increase user name up to 128.

The work was started by Rucha Deodhar <rucha.deodhar@mariadb.com>,
contains audit plugin fixes by Alexey Botchkov <holyfoot@askmonty.org>.
2021-04-20 16:36:56 +02:00

196 lines
14 KiB
Text

--source include/have_debug_sync.inc
--source include/not_embedded.inc
--echo # check user
# User 128 characters
create user user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678;
# User 129 characters
--error ER_WRONG_STRING_LENGTH
create user user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_3456789;
SELECT host, user FROM mysql.user where user like "user56789%";
drop user user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678;
# Host 255 characters
create user user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
# Host 256 characters
--error ER_WRONG_STRING_LENGTH
create user user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_3456;
SELECT host, user FROM mysql.user where user like "user56789%";
create database mariadbtestdb;
create database mariadbtestdb2;
create table mariadbtestdb.t1 (a int, b int);
create table mariadbtestdb2.t2 (a int);
create table mariadbtestdb.t3 (a int);
SET @saved_dbug = @@GLOBAL.debug_dbug;
set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_long_host,getaddrinfo_fake_good_ipv4";
--echo # check connect
connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,);
connection con1;
select current_user();
--echo # check global privileges
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb.t1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb2.t2;
connection default;
grant SELECT ON *.* TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
disconnect con1;
connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,);
connection con1;
select * from mariadbtestdb.t1;
select * from mariadbtestdb2.t2;
--echo # check revoke
connection default;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
disconnect con1;
connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,);
connection con1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb.t1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb2.t2;
--echo # check data base privileges
connection default;
grant SELECT ON mariadbtestdb.* TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
disconnect con1;
connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,);
connection con1;
select * from mariadbtestdb.t1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb2.t2;
select * from mariadbtestdb.t3;
--echo # check table privileges
connection default;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
grant SELECT ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
disconnect con1;
connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,);
connection con1;
select * from mariadbtestdb.t1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb2.t2;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb.t3;
--echo # check column privileges
connection default;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
grant SELECT (a) ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
disconnect con1;
connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,);
connection con1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb.t1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb2.t2;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb.t3;
select a from mariadbtestdb.t1;
--echo # check role
connection default;
# Role 128 characters
CREATE ROLE role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678;
# Role 129 characters
--error ER_WRONG_STRING_LENGTH
CREATE ROLE role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_3456789;
grant SELECT (a) ON mariadbtestdb.t1 TO role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
grant role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678 to user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
disconnect con1;
connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,);
connection con1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb.t1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb2.t2;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb.t3;
--error ER_TABLEACCESS_DENIED_ERROR
select a from mariadbtestdb.t1;
SELECT CURRENT_ROLE;
SET ROLE role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678;
SELECT CURRENT_ROLE;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb.t1;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb2.t2;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mariadbtestdb.t3;
select a from mariadbtestdb.t1;
--echo # check procedure
create procedure foo()
select a from mariadbtestdb.t1;
show create procedure foo;
connection default;
select Host,Db,User,Routine_name,Routine_type,Grantor,Proc_priv from mysql.procs_priv where Routine_name="foo";
connection default;
disconnect con1;
drop procedure foo;
SET @@GLOBAL.debug_dbug = @saved_dbug;
drop user user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345;
DROP ROLE role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678;
drop database mariadbtestdb;
drop database mariadbtestdb2;
--echo #
--echo # MDEV-24968: Assertion `magic < 1<<26' failed in get_magic_sort
--echo #
create user u1@'host5678901_345678902_345678903_345678904_345678905_345678906_345678907%';
drop user u1@'host5678901_345678902_345678903_345678904_345678905_345678906_345678907%';
create user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_34%';
drop user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_34%';
create user '5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'%';
drop user '5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'%';
create user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'h%s%5%7%9%1%3%5%7%9%2%3%5%7%9%3%3%5%7%9%4%3%5%7%9%5%3%5%7%9%6%3%5%7%9%7%3%5%7%9%8%3%5%7%9%9%3%5%7%9%0%3%5%7%';
drop user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'h%s%5%7%9%1%3%5%7%9%2%3%5%7%9%3%3%5%7%9%4%3%5%7%9%5%3%5%7%9%6%3%5%7%9%7%3%5%7%9%8%3%5%7%9%9%3%5%7%9%0%3%5%7%';
create user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%';
drop user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%?%';
create user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????';
drop user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????';