From 2e904ae233b2500f2e05fc4e4340bbedde428810 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Fri, 22 Feb 2013 13:25:34 +0100 Subject: [PATCH 1/2] mysql_db/user: Use password for my.cnf According to the MySQL docs[0] the password should be stored after 'password=' instead of 'pass='. [0] http://dev.mysql.com/doc/refman/5.1/en/password-security-user.html --- mysql_db | 2 +- mysql_user | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql_db b/mysql_db index 807603a83dd..eac18c4aba2 100644 --- a/mysql_db +++ b/mysql_db @@ -131,7 +131,7 @@ def load_mycnf(): return False try: config.readfp(open(mycnf)) - creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'pass')) + creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'password')) except (ConfigParser.NoOptionError, IOError): return False return creds diff --git a/mysql_user b/mysql_user index b9b833e1f64..9317bbdd7a1 100644 --- a/mysql_user +++ b/mysql_user @@ -230,7 +230,7 @@ def load_mycnf(): return False try: config.readfp(open(mycnf)) - creds = dict(user=config.get('client', 'user'),password=config.get('client', 'pass')) + creds = dict(user=config.get('client', 'user'),password=config.get('client', 'password')) except (ConfigParser.NoOptionError, IOError): return False return creds From 1738eba7496ded0e0ae5cc112d4416fa509261ca Mon Sep 17 00:00:00 2001 From: Till Maas Date: Fri, 22 Feb 2013 14:42:41 +0100 Subject: [PATCH 2/2] mysql_user: handle unnecessary GRANT revocation --- mysql_user | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mysql_user b/mysql_user index 9317bbdd7a1..3f40411b0db 100644 --- a/mysql_user +++ b/mysql_user @@ -213,7 +213,13 @@ def privileges_revoke(cursor, user,host,db_table): query = "REVOKE ALL PRIVILEGES ON %s FROM '%s'@'%s'" % (db_table,user,host) cursor.execute(query) query = "REVOKE GRANT OPTION ON %s FROM '%s'@'%s'" % (db_table,user,host) - cursor.execute(query) + try: + cursor.execute(query) + except MySQLdb.OperationalError, e: + # 1141 -> There is no such grant defined for user ... on host ... + # If this exception is raised, there is no need to revoke the GRANT privilege + if e.args[0] != 1141 or not e.args[1].startswith("There is no such grant defined for user"): + raise e def privileges_grant(cursor, user,host,db_table,priv):