summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Samiul Islam <samiul@google.com> 2022-04-05 14:03:28 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-04-05 14:03:28 +0000
commita607f48c41c48b51aab16b9815ba00fcbf966122 (patch)
tree7e02c9dea94b49c647b8d3a0c6f450c791992868
parent07bf36ad72d24a2be9127d01a2e52cdd6c8ef334 (diff)
parentd2ce603bf2e05196eff9a9a5b040d7e8c8fe52d5 (diff)
Merge "Set correct project id for sdk data directories" am: d2ce603bf2
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2051230 Change-Id: I4850f2cc53fa0124cdc7df8ed593bb1e79df4aa0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--cmds/installd/InstalldNativeService.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 358a0e027f..b6d786dc92 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -635,7 +635,8 @@ static void chown_app_profile_dir(const std::string &packageName, int32_t appId,
static binder::Status createAppDataDirs(const std::string& path, int32_t uid, int32_t gid,
int32_t* previousUid, int32_t cacheGid,
- const std::string& seInfo, mode_t targetMode) {
+ const std::string& seInfo, mode_t targetMode,
+ long projectIdApp, long projectIdCache) {
struct stat st{};
bool parent_dir_exists = (stat(path.c_str(), &st) == 0);
@@ -659,11 +660,9 @@ static binder::Status createAppDataDirs(const std::string& path, int32_t uid, in
}
// Prepare only the parent app directory
- long project_id_app = get_project_id(uid, PROJECT_ID_APP_START);
- long project_id_cache_app = get_project_id(uid, PROJECT_ID_APP_CACHE_START);
- if (prepare_app_dir(path, targetMode, uid, gid, project_id_app) ||
- prepare_app_cache_dir(path, "cache", 02771, uid, cacheGid, project_id_cache_app) ||
- prepare_app_cache_dir(path, "code_cache", 02771, uid, cacheGid, project_id_cache_app)) {
+ if (prepare_app_dir(path, targetMode, uid, gid, projectIdApp) ||
+ prepare_app_cache_dir(path, "cache", 02771, uid, cacheGid, projectIdCache) ||
+ prepare_app_cache_dir(path, "code_cache", 02771, uid, cacheGid, projectIdCache)) {
return error("Failed to prepare " + path);
}
@@ -719,10 +718,14 @@ binder::Status InstalldNativeService::createAppDataLocked(
cacheGid = uid;
}
+ long projectIdApp = get_project_id(uid, PROJECT_ID_APP_START);
+ long projectIdCache = get_project_id(uid, PROJECT_ID_APP_CACHE_START);
+
if (flags & FLAG_STORAGE_CE) {
auto path = create_data_user_ce_package_path(uuid_, userId, pkgname);
- auto status = createAppDataDirs(path, uid, uid, &previousUid, cacheGid, seInfo, targetMode);
+ auto status = createAppDataDirs(path, uid, uid, &previousUid, cacheGid, seInfo, targetMode,
+ projectIdApp, projectIdCache);
if (!status.isOk()) {
return status;
}
@@ -747,7 +750,8 @@ binder::Status InstalldNativeService::createAppDataLocked(
if (flags & FLAG_STORAGE_DE) {
auto path = create_data_user_de_package_path(uuid_, userId, pkgname);
- auto status = createAppDataDirs(path, uid, uid, &previousUid, cacheGid, seInfo, targetMode);
+ auto status = createAppDataDirs(path, uid, uid, &previousUid, cacheGid, seInfo, targetMode,
+ projectIdApp, projectIdCache);
if (!status.isOk()) {
return status;
}
@@ -947,8 +951,12 @@ binder::Status InstalldNativeService::reconcileSdkData(const std::optional<std::
}
const int32_t sandboxUid = multiuser_get_sdk_sandbox_uid(userId, appId);
int32_t previousSandboxUid = multiuser_get_sdk_sandbox_uid(userId, previousAppId);
- auto status = createAppDataDirs(path, sandboxUid, AID_NOBODY, &previousSandboxUid,
- cacheGid, seInfo, 0700 | S_ISGID);
+ int32_t appUid = multiuser_get_uid(userId, appId);
+ long projectIdApp = get_project_id(appUid, PROJECT_ID_APP_START);
+ long projectIdCache = get_project_id(appUid, PROJECT_ID_APP_CACHE_START);
+ auto status =
+ createAppDataDirs(path, sandboxUid, AID_NOBODY, &previousSandboxUid, cacheGid,
+ seInfo, 0700 | S_ISGID, projectIdApp, projectIdCache);
if (!status.isOk()) {
res = status;
continue;