Fix fetching the mysql_user password for MySQL >=5.7.6
The password column has been renamed to authentication_string in MySQL >=5.7.6. By using: SELECT /*!50706 AUTHENTICATION_STRING AS */ PASSWORD the query will continue to work in older versions as well as newer ones.
This commit is contained in:
parent
1823c7cd64
commit
afddc3ff7b
2 changed files with 3 additions and 3 deletions
|
@ -12,7 +12,7 @@ Puppet::Type.type(:mysql_user).provide(:mysql, :parent => Puppet::Provider::Mysq
|
|||
# To reduce the number of calls to MySQL we collect all the properties in
|
||||
# one big swoop.
|
||||
users.collect do |name|
|
||||
query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'"
|
||||
query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, /*!50706 AUTHENTICATION_STRING AS */ PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'"
|
||||
@max_user_connections, @max_connections_per_hour, @max_queries_per_hour,
|
||||
@max_updates_per_hour, @password, @plugin = mysql([defaults_file, "-NBe", query].compact).split(/\s/)
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ usvn_user@localhost
|
|||
Puppet::Util.stubs(:which).with('mysql').returns('/usr/bin/mysql')
|
||||
File.stubs(:file?).with('/root/.my.cnf').returns(true)
|
||||
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns('joe@localhost')
|
||||
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = 'joe@localhost'"]).returns('10 10 10 10 *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4')
|
||||
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, /*!50706 AUTHENTICATION_STRING AS */ PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = 'joe@localhost'"]).returns('10 10 10 10 *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4')
|
||||
end
|
||||
|
||||
let(:instance) { provider.class.instances.first }
|
||||
|
@ -47,7 +47,7 @@ usvn_user@localhost
|
|||
it 'returns an array of users' do
|
||||
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users)
|
||||
parsed_users.each do |user|
|
||||
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ')
|
||||
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, /*!50706 AUTHENTICATION_STRING AS */ PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ')
|
||||
end
|
||||
|
||||
usernames = provider.class.instances.collect {|x| x.name }
|
||||
|
|
Loading…
Reference in a new issue