From 8ceec702add98a28d68b33cbb0d1466ae05432be Mon Sep 17 00:00:00 2001 From: parseword Date: Sat, 3 Apr 2021 23:09:35 -0500 Subject: [PATCH] mysql_user: reinitialize the privs list in privileges_unpack() 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. --- plugins/modules/mysql_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/mysql_user.py b/plugins/modules/mysql_user.py index bb0f5a0..acbf27a 100644 --- a/plugins/modules/mysql_user.py +++ b/plugins/modules/mysql_user.py @@ -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)