mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 07:31:23 -07:00
Fix bad merge
This commit is contained in:
parent
288a5c9a77
commit
47d0719cfe
1 changed files with 20 additions and 25 deletions
|
@ -249,34 +249,29 @@ def user_mod(cursor, user, host, password, encrypted, new_priv, append_privs):
|
||||||
if old_user_mgmt:
|
if old_user_mgmt:
|
||||||
cursor.execute("SET PASSWORD FOR %s@%s = %s", (user, host, password))
|
cursor.execute("SET PASSWORD FOR %s@%s = %s", (user, host, password))
|
||||||
else:
|
else:
|
||||||
cursor.execute("ALTER USER %s@%s IDENTIFIED WITH mysql_native_password AS %s", (user, host, password))
|
cursor.execute("ALTER USER %s@%s IDENTIFIED BY %s", (user, host, password))
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
|
||||||
module.fail_json(msg="encrypted was specified however it does not appear to be a valid hash expecting: *SHA1(SHA1(your_password))")
|
# Handle privileges
|
||||||
else:
|
if new_priv is not None:
|
||||||
if old_user_mgmt:
|
curr_priv = privileges_get(cursor, user,host)
|
||||||
cursor.execute("SELECT PASSWORD(%s)", (password,))
|
|
||||||
else:
|
|
||||||
cursor.execute("SELECT CONCAT('*', UCASE(SHA1(UNHEX(SHA1(%s)))))", (password,))
|
|
||||||
new_pass_hash = cursor.fetchone()
|
|
||||||
if current_pass_hash[0] != new_pass_hash[0]:
|
|
||||||
cursor.execute("SET PASSWORD FOR %s@%s = PASSWORD(%s)", (user,host,password))
|
|
||||||
changed = True
|
|
||||||
|
|
||||||
|
# If the user has privileges on a db.table that doesn't appear at all in
|
||||||
|
# the new specification, then revoke all privileges on it.
|
||||||
|
for db_table, priv in curr_priv.iteritems():
|
||||||
|
# If the user has the GRANT OPTION on a db.table, revoke it first.
|
||||||
|
if "GRANT" in priv:
|
||||||
|
grant_option = True
|
||||||
|
if db_table not in new_priv:
|
||||||
|
if user != "root" and "PROXY" not in priv and not append_privs:
|
||||||
|
privileges_revoke(cursor, user,host,db_table,priv,grant_option)
|
||||||
|
changed = True
|
||||||
|
|
||||||
# Handle privileges
|
# If the user doesn't currently have any privileges on a db.table, then
|
||||||
if new_priv is not None:
|
# we can perform a straight grant operation.
|
||||||
curr_priv = privileges_get(cursor, user,host)
|
for db_table, priv in new_priv.iteritems():
|
||||||
|
if db_table not in curr_priv:
|
||||||
# If the user has privileges on a db.table that doesn't appear at all in
|
privileges_grant(cursor, user,host,db_table,priv)
|
||||||
# the new specification, then revoke all privileges on it.
|
|
||||||
for db_table, priv in curr_priv.iteritems():
|
|
||||||
# If the user has the GRANT OPTION on a db.table, revoke it first.
|
|
||||||
if "GRANT" in priv:
|
|
||||||
grant_option = True
|
|
||||||
if db_table not in new_priv:
|
|
||||||
if user != "root" and "PROXY" not in priv and not append_privs:
|
|
||||||
privileges_revoke(cursor, user,host,db_table,priv,grant_option)
|
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
# If the db.table specification exists in both the user's current privileges
|
# If the db.table specification exists in both the user's current privileges
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue