Merge "Remove support for converting from FDE to FBE"
This commit is contained in:
commit
37a4f4d243
5 changed files with 14 additions and 40 deletions
|
@ -369,7 +369,7 @@ InstallResult ApplyFromAdb(Device* device, bool rescue_mode, Device::BuiltinActi
|
||||||
"to the device with \"adb sideload <filename>\"...\n");
|
"to the device with \"adb sideload <filename>\"...\n");
|
||||||
} else {
|
} else {
|
||||||
command_map.emplace(MinadbdCommand::kWipeData, [&device]() {
|
command_map.emplace(MinadbdCommand::kWipeData, [&device]() {
|
||||||
bool result = WipeData(device, false);
|
bool result = WipeData(device);
|
||||||
return std::make_pair(result, true);
|
return std::make_pair(result, true);
|
||||||
});
|
});
|
||||||
command_map.emplace(MinadbdCommand::kNoOp, []() { return std::make_pair(true, true); });
|
command_map.emplace(MinadbdCommand::kNoOp, []() { return std::make_pair(true, true); });
|
||||||
|
|
|
@ -27,4 +27,4 @@ struct selabel_handle;
|
||||||
bool WipeCache(RecoveryUI* ui, const std::function<bool()>& confirm);
|
bool WipeCache(RecoveryUI* ui, const std::function<bool()>& confirm);
|
||||||
|
|
||||||
// Returns true on success.
|
// Returns true on success.
|
||||||
bool WipeData(Device* device, bool convert_fbe);
|
bool WipeData(Device* device);
|
||||||
|
|
|
@ -347,7 +347,7 @@ static bool PerformPowerwashIfRequired(ZipArchiveHandle zip, Device *device) {
|
||||||
const auto payload_properties = ExtractPayloadProperties(zip);
|
const auto payload_properties = ExtractPayloadProperties(zip);
|
||||||
if (payload_properties.find("POWERWASH=1") != std::string::npos) {
|
if (payload_properties.find("POWERWASH=1") != std::string::npos) {
|
||||||
LOG(INFO) << "Payload properties has POWERWASH=1, wiping userdata...";
|
LOG(INFO) << "Payload properties has POWERWASH=1, wiping userdata...";
|
||||||
return WipeData(device, true);
|
return WipeData(device);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,7 @@
|
||||||
|
|
||||||
#include "install/wipe_data.h"
|
#include "install/wipe_data.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -37,9 +35,8 @@ constexpr const char* CACHE_ROOT = "/cache";
|
||||||
constexpr const char* DATA_ROOT = "/data";
|
constexpr const char* DATA_ROOT = "/data";
|
||||||
constexpr const char* METADATA_ROOT = "/metadata";
|
constexpr const char* METADATA_ROOT = "/metadata";
|
||||||
|
|
||||||
static bool EraseVolume(const char* volume, RecoveryUI* ui, bool convert_fbe) {
|
static bool EraseVolume(const char* volume, RecoveryUI* ui) {
|
||||||
bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
|
bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
|
||||||
bool is_data = (strcmp(volume, DATA_ROOT) == 0);
|
|
||||||
|
|
||||||
std::vector<saved_log_file> log_files;
|
std::vector<saved_log_file> log_files;
|
||||||
if (is_cache) {
|
if (is_cache) {
|
||||||
|
@ -52,28 +49,7 @@ static bool EraseVolume(const char* volume, RecoveryUI* ui, bool convert_fbe) {
|
||||||
|
|
||||||
ensure_path_unmounted(volume);
|
ensure_path_unmounted(volume);
|
||||||
|
|
||||||
int result;
|
int result = format_volume(volume);
|
||||||
if (is_data && convert_fbe) {
|
|
||||||
constexpr const char* CONVERT_FBE_DIR = "/tmp/convert_fbe";
|
|
||||||
constexpr const char* CONVERT_FBE_FILE = "/tmp/convert_fbe/convert_fbe";
|
|
||||||
// Create convert_fbe breadcrumb file to signal init to convert to file based encryption, not
|
|
||||||
// full disk encryption.
|
|
||||||
if (mkdir(CONVERT_FBE_DIR, 0700) != 0) {
|
|
||||||
PLOG(ERROR) << "Failed to mkdir " << CONVERT_FBE_DIR;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
FILE* f = fopen(CONVERT_FBE_FILE, "wbe");
|
|
||||||
if (!f) {
|
|
||||||
PLOG(ERROR) << "Failed to convert to file encryption";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
result = format_volume(volume, CONVERT_FBE_DIR);
|
|
||||||
remove(CONVERT_FBE_FILE);
|
|
||||||
rmdir(CONVERT_FBE_DIR);
|
|
||||||
} else {
|
|
||||||
result = format_volume(volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_cache) {
|
if (is_cache) {
|
||||||
RestoreLogFilesAfterFormat(log_files);
|
RestoreLogFilesAfterFormat(log_files);
|
||||||
|
@ -97,12 +73,12 @@ bool WipeCache(RecoveryUI* ui, const std::function<bool()>& confirm_func) {
|
||||||
ui->SetBackground(RecoveryUI::ERASING);
|
ui->SetBackground(RecoveryUI::ERASING);
|
||||||
ui->SetProgressType(RecoveryUI::INDETERMINATE);
|
ui->SetProgressType(RecoveryUI::INDETERMINATE);
|
||||||
|
|
||||||
bool success = EraseVolume("/cache", ui, false);
|
bool success = EraseVolume("/cache", ui);
|
||||||
ui->Print("Cache wipe %s.\n", success ? "complete" : "failed");
|
ui->Print("Cache wipe %s.\n", success ? "complete" : "failed");
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WipeData(Device* device, bool convert_fbe) {
|
bool WipeData(Device* device) {
|
||||||
RecoveryUI* ui = device->GetUI();
|
RecoveryUI* ui = device->GetUI();
|
||||||
ui->Print("\n-- Wiping data...\n");
|
ui->Print("\n-- Wiping data...\n");
|
||||||
ui->SetBackground(RecoveryUI::ERASING);
|
ui->SetBackground(RecoveryUI::ERASING);
|
||||||
|
@ -115,13 +91,13 @@ bool WipeData(Device* device, bool convert_fbe) {
|
||||||
|
|
||||||
bool success = device->PreWipeData();
|
bool success = device->PreWipeData();
|
||||||
if (success) {
|
if (success) {
|
||||||
success &= EraseVolume(DATA_ROOT, ui, convert_fbe);
|
success &= EraseVolume(DATA_ROOT, ui);
|
||||||
bool has_cache = volume_for_mount_point("/cache") != nullptr;
|
bool has_cache = volume_for_mount_point("/cache") != nullptr;
|
||||||
if (has_cache) {
|
if (has_cache) {
|
||||||
success &= EraseVolume(CACHE_ROOT, ui, false);
|
success &= EraseVolume(CACHE_ROOT, ui);
|
||||||
}
|
}
|
||||||
if (volume_for_mount_point(METADATA_ROOT) != nullptr) {
|
if (volume_for_mount_point(METADATA_ROOT) != nullptr) {
|
||||||
success &= EraseVolume(METADATA_ROOT, ui, false);
|
success &= EraseVolume(METADATA_ROOT, ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
10
recovery.cpp
10
recovery.cpp
|
@ -207,8 +207,7 @@ static InstallResult prompt_and_wipe_data(Device* device) {
|
||||||
|
|
||||||
if (ask_to_wipe_data(device)) {
|
if (ask_to_wipe_data(device)) {
|
||||||
CHECK(device->GetReason().has_value());
|
CHECK(device->GetReason().has_value());
|
||||||
bool convert_fbe = device->GetReason().value() == "convert_fbe";
|
if (WipeData(device)) {
|
||||||
if (WipeData(device, convert_fbe)) {
|
|
||||||
return INSTALL_SUCCESS;
|
return INSTALL_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return INSTALL_ERROR;
|
return INSTALL_ERROR;
|
||||||
|
@ -437,10 +436,10 @@ static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status)
|
||||||
save_current_log = true;
|
save_current_log = true;
|
||||||
if (ui->IsTextVisible()) {
|
if (ui->IsTextVisible()) {
|
||||||
if (ask_to_wipe_data(device)) {
|
if (ask_to_wipe_data(device)) {
|
||||||
WipeData(device, false);
|
WipeData(device);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
WipeData(device, false);
|
WipeData(device);
|
||||||
return Device::NO_ACTION;
|
return Device::NO_ACTION;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -794,8 +793,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
|
||||||
} else if (should_wipe_data) {
|
} else if (should_wipe_data) {
|
||||||
save_current_log = true;
|
save_current_log = true;
|
||||||
CHECK(device->GetReason().has_value());
|
CHECK(device->GetReason().has_value());
|
||||||
bool convert_fbe = device->GetReason().value() == "convert_fbe";
|
if (!WipeData(device)) {
|
||||||
if (!WipeData(device, convert_fbe)) {
|
|
||||||
status = INSTALL_ERROR;
|
status = INSTALL_ERROR;
|
||||||
}
|
}
|
||||||
} else if (should_prompt_and_wipe_data) {
|
} else if (should_prompt_and_wipe_data) {
|
||||||
|
|
Loading…
Reference in a new issue