From 14c59da72c3651c7c35f2b950ff63b4538b59245 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Thu, 12 Jul 2018 12:40:57 -0700 Subject: [PATCH] Following a successful grant application in the MySQL module, the new grant and the desired grant are mismatched because the new grant from Mysql included hashmarks. This change adds the replace which is included for other items such as database name and username. --- salt/modules/mysql.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py index b7b221b4eb04..889de1cb367c 100644 --- a/salt/modules/mysql.py +++ b/salt/modules/mysql.py @@ -1812,11 +1812,16 @@ def grant_exists(grant, if not target_tokens: # Avoid the overhead of re-calc in loop target_tokens = _grant_to_tokens(target) grant_tokens = _grant_to_tokens(grant) - grant_tokens_database = grant_tokens['database'].replace('"', '').replace('\\', '').replace('`', '') - target_tokens_database = target_tokens['database'].replace('"', '').replace('\\', '').replace('`', '') - if grant_tokens['user'] == target_tokens['user'] and \ - grant_tokens_database == target_tokens_database and \ - grant_tokens['host'] == target_tokens['host'] and \ + + _grant_tokens = {} + _target_tokens = {} + for item in ['user', 'database', 'host']: + _grant_tokens[item] = grant_tokens[item].replace('"', '').replace('\\', '').replace('`', '') + _target_tokens[item] = target_tokens[item].replace('"', '').replace('\\', '').replace('`', '') + + if _grant_tokens['user'] == _target_tokens['user'] and \ + _grant_tokens['database'] == _target_tokens['database'] and \ + _grant_tokens['host'] == _target_tokens['host'] and \ set(grant_tokens['grant']) >= set(target_tokens['grant']): return True else: