// FIXME - all other existing privileges should be checked
}
+RUNNER_CHILD_TEST(security_manager_11_set_identity)
+{
+ pid_t pid1 = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid1 >= 0, "Fork 1 failed");
+ if (pid1 != 0) { //parent process
+ waitPid(pid1);
+ } else {
+ int result = security_manager_set_identity(process_type::SM_PROCESS_TYPE_SYSTEM, nullptr);
+ RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS,
+ "security_manager_set_identity(SM_PROCESS_TYPE_SYSTEM, nullptr) failed");
+ exit(0);
+ }
+
+ pid_t pid2 = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid2 >= 0, "Fork 2 failed");
+ if (pid2 != 0) { //parent process
+ waitPid(pid2);
+ } else {
+ int result = security_manager_set_identity(process_type::SM_PROCESS_TYPE_SYSTEM_PRIVILEGED, nullptr);
+ RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS,
+ "security_manager_set_identity(SM_PROCESS_TYPE_SYSTEM_PRIVILEGED, nullptr) failed");
+ exit(0);
+ }
+
+ const std::string appLocalName = "sm_test_set_identity_local1";
+ AppInstallHelper appLocal(appLocalName);
+ ScopedInstaller appInstall(appLocal);
+
+ pid_t pid3 = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid3 >= 0, "Fork 3 failed");
+ if (pid3 != 0) { //parent process
+ waitPid(pid3);
+ } else {
+ int result = security_manager_set_identity(process_type::SM_PROCESS_TYPE_APP, nullptr);
+ RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_ERROR_INPUT_PARAM,
+ "security_manager_set_identity(SM_PROCESS_TYPE_APP, nullptr) wrongly succeeded");
+ result = security_manager_set_identity(process_type::SM_PROCESS_TYPE_APP, appLocal.getAppId().c_str());
+ RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS,
+ "security_manager_set_identity(SM_PROCESS_TYPE_APP, appLocal.getAppId().c_str()) failed");
+ exit(0);
+ }
+}
+
RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_POLICY)
RUNNER_TEST(security_manager_20_user_cynara_policy)