| 1 |
--source include/have_expect.inc |
| 2 |
--source include/not_windows.inc |
| 3 |
--source include/have_validate_password_component.inc |
| 4 |
|
| 5 |
SELECT plugin into @plugin from mysql.user where user= 'root' and host='localhost'; |
| 6 |
SELECT password_last_changed into @plc from mysql.user where user= 'root' and host='localhost'; |
| 7 |
SELECT authentication_string into @auth_str from mysql.user where user= 'root' and host='localhost'; |
| 8 |
SELECT user_attributes into @user_attrib from mysql.user where user='root' and host='localhost'; |
| 9 |
SELECT plugin into @sys_plugin from mysql.user where user= 'mysql.sys' and host='localhost'; |
| 10 |
SELECT password_last_changed into @sys_plc from mysql.user where user= 'mysql.sys' and host='localhost'; |
| 11 |
SELECT authentication_string into @sys_auth_str from mysql.user where user= 'mysql.sys' and host='localhost'; |
| 12 |
update mysql.user set plugin= 'sha256_password', authentication_string= '' where user='root' and host='localhost'; |
| 13 |
FLUSH PRIVILEGES; |
| 14 |
SET PASSWORD='123'; |
| 15 |
call mtr.add_suppression("Dictionary file not specified"); |
| 16 |
--perl |
| 17 |
|
| 18 |
# Checking if perl Expect module is installed on the system. |
| 19 |
# If not, the test will be skipped. |
| 20 |
die "Please install the Expect module ." unless(eval{require Expect}); |
| 21 |
|
| 22 |
use strict; |
| 23 |
require Expect; |
| 24 |
|
| 25 |
my @texp; |
| 26 |
my $i; |
| 27 |
|
| 28 |
# Aggregating the commands which are executed post the password is input to |
| 29 |
# mysql_secure_installation into a function with the values no. |
| 30 |
sub after_commands() |
| 31 |
{ |
| 32 |
$texp[$i]->expect(5,' -re ',[ 'any other key for No' => sub { |
| 33 |
$texp[$i]->send("n\n");}]); |
| 34 |
$texp[$i]->expect(5,' -re ',[ 'any other key for No' => sub { |
| 35 |
$texp[$i]->send("n\n");}]); |
| 36 |
$texp[$i]->expect(5,' -re ',[ 'Remove anonymous users?' => sub { |
| 37 |
$texp[$i]->send("n\n");}]); |
| 38 |
$texp[$i]->expect(5,' -re ',[ 'Disallow root login remotely?' => sub { |
| 39 |
$texp[$i]->send("n\n");}]); |
| 40 |
$texp[$i]->expect(5,' -re ',[ 'Remove test database and access to it?' => sub { |
| 41 |
$texp[$i]->send("n\n");}]); |
| 42 |
$texp[$i]->expect(5,' -re ',[ 'Reload privilege tables now?' => sub { $texp[$i]->send("n\n");}]); |
| 43 |
print "Execution number $i was successful\n"; |
| 44 |
} |
| 45 |
|
| 46 |
# Defining a new Expect object and invoking mysql_secure_installation |
| 47 |
sub initial_commands() |
| 48 |
{ |
| 49 |
$texp[$i] = new Expect(); |
| 50 |
$texp[$i]->raw_pty(1); |
| 51 |
$texp[$i]->spawn("$ENV{MYSQL_SECURE_INSTALLATION} -S $ENV{MASTER_MYSOCK} --password='123' --ssl-ca=$ENV{MYSQL_TEST_DIR}/std_data/ca-sha512.pem --ssl-mode=VERIFY_CA"); |
| 52 |
} |
| 53 |
|
| 54 |
# Aggregating the commands which are executed post the password is input to |
| 55 |
# mysql_secure_installation into a function with the values yes. |
| 56 |
sub after_effects() |
| 57 |
{ |
| 58 |
$texp[$i]->expect(5,' -re ',[ 'any other key for No' => sub { |
| 59 |
$texp[$i]->send("y\n");}]); |
| 60 |
$texp[$i]->expect(5,' -re ',[ 'MEDIUM and 2 = STRONG' => sub { |
| 61 |
$texp[$i]->send("2\n");}]); |
| 62 |
$texp[$i]->expect(5,' -re ',[ 'any other key for No' => sub { |
| 63 |
$texp[$i]->send("y\n");}]); |
| 64 |
$texp[$i]->expect(5,' -re ',[ 'password' => sub { |
| 65 |
$texp[$i]->send("Vamsi#1234#\n");}]); |
| 66 |
$texp[$i]->expect(5,' -re ',[ 'password' => sub { |
| 67 |
$texp[$i]->send("Vamsi#1234#\n");}]); |
| 68 |
$texp[$i]->expect(5,' -re ',[ 'any other key for No' => sub { |
| 69 |
$texp[$i]->send("y\n");}]); |
| 70 |
$texp[$i]->expect(5,' -re ',[ 'Remove anonymous users?' => sub { |
| 71 |
$texp[$i]->send("y\n");}]); |
| 72 |
$texp[$i]->expect(5,' -re ',[ 'Disallow root login remotely?' => sub { |
| 73 |
$texp[$i]->send("y\n");}]); |
| 74 |
$texp[$i]->expect(5,' -re ',[ 'Remove test database and access to it?' => sub { |
| 75 |
$texp[$i]->send("y\n");}]); |
| 76 |
$texp[$i]->expect(5,' -re ',[ 'Reload privilege tables now?' => sub { $texp[$i]->send("y\n");}]); |
| 77 |
} |
| 78 |
|
| 79 |
$i = 1; |
| 80 |
initial_commands(); |
| 81 |
after_commands(); |
| 82 |
$i++; |
| 83 |
|
| 84 |
initial_commands(); |
| 85 |
after_effects(); |
| 86 |
|
| 87 |
$texp[$i]->soft_close(); |
| 88 |
|
| 89 |
EOF |
| 90 |
CREATE DATABASE test; |
| 91 |
REPLACE INTO mysql.user VALUES ('localhost','root','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'mysql_native_password','','N',NULL,NULL,'N','Y','Y', NULL, NULL,NULL,NULL); |
| 92 |
REPLACE INTO mysql.user VALUES ('localhost','mysql.sys','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0,0,'mysql_native_password','*THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE','N',NULL,NULL,'Y','N','N', NULL, NULL,NULL,NULL); |
| 93 |
INSERT INTO mysql.db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y'); |
| 94 |
UNINSTALL COMPONENT "file://component_validate_password"; |
| 95 |
UPDATE mysql.user SET password_last_changed=@plc, authentication_string=@auth_str, plugin= @plugin, user_attributes=@user_attrib where user='root'; |
| 96 |
UPDATE mysql.user SET password_last_changed=@sys_plc, authentication_string=@sys_auth_str, plugin= @sys_plugin where user='mysql.sys'; |
| 97 |
FLUSH PRIVILEGES; |