From dddb5270c8545c19c6619575bf99166ba6819e20 Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Wed, 19 Aug 2015 04:22:31 +0000 Subject: [PATCH 1/2] Refix bug 1226 after revert This patch properly fixes bug 1226 without introducing a breaking change to idempotency which was introduced in PR #1358 We can properly assign permissions to databases with a '.' in the name of the database as well as assign priviliges to all databases as specified with '*' --- database/mysql/mysql_user.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/database/mysql/mysql_user.py b/database/mysql/mysql_user.py index 4f0dee5374c..5ea825f7514 100644 --- a/database/mysql/mysql_user.py +++ b/database/mysql/mysql_user.py @@ -320,6 +320,11 @@ def privileges_unpack(priv): privs = [] for item in priv.strip().split('/'): pieces = item.strip().split(':') + dbpriv = pieces[0].rsplit(".", 1) + # Do not escape if privilege is for database '*' (all databases) + if dbpriv[0].strip('`') != '*': + pieces[0] = "`%s`.%s" % (dbpriv[0].strip('`'), dbpriv[1]) + if '.' in pieces[0]: pieces[0] = pieces[0].split('.') for idx, piece in enumerate(pieces): From 54804d25e31263a332c66e62d3904cfbd43c958d Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Wed, 19 Aug 2015 08:52:05 +0000 Subject: [PATCH 2/2] Actually remove the section we are replacing --- database/mysql/mysql_user.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/database/mysql/mysql_user.py b/database/mysql/mysql_user.py index 5ea825f7514..1ea54b41b3a 100644 --- a/database/mysql/mysql_user.py +++ b/database/mysql/mysql_user.py @@ -325,13 +325,6 @@ def privileges_unpack(priv): if dbpriv[0].strip('`') != '*': pieces[0] = "`%s`.%s" % (dbpriv[0].strip('`'), dbpriv[1]) - if '.' in pieces[0]: - pieces[0] = pieces[0].split('.') - for idx, piece in enumerate(pieces): - if pieces[0][idx] != "*": - pieces[0][idx] = "`" + pieces[0][idx] + "`" - pieces[0] = '.'.join(pieces[0]) - if '(' in pieces[1]: output[pieces[0]] = re.split(r',\s*(?=[^)]*(?:\(|$))', pieces[1].upper()) for i in output[pieces[0]]: