Skip to content

Commit

Permalink
Merge pull request #55655 from M2Mobi/mariadb_password_hash
Browse files Browse the repository at this point in the history
Fix using password hashes with MariaDB
  • Loading branch information
dwoz authored Dec 16, 2019
2 parents 28d8052 + e14a510 commit b0fb791
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions salt/modules/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,10 @@ def user_create(user,
args['password'] = six.text_type(password)
elif password_hash is not None:
if salt.utils.versions.version_cmp(server_version, compare_version) >= 0:
qry += ' IDENTIFIED BY %(password)s'
if 'MariaDB' in server_version:
qry += ' IDENTIFIED BY PASSWORD %(password)s'
else:
qry += ' IDENTIFIED BY %(password)s'
else:
qry += ' IDENTIFIED BY PASSWORD %(password)s'
args['password'] = password_hash
Expand Down Expand Up @@ -1552,7 +1555,10 @@ def user_chpass(user,
args['user'] = user
args['host'] = host
if salt.utils.versions.version_cmp(server_version, compare_version) >= 0:
qry = "ALTER USER %(user)s@%(host)s IDENTIFIED BY %(password)s;"
if 'MariaDB' in server_version and password_hash is not None:
qry = "ALTER USER %(user)s@%(host)s IDENTIFIED BY PASSWORD %(password)s;"
else:
qry = "ALTER USER %(user)s@%(host)s IDENTIFIED BY %(password)s;"
else:
qry = ('UPDATE mysql.user SET ' + password_column + '=' + password_sql +
' WHERE User=%(user)s AND Host = %(host)s;')
Expand Down

0 comments on commit b0fb791

Please sign in to comment.