SM: Add pkgName and isHybrid params to label generation 95/87595/1
authorZofia Abramowska <z.abramowska@samsung.com>
Thu, 8 Sep 2016 16:07:32 +0000 (18:07 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Thu, 8 Sep 2016 16:12:27 +0000 (18:12 +0200)
Change-Id: I0a5cbf75a27943ef5eb0ff22665250b91960a701

src/security-manager-tests/common/app_install_helper.h
src/security-manager-tests/common/sm_commons.cpp
src/security-manager-tests/common/sm_commons.h
src/security-manager-tests/test_cases.cpp
src/security-manager-tests/test_cases_credentials.cpp
src/security-manager-tests/test_cases_dyntransition.cpp
src/security-manager-tests/test_cases_privacy_manager.cpp
src/security-manager-tests/test_cases_public_sharing.cpp
src/security-manager-tests/test_cases_trusted_sharing.cpp

index 2a15dc4..ff62982 100644 (file)
@@ -91,7 +91,7 @@ struct AppInstallHelper {
     }
 
     std::string generateAppLabel() const {
-        return generateProcessLabel(getAppId());
+        return generateProcessLabel(getAppId(), getPkgId());
     }
 
     std::string generatePkgLabel() const {
index 31cf3e2..90581b2 100644 (file)
@@ -65,8 +65,10 @@ const std::string uidToStr(const uid_t uid)
 
 // Common implementation details
 
-std::string generateProcessLabel(const std::string &appId)
+std::string generateProcessLabel(const std::string &appId, const std::string &pkgId, bool isHybrid)
 {
+    (void) pkgId;
+    (void) isHybrid;
     return "User::App::" + appId;
 }
 
@@ -217,7 +219,7 @@ void check_app_permissions(const char *const app_id, const char *const pkg_id,
                            const privileges_t &denied_privs)
 {
     (void) pkg_id;
-    std::string smackLabel = generateProcessLabel(app_id);
+    std::string smackLabel = generateProcessLabel(app_id, pkg_id);
 
     CynaraTestClient::Client ctc;
 
index 971eace..287294c 100644 (file)
@@ -48,7 +48,7 @@ const std::string SM_RW_PATH =
 
 const std::string uidToStr(const uid_t uid);
 
-std::string generateProcessLabel(const std::string &appId);
+std::string generateProcessLabel(const std::string &appId, const std::string &pkgId, bool isHybrid = false);
 std::string generatePathRWLabel(const std::string &pkgId);
 std::string genRWPath(int app_num);
 std::string genROPath(int app_num);
index a4d95db..a985d6c 100644 (file)
@@ -172,7 +172,7 @@ RUNNER_CHILD_TEST_SMACK(security_manager_03_set_label_from_appid)
     const char *const app_id = "sm_test_03_app_id_set_label_from_appid_smack";
     const char *const pkg_id = "sm_test_03_pkg_id_set_label_from_appid_smack";
     const char *const socketLabel = "not_expected_label";
-    std::string expected_label = generateProcessLabel(app_id);
+    std::string expected_label = generateProcessLabel(app_id, pkg_id);
     std::string expected_socket_label = socketLabel;
     char *label = nullptr;
     CStringPtr labelPtr;
index ce5c1f9..16a2830 100644 (file)
@@ -112,7 +112,7 @@ RUNNER_CHILD_TEST(security_manager_51a_get_id_by_socket)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int sock, pid_t) {
         std::string rcvPkgId, rcvAppId;
@@ -140,7 +140,7 @@ RUNNER_CHILD_TEST(security_manager_51b_get_id_by_socket)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int sock, pid_t) {
         std::string rcvPkgId, rcvAppId;
@@ -164,7 +164,7 @@ RUNNER_CHILD_TEST(security_manager_51c_get_id_by_socket)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int sock, pid_t) {
         std::string rcvPkgId;
@@ -190,7 +190,7 @@ RUNNER_CHILD_TEST(security_manager_51d_get_id_by_socket)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int sock, pid_t) {
         std::string rcvAppId;
@@ -216,7 +216,7 @@ RUNNER_CHILD_TEST(security_manager_51e_get_id_by_socket)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int sock, pid_t) {
         Api::getPkgIdBySocket(sock, nullptr, nullptr, SECURITY_MANAGER_ERROR_INPUT_PARAM);
@@ -239,7 +239,7 @@ RUNNER_CHILD_TEST(security_manager_52a_get_id_by_pid)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int, pid_t pid) {
         std::string rcvPkgId, rcvAppId;
@@ -267,7 +267,7 @@ RUNNER_CHILD_TEST(security_manager_52b_get_id_by_pid)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int, pid_t pid) {
         std::string rcvPkgId, rcvAppId;
@@ -291,7 +291,7 @@ RUNNER_CHILD_TEST(security_manager_52c_get_id_by_pid)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int, pid_t pid) {
         std::string rcvPkgId;
@@ -317,7 +317,7 @@ RUNNER_CHILD_TEST(security_manager_52d_get_id_by_pid)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int, pid_t pid) {
         std::string rcvAppId;
@@ -343,7 +343,7 @@ RUNNER_CHILD_TEST(security_manager_52e_get_id_by_pid)
 
     Api::install(requestInst);
 
-    std::string smackLabel = generateProcessLabel(sm_app_id);
+    std::string smackLabel = generateProcessLabel(sm_app_id, sm_pkg_id);
 
     clientTestTemplate([&] (int sock, pid_t) {
         Api::getPkgIdByPid(sock, nullptr, nullptr, SECURITY_MANAGER_ERROR_INPUT_PARAM);
index 28b7a35..d7b7ec5 100644 (file)
@@ -57,9 +57,10 @@ static UidGidMsg readCreds(int pipefd0)
     return msg;
 }
 
-static void testSetLabelForSelf(const char *app_id, bool expected_success)
+static void testSetLabelForSelf(const std::string &appName, const std::string &pkgName,
+                                bool expected_success)
 {
-    std::string label =  generateProcessLabel(app_id);
+    std::string label =  generateProcessLabel(appName, pkgName);
     int result = smack_set_label_for_self(label.c_str());
     if (expected_success)
         RUNNER_ASSERT_MSG(result == 0, "smack_set_label_for_self(" << label <<
@@ -242,8 +243,8 @@ RUNNER_CHILD_TEST(security_manager_73_app_label_monitor_different_users) {
         Api::labelsProcess(monitor);
         Api::labelsMonitorFinish(monitor);
         setCaps("cap_mac_admin-eip");
-        testSetLabelForSelf(sm_app_id_a, false); // local installation by another user
-        testSetLabelForSelf(sm_app_id_b, true); // global installation by another user
+        testSetLabelForSelf(sm_app_id_a, sm_pkg_id_a, false); // local installation by another user
+        testSetLabelForSelf(sm_app_id_b, sm_pkg_id_b, true); // global installation by another user
         s_pipe.post(); //C
     }
 }
@@ -296,9 +297,9 @@ RUNNER_CHILD_TEST(security_manager_74_app_label_monitor_relabel_changes_1) {
         Api::labelsProcess(monitor);
         Api::labelsMonitorFinish(monitor);
         setCaps("cap_mac_admin-eip");
-        testSetLabelForSelf(sm_app_id_a, true); // global installation (OK)
-        testSetLabelForSelf(sm_app_id_b, false); //second change
-        testSetLabelForSelf(sm_app_id_c, false); //second change
+        testSetLabelForSelf(sm_app_id_a, sm_pkg_id_a, true); // global installation (OK)
+        testSetLabelForSelf(sm_app_id_b, sm_pkg_id_b, false); //second change
+        testSetLabelForSelf(sm_app_id_c, sm_pkg_id_c, false); //second change
         s_pipe.post(); //B
     }
 }
@@ -352,10 +353,10 @@ RUNNER_CHILD_TEST(security_manager_75_app_label_monitor_relabel_changes_2) {
         Api::labelsProcess(monitor);
         Api::labelsMonitorFinish(monitor);
         setCaps("cap_mac_admin-eip");
-        testSetLabelForSelf(bad_seed, false); //not premitted
-        testSetLabelForSelf(sm_app_id_a, false); //uninstalled
-        testSetLabelForSelf(sm_app_id_b, true); //installed
-        testSetLabelForSelf(sm_app_id_c, false); //second change
+        testSetLabelForSelf(bad_seed, "", false); //not premitted
+        testSetLabelForSelf(sm_app_id_a, sm_pkg_id_a, false); //uninstalled
+        testSetLabelForSelf(sm_app_id_b, sm_pkg_id_b, true); //installed
+        testSetLabelForSelf(sm_app_id_c, sm_pkg_id_c, false); //second change
         s_pipe.post(); //B
     }
 }
index 7645f55..a09d294 100644 (file)
@@ -772,7 +772,7 @@ RUNNER_CHILD_TEST(security_manager_15_privacy_manager_send_policy_update_for_adm
 
         waitPid(pid);
 
-        admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id).c_str(),
+        admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id, "").c_str(),
                 std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_ALLOW, nullptr);
     }
     if(pid == 0)
@@ -788,6 +788,7 @@ RUNNER_CHILD_TEST(security_manager_15_privacy_manager_send_policy_update_for_adm
         result = drop_root_privileges(msg.uid, msg.gid);
         RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
 
+        // FIXME - Application has to be installed for it to have policy set in SM
         PolicyEntry entry(update_app_id, std::to_string(static_cast<int>(msg.uid)), update_privilege);
         entry.setMaxLevel("Allow");
 
@@ -839,7 +840,7 @@ RUNNER_CHILD_TEST(security_manager_15_privacy_manager_send_policy_update_for_adm
 
         waitPid(pid);
 
-        admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_other_app_id).c_str(),
+        admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_other_app_id, "").c_str(),
                 std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_ALLOW, nullptr);
     }
     if(pid == 0)
@@ -907,7 +908,7 @@ RUNNER_CHILD_TEST(security_manager_15_privacy_manager_send_policy_update_for_sel
 
         waitPid(pid);
 
-        admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id).c_str(),
+        admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id, "").c_str(),
                 std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_ALLOW, nullptr);
     }
     if(pid == 0)
@@ -923,6 +924,7 @@ RUNNER_CHILD_TEST(security_manager_15_privacy_manager_send_policy_update_for_sel
         result = drop_root_privileges(msg.uid, msg.gid);
         RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
 
+        // FIXME - Application has to be installed for it to have policy set in SM
         PolicyEntry entry(update_app_id, std::to_string(static_cast<int>(msg.uid)), update_privilege);
         entry.setLevel("Allow");
 
@@ -1050,7 +1052,7 @@ RUNNER_CHILD_TEST(security_manager_17_privacy_manager_delete_policy_for_self)
 
         waitPid(pid[0]);
 
-        admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id).c_str(),
+        admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id, "").c_str(),
                 std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_ALLOW, nullptr);
 
         pid[1] = fork();
@@ -1068,7 +1070,7 @@ RUNNER_CHILD_TEST(security_manager_17_privacy_manager_delete_policy_for_self)
 
             waitPid(pid[1]);
 
-            admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id).c_str(),
+            admin.adminCheck(check_start_bucket, false, generateProcessLabel(update_app_id, "").c_str(),
                     std::to_string(static_cast<int>(msg.uid)).c_str(), update_privilege, CYNARA_ADMIN_DENY, nullptr);
         }
         if(pid[1] == 0)
@@ -1084,6 +1086,7 @@ RUNNER_CHILD_TEST(security_manager_17_privacy_manager_delete_policy_for_self)
 
             // delete this entry
             PolicyRequest deletePolicyRequest;
+            // FIXME - Application has to be installed for it to have policy set in SM
             PolicyEntry deleteEntry(update_app_id, std::to_string(static_cast<int>(msg.uid)), update_privilege);
             deleteEntry.setLevel(SECURITY_MANAGER_DELETE);
 
@@ -1105,6 +1108,7 @@ RUNNER_CHILD_TEST(security_manager_17_privacy_manager_delete_policy_for_self)
         result = drop_root_privileges(msg.uid, msg.gid);
         RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed");
 
+        // FIXME - Application has to be installed for it to have policy set in SM
         PolicyEntry entry(update_app_id, std::to_string(static_cast<int>(msg.uid)), update_privilege);
         entry.setLevel("Allow");
 
index b021864..ec1ae4c 100644 (file)
@@ -51,21 +51,21 @@ void changeSecurityContext(const std::string& label, uid_t uid, gid_t gid)
     RUNNER_ASSERT_ERRNO_MSG(0 == setuid(uid), "Error in setuid.");
 }
 
-void test_success_worker(const std::string &appName, int test_num)
+void test_success_worker(const std::string &appName, const std::string &pkgName, int test_num)
 {
     std::string SM_OWNER_RW_OTHERS_RO_PATH = genOwnerRWOthersROPath(test_num);
 
-    changeSecurityContext(generateProcessLabel(appName), APP_UID, APP_GID);
+    changeSecurityContext(generateProcessLabel(appName, pkgName), APP_UID, APP_GID);
 
     RUNNER_ASSERT_ERRNO_MSG(::access(SM_OWNER_RW_OTHERS_RO_PATH.c_str(), R_OK|X_OK) != -1,
         "access (" << SM_OWNER_RW_OTHERS_RO_PATH << ") from " << appName << " failed " << " to " << SM_OWNER_RW_OTHERS_RO_PATH );
 }
 
-void test_fail_worker(const std::string &appName, int test_num)
+void test_fail_worker(const std::string &appName, const std::string &pkgName, int test_num)
 {
     std::string SM_OWNER_RW_OTHERS_RO_PATH = genOwnerRWOthersROPath(test_num);
 
-    changeSecurityContext(generateProcessLabel(appName), APP_UID, APP_GID);
+    changeSecurityContext(generateProcessLabel(appName, pkgName), APP_UID, APP_GID);
 
     RUNNER_ASSERT_MSG(::access(SM_OWNER_RW_OTHERS_RO_PATH.c_str(), R_OK|X_OK) == -1,
         "access (" << SM_OWNER_RW_OTHERS_RO_PATH << ") from " << appName
@@ -135,37 +135,37 @@ RUNNER_TEST(security_manager_27a_API2X_app_install)
 
 RUNNER_CHILD_TEST(security_manager_27b_owner_1_have_access)
 {
-    test_success_worker(sm_app_shared_id, sm_app_shared_test_id);
+    test_success_worker(sm_app_shared_id, sm_pkg_shared_id, sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27c_owner_2_have_access)
 {
-    test_success_worker(sm_app_shared_another_in_package_id, sm_app_shared_test_id);
+    test_success_worker(sm_app_shared_another_in_package_id, sm_pkg_shared_id, sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27d_API2X_apps_have_access_app_1)
 {
-    test_success_worker("security_manager_10_app_1", sm_app_shared_test_id);
+    test_success_worker("security_manager_10_app_1", "security_manager_10_pkg_1", sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27e_API2X_apps_dont_have_access_app_2)
 {
-    test_fail_worker("security_manager_10_app_2", sm_app_shared_test_id);
+    test_fail_worker("security_manager_10_app_2", "security_manager_10_pkg_2", sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27f_API2X_apps_have_access_app_3)
 {
-    test_success_worker("security_manager_10_app_3", sm_app_shared_test_id);
+    test_success_worker("security_manager_10_app_3", "security_manager_10_pkg_3", sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27g_API2X_apps_dont_have_access_app_4)
 {
-    test_fail_worker("security_manager_10_app_4", sm_app_shared_test_id);
+    test_fail_worker("security_manager_10_app_4", "security_manager_10_pkg_4", sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27h_API2X_apps_have_access_app_5)
 {
-    test_success_worker("security_manager_10_app_5", sm_app_shared_test_id);
+    test_success_worker("security_manager_10_app_5", "security_manager_10_pkg_5", sm_app_shared_test_id);
 }
 
 
@@ -224,27 +224,27 @@ RUNNER_TEST(security_manager_27j_API30_app_install)
 
 RUNNER_CHILD_TEST(security_manager_27k_API30_apps_dont_have_access_app_1)
 {
-    test_fail_worker("security_manager_10_app_1", sm_app_shared_test_id);
+    test_fail_worker("security_manager_10_app_1", "security_manager_10_pkg_1", sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27l_API30_apps_dont_have_access_app_2)
 {
-    test_fail_worker("security_manager_10_app_2", sm_app_shared_test_id);
+    test_fail_worker("security_manager_10_app_2", "security_manager_10_pkg_2", sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27m_API30_apps_dont_have_access_app_3)
 {
-    test_fail_worker("security_manager_10_app_3", sm_app_shared_test_id);
+    test_fail_worker("security_manager_10_app_3", "security_manager_10_pkg_3", sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27n_API30_apps_dont_have_access_app_4)
 {
-    test_fail_worker("security_manager_10_app_4", sm_app_shared_test_id);
+    test_fail_worker("security_manager_10_app_4", "security_manager_10_pkg_4", sm_app_shared_test_id);
 }
 
 RUNNER_CHILD_TEST(security_manager_27o_API30_apps_dont_have_access_app_5)
 {
-    test_fail_worker("security_manager_10_app_5", sm_app_shared_test_id);
+    test_fail_worker("security_manager_10_app_5", "security_manager_10_pkg_5", sm_app_shared_test_id);
 }
 
 RUNNER_TEST(security_manager_27p_API30_app_uninstall)
index 975f350..d493b74 100644 (file)
@@ -131,7 +131,8 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path)
     // check rules
     check_exact_access("System", trusted_label, system_access);
     check_exact_access("User", trusted_label, system_access);
-    check_exact_access(generateProcessLabel(provider.getAppId()), trusted_label, trusted_access);
+    check_exact_access(generateProcessLabel(provider.getAppId(), provider.getPkgId()),
+                       trusted_label, trusted_access);
     check_exact_access(generatePathRWLabel(provider.getPkgId()), trusted_label, "");
 
     // install trusted app
@@ -142,7 +143,8 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path)
     Api::install(trustedApp);
 
     // check rules
-    check_exact_access(generateProcessLabel(user.getAppId()), trusted_label, trusted_access);
+    check_exact_access(generateProcessLabel(user.getAppId(), user.getPkgId()),
+                       trusted_label, trusted_access);
     check_exact_access(generatePathRWLabel(user.getPkgId()), trusted_label, "");
 
     // install untrusted app
@@ -152,7 +154,8 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path)
     Api::install(untrustedApp);
 
     // check rules
-    check_exact_access(generateProcessLabel(untrusted.getAppId()), trusted_label, "");
+    check_exact_access(generateProcessLabel(untrusted.getAppId(), untrusted.getPkgId()),
+                       trusted_label, "");
     check_exact_access(generatePathRWLabel(untrusted.getPkgId()), trusted_label, "");
 
     // uninstall trusting app
@@ -161,9 +164,11 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path)
     // there's still one app with author id, rules should be kept
     check_exact_access("System", trusted_label, system_access);
     check_exact_access("User", trusted_label, system_access);
-    check_exact_access(generateProcessLabel(provider.getAppId()), trusted_label, "");
+    check_exact_access(generateProcessLabel(provider.getAppId(), provider.getPkgId()),
+                       trusted_label, "");
     check_exact_access(generatePathRWLabel(provider.getPkgId()), trusted_label, "");
-    check_exact_access(generateProcessLabel(user.getAppId()), trusted_label, trusted_access);
+    check_exact_access(generateProcessLabel(user.getAppId(), user.getPkgId()),
+                       trusted_label, trusted_access);
     check_exact_access(generatePathRWLabel(user.getPkgId()), trusted_label, "");
 
     Api::uninstall(trustedApp);
@@ -171,7 +176,8 @@ RUNNER_TEST(security_manager_43_app_install_with_trusted_path)
     // no more apps with author id
     check_exact_access("System", trusted_label, "");
     check_exact_access("User", trusted_label, "");
-    check_exact_access(generateProcessLabel(user.getAppId()), trusted_label, "");
+    check_exact_access(generateProcessLabel(user.getAppId(), user.getPkgId()),
+                       trusted_label, "");
     check_exact_access(generatePathRWLabel(user.getPkgId()), trusted_label, "");
 
     Api::uninstall(untrustedApp);
@@ -268,26 +274,32 @@ RUNNER_TEST(security_manager_46_pkgId_deinstalation_test)
     trustingApp2.setAuthorId(authorId1);
     Api::install(trustingApp2);
 
-    check_exact_access("System", generateProcessLabel(trusted1.getAppId()), "rwxl");
-    check_exact_access("User", generateProcessLabel(trusted1.getAppId()), "rwxl");
+    check_exact_access("System", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()),
+                       "rwxl");
+    check_exact_access("User", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()),
+                        "rwxl");
     check_exact_access("System", generatePathRWLabel(trusted1.getPkgId()), "rwxatl");
     check_exact_access("User", generatePathRWLabel(trusted1.getPkgId()), "rwxatl");
-    check_exact_access("System", generateProcessLabel(trusted2.getAppId()), "rwxl");
-    check_exact_access("User", generateProcessLabel(trusted2.getAppId()), "rwxl");
+    check_exact_access("System", generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId()),
+                       "rwxl");
+    check_exact_access("User", generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId()),
+                       "rwxl");
 
     Api::uninstall(trustingApp2);
 
-    check_exact_access("System", generateProcessLabel(trusted1.getAppId()), "rwxl");
-    check_exact_access("User", generateProcessLabel(trusted1.getAppId()), "rwxl");
+    check_exact_access("System", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()),
+                       "rwxl");
+    check_exact_access("User", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()),
+                       "rwxl");
     check_exact_access("System", generatePathRWLabel(trusted1.getPkgId()), "rwxatl");
     check_exact_access("User", generatePathRWLabel(trusted1.getPkgId()), "rwxatl");
-    check_exact_access("System", generateProcessLabel(trusted2.getAppId()), "");
-    check_exact_access("User", generateProcessLabel(trusted2.getAppId()), "");
+    check_exact_access("System", generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId()), "");
+    check_exact_access("User", generateProcessLabel(trusted2.getAppId(), trusted2.getPkgId()), "");
 
     Api::uninstall(trustingApp);
 
-    check_exact_access("System", generateProcessLabel(trusted1.getAppId()), "");
-    check_exact_access("User", generateProcessLabel(trusted1.getAppId()), "");
+    check_exact_access("System", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()), "");
+    check_exact_access("User", generateProcessLabel(trusted1.getAppId(), trusted1.getPkgId()), "");
     check_exact_access("System", generatePathRWLabel(trusted1.getPkgId()), "");
     check_exact_access("User", generatePathRWLabel(trusted1.getPkgId()), "");
 }