app1.checkAfterUninstall(false);
app2.checkAfterUninstall();
}
+
+RUNNER_CHILD_TEST(security_manager_26_1_security_manager_get_app_owner_uid)
+{
+ TemporaryTestUser testUser("sm_test_26_1_user_name", GUM_USERTYPE_NORMAL);
+ testUser.create();
+ pid_t pid = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed");
+ if (pid != 0) {
+ uid_t parent_uid;
+ RUNNER_ASSERT_MSG(security_manager_get_app_owner_uid(getpid(), &parent_uid) == SECURITY_MANAGER_SUCCESS,
+ "Invalid return from security_manager_get_app_owner_uid()");
+ RUNNER_ASSERT_MSG(parent_uid == getuid(), "Invalid uid returned");
+ waitPid(pid);
+ } else {
+ RUNNER_ASSERT_ERRNO_MSG(setuid(testUser.getUid()) == 0, "setuid failed");
+ uid_t uid;
+ RUNNER_ASSERT_MSG(security_manager_get_app_owner_uid(getpid(), &uid) == SECURITY_MANAGER_SUCCESS,
+ "Invalid return from security_manager_get_app_owner_uid()");
+ RUNNER_ASSERT_MSG(uid == testUser.getUid(), "Invalid uid returned");
+ exit(0);
+ }
+}
+
+
+RUNNER_CHILD_TEST(security_manager_26_2_security_manager_self_is_app)
+{
+ TemporaryTestUser testUser("sm_test_26_2_user_name", GUM_USERTYPE_NORMAL);
+ testUser.create();
+
+ AppInstallHelperExt app("sm_test_26_2");
+ {
+ ScopedInstaller appInstall(app);
+
+ app.checkAfterInstall();
+
+ pid_t pid = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed");
+ if (pid != 0) {
+ // here we can check if function will return it is NOT an app
+ bool is_app;
+ RUNNER_ASSERT_MSG(security_manager_self_is_app(&is_app) == SECURITY_MANAGER_SUCCESS,
+ "failed security_manager_self_is_app");
+ RUNNER_ASSERT_MSG(is_app == false, "this should not be an app");
+ waitPid(pid);
+ } else {
+ // here we can check if the function will return it IS an app
+ Api::setProcessLabel(app.getAppId());
+ bool is_app;
+ RUNNER_ASSERT_MSG(security_manager_self_is_app(&is_app) == SECURITY_MANAGER_SUCCESS,
+ "failed security_manager_self_is_app");
+ RUNNER_ASSERT_MSG(is_app == true, "this should be an app");
+ exit(0);
+ }
+ }
+ app.checkAfterUninstall();
+}