Merge "Wipe device on policy error" into nyc-dev
am: 8a59fa8524
* commit '8a59fa85243a5f748108279f6d30b01292518b0a':
Wipe device on policy error
Change-Id: I211e83f34ff89ebe6120c952994c54a331165b93
This commit is contained in:
commit
2b2e3f1130
1 changed files with 20 additions and 13 deletions
|
|
@ -36,6 +36,7 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <linux/loop.h>
|
#include <linux/loop.h>
|
||||||
|
#include <ext4_crypt.h>
|
||||||
#include <ext4_crypt_init_extensions.h>
|
#include <ext4_crypt_init_extensions.h>
|
||||||
|
|
||||||
#include <selinux/selinux.h>
|
#include <selinux/selinux.h>
|
||||||
|
|
@ -135,6 +136,17 @@ static void turnOffBacklight() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int wipe_data_via_recovery(const std::string& reason) {
|
||||||
|
const std::vector<std::string> options = {"--wipe_data", std::string() + "--reason=" + reason};
|
||||||
|
std::string err;
|
||||||
|
if (!write_bootloader_message(options, &err)) {
|
||||||
|
ERROR("failed to set bootloader message: %s", err.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
|
||||||
|
while (1) { pause(); } // never reached
|
||||||
|
}
|
||||||
|
|
||||||
static void unmount_and_fsck(const struct mntent *entry) {
|
static void unmount_and_fsck(const struct mntent *entry) {
|
||||||
if (strcmp(entry->mnt_type, "f2fs") && strcmp(entry->mnt_type, "ext4"))
|
if (strcmp(entry->mnt_type, "f2fs") && strcmp(entry->mnt_type, "ext4"))
|
||||||
return;
|
return;
|
||||||
|
|
@ -324,7 +336,13 @@ static int do_mkdir(const std::vector<std::string>& args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return e4crypt_set_directory_policy(args[1].c_str());
|
if (e4crypt_is_native()) {
|
||||||
|
if (e4crypt_set_directory_policy(args[1].c_str())) {
|
||||||
|
wipe_data_via_recovery(std::string() + "set_policy_failed:" + args[1]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
|
@ -452,17 +470,6 @@ exit_success:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wipe_data_via_recovery() {
|
|
||||||
const std::vector<std::string> options = {"--wipe_data", "--reason=wipe_data_via_recovery"};
|
|
||||||
std::string err;
|
|
||||||
if (!write_bootloader_message(options, &err)) {
|
|
||||||
ERROR("failed to set bootloader message: %s", err.c_str());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
|
|
||||||
while (1) { pause(); } // never reached
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Imports .rc files from the specified paths. Default ones are applied if none is given.
|
/* Imports .rc files from the specified paths. Default ones are applied if none is given.
|
||||||
*
|
*
|
||||||
* start_index: index of the first path in the args list
|
* start_index: index of the first path in the args list
|
||||||
|
|
@ -553,7 +560,7 @@ static int do_mount_all(const std::vector<std::string>& args) {
|
||||||
} else if (ret == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) {
|
} else if (ret == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) {
|
||||||
/* Setup a wipe via recovery, and reboot into recovery */
|
/* Setup a wipe via recovery, and reboot into recovery */
|
||||||
ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n");
|
ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n");
|
||||||
ret = wipe_data_via_recovery();
|
ret = wipe_data_via_recovery("wipe_data_via_recovery");
|
||||||
/* If reboot worked, there is no return. */
|
/* If reboot worked, there is no return. */
|
||||||
} else if (ret == FS_MGR_MNTALL_DEV_FILE_ENCRYPTED) {
|
} else if (ret == FS_MGR_MNTALL_DEV_FILE_ENCRYPTED) {
|
||||||
if (e4crypt_install_keyring()) {
|
if (e4crypt_install_keyring()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue