mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-18 16:31:26 -07:00
[stable-1] mysql_user: fix parsing privs when a user has roles assigned to it (#346)
* mysql_user: fix parsing privs when a user has roles assigned to it * Fix CI * Fix CI
This commit is contained in:
parent
256817ca32
commit
393023eb07
5 changed files with 115 additions and 0 deletions
|
@ -750,8 +750,19 @@ def privileges_get(cursor, user, host):
|
|||
|
||||
for grant in grants:
|
||||
res = re.match("""GRANT (.+) ON (.+) TO (['`"]).*\\3@(['`"]).*\\4( IDENTIFIED BY PASSWORD (['`"]).+\\6)? ?(.*)""", grant[0])
|
||||
|
||||
if res is None:
|
||||
# If a user has roles assigned, we'll have one of priv tuples looking like
|
||||
# GRANT `admin`@`%` TO `user1`@`localhost`
|
||||
# which will result None as res value.
|
||||
# As we use the mysql_role module (community.mysql 2.0.0+) to manipulate roles
|
||||
# we just ignore such privs below:
|
||||
res = re.match("""GRANT (.+) TO (['`"]).*""", grant[0])
|
||||
if res:
|
||||
continue
|
||||
|
||||
raise InvalidPrivsError('unable to parse the MySQL grant string: %s' % grant[0])
|
||||
|
||||
privileges = res.group(1).split(",")
|
||||
privileges = [pick(x.strip()) for x in privileges]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue