Server IP : 104.21.38.3 / Your IP : 162.158.88.150 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/server/mysql/src/mysql-test/suite/interactive_utilities/t/ |
Upload File : |
# 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_embedded.inc --source include/not_windows.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 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 PLUGIN validate_password; # Restoring the server to the state prior to this test. SET PASSWORD for root@localhost = ''; CREATE DATABASE test; INSERT INTO mysql.user SELECT LOWER(@@hostname),'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'; 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'); REPLACE INTO mysql.user VALUES ('127.0.0.1','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'); REPLACE INTO mysql.user VALUES ('::1','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'); 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'); 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'); 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 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;