diff options
| author | 2017-01-17 04:13:37 +0000 | |
|---|---|---|
| committer | 2017-01-17 04:13:37 +0000 | |
| commit | fc7bb04d261c794bf80589e0f040f46992bd39d2 (patch) | |
| tree | ddc248e1080eec1972e8dcb572fbc232c8887f78 | |
| parent | eed9f305d1c8eeb3a951e8a0624ee5a36fae5390 (diff) | |
| parent | 0e636867b5753d338f4da4fd875661fc62404802 (diff) | |
Mask st_mode before comparing it. am: 24ef15bd00
am: 0e636867b5
Change-Id: Ic8968f123759d36d49bf9bd65ec17e7f6024b888
| -rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 12 |
1 files 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<std::s // Assume invalid inode unless filled in below if (_aidl_return != nullptr) *_aidl_return = -1; - uid_t uid = multiuser_get_uid(userId, appId); - gid_t cacheGid = multiuser_get_cache_gid(userId, appId); + int32_t uid = multiuser_get_uid(userId, appId); + int32_t cacheGid = multiuser_get_cache_gid(userId, appId); mode_t targetMode = targetSdkVersion >= 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); |