Skip to content

Commit

Permalink
mysql_user: reinitialize the privs list in privileges_unpack()
Browse files Browse the repository at this point in the history
In some scenarios, `privileges_unpack()` called `privs.append()` inside a loop
without first emptying or reinitializing the `privs` list from the prior
iteration. This could result in an invalid `GRANT` statement, which incorrectly
included privileges from a previously-built `GRANT` statement.

Reinitialize `privs` on each pass of the loop to prevent this from occurring.
  • Loading branch information
parseword committed Apr 4, 2021
1 parent ba791bf commit 8ceec70
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/modules/mysql_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,8 @@ def privileges_unpack(priv, mode):
else:
quote = '`'
output = {}
privs = []
for item in priv.strip().split('/'):
privs = []
pieces = item.strip().rsplit(':', 1)
dbpriv = pieces[0].rsplit(".", 1)

Expand Down

0 comments on commit 8ceec70

Please sign in to comment.