source include/have_ndb.inc; # Use $MYSQLTEST_VARDIR for temporary password files since that is allowed for # SELECT INTO DUMPFILE by secure-file-priv. let $NDB_PASSWORD_DIR = $MYSQLTEST_VARDIR/tmp; --echo # backup_password.txt will contain password and os dependent line ending. exec echo TOPSECRET > $NDB_PASSWORD_DIR/backup_password.txt; let $NDB_SAVED_BACKUPS = $MYSQL_TEST_DIR/suite/ndb/backups; --echo --echo # --decrypt-password=SECRET will not be used since input file is not --echo # encrypted, but will cause warning. --echo # Command will create a file encrypted with password from stdin without --echo # line ending. exec $NDBXFRM 2>&1 --decrypt-password=SECRET --encrypt-password-from-stdin < $NDB_PASSWORD_DIR/backup_password.txt $NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1.1.ctl $MYSQL_TMP_DIR/BACKUP-1.1.ctl; --echo --echo # Encrypt also a backup data file - to be able to do restore later --echo # With same password given in different way, also compress just for --echo # some variation, will show up in ndbxfrm --info later. exec $NDBXFRM 2>&1 --decrypt-password=SECRET --compress --encrypt-password=TOPSECRET $NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1-0.1.Data $MYSQL_TMP_DIR/BACKUP-1-0.1.Data; --echo --echo # Encrypt also a backup log file - to be able to do restore later exec $NDBXFRM 2>&1 --encrypt-password-from-stdin < $NDB_PASSWORD_DIR/backup_password.txt $NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1.1.log $MYSQL_TMP_DIR/BACKUP-1.1.log; --echo --echo # Check that new files are encrypted, and old files are not. --echo # One can note that of the new files only data file is compressed. --echo # Later restore will handle both compressed and uncompressed files. replace_result $NDB_SAVED_BACKUPS NDB_SAVED_BACKUPS $MYSQL_TMP_DIR MYSQL_TMP_DIR ; exec $NDBXFRM 2>&1 --info $NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1.1.ctl $NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1-0.1.Data $NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1.1.log $MYSQL_TMP_DIR/BACKUP-1.1.ctl $MYSQL_TMP_DIR/BACKUP-1-0.1.Data $MYSQL_TMP_DIR/BACKUP-1.1.log; --echo --echo # Verify that ndb_print_backup_file can decrypt file using the TOPSECRET --echo # password, given on command line to ensure no line ending. This also --echo # verifies that reading password from stdin do not include the line --echo # endings in password. exec $NDB_PRINT_BACKUP_FILE 2>&1 >> $NDB_TOOLS_OUTPUT --backup-password=TOPSECRET $MYSQL_TMP_DIR/BACKUP-1.1.ctl; --echo --echo # Do restore using the new encrypted files. --echo # extra_encrypted_backup.cnf specifies backup-password for ndb_restore, --echo # need to skip that for --backup-password not conflict with --echo # --backup-password-from-stdin. exec $NDB_RESTORE >> $NDB_TOOLS_OUTPUT --decrypt --backup-password-from-stdin < $NDB_PASSWORD_DIR/backup_password.txt --skip-backup-password --restore-meta --restore-data --nodeid=1 --backupid=1 $MYSQL_TMP_DIR/; --echo # Trigger sync of created logfile group, tablespace, and, tables to be --echo # recognized by MySQL server. SET GLOBAL ndb_metadata_sync=ON; --echo --echo # Pass two passwords via stdin. --echo # Passing file with one password. error 2; exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password.txt --decrypt-password-from-stdin --encrypt-password-from-stdin $MYSQL_TMP_DIR/BACKUP-1.1.ctl $MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-1; exec echo TOPSECRET > $NDB_PASSWORD_DIR/backup_password_twice.txt; exec echo TOPSECRET-2 >> $NDB_PASSWORD_DIR/backup_password_twice.txt; --echo --echo # Pass two passwords via stdin. --echo # Passing file with two passwords. exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_twice.txt --decrypt-password-from-stdin --encrypt-password-from-stdin $MYSQL_TMP_DIR/BACKUP-1.1.ctl $MYSQL_TMP_DIR/BACKUP-1.1.ctl.ENC; remove_file $MYSQL_TMP_DIR/BACKUP-1.1.ctl.ENC; --echo --echo # Pass one passwords via stdin. --echo # Passing file with one password without any new line character. replace_result $NDB_PASSWORD_DIR NDB_PASSWORD_DIR ; eval select "TOPSECRET-NO-NL" into dumpfile "$NDB_PASSWORD_DIR/backup_password_no_nl.txt"; error 2; exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_no_nl.txt --decrypt-password-from-stdin $MYSQL_TMP_DIR/BACKUP-1.1.ctl $MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-2; --echo --echo # Pass a too long passwords via stdin. replace_result $NDB_PASSWORD_DIR NDB_PASSWORD_DIR ; eval select repeat("TOPSECRET", 60) into outfile "$NDB_PASSWORD_DIR/backup_password_long.txt"; replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR ; error 2; exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_long.txt --decrypt-password-from-stdin $MYSQL_TMP_DIR/BACKUP-1.1.ctl $MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-3; --echo --echo # Pass a too long passwords via stdin. replace_result $NDB_PASSWORD_DIR NDB_PASSWORD_DIR ; eval select repeat("TOPSECRET", 120) into outfile "$NDB_PASSWORD_DIR/backup_password_long2.txt"; error 2; exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_long2.txt --decrypt-password-from-stdin $MYSQL_TMP_DIR/BACKUP-1.1.ctl $MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-4; --echo --echo # Pass a passwords with control character (ctrl-V) via stdin. replace_result $NDB_PASSWORD_DIR NDB_PASSWORD_DIR ; eval select char(22) into outfile "$NDB_PASSWORD_DIR/backup_password_ctrl.txt"; error 2; exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_ctrl.txt --decrypt-password=TOPSECRET --encrypt-password-from-stdin $MYSQL_TMP_DIR/BACKUP-1.1.ctl $MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-5; --echo --echo # Pass wrong passwords replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR ; error 2; exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password.txt --decrypt-password=WRONGSECRET --encrypt-password-from-stdin $MYSQL_TMP_DIR/BACKUP-1.1.ctl $MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-6; --echo --echo # Wait for schema synchronization to finish. let $wait_condition = select @@ndb_metadata_sync = 0; source include/wait_condition.inc; --echo --echo # Drop tables, tablespace and logfile group created by restore. DROP TABLE test . t_gis; DROP TABLE test . t_num; DROP TABLE test . t_string_1; DROP TABLE test . t_string_2; DROP TABLE test . t_string_3; DROP TABLE test . t_string_4; DROP TABLE test . t_string_5; DROP TABLE test . t_datetime; ALTER TABLESPACE ts1 DROP DATAFILE 'datafile.dat'; DROP TABLESPACE ts1; DROP LOGFILE GROUP lg1 ENGINE NDBCLUSTER; --echo --echo # Test ended, cleanup files. remove_file $NDB_PASSWORD_DIR/backup_password.txt; remove_file $NDB_PASSWORD_DIR/backup_password_twice.txt; remove_file $NDB_PASSWORD_DIR/backup_password_no_nl.txt; remove_file $NDB_PASSWORD_DIR/backup_password_long.txt; remove_file $NDB_PASSWORD_DIR/backup_password_long2.txt; remove_file $NDB_PASSWORD_DIR/backup_password_ctrl.txt; remove_file $MYSQL_TMP_DIR/BACKUP-1.1.ctl; remove_file $MYSQL_TMP_DIR/BACKUP-1-0.1.Data; remove_file $MYSQL_TMP_DIR/BACKUP-1.1.log; remove_file $NDB_TOOLS_OUTPUT;