From efe2102b16836bc84463686063b7cddd6e0d6b58 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sat, 1 Jan 2022 14:25:24 +0100 Subject: [PATCH] Add missing MariaDB Grants to mysql module MariaDB has added some grants in 10.4.x and 10.5.x that are not present here, which results in an error when creating. This is an addition to #59280. Also improved exception handling in `grant_add` which did not log the original error message and replaced it with a generic error. --- changelog/61409.changed | 3 +++ salt/modules/mysql.py | 28 +++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 changelog/61409.changed diff --git a/changelog/61409.changed b/changelog/61409.changed new file mode 100644 index 00000000000..1c210d80b34 --- /dev/null +++ b/changelog/61409.changed @@ -0,0 +1,3 @@ +Add missing MariaDB Grants to mysql module. +MariaDB has added some grants in 10.4.x and 10.5.x that are not present here, which results in an error when creating. +Also improved exception handling in `grant_add` which did not log the original error message and replaced it with a generic error. diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py index 443da779931..c9c6ad69fe7 100644 --- a/salt/modules/mysql.py +++ b/salt/modules/mysql.py @@ -78,11 +78,11 @@ __grants__ = [ "ALTER ROUTINE", "BACKUP_ADMIN", "BINLOG_ADMIN", - "BINLOG ADMIN", - "BINLOG MONITOR", - "BINLOG REPLAY", + "BINLOG ADMIN", # MariaDB since 10.5.2 + "BINLOG MONITOR", # MariaDB since 10.5.2 + "BINLOG REPLAY", # MariaDB since 10.5.2 "CONNECTION_ADMIN", - "CONNECTION ADMIN", + "CONNECTION ADMIN", # MariaDB since 10.5.2 "CREATE", "CREATE ROLE", "CREATE ROUTINE", @@ -91,12 +91,13 @@ __grants__ = [ "CREATE USER", "CREATE VIEW", "DELETE", + "DELETE HISTORY", # MariaDB since 10.3.4 "DROP", "DROP ROLE", "ENCRYPTION_KEY_ADMIN", "EVENT", "EXECUTE", - "FEDERATED ADMIN", + "FEDERATED ADMIN", # MariaDB since 10.5.2 "FILE", "GRANT OPTION", "GROUP_REPLICATION_ADMIN", @@ -105,26 +106,26 @@ __grants__ = [ "LOCK TABLES", "PERSIST_RO_VARIABLES_ADMIN", "PROCESS", - "READ_ONLY ADMIN", + "READ_ONLY ADMIN", # MariaDB since 10.5.2 "REFERENCES", "RELOAD", - "REPLICA MONITOR", + "REPLICA MONITOR", # MariaDB since 10.5.9 "REPLICATION CLIENT", - "REPLICATION MASTER ADMIN", - "REPLICATION REPLICA", + "REPLICATION MASTER ADMIN", # MariaDB since 10.5.2 + "REPLICATION REPLICA", # MariaDB since 10.5.1 "REPLICATION SLAVE", "REPLICATION_SLAVE_ADMIN", - "REPLICATION SLAVE ADMIN", + "REPLICATION SLAVE ADMIN", # MariaDB since 10.5.2 "RESOURCE_GROUP_ADMIN", "RESOURCE_GROUP_USER", "ROLE_ADMIN", "SELECT", - "SET USER", + "SET USER", # MariaDB since 10.5.2 "SET_USER_ID", "SHOW DATABASES", "SHOW VIEW", "SHUTDOWN", - "SLAVE MONITOR", + "SLAVE MONITOR", # MariaDB since 10.5.9 "SUPER", "SYSTEM_VARIABLES_ADMIN", "TRIGGER", @@ -2490,8 +2491,9 @@ def grant_exists( try: target = __grant_generate(grant, database, user, host, grant_option, escape) - except Exception: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except log.error("Error during grant generation.") + log.error(exc) return False grants = user_grants(user, host, **connection_args)