Handle invalid shared GIDs.
Shared GIDs are only available inside a range from 50000-59999, so
system UIDs (outside the normal app range) don't have a valid GID to
use. The best we can do is skip the profile setup in those cases.
Test: builds
Bug: 27948817
Change-Id: I8c38a0e3631eafd07e96da3e37e641b3cce195a6
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index bee947f..75e5668 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -322,8 +322,8 @@
const std::string ref_profile_path = create_data_ref_profile_package_path(pkgname);
// dex2oat/profman runs under the shared app gid and it needs to read/write reference
// profiles.
- appid_t shared_app_gid = multiuser_get_shared_app_gid(uid);
- if (fs_prepare_dir_strict(
+ int shared_app_gid = multiuser_get_shared_app_gid(uid);
+ if ((shared_app_gid != -1) && fs_prepare_dir_strict(
ref_profile_path.c_str(), 0700, shared_app_gid, shared_app_gid) != 0) {
return error("Failed to prepare " + ref_profile_path);
}