Skip to content

Commit

Permalink
read_only failures
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Sep 23, 2022
1 parent 47dccac commit e30f30d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 36 deletions.
2 changes: 1 addition & 1 deletion mysql-test/suite/sys_vars/r/read_only_func.result
Expand Up @@ -20,7 +20,7 @@ id name
CREATE user sameea;
CONNECT connn,localhost,sameea,,;
SET Global read_ONLY=ON;
ERROR 42000: Access denied; you need (at least one of) the SUPER, READ_ONLY ADMIN privilege(s) for this operation
ERROR 42000: Access denied; you need (at least one of) the READ_ONLY ADMIN privilege(s) for this operation
CREATE TABLE t2
(
id INT NOT NULL auto_increment,
Expand Down
19 changes: 3 additions & 16 deletions mysql-test/suite/sys_vars/r/read_only_grant.result
@@ -1,14 +1,14 @@
#
# MDEV-21960 Bind READ_ONLY ADMIN to @@read_only
#
# Test that "SET read_only" is not allowed without READ_ONLY ADMIN or SUPER
# Test that "SET read_only" is not allowed without READ_ONLY ADMIN
CREATE USER user1@localhost;
GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
REVOKE READ_ONLY ADMIN, SUPER ON *.* FROM user1@localhost;
REVOKE READ_ONLY ADMIN ON *.* FROM user1@localhost;
connect user1,localhost,user1,,;
connection user1;
SET GLOBAL read_only=0;
ERROR 42000: Access denied; you need (at least one of) the SUPER, READ_ONLY ADMIN privilege(s) for this operation
ERROR 42000: Access denied; you need (at least one of) the READ_ONLY ADMIN privilege(s) for this operation
SET read_only=0;
ERROR HY000: Variable 'read_only' is a GLOBAL variable and should be set with SET GLOBAL
SET SESSION read_only=0;
Expand All @@ -29,16 +29,3 @@ ERROR HY000: Variable 'read_only' is a GLOBAL variable and should be set with SE
disconnect user1;
connection default;
DROP USER user1@localhost;
# Test that "SET read_only" is allowed with SUPER
CREATE USER user1@localhost;
GRANT SUPER ON *.* TO user1@localhost;
connect user1,localhost,user1,,;
connection user1;
SET GLOBAL read_only=0;
SET read_only=0;
ERROR HY000: Variable 'read_only' is a GLOBAL variable and should be set with SET GLOBAL
SET SESSION read_only=0;
ERROR HY000: Variable 'read_only' is a GLOBAL variable and should be set with SET GLOBAL
disconnect user1;
connection default;
DROP USER user1@localhost;
2 changes: 1 addition & 1 deletion mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
Expand Up @@ -3015,7 +3015,7 @@ COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME READ_ONLY
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege
VARIABLE_COMMENT Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the 'READ ONLY ADMIN' privilege
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
Expand Down
Expand Up @@ -3195,7 +3195,7 @@ COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME READ_ONLY
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege
VARIABLE_COMMENT Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the 'READ ONLY ADMIN' privilege
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
Expand Down
19 changes: 2 additions & 17 deletions mysql-test/suite/sys_vars/t/read_only_grant.test
Expand Up @@ -4,11 +4,11 @@
--echo # MDEV-21960 Bind READ_ONLY ADMIN to @@read_only
--echo #

--echo # Test that "SET read_only" is not allowed without READ_ONLY ADMIN or SUPER
--echo # Test that "SET read_only" is not allowed without READ_ONLY ADMIN

CREATE USER user1@localhost;
GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
REVOKE READ_ONLY ADMIN, SUPER ON *.* FROM user1@localhost;
REVOKE READ_ONLY ADMIN ON *.* FROM user1@localhost;
--connect(user1,localhost,user1,,)
--connection user1
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
Expand All @@ -35,18 +35,3 @@ SET SESSION read_only=0;
--disconnect user1
--connection default
DROP USER user1@localhost;

--echo # Test that "SET read_only" is allowed with SUPER

CREATE USER user1@localhost;
GRANT SUPER ON *.* TO user1@localhost;
--connect(user1,localhost,user1,,)
--connection user1
SET GLOBAL read_only=0;
--error ER_GLOBAL_VARIABLE
SET read_only=0;
--error ER_GLOBAL_VARIABLE
SET SESSION read_only=0;
--disconnect user1
--connection default
DROP USER user1@localhost;

0 comments on commit e30f30d

Please sign in to comment.