Fix revoke only grant (#503)

* fix

* test

* changelog
This commit is contained in:
Markus Bergholz 2023-02-08 09:24:35 +01:00 committed by GitHub
parent 521443a671
commit b34c23d07d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 9 deletions

View file

@ -692,17 +692,19 @@ def privileges_revoke(cursor, user, host, db_table, priv, grant_option, maria_ro
query = ' '.join(query)
cursor.execute(query, (user, host))
priv_string = ",".join([p for p in priv if p not in ('GRANT', )])
query = ["REVOKE %s ON %s" % (priv_string, db_table)]
if not maria_role:
query.append("FROM %s@%s")
params = (user, host)
else:
query.append("FROM %s")
params = (user,)
if priv_string != "":
query = ["REVOKE %s ON %s" % (priv_string, db_table)]
query = ' '.join(query)
cursor.execute(query, params)
if not maria_role:
query.append("FROM %s@%s")
params = (user, host)
else:
query.append("FROM %s")
params = (user,)
query = ' '.join(query)
cursor.execute(query, params)
cursor.execute("FLUSH PRIVILEGES")