Skip to content

Commit

Permalink
mysql_user: handle unnecessary GRANT revocation
Browse files Browse the repository at this point in the history
  • Loading branch information
tyll committed Feb 22, 2013
1 parent 813d233 commit cc8fbe3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/mysql_user
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit cc8fbe3

Please sign in to comment.