Merge "Remove code to handle non-default file encryption"

This commit is contained in:
Paul Lawrence 2016-02-02 23:16:02 +00:00 committed by Android (Google) Code Review
commit 1446f0f318
3 changed files with 6 additions and 47 deletions

View File

@ -441,7 +441,7 @@ out:
}
// Check to see if a mountable volume has encryption requirements
static int handle_encryptable(struct fstab *fstab, const struct fstab_rec* rec)
static int handle_encryptable(const struct fstab_rec* rec)
{
/* Check for existence of convert_fbe breadcrumb file */
char convert_fbe_name[PATH_MAX];
@ -472,41 +472,8 @@ static int handle_encryptable(struct fstab *fstab, const struct fstab_rec* rec)
// Deal with file level encryption
if ( (rec->fs_mgr_flags & MF_FILEENCRYPTION)
|| ((rec->fs_mgr_flags & MF_FORCEFDEORFBE) && convert_fbe)) {
// Default or not yet initialized encryption requires no more work here
if (!e4crypt_non_default_key(rec->mount_point)) {
INFO("%s is default file encrypted\n", rec->mount_point);
return FS_MGR_MNTALL_DEV_DEFAULT_FILE_ENCRYPTED;
}
INFO("%s is non-default file encrypted\n", rec->mount_point);
// Uses non-default key, so must unmount and set up temp file system
if (umount(rec->mount_point)) {
ERROR("Failed to umount %s - rebooting\n", rec->mount_point);
return FS_MGR_MNTALL_FAIL;
}
if (fs_mgr_do_tmpfs_mount(rec->mount_point) != 0) {
ERROR("Failed to mount a tmpfs at %s\n", rec->mount_point);
return FS_MGR_MNTALL_FAIL;
}
// Mount data temporarily so we can access unencrypted dir
char tmp_mnt[PATH_MAX];
strlcpy(tmp_mnt, rec->mount_point, sizeof(tmp_mnt));
strlcat(tmp_mnt, "/tmp_mnt", sizeof(tmp_mnt));
if (mkdir(tmp_mnt, 0700)) {
ERROR("Failed to create temp mount point\n");
return FS_MGR_MNTALL_FAIL;
}
if (fs_mgr_do_mount(fstab, rec->mount_point,
rec->blk_device, tmp_mnt)) {
ERROR("Error temp mounting encrypted file system\n");
return FS_MGR_MNTALL_FAIL;
}
return FS_MGR_MNTALL_DEV_NON_DEFAULT_FILE_ENCRYPTED;
INFO("%s is file encrypted\n", rec->mount_point);
return FS_MGR_MNTALL_DEV_FILE_ENCRYPTED;
}
return FS_MGR_MNTALL_DEV_NOT_ENCRYPTED;
@ -584,7 +551,7 @@ int fs_mgr_mount_all(struct fstab *fstab)
/* Deal with encryptability. */
if (!mret) {
int status = handle_encryptable(fstab, &fstab->recs[attempted_idx]);
int status = handle_encryptable(&fstab->recs[attempted_idx]);
if (status == FS_MGR_MNTALL_FAIL) {
/* Fatal error - no point continuing */

View File

@ -74,8 +74,7 @@ typedef void (*fs_mgr_verity_state_callback)(struct fstab_rec *fstab,
struct fstab *fs_mgr_read_fstab(const char *fstab_path);
void fs_mgr_free_fstab(struct fstab *fstab);
#define FS_MGR_MNTALL_DEV_NON_DEFAULT_FILE_ENCRYPTED 5
#define FS_MGR_MNTALL_DEV_DEFAULT_FILE_ENCRYPTED 4
#define FS_MGR_MNTALL_DEV_FILE_ENCRYPTED 4
#define FS_MGR_MNTALL_DEV_NEEDS_RECOVERY 3
#define FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION 2
#define FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED 1

View File

@ -510,7 +510,7 @@ static int do_mount_all(const std::vector<std::string>& args) {
ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n");
ret = wipe_data_via_recovery();
/* If reboot worked, there is no return. */
} else if (ret == FS_MGR_MNTALL_DEV_DEFAULT_FILE_ENCRYPTED) {
} else if (ret == FS_MGR_MNTALL_DEV_FILE_ENCRYPTED) {
if (e4crypt_install_keyring()) {
return -1;
}
@ -520,13 +520,6 @@ static int do_mount_all(const std::vector<std::string>& args) {
// Although encrypted, we have device key, so we do not need to
// do anything different from the nonencrypted case.
ActionManager::GetInstance().QueueEventTrigger("nonencrypted");
} else if (ret == FS_MGR_MNTALL_DEV_NON_DEFAULT_FILE_ENCRYPTED) {
if (e4crypt_install_keyring()) {
return -1;
}
property_set("ro.crypto.state", "encrypted");
property_set("ro.crypto.type", "file");
property_set("vold.decrypt", "trigger_restart_min_framework");
} else if (ret > 0) {
ERROR("fs_mgr_mount_all returned unexpected error %d\n", ret);
}