mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix issue with MySQL8 and "all privileges" grant
Converts the given "grant" to upper case before compare to "ALL". This fixes a problem granting "all privileges" to a MySQL user.
This commit is contained in:
parent
0e4e8a458a
commit
13379fc370
3 changed files with 13 additions and 1 deletions
2
changelog/58933.fixed
Normal file
2
changelog/58933.fixed
Normal file
|
@ -0,0 +1,2 @@
|
|||
Converts the given "grant" to upper case before compare to "ALL".
|
||||
This fixes a problem granting "all privileges" to a MySQL user.
|
|
@ -2370,7 +2370,7 @@ def grant_exists(
|
|||
)
|
||||
log.error(err)
|
||||
return False
|
||||
if "ALL" in grant:
|
||||
if "ALL" in grant.upper():
|
||||
if (
|
||||
salt.utils.versions.version_cmp(server_version, "8.0") >= 0
|
||||
and "MariaDB" not in server_version
|
||||
|
|
|
@ -587,6 +587,16 @@ class MySQLTestCase(TestCase, LoaderModuleMockMixin):
|
|||
ret = mysql.grant_exists("ALL", "testdb.testtableone", "testuser", "%")
|
||||
self.assertEqual(ret, True)
|
||||
|
||||
with patch.object(mysql, "version", return_value="8.0.10"):
|
||||
mock = MagicMock(return_value=mock_grants)
|
||||
with patch.object(
|
||||
mysql, "user_grants", return_value=mock_grants
|
||||
) as mock_user_grants:
|
||||
ret = mysql.grant_exists(
|
||||
"all privileges", "testdb.testtableone", "testuser", "%"
|
||||
)
|
||||
self.assertEqual(ret, True)
|
||||
|
||||
mock_grants = ["GRANT ALL PRIVILEGES ON testdb.testtableone TO `testuser`@`%`"]
|
||||
with patch.object(mysql, "version", return_value="5.6.41"):
|
||||
mock = MagicMock(return_value=mock_grants)
|
||||
|
|
Loading…
Add table
Reference in a new issue