From c79fb89a10ea9bc3b0f1f9c7caa809a705989479 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 12 Nov 2015 20:18:02 -0800 Subject: [PATCH] Switch to new FBE emulation property. Also prepare CE/DE storage directories for owner user at boot. Bug: 22358539 Change-Id: I76228952c990ebed83360c69ef36321b99114196 --- Ext4Crypt.cpp | 6 ++++-- main.cpp | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp index ae6a960..028c12c 100644 --- a/Ext4Crypt.cpp +++ b/Ext4Crypt.cpp @@ -52,6 +52,8 @@ using android::base::StringPrintf; +static const char* kPropEmulateFbe = "persist.vold.emulate_fbe"; + namespace { // Key length in bits const int key_length = 128; @@ -683,7 +685,7 @@ int e4crypt_destroy_user_key(userid_t user_id) { } int e4crypt_unlock_user_key(userid_t user_id, const char* token) { - if (property_get_bool("vold.emulate_fbe", false)) { + if (property_get_bool(kPropEmulateFbe, false)) { // When in emulation mode, we just use chmod if (chmod(android::vold::BuildDataSystemCePath(user_id).c_str(), 0771) || chmod(android::vold::BuildDataUserPath(nullptr, user_id).c_str(), 0771)) { @@ -704,7 +706,7 @@ int e4crypt_unlock_user_key(userid_t user_id, const char* token) { } int e4crypt_lock_user_key(userid_t user_id) { - if (property_get_bool("vold.emulate_fbe", false)) { + if (property_get_bool(kPropEmulateFbe, false)) { // When in emulation mode, we just use chmod if (chmod(android::vold::BuildDataSystemCePath(user_id).c_str(), 0000) || chmod(android::vold::BuildDataUserPath(nullptr, user_id).c_str(), 0000)) { diff --git a/main.cpp b/main.cpp index 648f36a..537e0a0 100644 --- a/main.cpp +++ b/main.cpp @@ -18,6 +18,7 @@ #include "VolumeManager.h" #include "CommandListener.h" #include "CryptCommandListener.h" +#include "Ext4Crypt.h" #include "NetlinkManager.h" #include "cryptfs.h" #include "sehandle.h" @@ -96,6 +97,9 @@ int main(int argc, char** argv) { vm->setDebug(true); } + // Prepare owner storage + e4crypt_prepare_user_storage(nullptr, 0); + cl = new CommandListener(); ccl = new CryptCommandListener(); vm->setBroadcaster((SocketListener *) cl);