{
TemporaryTestUser testUser("sm_test_26_1_user_name", GUM_USERTYPE_NORMAL);
testUser.create();
+ AppInstallHelperExt app("sm_test_26_1", "sm_test_26_1", testUser.getUid());
+ ScopedInstaller appInstall(app);
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");
+ // wait for child to exit before uninstallation
waitPid(pid);
+ Api::cleanupApp(app.getAppId(), testUser.getUid(), 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");
+ // child - the actual application
+ RUNNER_ASSERT_MSG(setLauncherSecurityAttributes(testUser) == 0, "launcher failed");
+ Api::prepareAppCandidate();
+ Api::prepareApp(app.getAppId());
+ uid_t owner_uid = 0;
+ RUNNER_ASSERT_MSG(
+ security_manager_get_app_owner_uid(getpid(), &owner_uid) == SECURITY_MANAGER_SUCCESS,
+ "Invalid return from security_manager_get_app_owner_uid()");
+ // TODO - on smack-enabled image prepareApp call doesn't change UID as its inherited
+ // normally from launchpad. Calling setuid() will drop caps, that can be mitigated by
+ // prctl & libcap, but namespace setup fails in that case. Hence, for now, the test on
+ // smack-enabled image expects to return UID of the calling process that tests were executed
+ // with.
+ //
+ // This will be changed once we'll do completely black-box security tests that will actually
+ // install a real app.
+#ifdef SMACK_ENABLED
+ RUNNER_ASSERT_MSG(owner_uid == getuid(), "Invalid uid returned - expected: "
+ << getuid() << " returned: " << owner_uid);
+#else
+ RUNNER_ASSERT_MSG(owner_uid == testUser.getUid(), "Invalid uid returned - expected: "
+ << testUser.getUid() << " returned: " << owner_uid);
+#endif
exit(0);
}
}