From 24ef15bd009204b73ebf0e94ba3d868177a5f44c Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 12 Jan 2017 19:27:03 -0700 Subject: Mask st_mode before comparing it. Otherwise it will never match the requested mode_t. Test: builds, boots, skips when matching Bug: 34201111 Change-Id: Iebaa8063a72eb6eaf2e773c1d35204617d0f16b8 --- cmds/installd/InstalldNativeService.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index 7fe2e19e77..30365889ef 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -287,12 +287,13 @@ static int prepare_app_cache_dir(const std::string& parent, const char* name, mo } } + mode_t actual_mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISGID); if (st.st_uid != uid) { // Mismatched UID is real trouble; we can't recover LOG(ERROR) << "Mismatched UID at " << path << ": found " << st.st_uid << " but expected " << uid; return -1; - } else if (st.st_gid == gid && st.st_mode == target_mode) { + } else if (st.st_gid == gid && actual_mode == target_mode) { // Everything looks good! return 0; } @@ -343,10 +344,15 @@ binder::Status InstalldNativeService::createAppData(const std::unique_ptr= MIN_RESTRICTED_HOME_SDK_VERSION ? 0700 : 0751; + // If UID doesn't have a specific cache GID, use UID value + if (cacheGid == -1) { + cacheGid = uid; + } + if (flags & FLAG_STORAGE_CE) { auto path = create_data_user_ce_package_path(uuid_, userId, pkgname); bool existing = (access(path.c_str(), F_OK) == 0); -- cgit v1.2.3-59-g8ed1b