Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
513cfd04
Commit
513cfd04
authored
Mar 17, 2020
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-21960 Bind READ_ONLY ADMIN to @@read_only
parent
b6025841
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
2 deletions
+115
-2
mysql-test/suite/sys_vars/r/read_only_func.result
mysql-test/suite/sys_vars/r/read_only_func.result
+1
-1
mysql-test/suite/sys_vars/r/read_only_grant.result
mysql-test/suite/sys_vars/r/read_only_grant.result
+44
-0
mysql-test/suite/sys_vars/t/read_only_grant.test
mysql-test/suite/sys_vars/t/read_only_grant.test
+52
-0
sql/privilege.h
sql/privilege.h
+4
-0
sql/sys_vars.cc
sql/sys_vars.cc
+3
-1
sql/sys_vars.ic
sql/sys_vars.ic
+11
-0
No files found.
mysql-test/suite/sys_vars/r/read_only_func.result
View file @
513cfd04
...
...
@@ -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 privilege(s) for this operation
ERROR 42000: Access denied; you need (at least one of) the SUPER
, READ_ONLY ADMIN
privilege(s) for this operation
CREATE TABLE t2
(
id INT NOT NULL auto_increment,
...
...
mysql-test/suite/sys_vars/r/read_only_grant.result
0 → 100644
View file @
513cfd04
#
# MDEV-21960 Bind READ_ONLY ADMIN to @@read_only
#
# Test that "SET read_only" is not allowed without READ_ONLY ADMIN or SUPER
CREATE USER user1@localhost;
GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
REVOKE READ_ONLY ADMIN, SUPER 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
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;
# Test that "SET read_only" is allowed with READ_ONLY ADMIN
CREATE USER user1@localhost;
GRANT READ_ONLY ADMIN 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;
# 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;
mysql-test/suite/sys_vars/t/read_only_grant.test
0 → 100644
View file @
513cfd04
--
source
include
/
not_embedded
.
inc
--
echo
#
--
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
CREATE
USER
user1
@
localhost
;
GRANT
ALL
PRIVILEGES
ON
*.*
TO
user1
@
localhost
;
REVOKE
READ_ONLY
ADMIN
,
SUPER
ON
*.*
FROM
user1
@
localhost
;
--
connect
(
user1
,
localhost
,
user1
,,)
--
connection
user1
--
error
ER_SPECIFIC_ACCESS_DENIED_ERROR
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
;
--
echo
# Test that "SET read_only" is allowed with READ_ONLY ADMIN
CREATE
USER
user1
@
localhost
;
GRANT
READ_ONLY
ADMIN
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
;
--
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
;
sql/privilege.h
View file @
513cfd04
...
...
@@ -325,7 +325,11 @@ constexpr privilege_t PRIV_SET_SYSTEM_VAR_SQL_LOG_BIN=
/* Privileges related to --read-only */
// Was super prior to 10.5.2
constexpr
privilege_t
PRIV_IGNORE_READ_ONLY
=
READ_ONLY_ADMIN_ACL
|
SUPER_ACL
;
// Was super prior to 10.5.2
constexpr
privilege_t
PRIV_SET_SYSTEM_GLOBAL_VAR_READ_ONLY
=
READ_ONLY_ADMIN_ACL
|
SUPER_ACL
;
/*
Privileges related to connection handling.
...
...
sql/sys_vars.cc
View file @
513cfd04
...
...
@@ -2822,7 +2822,9 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type)
transition (especially when transitioning from false to true) and
synchronizes both booleans in the end.
*/
static
Sys_var_mybool
Sys_readonly
(
static
Sys_var_on_access_global
<
Sys_var_mybool
,
PRIV_SET_SYSTEM_GLOBAL_VAR_READ_ONLY
>
Sys_readonly
(
"read_only"
,
"Make all non-temporary tables read-only, with the exception for "
"replication (slave) threads and users with the SUPER privilege"
,
...
...
sql/sys_vars.ic
View file @
513cfd04
...
...
@@ -118,6 +118,17 @@ class Sys_var_on_access: public BASE
};
template<class BASE, privilege_t GLOBAL_PRIV>
class Sys_var_on_access_global: public BASE
{
using BASE::BASE;
bool on_check_access_global(THD *thd) const override
{
return check_global_access(thd, GLOBAL_PRIV);
}
};
/**
A small wrapper class to pass getopt arguments as a pair
to the Sys_var_* constructors. It improves type safety and helps
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment