@@ -23,10 +23,10 @@ def self.instances
23
23
# rubocop:enable Layout/LineLength
24
24
@max_user_connections , @max_connections_per_hour , @max_queries_per_hour , @max_updates_per_hour , ssl_type , ssl_cipher ,
25
25
x509_issuer , x509_subject , @password , @plugin , @authentication_string = mysql_caller ( query , 'regular' ) . chomp . split ( %r{\t } )
26
-
26
+
27
27
if @plugin == 'caching_sha2_password'
28
28
# Escaping all single quotes to prevent errors when password generated it
29
- @password = @password . gsub ( "'" ) { "\\ '" }
29
+ @password = @password . gsub ( "'" ) { "\\ '" }
30
30
@password = mysql_caller ( "SELECT CONCAT('0x',HEX('#{ @password } '))" , 'regular' ) . chomp
31
31
end
32
32
@@ -83,7 +83,7 @@ def create
83
83
if !plugin . nil?
84
84
if password_hash . nil?
85
85
self . class . mysql_caller ( "CREATE USER '#{ merged_name } ' IDENTIFIED WITH '#{ plugin } '" , 'system' )
86
- elsif plugin . eql? " caching_sha2_password"
86
+ elsif plugin . eql? ' caching_sha2_password'
87
87
self . class . mysql_caller ( "CREATE USER '#{ merged_name } ' IDENTIFIED WITH '#{ plugin } ' AS X'#{ password_hash [ 2 ..-1 ] } '" , 'system' )
88
88
else
89
89
self . class . mysql_caller ( "CREATE USER '#{ merged_name } ' IDENTIFIED WITH '#{ plugin } ' AS '#{ password_hash } '" , 'system' )
@@ -168,12 +168,14 @@ def password_hash=(string)
168
168
end
169
169
self . class . mysql_caller ( sql , 'system' )
170
170
elsif !mysqld_version . nil? && newer_than ( 'mysql' => '5.7.6' , 'percona' => '5.7.6' , 'mariadb' => '10.2.0' )
171
- raise ArgumentError , _ ( 'Only mysql_native_password (*ABCD...XXX) or caching_sha2_password (0x1234ABC...XXX) hashes are supported.' ) unless %r{^\* |^$} . match? ( string ) || %r{0x[A-F0-9]+$} . match? ( string )
171
+ raise ArgumentError , _ ( 'Only mysql_native_password (*ABCD...XXX) or caching_sha2_password (0x1234ABC...XXX) hashes are supported.' ) unless
172
+ %r{^\* |^$} . match? ( string ) || %r{0x[A-F0-9]+$} . match? ( string )
173
+
172
174
sql = "ALTER USER #{ merged_name } IDENTIFIED WITH"
173
175
if plugin == 'caching_sha2_password'
174
- sql += " 'caching_sha2_password' AS X'#{ string [ 2 ..-1 ] } '"
176
+ sql << " 'caching_sha2_password' AS X'#{ string [ 2 ..-1 ] } '"
175
177
else
176
- sql += " 'mysql_native_password' AS '#{ string } '"
178
+ sql << " 'mysql_native_password' AS '#{ string } '"
177
179
end
178
180
self . class . mysql_caller ( sql , 'system' )
179
181
else
0 commit comments