Skip to content

Commit

Permalink
Merge pull request #48561 from garethgreenaway/48507_mysql_grants_inc…
Browse files Browse the repository at this point in the history
…orrect_failure

[2018.3] fixes to grants in mysql module
  • Loading branch information
Nicole Thomas committed Jul 13, 2018
2 parents 5b5a930 + 14c59da commit 2d923f2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions salt/modules/mysql.py
Expand Up @@ -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:
Expand Down

0 comments on commit 2d923f2

Please sign in to comment.