-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mysql_user: fix compatibility issues with various MySQL/MariaDB versions #45355
mysql_user: fix compatibility issues with various MySQL/MariaDB versions #45355
Conversation
This comment has been minimized.
This comment has been minimized.
... still working on a fix |
@ansibot WIP |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
402ca8c
to
cebf2f6
Compare
The test
|
…ties to add YML extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I assume you have tested this with newer and older versions of both MariaDB and MySQL :)
WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'user' AND COLUMN_NAME IN ('Password', 'authentication_string') | ||
ORDER BY COLUMN_NAME ASC LIMIT 1 | ||
""") | ||
colB = cursor.fetchone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not select both columns in one query (without the LIMIT
) and fill colA
and colB
in module code? This will save one query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a trick to get an ordered list of valid columns to use in the next queries.
It's a way of getting the right list without using tons of if
conditions which may be error prone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also work:
cursor.execute("""
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'user' AND COLUMN_NAME IN ('Password', 'authentication_string')
""")
cols = sorted([row[0] for row in cursor.fetchall()])
colA, colB = cols[0], cols[-1]
(no idea if fetchall()
exists and works like this, but I guess there will be some method which fetches more than one row?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can still change that later (once this is merged) if you want.
Yes, definitely, as well as other contributors in various environments. |
Great work everybody on this. |
Finally we get it merged ! |
SUMMARY
To handle properly user management, version check needed refactoring, as well as the query used to get existing password hash.
Fixes #44441
Fixes #43361
Fixes #43255
Fixes #42564
Possibly fixes #40091
Possibly fixes #29625
Fixes #29615
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
mysql_user
ANSIBLE VERSION
ADDITIONAL INFORMATION
Module wasn't able to handle properly MariaDB 10.3 as well as edge cases (mixed situations with user table including users with new style and users with old style).
It's now able to:
The module now handles properly idempotence and was tested successfully against
Debian 9.5
withMariaDB 10.3.9
.