Don't re-prepare main storage when preparing SD card storage

Test: Boots correctly, logs show main storage no longer prepared when
SD card is.

Change-Id: I9a123436e7083d8331c7543fe77aa6587b28db9f
This commit is contained in:
Paul Crowley 2017-10-05 14:07:09 -07:00
parent 82e249ac7d
commit 6b756ce5e9

View file

@ -601,6 +601,7 @@ bool e4crypt_prepare_user_storage(const char* volume_uuid, userid_t user_id, int
auto misc_de_path = android::vold::BuildDataMiscDePath(user_id); auto misc_de_path = android::vold::BuildDataMiscDePath(user_id);
auto user_de_path = android::vold::BuildDataUserDePath(volume_uuid, user_id); auto user_de_path = android::vold::BuildDataUserDePath(volume_uuid, user_id);
if (volume_uuid == nullptr) {
if (!prepare_dir(system_legacy_path, 0700, AID_SYSTEM, AID_SYSTEM)) return false; if (!prepare_dir(system_legacy_path, 0700, AID_SYSTEM, AID_SYSTEM)) return false;
#if MANAGE_MISC_DIRS #if MANAGE_MISC_DIRS
if (!prepare_dir(misc_legacy_path, 0750, multiuser_get_uid(user_id, AID_SYSTEM), if (!prepare_dir(misc_legacy_path, 0750, multiuser_get_uid(user_id, AID_SYSTEM),
@ -610,13 +611,16 @@ bool e4crypt_prepare_user_storage(const char* volume_uuid, userid_t user_id, int
if (!prepare_dir(system_de_path, 0770, AID_SYSTEM, AID_SYSTEM)) return false; 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(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(user_de_path, 0771, AID_SYSTEM, AID_SYSTEM)) return false;
if (e4crypt_is_native()) { if (e4crypt_is_native()) {
std::string de_raw_ref; std::string de_raw_ref;
if (!lookup_key_ref(s_de_key_raw_refs, user_id, &de_raw_ref)) return false; if (!lookup_key_ref(s_de_key_raw_refs, user_id, &de_raw_ref)) return false;
if (volume_uuid == nullptr) {
if (!ensure_policy(de_raw_ref, system_de_path)) return false; 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, misc_de_path)) return false;
}
if (!ensure_policy(de_raw_ref, user_de_path)) return false; if (!ensure_policy(de_raw_ref, user_de_path)) return false;
} }
} }
@ -628,18 +632,19 @@ bool e4crypt_prepare_user_storage(const char* volume_uuid, userid_t user_id, int
auto media_ce_path = android::vold::BuildDataMediaCePath(volume_uuid, user_id); auto media_ce_path = android::vold::BuildDataMediaCePath(volume_uuid, user_id);
auto user_ce_path = android::vold::BuildDataUserCePath(volume_uuid, user_id); auto user_ce_path = android::vold::BuildDataUserCePath(volume_uuid, user_id);
if (volume_uuid == nullptr) {
if (!prepare_dir(system_ce_path, 0770, AID_SYSTEM, AID_SYSTEM)) return false; if (!prepare_dir(system_ce_path, 0770, AID_SYSTEM, AID_SYSTEM)) return false;
if (!prepare_dir(misc_ce_path, 01771, AID_SYSTEM, AID_MISC)) return false; if (!prepare_dir(misc_ce_path, 01771, AID_SYSTEM, AID_MISC)) return false;
}
if (!prepare_dir(media_ce_path, 0770, AID_MEDIA_RW, AID_MEDIA_RW)) return false; if (!prepare_dir(media_ce_path, 0770, AID_MEDIA_RW, AID_MEDIA_RW)) return false;
if (!prepare_dir(user_ce_path, 0771, AID_SYSTEM, AID_SYSTEM)) return false; if (!prepare_dir(user_ce_path, 0771, AID_SYSTEM, AID_SYSTEM)) return false;
if (e4crypt_is_native()) { if (e4crypt_is_native()) {
std::string ce_raw_ref; std::string ce_raw_ref;
if (!lookup_key_ref(s_ce_key_raw_refs, user_id, &ce_raw_ref)) return false; if (!lookup_key_ref(s_ce_key_raw_refs, user_id, &ce_raw_ref)) return false;
if (volume_uuid == nullptr) {
if (!ensure_policy(ce_raw_ref, system_ce_path)) return false; if (!ensure_policy(ce_raw_ref, system_ce_path)) return false;
if (!ensure_policy(ce_raw_ref, misc_ce_path)) return false; if (!ensure_policy(ce_raw_ref, misc_ce_path)) return false;
if (!ensure_policy(ce_raw_ref, media_ce_path)) return false;
if (!ensure_policy(ce_raw_ref, user_ce_path)) return false;
// Now that credentials have been installed, we can run restorecon // Now that credentials have been installed, we can run restorecon
// over these paths // over these paths
@ -647,6 +652,9 @@ bool e4crypt_prepare_user_storage(const char* volume_uuid, userid_t user_id, int
android::vold::RestoreconRecursive(system_ce_path); android::vold::RestoreconRecursive(system_ce_path);
android::vold::RestoreconRecursive(misc_ce_path); android::vold::RestoreconRecursive(misc_ce_path);
} }
if (!ensure_policy(ce_raw_ref, media_ce_path)) return false;
if (!ensure_policy(ce_raw_ref, user_ce_path)) return false;
}
} }
return true; return true;