Merge changes I310feb08,I2b6d6b08 am: 242ed1bb20
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2004994 Change-Id: I7a2739b22d9e25cb4352832c6bcb47eab5bcf7a9
This commit is contained in:
commit
82f6d2dcc7
4 changed files with 20 additions and 20 deletions
|
@ -30,7 +30,7 @@ extern userid_t multiuser_get_user_id(uid_t uid);
|
|||
extern appid_t multiuser_get_app_id(uid_t uid);
|
||||
|
||||
extern uid_t multiuser_get_uid(userid_t user_id, appid_t app_id);
|
||||
extern uid_t multiuser_get_supplemental_uid(userid_t user_id, appid_t app_id);
|
||||
extern uid_t multiuser_get_sdk_sandbox_uid(userid_t user_id, appid_t app_id);
|
||||
|
||||
extern gid_t multiuser_get_cache_gid(userid_t user_id, appid_t app_id);
|
||||
extern gid_t multiuser_get_ext_gid(userid_t user_id, appid_t app_id);
|
||||
|
|
|
@ -210,9 +210,9 @@
|
|||
*/
|
||||
#define AID_OVERFLOWUID 65534 /* unmapped user in the user namespace */
|
||||
|
||||
/* use the ranges below to determine whether a process is supplemental */
|
||||
#define AID_SUPPLEMENTAL_PROCESS_START 20000 /* start of uids allocated to supplemental process */
|
||||
#define AID_SUPPLEMENTAL_PROCESS_END 29999 /* end of uids allocated to supplemental process */
|
||||
/* use the ranges below to determine whether a process is sdk sandbox */
|
||||
#define AID_SDK_SANDBOX_PROCESS_START 20000 /* start of uids allocated to sdk sandbox processes */
|
||||
#define AID_SDK_SANDBOX_PROCESS_END 29999 /* end of uids allocated to sdk sandbox processes */
|
||||
|
||||
/* use the ranges below to determine whether a process is isolated */
|
||||
#define AID_ISOLATED_START 90000 /* start of uids for fully isolated sandboxed processes */
|
||||
|
|
|
@ -29,10 +29,10 @@ uid_t multiuser_get_uid(userid_t user_id, appid_t app_id) {
|
|||
return (user_id * AID_USER_OFFSET) + (app_id % AID_USER_OFFSET);
|
||||
}
|
||||
|
||||
uid_t multiuser_get_supplemental_uid(userid_t user_id, appid_t app_id) {
|
||||
int supplementalProcessOffset = AID_SUPPLEMENTAL_PROCESS_START - AID_APP_START;
|
||||
uid_t multiuser_get_sdk_sandbox_uid(userid_t user_id, appid_t app_id) {
|
||||
int sdk_sandbox_offset = AID_SDK_SANDBOX_PROCESS_START - AID_APP_START;
|
||||
if (app_id >= AID_APP_START && app_id <= AID_APP_END) {
|
||||
return (user_id * AID_USER_OFFSET) + (app_id % AID_USER_OFFSET) + supplementalProcessOffset;
|
||||
return (user_id * AID_USER_OFFSET) + (app_id % AID_USER_OFFSET) + sdk_sandbox_offset;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -31,20 +31,20 @@ TEST(MultiuserTest, TestMerge) {
|
|||
EXPECT_EQ(1050000U, multiuser_get_uid(10, 50000));
|
||||
}
|
||||
|
||||
TEST(MultiuserTest, TestSupplementalUid) {
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_supplemental_uid(0, 0));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_supplemental_uid(0, 1000));
|
||||
EXPECT_EQ(20000U, multiuser_get_supplemental_uid(0, 10000));
|
||||
EXPECT_EQ(25000U, multiuser_get_supplemental_uid(0, 15000));
|
||||
EXPECT_EQ(29999U, multiuser_get_supplemental_uid(0, 19999));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_supplemental_uid(0, 50000));
|
||||
TEST(MultiuserTest, TestSdkSandboxUid) {
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_sdk_sandbox_uid(0, 0));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_sdk_sandbox_uid(0, 1000));
|
||||
EXPECT_EQ(20000U, multiuser_get_sdk_sandbox_uid(0, 10000));
|
||||
EXPECT_EQ(25000U, multiuser_get_sdk_sandbox_uid(0, 15000));
|
||||
EXPECT_EQ(29999U, multiuser_get_sdk_sandbox_uid(0, 19999));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_sdk_sandbox_uid(0, 50000));
|
||||
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_supplemental_uid(10, 0));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_supplemental_uid(10, 1000));
|
||||
EXPECT_EQ(1020000U, multiuser_get_supplemental_uid(10, 10000));
|
||||
EXPECT_EQ(1025000U, multiuser_get_supplemental_uid(10, 15000));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_supplemental_uid(10, 20000));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_supplemental_uid(10, 50000));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_sdk_sandbox_uid(10, 0));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_sdk_sandbox_uid(10, 1000));
|
||||
EXPECT_EQ(1020000U, multiuser_get_sdk_sandbox_uid(10, 10000));
|
||||
EXPECT_EQ(1025000U, multiuser_get_sdk_sandbox_uid(10, 15000));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_sdk_sandbox_uid(10, 20000));
|
||||
EXPECT_EQ(ERR_UID, multiuser_get_sdk_sandbox_uid(10, 50000));
|
||||
}
|
||||
|
||||
TEST(MultiuserTest, TestSplitUser) {
|
||||
|
|
Loading…
Reference in a new issue