mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-27 16:31:47 -07:00
Fix: do not revoke GRANT permission when it's already allowed and present in priv parameter
This commit is contained in:
parent
3ae3e30ed6
commit
d8ac050bac
1 changed files with 10 additions and 1 deletions
|
@ -359,9 +359,18 @@ def user_mod(cursor, user, host, host_all, password, encrypted,
|
||||||
revoke_privs = list(set(new_priv[db_table]) & set(curr_priv[db_table]))
|
revoke_privs = list(set(new_priv[db_table]) & set(curr_priv[db_table]))
|
||||||
else:
|
else:
|
||||||
# When replacing (neither append_privs nor subtract_privs), grant all missing privileges
|
# When replacing (neither append_privs nor subtract_privs), grant all missing privileges
|
||||||
# and revoke existing privileges that were not requested.
|
# and revoke existing privileges that were not requested...
|
||||||
grant_privs = list(set(new_priv[db_table]) - set(curr_priv[db_table]))
|
grant_privs = list(set(new_priv[db_table]) - set(curr_priv[db_table]))
|
||||||
revoke_privs = list(set(curr_priv[db_table]) - set(new_priv[db_table]))
|
revoke_privs = list(set(curr_priv[db_table]) - set(new_priv[db_table]))
|
||||||
|
|
||||||
|
# ... but do not revoke GRANT option when it's already allowed
|
||||||
|
# and already in privs.
|
||||||
|
#
|
||||||
|
# For more details
|
||||||
|
# https://github.com/ansible-collections/community.mysql/issues/77#issuecomment-1209693807
|
||||||
|
if 'GRANT' in new_priv[db_table] and 'GRANT' in curr_priv[db_table]:
|
||||||
|
grant_privs.append('GRANT')
|
||||||
|
|
||||||
if grant_privs == ['GRANT']:
|
if grant_privs == ['GRANT']:
|
||||||
# USAGE grants no privileges, it is only needed because 'WITH GRANT OPTION' cannot stand alone
|
# USAGE grants no privileges, it is only needed because 'WITH GRANT OPTION' cannot stand alone
|
||||||
grant_privs.append('USAGE')
|
grant_privs.append('USAGE')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue