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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
# Checking if perl Expect module is installed on the system.
# If not, the test will be skipped.
--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';
call mtr.add_suppression("Dictionary file not specified");
SET PASSWORD for root@localhost = '';
# The execution of mysql_secure_installation using perl which uses the
# Expect module as mysql_secure_installation is user interactive.
--perl
use strict;
require Expect;
# Declaring variables for 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(15,' -re ',[ 'Remove anonymous users?' => sub {
$texp[$i]->send("n\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Disallow root login remotely?' => sub {
$texp[$i]->send("n\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Remove test database and access to it?' => sub {
$texp[$i]->send("n\n");}]);
$texp[$i]->expect(15,' -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);
}
# 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(15,' -re ',[ 'Remove anonymous users?' => sub {
$texp[$i]->send("y\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Disallow root login remotely?' => sub {
$texp[$i]->send("y\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Remove test database and access to it?' => sub {
$texp[$i]->send("y\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Reload privilege tables now?' => sub { $texp[$i]->send("y\n");}]);
print "Execution number $i was successful\n";
}
$i = 1;
# Invoking mysql_secure_installation.
initial_commands();
if (-e $ENV{MASTER_MYSOCK} ){
$texp[$i]->spawn("$ENV{MYSQL_SECURE_INSTALLATION} -S $ENV{MASTER_MYSOCK }");
}
$texp[$i]->expect(15,' -re ',[ 'any other key for No' => sub {
$texp[$i]->send("n\n");}]);
$texp[$i]->expect(15,' -re ',[ 'New password' => sub {
$texp[$i]->send("1\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Re-enter' => sub { $texp[$i]->send("1\n");}]);
after_commands();
$i++;
# Invoking mysql_secure_installation with different password values.
initial_commands();
if (-e $ENV{MASTER_MYSOCK} ){
$texp[$i]->spawn("$ENV{MYSQL_SECURE_INSTALLATION} -S $ENV{MASTER_MYSOCK } -p");
}
$texp[$i]->expect(15,' -re ',[ 'password' => sub {
$texp[$i]->send("1\n");}]);
$texp[$i]->expect(15,' -re ',[ 'any other key for No' => sub {
$texp[$i]->send("n\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Change the password for root' => sub {
$texp[$i]->send("y\n");}]);
$texp[$i]->expect(15,' -re ',[ 'New password' => sub {
$texp[$i]->send("null\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Re-enter' => sub { $texp[$i]->send("null\n");}]);
after_effects();
$i++;
# Invoking mysql_secure_installation and installing the validate_password plugin.
initial_commands();
if (-e $ENV{MASTER_MYSOCK} ){
$texp[$i]->spawn("$ENV{MYSQL_SECURE_INSTALLATION} -S $ENV{MASTER_MYSOCK } -p");
}
$texp[$i]->expect(15,' -re ',[ 'password' => sub {
$texp[$i]->send("null\n");}]);
$texp[$i]->expect(15,' -re ',[ 'any other key for No' => sub {
$texp[$i]->send("y\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Please enter' => sub {
$texp[$i]->send("1\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Change the password for root' => sub {
$texp[$i]->send("y\n");}]);
$texp[$i]->expect(15,' -re ',[ 'New password' => sub {
$texp[$i]->send("passPASS1234!@#\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Re-enter' => sub {
$texp[$i]->send("passPASS1234!@#\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Do you' => sub { $texp[$i]->send("y\n");}]);
after_effects();
$i++;
initial_commands();
if (-e $ENV{MASTER_MYSOCK} ){
$texp[$i]->spawn("$ENV{MYSQL_SECURE_INSTALLATION} -S $ENV{MASTER_MYSOCK } -p");
}
$texp[$i]->expect(15,' -re ',[ 'password' => sub {
$texp[$i]->send("passPASS1234!@#\n");}]);
$texp[$i]->expect(15,' -re ',[ 'any other key for No' => sub {
$texp[$i]->send("y\n");}]);
$texp[$i]->expect(15,' -re ',[ 'New password' => sub {
$texp[$i]->send("secure\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Re-enter new password' => sub {
$texp[$i]->send("secure\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Do you' => sub { $texp[$i]->send("y\n");}]);
$texp[$i]->expect(15,' -re ',[ 'New password' => sub {
$texp[$i]->send("secureINSTALL09#)(\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Re-enter new password' => sub {
$texp[$i]->send("secureINSTALL09#)(\n");}]);
$texp[$i]->expect(15,' -re ',[ 'Do you' => sub { $texp[$i]->send("y\n");}]);
after_effects();
$i++;
initial_commands();
if (-e $ENV{MASTER_MYSOCK} ){
$texp[$i]->spawn("$ENV{MYSQL_SECURE_INSTALLATION} -S $ENV{MASTER_MYSOCK } -D -p");
}
$texp[$i]->expect(15,' -re ',[ 'password' => sub {
$texp[$i]->send("secureINSTALL09#)(\n");}]);
print("Execution ".$i." was successful\n");
$i++;
EOF
# Uninstalling validate_password plugin
UNINSTALL COMPONENT "file://component_validate_password";
# Restoring the server to the state prior to this test.
SET PASSWORD for root@localhost = '';
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');
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;
|