From 7760d61951220df00c8ea853a91749e9864230b9 Mon Sep 17 00:00:00 2001 From: Bartlomiej Grzelewski Date: Tue, 21 Jan 2014 14:37:41 +0100 Subject: [PATCH] Fix compilation problem with gcc 4.8. [Issue#] N/A [Bug] Build break. [Cause] Lack of header files. [Solution] N/A [Verification] Build. Change-Id: Idd057f34c57278ee25841732847b8ade4175696e --- tests/common/gdbbacktrace.cpp | 3 +- .../common/libprivilege-control_test_common.h | 1 + .../libprivilege-control_test_common.cpp | 5 +- tests/libprivilege-control-tests/test_cases.cpp | 59 ++++++++++++---------- .../test_cases_stress.cpp | 3 +- .../security_server_clean_env.cpp | 2 + .../security_server_tests_client_smack.cpp | 11 +--- .../security_server_tests_open_for.cpp | 1 + .../security_server_tests_password.cpp | 2 +- .../security_server_tests_stress.cpp | 3 +- tests/security-server-tests/server.cpp | 2 +- 11 files changed, 48 insertions(+), 44 deletions(-) diff --git a/tests/common/gdbbacktrace.cpp b/tests/common/gdbbacktrace.cpp index b31a3e1..b44e30f 100644 --- a/tests/common/gdbbacktrace.cpp +++ b/tests/common/gdbbacktrace.cpp @@ -26,7 +26,8 @@ #include #include #include - +#include +#include #include "gdbbacktrace.h" namespace { diff --git a/tests/libprivilege-control-tests/common/libprivilege-control_test_common.h b/tests/libprivilege-control-tests/common/libprivilege-control_test_common.h index 998359d..cc040e6 100644 --- a/tests/libprivilege-control-tests/common/libprivilege-control_test_common.h +++ b/tests/libprivilege-control-tests/common/libprivilege-control_test_common.h @@ -31,6 +31,7 @@ #include #include #include +#include // How many open file descriptors should ftw() function use? #define FTW_MAX_FDS 16 diff --git a/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp b/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp index e1377df..726142c 100644 --- a/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp +++ b/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp @@ -21,11 +21,14 @@ * @brief Main file for libprivilege-control unit tests. */ +#include +#include +#include + #include #include #include #include -#include #define CANARY_LABEL "tiny_yellow_canary" diff --git a/tests/libprivilege-control-tests/test_cases.cpp b/tests/libprivilege-control-tests/test_cases.cpp index c62c3f4..f738e77 100644 --- a/tests/libprivilege-control-tests/test_cases.cpp +++ b/tests/libprivilege-control-tests/test_cases.cpp @@ -564,69 +564,74 @@ RUNNER_TEST(privilege_control11_add_api_feature) result = perm_add_api_feature(APP_TYPE_WGT,"blahblah", NULL, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); - // empty rules - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[0].c_str(), { NULL }, NULL, 0); + const char *test1[] = { NULL }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[0].c_str(), test1, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[1].c_str(), (const char*[]) { "", NULL }, NULL, 0); + const char *test2[] = { "", NULL }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[1].c_str(), test2, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[2].c_str(), (const char*[]) { " \t\n", "\t \n", "\n\t ", NULL }, NULL, 0); + const char *test3[] = { " \t\n", "\t \n", "\n\t ", NULL }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[2].c_str(), test3, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); // malformed rules - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[3].c_str(), (const char*[]) { "malformed", NULL }, NULL, 0); + const char *test4[] = { "malformed", NULL }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[3].c_str(), test4, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[4].c_str(), (const char*[]) { "malformed malformed", NULL }, NULL, 0); + const char *test5[] = { "malformed malformed", NULL }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[4].c_str(), test5, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[5].c_str(), (const char*[]) { "-malformed malformed rwxat", NULL }, NULL, 0); + const char *test6[] = { "-malformed malformed rwxat" }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[5].c_str(), test6, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[6].c_str(), (const char*[]) { "~/\"\\ malformed rwxat", NULL }, NULL, 0); + const char *test7[] = { "~/\"\\ malformed rwxat", NULL }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[6].c_str(), test7, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[7].c_str(), (const char*[]) { "subject object rwxat something else", NULL }, NULL, 0); + const char *test8[] = { "subject object rwxat something else", NULL }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[7].c_str(), test8, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); // correct rules - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[8].c_str(), (const char*[]) { + const char *test9[] = { "~APP~ object\t rwxatl", " \t \n", "subject2\t~APP~ ltxarw", "", - NULL - }, NULL, 0); + NULL}; + + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[8].c_str(), test9, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[9].c_str(), (const char*[]) { - "Sub::jE,ct ~APP~ a-rwxl", - NULL - }, NULL, 0); + const char *test10[] = { "Sub::jE,ct ~APP~ a-rwxl", NULL }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[9].c_str(), test10, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[10].c_str(), (const char*[]) { - "Sub::sjE,ct ~APP~ a-RwXL", // TODO This fails. - NULL - }, NULL, 0); + const char *test11[] = { "Sub::sjE,ct ~APP~ a-RwXL", NULL}; // TODO This fails. + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[10].c_str(), test11, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); // TODO For now identical/complementary rules are not merged. - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[11].c_str(), (const char*[]) { + const char *test12[] = { "subject1 ~APP~ rwxatl", " \t \n", "subject2 ~APP~ ltxarw", "", - NULL - }, NULL, 0); + NULL}; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[11].c_str(), test12, NULL, 0); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); // empty group ids - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[12].c_str(), (const char*[]) {"~APP~ b a",NULL},(const gid_t[]) {0,1,2},0); + const char *test13[] = { "~APP~ b a",NULL }; + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[12].c_str(), test13,(const gid_t[]) {0,1,2},0); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); result = file_exists(OSP_BLAHBLAH_DAC[12].c_str()); RUNNER_ASSERT_BT(result == -1); @@ -634,17 +639,17 @@ RUNNER_TEST(privilege_control11_add_api_feature) // valid group ids - result = perm_add_api_feature(APP_TYPE_OSP,BLAHBLAH_FEATURE[13].c_str(), (const char*[]) {"~APP~ b a",NULL},(const gid_t[]) {0,1,2},3); + result = perm_add_api_feature(APP_TYPE_OSP,BLAHBLAH_FEATURE[13].c_str(), test13,(const gid_t[]) {0,1,2},3); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); osp_blahblah_dac_check(__LINE__, {0,1,2}, OSP_BLAHBLAH_DAC[13]); remove_smack_files(); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[14].c_str(), (const char*[]) {"~APP~ b a",NULL},(const gid_t[]) {0,1,2},1); + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[14].c_str(), test13,(const gid_t[]) {0,1,2},1); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); osp_blahblah_dac_check(__LINE__, {0}, OSP_BLAHBLAH_DAC[14]); remove_smack_files(); - result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[15].c_str(), (const char*[]) {"~APP~ b a",NULL},(const gid_t[]) {1,1,1},3); + result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[15].c_str(), test13,(const gid_t[]) {1,1,1},3); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); osp_blahblah_dac_check(__LINE__, {1,1,1},OSP_BLAHBLAH_DAC[15]); remove_smack_files(); diff --git a/tests/libprivilege-control-tests/test_cases_stress.cpp b/tests/libprivilege-control-tests/test_cases_stress.cpp index 51fff47..cf94865 100644 --- a/tests/libprivilege-control-tests/test_cases_stress.cpp +++ b/tests/libprivilege-control-tests/test_cases_stress.cpp @@ -141,8 +141,9 @@ RUNNER_TEST(privilege_control22_app_installation_1x100) result = perm_app_install(TEST_OSP_FEATURE_APP_ID); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "Error in perm_app_install. Result: " << result); + const char *test1[] = { NULL }; result = perm_app_setup_permissions(TEST_OSP_FEATURE_APP_ID, - APP_TYPE_OSP,(const char*[]) {NULL}); + APP_TYPE_OSP, test1); RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "Error enabling permissions. Result: " << result); diff --git a/tests/security-server-tests/security_server_clean_env.cpp b/tests/security-server-tests/security_server_clean_env.cpp index 13bbbef..1b5ab93 100644 --- a/tests/security-server-tests/security_server_clean_env.cpp +++ b/tests/security-server-tests/security_server_clean_env.cpp @@ -10,6 +10,8 @@ */ #include +#include + #include #include diff --git a/tests/security-server-tests/security_server_tests_client_smack.cpp b/tests/security-server-tests/security_server_tests_client_smack.cpp index 8f69bc0..bcffc77 100644 --- a/tests/security-server-tests/security_server_tests_client_smack.cpp +++ b/tests/security-server-tests/security_server_tests_client_smack.cpp @@ -759,8 +759,7 @@ RUNNER_CHILD_TEST_SMACK(tc15_security_server_get_gid_by_cookie_smack) RUNNER_ASSERT_MSG_BT(setuid(APP_UID) == 0, "Unable to drop privileges"); //checking function - gid_t cookieGid, realGid; - realGid = getgid(); + gid_t cookieGid; retval = security_server_get_gid_by_cookie(&cookie[0], &cookieGid); RUNNER_ASSERT_MSG_BT(retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "Socket not protected by smack"); } @@ -859,8 +858,6 @@ RUNNER_CHILD_TEST_NOSMACK(tc17_security_server_get_gid_by_cookie_nosmack) RUNNER_TEST_SMACK(tc18_security_server_get_smacklabel_cookie) { int res; - pid_t mypid; - char *label_smack = NULL; char *label_ss = NULL; char *cookie = NULL; @@ -868,8 +865,6 @@ RUNNER_TEST_SMACK(tc18_security_server_get_smacklabel_cookie) { int cookie_size = security_server_get_cookie_size(); RUNNER_ASSERT_MSG_BT(PROPER_COOKIE_SIZE == cookie_size, "Wrong cookie size from security-server"); - mypid = getpid(); - cookie = (char*) calloc(cookie_size, 1); RUNNER_ASSERT_MSG_BT(NULL != cookie, "Memory allocation error"); @@ -913,8 +908,6 @@ RUNNER_TEST_SMACK(tc18_security_server_get_smacklabel_cookie) { RUNNER_TEST_NOSMACK(tc18_security_server_get_smacklabel_cookie_nosmack) { int res; - pid_t mypid; - char* label_ss = NULL; char* cookie = NULL; @@ -925,8 +918,6 @@ RUNNER_TEST_NOSMACK(tc18_security_server_get_smacklabel_cookie_nosmack) { cookie = (char*) calloc(cookie_size, sizeof(char)); RUNNER_ASSERT_MSG_BT(NULL != cookie, "Memory allocation error"); - mypid = getpid(); - //Request cookie from SS res = security_server_request_cookie(cookie, cookie_size); std::unique_ptr > cookie_ptr(cookie, free); diff --git a/tests/security-server-tests/security_server_tests_open_for.cpp b/tests/security-server-tests/security_server_tests_open_for.cpp index 057e6f5..2c68d25 100644 --- a/tests/security-server-tests/security_server_tests_open_for.cpp +++ b/tests/security-server-tests/security_server_tests_open_for.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include diff --git a/tests/security-server-tests/security_server_tests_password.cpp b/tests/security-server-tests/security_server_tests_password.cpp index e5e2ed3..c434382 100644 --- a/tests/security-server-tests/security_server_tests_password.cpp +++ b/tests/security-server-tests/security_server_tests_password.cpp @@ -1500,7 +1500,7 @@ RUNNER_TEST(tc50_security_server_set_pwd_current_pwd_with_infinite_expiration_ti ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); - RUNNER_ASSERT_MSG_BT((time_t) expire_sec == PASSWORD_INFINITE_EXPIRATION_TIME, + RUNNER_ASSERT_MSG_BT(expire_sec == PASSWORD_INFINITE_EXPIRATION_TIME, "invalid expiration time " << expire_sec); clean_password_dir(); diff --git a/tests/security-server-tests/security_server_tests_stress.cpp b/tests/security-server-tests/security_server_tests_stress.cpp index 90b1ff5..e3c1a05 100644 --- a/tests/security-server-tests/security_server_tests_stress.cpp +++ b/tests/security-server-tests/security_server_tests_stress.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "security-server.h" std::mutex g_mutex; @@ -64,7 +65,6 @@ void cookie_api_thread_function(bool isSmack) int ret; size_t COOKIE_SIZE; - pid_t pid; uid_t uid; gid_t gid; @@ -98,7 +98,6 @@ void cookie_api_thread_function(bool isSmack) } //security_server_get_cookie_pid - pid = getpid(); ret = security_server_get_cookie_pid(cookie.data()); if (ret < 0) { appendError("Error in security_server_get_cookie_pid(): " + std::to_string(ret)); diff --git a/tests/security-server-tests/server.cpp b/tests/security-server-tests/server.cpp index 6dc2861..a0c5a0b 100644 --- a/tests/security-server-tests/server.cpp +++ b/tests/security-server-tests/server.cpp @@ -464,7 +464,7 @@ RUNNER_CHILD_TEST(tc06_check_API_middleware_denied) RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret); ss_label = security_server_get_smacklabel_cookie(cookie); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret); + RUNNER_ASSERT_MSG_BT(ss_label != NULL && !strcmp(ss_label, TEST06_SUBJECT), "label:" << ss_label); ret = security_server_check_privilege_by_pid(getpid(), "_", "rx"); RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret); -- 2.7.4