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