Skip to content
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

addressing #29265 #30603

Merged
merged 3 commits into from
Jan 25, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions salt/modules/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ def user_exists(user,
password_hash=None,
passwordless=False,
unix_socket=False,
password_column='Password',
**connection_args):
'''
Checks if a user exists on the MySQL server. A login can be checked to see
Expand All @@ -1098,6 +1099,7 @@ def user_exists(user,
salt '*' mysql.user_exists 'username' 'hostname' 'password'
salt '*' mysql.user_exists 'username' 'hostname' password_hash='hash'
salt '*' mysql.user_exists 'username' passwordless=True
salt '*' mysql.user_exists 'username' password_column='authentication_string'
'''
dbc = _connect(**connection_args)
# Did we fail to connect with the user we are checking
Expand Down Expand Up @@ -1125,12 +1127,12 @@ def user_exists(user,
qry += ' AND plugin=%(unix_socket)s'
args['unix_socket'] = 'unix_socket'
else:
qry += ' AND Password = \'\''
qry += ' AND ' + password_column + ' = \'\''
elif password:
qry += ' AND Password = PASSWORD(%(password)s)'
qry += ' AND ' + password_column + ' = PASSWORD(%(password)s)'
args['password'] = str(password)
elif password_hash:
qry += ' AND Password = %(password)s'
qry += ' AND ' + password_column + ' = %(password)s'
args['password'] = password_hash

try:
Expand Down