-/**
- * Make two applications "friends", by giving them both full permissions on
- * each other.
- */
-RUNNER_TEST_SMACK(privilege_control14_app_add_friend)
-{
- RUNNER_IGNORED_MSG("perm_app_add_friend is not implemented");
-
- int result;
-
-/**
- * Test - making friends with no permissions on each other
- */
-
- DB_BEGIN
-
- result = perm_app_revoke_permissions(APP_FRIEND_1);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error revoking app permissions. Result: " << result);
- result = perm_app_revoke_permissions(APP_FRIEND_2);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error revoking app permissions. Result: " << result);
-
- perm_app_uninstall(APP_FRIEND_1);
- perm_app_uninstall(APP_FRIEND_2);
-
- // Installing friends to be
- result = perm_app_install(APP_FRIEND_1);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- " Error installing first app. Result: " << result);
- result = perm_app_install(APP_FRIEND_2);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- " Error installing second app. Result: " << result);
-
- // Making friends
- result = perm_app_add_friend(APP_FRIEND_1, APP_FRIEND_2);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- " Error making friends. Errno: " << result);
-
- DB_END
-
- // Checking if friends were made
- result = smack_have_access(APP_FRIEND_1, APP_FRIEND_2, "wrxat");
- RUNNER_ASSERT_MSG_BT(result == 1,
- " Error first one sided friednship failed. Result: " << result);
- result = smack_have_access(APP_FRIEND_2, APP_FRIEND_1, "wrxat");
- RUNNER_ASSERT_MSG_BT(result == 1,
- " Error second one sided friednship failed. Result: " << result);
-
- DB_BEGIN
-
- // Clean up
- result = perm_app_revoke_permissions(APP_FRIEND_1);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error revoking app permissions. Result: " << result);
- result = perm_app_revoke_permissions(APP_FRIEND_2);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error revoking app permissions. Result: " << result);
-
- perm_app_uninstall(APP_FRIEND_1);
- perm_app_uninstall(APP_FRIEND_2);
-
- DB_END
-
-/**
- * Test - making friends with nonexistent friend
- */
-
- DB_BEGIN
-
- // Installing one friend
- result = perm_app_install(APP_FRIEND_1);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- " Error installing first app. Errno: " << result);
-
- // Adding imaginary friend as second
- result = perm_app_add_friend(APP_FRIEND_1, APP_FRIEND_2);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- " Error making friends (first) with imaginairy friend failed. Result: "
- << result);
- // Adding imaginary friend as first
- result = perm_app_add_friend(APP_FRIEND_2, APP_FRIEND_1);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- " Error making friends (second) with imaginairy friend failed. Result: "
- << result);
- // Clean up
- result = perm_app_revoke_permissions(APP_FRIEND_1);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error revoking app permissions. Result: " << result);
- result = perm_app_revoke_permissions(APP_FRIEND_2);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error revoking app permissions. Result: " << result);
-
- perm_app_uninstall(APP_FRIEND_1);
- perm_app_uninstall(APP_FRIEND_2);
-
- DB_END
-
-/**
- * Test - making friends with some permissions already added
- */
- unsigned int i;
- unsigned int j;
-
- struct smack_accesses *rulesFriend = NULL;
-
- std::vector<std::string> accessesFriend =
- { "r", "w", "x", "rw", "rx", "wx", "rwx", "rwxat" };
-
- DB_BEGIN
-
- // Installing friends to be
- result = perm_app_install(APP_FRIEND_1);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- " Error installing first app. Result: " << result);
- result = perm_app_install(APP_FRIEND_2);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- " Error installing second app. Result: " << result);
-
- DB_END
-
- for (i = 0; i < accessesFriend.size(); ++i)
- {
- for (j = 0; j < accessesFriend.size(); ++j)
- {
- // Adding rules before making friends
- result = smack_accesses_new(&rulesFriend);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error in smack_accesses_new. Result: " << result);
-
- result = smack_accesses_add(rulesFriend,
- APP_FRIEND_1, APP_FRIEND_2, accessesFriend[i].c_str());
- RUNNER_ASSERT_MSG_BT(result == 0,
- "Unable to add modify rulesFirend (first). Result: " << result);
- result = smack_accesses_add(rulesFriend, APP_FRIEND_2,
- APP_FRIEND_1, accessesFriend[j].c_str());
- RUNNER_ASSERT_MSG_BT(result == 0,
- "Unable to add modify rulesFirend (second). Result: " << result);
-
- result = smack_accesses_apply(rulesFriend);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error in smack_accesses_apply. Result: " << result);
-
- DB_BEGIN
-
- // Adding friends
- result = perm_app_add_friend(APP_FRIEND_1, APP_FRIEND_2);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- " Error making friends. Result: " << result);
-
- DB_END
-
- // Checking if friends were made
- result = smack_have_access(APP_FRIEND_1, APP_FRIEND_2, "wrxat");
- RUNNER_ASSERT_MSG_BT(result == 1,
- " Error first one sided friednship failed. Result: " << result);
- result = smack_have_access(APP_FRIEND_2, APP_FRIEND_1, "wrxat");
- RUNNER_ASSERT_MSG_BT(result == 1,
- " Error second one sided friednship failed. Result: " << result);
-
- // Deleting all rules between friends
- smack_accesses_add_modify(rulesFriend,
- APP_FRIEND_1, APP_FRIEND_2,"","rwxat");
- smack_accesses_add_modify(rulesFriend,
- APP_FRIEND_2, APP_FRIEND_1,"","rwxat");
-
- result = smack_accesses_apply(rulesFriend);
-
- smack_accesses_free(rulesFriend);
- rulesFriend = NULL;
- }
- }
-
- DB_BEGIN
-
- // Clean up
- result = perm_app_revoke_permissions(APP_FRIEND_1);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error revoking app permissions. Result: " << result);
- result = perm_app_revoke_permissions(APP_FRIEND_2);
- RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS,
- "Error revoking app permissions. Result: " << result);
-
- perm_app_uninstall(APP_FRIEND_1);
- perm_app_uninstall(APP_FRIEND_2);
-
- DB_END
-}
-