RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for " << path);
}
-// TODO trusted rw
+RUNNER_TEST(security_manager_69_path_req_trusted_rw_no_author)
+{
+ const char *const sm_app_id = "sm_test_69_app_id";
+ const char *const sm_pkg_id = "sm_test_69_pkg_id";
+
+ TemporaryTestUser user("sm_test_69_user_name", GUM_USERTYPE_NORMAL, false);
+ user.create();
+ std::string path = appDirPath(user, sm_app_id, sm_pkg_id);
+
+ removeTestDirs(user, sm_app_id, sm_pkg_id);
+ createTestDirs(user, sm_app_id, sm_pkg_id);
+
+ install_app(sm_app_id, sm_pkg_id, user.getUid());
+
+ PathsRequest preq;
+ preq.setPkgId(sm_pkg_id);
+ preq.setUid(user.getUid());
+ preq.addPath(path, SECURITY_MANAGER_PATH_TRUSTED_RW);
+
+ Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
+}
+
+RUNNER_TEST(security_manager_70_path_req_trusted_rw_positive)
+{
+ const char *const sm_app_id = "sm_test_70_app_id";
+ const char *const sm_pkg_id = "sm_test_70_pkg_id";
+ const char *const author_id = "sm_test_70_author_id";
+
+ TemporaryTestUser user("sm_test_70_user_name", GUM_USERTYPE_NORMAL, false);
+ user.create();
+ std::string path = appDirPath(user, sm_app_id, sm_pkg_id);
+
+ removeTestDirs(user, sm_app_id, sm_pkg_id);
+ createTestDirs(user, sm_app_id, sm_pkg_id);
+
+ InstallRequest ireq;
+ ireq.setAppId(sm_app_id);
+ ireq.setPkgId(sm_pkg_id);
+ ireq.setUid(user.getUid());
+ ireq.setAuthorId(author_id);
+ Api::install(ireq);
+
+ PathsRequest preq;
+ preq.setPkgId(sm_pkg_id);
+ preq.setUid(user.getUid());
+ preq.addPath(path, SECURITY_MANAGER_PATH_TRUSTED_RW);
+
+ Api::registerPaths(preq);
+
+ // check labels
+ TestSecurityManagerDatabase dbtest;
+ int64_t authorDb = dbtest.get_author_id(author_id);
+ nftw_expected_label = std::string("User::Author::") + std::to_string(authorDb);
+ nftw_expected_transmute = true;
+ nftw_expected_exec = false;
+ int result = nftw(path.c_str(), &nftw_check_sm_labels, FTW_MAX_FDS, FTW_PHYS);
+ RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for " << path);
+}
int main(int argc, char *argv[])
{