OSDN Git Service

Prepare user profile folder
authorCalin Juravle <calin@google.com>
Wed, 17 Feb 2016 20:14:46 +0000 (20:14 +0000)
committerCalin Juravle <calin@google.com>
Fri, 19 Feb 2016 13:43:02 +0000 (13:43 +0000)
Bug: 26719109
Bug: 26563023
Change-Id: I4737b7f73df74b2b787a62db2e231f136115b359

Ext4Crypt.cpp
Utils.cpp
Utils.h

index d456cfd..a785856 100644 (file)
@@ -600,10 +600,12 @@ bool e4crypt_prepare_user_storage(const char* volume_uuid, userid_t user_id,
         auto system_de_path = android::vold::BuildDataSystemDePath(user_id);
         auto misc_de_path = android::vold::BuildDataMiscDePath(user_id);
         auto user_de_path = android::vold::BuildDataUserDePath(volume_uuid, user_id);
+        auto profiles_de_path = android::vold::BuildDataProfilesDePath(user_id);
 
         if (!prepare_dir(system_de_path, 0770, AID_SYSTEM, AID_SYSTEM)) return false;
         if (!prepare_dir(misc_de_path, 01771, AID_SYSTEM, AID_MISC)) return false;
         if (!prepare_dir(user_de_path, 0771, AID_SYSTEM, AID_SYSTEM)) return false;
+        if (!prepare_dir(profiles_de_path, 0771, AID_SYSTEM, AID_SYSTEM)) return false;
 
         if (e4crypt_is_native()) {
             std::string de_raw_ref;
@@ -611,6 +613,8 @@ bool e4crypt_prepare_user_storage(const char* volume_uuid, userid_t user_id,
             if (!ensure_policy(de_raw_ref, system_de_path)) return false;
             if (!ensure_policy(de_raw_ref, misc_de_path)) return false;
             if (!ensure_policy(de_raw_ref, user_de_path)) return false;
+            // No need to set the policy for profiles_de_path. The parent directory (/data/misc)
+            // already has a DE_sys policy set.
         }
     }
 
index 1d1b236..2514f9a 100644 (file)
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -576,6 +576,11 @@ std::string BuildDataMiscDePath(userid_t userId) {
     return StringPrintf("%s/misc_de/%u", BuildDataPath(nullptr).c_str(), userId);
 }
 
+// Keep in sync with installd (frameworks/native/cmds/installd/utils.h)
+std::string BuildDataProfilesDePath(userid_t userId) {
+    return StringPrintf("%s/misc/profiles/cur/%u", BuildDataPath(nullptr).c_str(), userId);
+}
+
 std::string BuildDataPath(const char* volumeUuid) {
     // TODO: unify with installd path generation logic
     if (volumeUuid == nullptr) {
diff --git a/Utils.h b/Utils.h
index 7ff92c8..0248b85 100644 (file)
--- a/Utils.h
+++ b/Utils.h
@@ -100,6 +100,7 @@ std::string BuildDataSystemCePath(userid_t userid);
 std::string BuildDataSystemDePath(userid_t userid);
 std::string BuildDataMiscCePath(userid_t userid);
 std::string BuildDataMiscDePath(userid_t userid);
+std::string BuildDataProfilesDePath(userid_t userid);
 
 std::string BuildDataPath(const char* volumeUuid);
 std::string BuildDataMediaPath(const char* volumeUuid, userid_t userid);