mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge branch '2018.3.4' into fix_test_win_dns_client
This commit is contained in:
commit
c9f6b019cb
@ -1533,28 +1533,23 @@ def user_chpass(user,
|
|||||||
password_column = __password_column(**connection_args)
|
password_column = __password_column(**connection_args)
|
||||||
|
|
||||||
cur = dbc.cursor()
|
cur = dbc.cursor()
|
||||||
if salt.utils.versions.version_cmp(server_version, '8.0.11') >= 0:
|
|
||||||
qry = ("ALTER USER '" + user + "'@'" + host + "'"
|
|
||||||
" IDENTIFIED BY '" + password + "';")
|
|
||||||
args = {}
|
|
||||||
else:
|
|
||||||
qry = ('UPDATE mysql.user SET ' + password_column + '='
|
|
||||||
+ password_sql +
|
|
||||||
' WHERE User=%(user)s AND Host = %(host)s;')
|
|
||||||
args['user'] = user
|
args['user'] = user
|
||||||
args['host'] = host
|
args['host'] = host
|
||||||
|
if salt.utils.versions.version_cmp(server_version, '8.0.11') >= 0:
|
||||||
|
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;')
|
||||||
if salt.utils.data.is_true(allow_passwordless) and \
|
if salt.utils.data.is_true(allow_passwordless) and \
|
||||||
salt.utils.data.is_true(unix_socket):
|
salt.utils.data.is_true(unix_socket):
|
||||||
if host == 'localhost':
|
if host == 'localhost':
|
||||||
|
args['unix_socket'] = 'auth_socket'
|
||||||
if salt.utils.versions.version_cmp(server_version, '8.0.11') >= 0:
|
if salt.utils.versions.version_cmp(server_version, '8.0.11') >= 0:
|
||||||
qry = ("ALTER USER '" + user + "'@'" + host + "'"
|
qry = "ALTER USER %(user)s@%(host)s IDENTIFIED WITH %(unix_socket)s AS %(user)s;"
|
||||||
" IDENTIFIED BY '" + password + "';")
|
|
||||||
args = {}
|
|
||||||
else:
|
else:
|
||||||
qry = ('UPDATE mysql.user SET ' + password_column + '='
|
qry = ('UPDATE mysql.user SET ' + password_column + '='
|
||||||
+ password_sql + ', plugin=%(unix_socket)s' +
|
+ password_sql + ', plugin=%(unix_socket)s' +
|
||||||
' WHERE User=%(user)s AND Host = %(host)s;')
|
' WHERE User=%(user)s AND Host = %(host)s;')
|
||||||
args['unix_socket'] = 'unix_socket'
|
|
||||||
else:
|
else:
|
||||||
log.error('Auth via unix_socket can be set only for host=localhost')
|
log.error('Auth via unix_socket can be set only for host=localhost')
|
||||||
try:
|
try:
|
||||||
|
@ -187,7 +187,11 @@ class MySQLTestCase(TestCase, LoaderModuleMockMixin):
|
|||||||
mysql.user_chpass('testuser', password='BLUECOW')
|
mysql.user_chpass('testuser', password='BLUECOW')
|
||||||
calls = (
|
calls = (
|
||||||
call().cursor().execute(
|
call().cursor().execute(
|
||||||
"ALTER USER 'testuser'@'localhost' IDENTIFIED BY 'BLUECOW';"
|
"ALTER USER %(user)s@%(host)s IDENTIFIED BY %(password)s;",
|
||||||
|
{'password': 'BLUECOW',
|
||||||
|
'user': 'testuser',
|
||||||
|
'host': 'localhost',
|
||||||
|
}
|
||||||
),
|
),
|
||||||
call().cursor().execute('FLUSH PRIVILEGES;'),
|
call().cursor().execute('FLUSH PRIVILEGES;'),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user