From e73e9ecbc338f38105e37e1b14dc1cc389ab3657 Mon Sep 17 00:00:00 2001 From: plumbeo Date: Fri, 22 Feb 2019 01:39:51 +0100 Subject: [PATCH] mysql_user: fix malformed regex used to check current privileges (#52278) * mysql_user: fix malformed regex used to check current privileges * Add changelog fragment for PR #52278 --- changelogs/fragments/52278-mysql_user-fix-regex | 2 ++ lib/ansible/modules/database/mysql/mysql_user.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/52278-mysql_user-fix-regex diff --git a/changelogs/fragments/52278-mysql_user-fix-regex b/changelogs/fragments/52278-mysql_user-fix-regex new file mode 100644 index 00000000000..24a6f39451e --- /dev/null +++ b/changelogs/fragments/52278-mysql_user-fix-regex @@ -0,0 +1,2 @@ +bugfixes: + - "mysql_user: fix the working but incorrect regex used to check the user privileges." diff --git a/lib/ansible/modules/database/mysql/mysql_user.py b/lib/ansible/modules/database/mysql/mysql_user.py index 12540007678..6205909de0e 100644 --- a/lib/ansible/modules/database/mysql/mysql_user.py +++ b/lib/ansible/modules/database/mysql/mysql_user.py @@ -444,7 +444,7 @@ def privileges_get(cursor, user, host): return x for grant in grants: - res = re.match("""GRANT (.+) ON (.+) TO (['`"]).*\\3@(['`"]).*\\4( IDENTIFIED BY PASSWORD (['`"]).+\5)? ?(.*)""", grant[0]) + res = re.match("""GRANT (.+) ON (.+) TO (['`"]).*\\3@(['`"]).*\\4( IDENTIFIED BY PASSWORD (['`"]).+\\6)? ?(.*)""", grant[0]) if res is None: raise InvalidPrivsError('unable to parse the MySQL grant string: %s' % grant[0]) privileges = res.group(1).split(", ")