From 4d1e21bf18e2171549156dd78845a22ba4bdb5fa Mon Sep 17 00:00:00 2001 From: Roman Haefeli Date: Fri, 24 Jan 2020 19:32:15 +0100 Subject: [PATCH] mysql_user: make sure current_pass_hash is a string before using it in comparison (#64059) * make sure current_pass_hash is a string before using it in comparison * add changelogs/fragments file * fix changelogs/fragments file: it is actually a bugfix, not a minor change --- .../fragments/64059-mysql_user_fix_password_comparison.yaml | 2 ++ lib/ansible/modules/database/mysql/mysql_user.py | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/64059-mysql_user_fix_password_comparison.yaml diff --git a/changelogs/fragments/64059-mysql_user_fix_password_comparison.yaml b/changelogs/fragments/64059-mysql_user_fix_password_comparison.yaml new file mode 100644 index 00000000000..50fd48ff980 --- /dev/null +++ b/changelogs/fragments/64059-mysql_user_fix_password_comparison.yaml @@ -0,0 +1,2 @@ +bugfixes: +- mysql_user - make sure current_pass_hash is a string before using it in comparison (https://github.com/ansible/ansible/issues/60567). diff --git a/lib/ansible/modules/database/mysql/mysql_user.py b/lib/ansible/modules/database/mysql/mysql_user.py index 1ca59940718..f999abb74ae 100644 --- a/lib/ansible/modules/database/mysql/mysql_user.py +++ b/lib/ansible/modules/database/mysql/mysql_user.py @@ -390,6 +390,8 @@ def user_mod(cursor, user, host, host_all, password, encrypted, FROM mysql.user WHERE user = %%s AND host = %%s """ % (colA[0], colA[0], colB[0], colB[0]), (user, host)) current_pass_hash = cursor.fetchone()[0] + if isinstance(current_pass_hash, bytes): + current_pass_hash = current_pass_hash.decode('ascii') if encrypted: encrypted_password = password