Revert "Add support for multi-user decryption"

This reverts commit 0b25b1d79b.

Reason for revert: Changes need to be made to libtwrpfscrypt to include this patchset. Will cherry-pick this patch later and make necessary modifications.

Change-Id: I7601d7b820129709b05d9b4368573b6f1048de02
This commit is contained in:
bigbiff
2020-05-28 19:36:30 +00:00
parent 0b25b1d79b
commit adc599e005
18 changed files with 655 additions and 640 deletions
+26 -62
View File
@@ -404,22 +404,13 @@ int OpenRecoveryScript::run_script_file(void) {
if (ret_val != 0)
ret_val = 1; // failure
} else if (strcmp(command, "decrypt") == 0) {
// twrp cmd cannot decrypt a password with space, should decrypt on gui
if (*value) {
string tmp = value;
std::vector<string> args = TWFunc::Split_String(tmp, " ");
string pass = args[0];
string userid = "0";
if (args.size() > 1)
userid = args[1];
ret_val = PartitionManager.Decrypt_Device(pass, atoi(userid.c_str()));
ret_val = PartitionManager.Decrypt_Device(value);
if (ret_val != 0)
ret_val = 1; // failure
ret_val = 1; // failure
} else {
gui_err("no_pwd=No password provided.");
ret_val = 1; // failure
ret_val = 1; // failure
}
} else {
LOGERR("Unrecognized script command: '%s'\n", command);
@@ -430,28 +421,23 @@ int OpenRecoveryScript::run_script_file(void) {
unlink(SCRIPT_FILE_TMP);
gui_msg("done_ors=Done processing script file");
} else {
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(SCRIPT_FILE_TMP)(
strerror(errno)));
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(SCRIPT_FILE_TMP)(strerror(errno)));
return 1;
}
if (install_cmd && DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 &&
DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
if (install_cmd && DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
gui_msg("injecttwrp=Injecting TWRP into boot image...");
TWPartition* Boot = PartitionManager.Find_Partition_By_Path("/boot");
if (Boot == NULL || Boot->Current_File_System != "emmc")
TWFunc::Exec_Cmd(
"injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash");
TWFunc::Exec_Cmd("injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash");
else {
string injectcmd =
"injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" +
Boot->Actual_Block_Device;
string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device;
TWFunc::Exec_Cmd(injectcmd.c_str());
}
gui_msg("done=Done.");
}
if (sideload)
ret_val = 1; // Forces booting to the home page after sideload
ret_val = 1; // Forces booting to the home page after sideload
return ret_val;
}
@@ -664,48 +650,26 @@ int OpenRecoveryScript::Run_OpenRecoveryScript_Action() {
// this is called by the "twcmd" GUI action when a command is received via FIFO from the "twrp" command line tool
void OpenRecoveryScript::Run_CLI_Command(const char* command) {
string tmp = command;
std::vector<string> parts =
TWFunc::Split_String(tmp, " "); // pats[0] is cmd, parts[1...] is args
string cmd_str = parts[0];
if (cmd_str == "runscript") {
if (parts.size() > 1) {
string filename = parts[1];
if (OpenRecoveryScript::copy_script_file(filename) == 0) {
LOGINFO("Unable to copy script file\n");
} else {
OpenRecoveryScript::run_script_file();
}
if (strlen(command) > 11 && strncmp(command, "runscript", 9) == 0) {
const char* filename = command + 10;
if (OpenRecoveryScript::copy_script_file(filename) == 0) {
LOGINFO("Unable to copy script file\n");
} else {
LOGINFO("Missing parameter: script file name\n");
OpenRecoveryScript::run_script_file();
}
} else if (cmd_str == "get") {
if (parts.size() > 1) {
string varname = parts[1];
string value;
DataManager::GetValue(varname, value);
gui_print("%s = %s\n", varname.c_str(), value.c_str());
} else {
LOGINFO("Missing parameter: var name\n");
}
} else if (cmd_str == "decrypt") {
// twrp cmd cannot decrypt a password with space, should decrypt on gui
if (parts.size() == 1) {
gui_err("no_pwd=No password provided.");
} else {
string pass = parts[1];
string userid = "0";
if (parts.size() > 2)
userid = parts[2];
gui_msg("decrypt_cmd=Attempting to decrypt data partition or user data via command line.");
if (PartitionManager.Decrypt_Device(pass, atoi(userid.c_str())) == 0) {
// set_page_done = 1; // done by singleaction_page anyway
std::string orsFile = TWFunc::get_cache_dir() + "/openrecoveryscript";
if (TWFunc::Path_Exists(orsFile)) {
Run_OpenRecoveryScript_Action();
}
} else if (strlen(command) > 5 && strncmp(command, "get", 3) == 0) {
const char* varname = command + 4;
string value;
DataManager::GetValue(varname, value);
gui_print("%s = %s\n", varname, value.c_str());
} else if (strlen(command) > 9 && strncmp(command, "decrypt", 7) == 0) {
const char* pass = command + 8;
gui_msg("decrypt_cmd=Attempting to decrypt data partition via command line.");
if (PartitionManager.Decrypt_Device(pass) == 0) {
// set_page_done = 1; // done by singleaction_page anyway
std::string orsFile = TWFunc::get_cache_dir() + "/openrecoveryscript";
if (TWFunc::Path_Exists(orsFile)) {
Run_OpenRecoveryScript_Action();
}
}
} else if (OpenRecoveryScript::Insert_ORS_Command(command)) {