From 1cb9f369d0f8a89bd81b6b99ce07e95beeb7459c Mon Sep 17 00:00:00 2001 From: george2asenov Date: Thu, 16 Oct 2025 10:26:35 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20case=20when=20grant=20options=20is=20set?= =?UTF-8?q?=20with=20no=20other=20user=20permissions=20in=E2=80=A6=20(#744?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: case when grant options is set with no other user permissions in mariadb * Create changelog fragment * fix: wrong file name ext * Update changelogs/fragments/fix_user_perms_revoke_grant_option.yml Co-authored-by: Andrew Klychkov --------- Co-authored-by: Andrew Klychkov --- changelogs/fragments/fix_user_perms_revoke_grant_option.yml | 2 ++ plugins/module_utils/user.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/fix_user_perms_revoke_grant_option.yml diff --git a/changelogs/fragments/fix_user_perms_revoke_grant_option.yml b/changelogs/fragments/fix_user_perms_revoke_grant_option.yml new file mode 100644 index 0000000..46b47b4 --- /dev/null +++ b/changelogs/fragments/fix_user_perms_revoke_grant_option.yml @@ -0,0 +1,2 @@ +bugfixes: + - mysql_user, mysql_role - fix not existent grant when revoking perms on user/role which do not have any other perms than grant option (https://github.com/ansible-collections/community.mysql/issues/664). diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index d3d99ea..2763305 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -885,7 +885,7 @@ def privileges_revoke(cursor, user, host, db_table, priv, grant_option, maria_ro cursor.execute(query, (user, host)) priv_string = ",".join([p for p in priv if p not in ('GRANT', )]) - if priv_string != "": + if priv_string != "" and not (grant_option and priv_string == "USAGE"): query = ["REVOKE %s ON %s" % (priv_string, db_table)] if not maria_role: