Skip to content

Commit 9d1bb5f

Browse files
committed
call ruby instead of mysql to generate hex string and replace regex with more explicit one
1 parent 20f6fa1 commit 9d1bb5f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/puppet/functions/mysql/password.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
def password(password, sensitive = false)
2323
password = password.unwrap if password.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
2424

25-
result_string = if %r{\*[A-F0-9]{40}$}.match?(password) || %r{0x[A-F0-9]+$}.match?(password)
25+
result_string = if %r{\*[A-F0-9]{40}$}.match?(password) || %r{0x24412430303524[A-F0-9]{63}$}.match?(password)
2626
password
2727
elsif password.empty?
2828
''

lib/puppet/provider/mysql_user/mysql.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.instances
2727
if @plugin == 'caching_sha2_password'
2828
# Escaping all single quotes to prevent errors when password generated it
2929
@password = @password.gsub("'") { "\\'" }
30-
@password = mysql_caller("SELECT CONCAT('0x',HEX('#{@password}'))", 'regular').chomp
30+
@password = '0x' + @password.each_byte.map { |b| b.to_s(16) }.join
3131
end
3232

3333
@tls_options = parse_tls_options(ssl_type, ssl_cipher, x509_issuer, x509_subject)

0 commit comments

Comments
 (0)