*/
RUNNER_TEST_SMACK(privilege_control04_add_permissions)
{
- int result = app_add_permissions(APP_ID, PRIVS);
+ int result = perm_app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS, 1);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
" Error adding app permissions. Result: " << result);
}
}
+//Functions add_shared_dir_readers and app_register_av are deprecated and
+//have no replacement. Until those functions are deleted warnings for
+//tests using those functions are supressed.
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
RUNNER_TEST_SMACK(privilege_control05_add_shared_dir_readers)
{
#define TEST_OBJ "TEST_OBJECT"
free(path);
fclose(file);
}
-
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
/**
* Set APP privileges.
* Check app_register_av function
* Notice that this test case may have no sense if previous would fail (privilege_control06_app_install)
*/
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
RUNNER_TEST_SMACK(privilege_control10_app_register_av)
{
int result;
cleaning_smack_app_files();
cleaning_smack_database_files();
}
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
/**
* Grant SMACK permissions based on permissions list.
RUNNER_TEST_NOSMACK(privilege_control04_add_permissions_nosmack)
{
//Add permissions
- auto result = app_add_permissions(APP_ID, PRIVS);
+ auto result = perm_app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS, 1);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"Error adding app permissions. Result: " << result);
* This test is very similar to it's SMACK version - only difference is different result expected
* from smack_have_access.
*/
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
RUNNER_TEST_NOSMACK(privilege_control05_add_shared_dir_readers_nosmack)
{
-#define TEST_OBJ "TEST_OBJECT"
-#define TEST_OBJ_SOME_OTHER "TEST_OBJA"
-#define test_string_01 "TEST_raz TEST_OBJECT r-x--- ------"
-#define test_string_21 "TEST_trzy TEST_OBJA -wx---"
-#define test_string_22 "TEST_trzy TEST_OBJECT r-x--- ------"
+ const char* test_obj = "TEST_OBJECT";
+ const char* test_obj_some_other = "TEST_OBJA";
+ const char* test_str_01 = "TEST_raz TEST_OBJECT r-x--- ------";
+ const char* test_str_21 = "TEST_trzy TEST_OBJA -wx---";
+ const char* test_str_22 = "TEST_trzy TEST_OBJECT r-x--- ------";
int result;
int i;
int fd = -1;
- char* path_ref;
const char* app_labels_wrong[] = {"-TEST_raz", NULL};
const char* app_labels[] = {"TEST_raz", "TEST_dwa", "TEST_trzy", NULL};
cleaning_smack_database_files();
//test what happens when the label is not correct SMACK label
- result = add_shared_dir_readers(TEST_OBJ,app_labels_wrong);
+ result = add_shared_dir_readers(test_obj,app_labels_wrong);
RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM,
"add_shared_dir_readers should fail here. Result: " << result);
-
- result = smack_have_access(app_labels_wrong[0],TEST_OBJ,"rx");
+ result = smack_have_access(app_labels_wrong[0],test_obj,"rx");
RUNNER_ASSERT_MSG(result != 1,
"add_shared_dir_readers should not grant permission here. Result: " << result);
RUNNER_ASSERT_MSG(fd != -1, "Error in opening file");
if (i == 1) {
- result = smack_accesses_add(rules.get(), app_labels[i], TEST_OBJ, "wt");
+ result = smack_accesses_add(rules.get(), app_labels[i], test_obj, "wt");
RUNNER_ASSERT_MSG(result == 0,
"smack_accesses_add failed. Result: " << result);
}
rules.reset(tmp);
result = smack_accesses_add(rules.get(), app_labels[i],
- TEST_OBJ_SOME_OTHER, "wx");
+ test_obj_some_other, "wx");
RUNNER_ASSERT_MSG(result == 0,
"smack_accesses_add failed. Result: " << result);
}
}
//Use add_shared_dir_readers and check if smack_have_access still fails
- result = add_shared_dir_readers(TEST_OBJ,app_labels);
+ result = add_shared_dir_readers(test_obj,app_labels);
RUNNER_ASSERT_MSG(result == 0, "add_shared_dir_readers failed. Result: " << result);
- result = smack_have_access(app_labels[0],TEST_OBJ,"rx");
+ result = smack_have_access(app_labels[0],test_obj,"rx");
RUNNER_ASSERT_MSG(result == -1,
"smack_have_access should return error (SMACK is off). Result: " << result);
- result = smack_have_access(app_labels[1],TEST_OBJ,"rx");
+ result = smack_have_access(app_labels[1],test_obj,"rx");
RUNNER_ASSERT_MSG(result == -1,
"smack_have_access should return error (SMACK is off). Result: " << result);
- result = smack_have_access(app_labels[2],TEST_OBJ,"rx");
+ result = smack_have_access(app_labels[2],test_obj,"rx");
RUNNER_ASSERT_MSG(result == -1,
"smack_have_access should return error (SMACK is off). Result: " << result);
- result = smack_have_access(app_labels[1],TEST_OBJ,"rwxt");
+ result = smack_have_access(app_labels[1],test_obj,"rwxt");
RUNNER_ASSERT_MSG(result == -1,
"smack_have_access should return error (SMACK is off). Result: " << result);
- result = smack_have_access(app_labels[2],TEST_OBJ_SOME_OTHER,"wx");
+ result = smack_have_access(app_labels[2],test_obj_some_other,"wx");
RUNNER_ASSERT_MSG(result == -1,
"smack_have_access should return error (SMACK is off). Result: " << result);
RUNNER_ASSERT_MSG(fs.good(), "Opening file stream failed. Error: " << strerror(errno));
fs.get(buf, READ_BUF_SIZE);
- result = strcmp(buf, test_string_01);
+ result = strcmp(buf, test_str_01);
RUNNER_ASSERT_MSG(result == 0,
"add_shared_dir_readers ERROR, file not formatted " << path.str().c_str() <<
". Result: " << result);
RUNNER_ASSERT_MSG(fs.good(), "fopen failed, errno:" << strerror(errno));
fs.getline(buf, READ_BUF_SIZE);
- result = strcmp(buf, test_string_21);
+ result = strcmp(buf, test_str_21);
RUNNER_ASSERT_MSG( result == 0,
"add_shared_dir_readers ERROR, file not formatted " << path.str().c_str()
<< ". Result: " << result);
fs.getline(buf, READ_BUF_SIZE);
- result = strcmp(buf, test_string_22);
+ result = strcmp(buf, test_str_22);
RUNNER_ASSERT_MSG( result == 0,
"add_shared_dir_readers ERROR, file not formatted " << path.str().c_str()
<< ". Result: " << result);
}
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
+
/**
* NOSMACK version of privilege_control05_set_app_privilege test.
int result;
result = smack_have_access(av_id, app_id, "rwx");
RUNNER_ASSERT_MSG(result == -1,
- "smack_have_access should return error (SMACK is off). Result: " << result);
+ "smack_have_access should return error (SMACK is off). Result: " << result
+ << " when testing " << comment);
result = smack_have_access(av_id, app_id, "a");
RUNNER_ASSERT_MSG(result == -1,
- "smack_have_access should return error (SMACK is off). Result: " << result);
+ "smack_have_access should return error (SMACK is off). Result: " << result
+ << " when testing " << comment);
result = smack_have_access(av_id, app_id, "t");
RUNNER_ASSERT_MSG(result == -1,
- "smack_have_access should return error (SMACK is off). Result: " << result);
+ "smack_have_access should return error (SMACK is off). Result: " << result
+ << " when testing " << comment);
}
/*
* Uses NOSMACK version of checkOnlyAvAccess (mentioned above), rest of the test is identical to
* it's SMACK version.
*/
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
RUNNER_TEST_NOSMACK(privilege_control10_app_register_av_nosmack)
{
int result;
cleaning_smack_app_files();
cleaning_smack_database_files();
}
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
/**
* NOSMACK version of privilege_control11_app_enable_permissions test.
RUNNER_TEST_NOSMACK(privilege_control11_app_enable_permissions_nosmack)
{
int result;
- int smack_file_length;
std::fstream fs;
result = perm_app_revoke_permissions(APP_ID);