From 70366ec80c16018842a0618ba007ea9859bf1acc Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 14 Nov 2012 20:02:39 -0500 Subject: [PATCH] Fix for #1577 (python 2.4 compliance for mysql_user), tested only for syntax, please exercise MySQL fans! --- mysql_user | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mysql_user b/mysql_user index 7114d7bbd63..bcf90b70332 100755 --- a/mysql_user +++ b/mysql_user @@ -169,12 +169,19 @@ def privileges_get(cursor, user,host): output = {} cursor.execute("SHOW GRANTS FOR %s@%s", (user,host)) grants = cursor.fetchall() + + def pick(x): + if x == 'ALL PRIVILEGES': + return 'ALL' + else: + return x + for grant in grants: res = re.match("GRANT (.+) ON (.+) TO '.+'@'.+'( IDENTIFIED BY PASSWORD '.+')? ?(.*)", grant[0]) if res is None: module.fail_json(msg="unable to parse the MySQL grant string") privileges = res.group(1).split(", ") - privileges = ['ALL' if x=='ALL PRIVILEGES' else x for x in privileges] + privileges = [ pick(x) for x in privileges] if "WITH GRANT OPTION" in res.group(4): privileges.append('GRANT') db = res.group(2).replace('`', '')