SET(TARGET_SEC_SRV_CLIENT_SMACK_TESTS "security-server-tests-client-smack")
SET(TARGET_SEC_SRV_LABEL_TESTS "security-server-tests-label")
-SET(TARGET_SEC_SRV_PID_TESTS "security-server-tests-pid-reuser")
SET(TARGET_SEC_SRV_TC_SERVER_TESTS "security-server-tests-server")
SET(TARGET_SEC_SRV_PWD_TESTS "security-server-tests-password")
SET(TARGET_SEC_SRV_MT_TESTS "security-server-tests-mt")
${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_tests_label.cpp
)
-SET(SEC_SRV_PID_SOURCES
- ${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_tests_pid_reuser.cpp
- )
-
SET(SEC_SRV_TC_SERVER_SOURCES
${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_tests_server.cpp
${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_tests_weird_arguments.cpp
ADD_EXECUTABLE(${TARGET_SEC_SRV_CLIENT_SMACK_TESTS} ${SEC_SRV_CLIENT_SMACK_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_LABEL_TESTS} ${SEC_SRV_LABEL_SOURCES})
-ADD_EXECUTABLE(${TARGET_SEC_SRV_PID_TESTS} ${SEC_SRV_PID_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_TC_SERVER_TESTS} ${SEC_SRV_TC_SERVER_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_PWD_TESTS} ${SEC_SRV_PWD_SOURCES})
ADD_EXECUTABLE(${TARGET_SEC_SRV_MT_TESTS} ${SEC_SRV_MT_SOURCES})
${SEC_SRV_TESTS_DEP_LIBRARIES}
tests-common)
-TARGET_LINK_LIBRARIES(${TARGET_SEC_SRV_PID_TESTS}
- ${SEC_SRV_TESTS_DEP_LIBRARIES}
- tests-common)
-
TARGET_LINK_LIBRARIES(${TARGET_SEC_SRV_TC_SERVER_TESTS}
${SEC_SRV_TESTS_DEP_LIBRARIES}
tests-common)
INSTALL(TARGETS ${TARGET_SEC_SRV_CLIENT_SMACK_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_LABEL_TESTS} DESTINATION /usr/bin)
-INSTALL(TARGETS ${TARGET_SEC_SRV_PID_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_TC_SERVER_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_PWD_TESTS} DESTINATION /usr/bin)
INSTALL(TARGETS ${TARGET_SEC_SRV_MT_TESTS} DESTINATION /usr/bin)
+++ /dev/null
-/*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
- */
-/*
- * @file security_server_tests_pid_reuser.cpp
- * @author Bumjin Im (bj.im@samsung.com)
- * @author Mariusz Domanski (m.domanski@samsung.com)
- * @version 1.0
- * @brief Test cases for security server
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include "security-server.h"
-#include <dpl/test/test_runner.h>
-#include <dlog.h>
-#include "test.h"
-
-unsigned int target_pid, target_uid;
-unsigned char *prev_cookie, *new_cookie;
-int cookie_size;
-
-/* deprecated info for old c-style binary
- * still useful for understanding the test itself
- *
- * Usage:
- * cmd uid pid hexa_decimal_cookie
- * pid: PID want to be reused
- * hexa_decimal_cookie: Cookie value which is issued to the previous process
- * with the [pid] for comparison\nThe cookie must be hexa
- * decimal, with lower case and without whitespace and
- * new line characters
- * This test program must be executed as root process
- */
-
-void convert_prev_cookie(const char * /*cmdline*/, const char *prev, unsigned char *now)
-{
- int i, cnt;
- char tmphexnum[3] = {0};
- cnt = security_server_get_cookie_size();
- cnt = cnt * 2;
- if ((int)strlen(prev) != cnt)
- {
- printf("%s\n", "Cookie length is wrong");
- exit(1);
- }
-
- for (i = 0, cnt = 0; i < (int)strlen(prev); i = i + 2)
- {
- strncpy(tmphexnum, prev + i, 2);
- tmphexnum[2] = 0;
- errno = 0;
- now[cnt] = strtoul(tmphexnum, 0, 16);
- if (errno != 0)
- {
- printf("%s\n", "cannot convert hex cookie to binary");
- exit(1);
- }
- cnt++;
- }
-}
-
-void check_status()
-{
- struct stat statbuf;
- int ret;
- ret = stat("/opt/home/root/pid_cycle", &statbuf);
- if (ret != 0)
- {
- printf("Interrupt encountered. exiting...\n");
- exit(0);
- }
-}
-
-void cycle_pid(int pid)
-{
- int cur_pid = getpid();
- int dotval;
-
- while (cur_pid != pid)
- {
- if (fork() != 0)
- {
- dotval = cur_pid % 1000;
- if (dotval == 0)
- SLOGD(".");
- exit(0);
- }
- cur_pid = getpid();
- check_status();
- }
-}
-
-RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_TESTS_PID);
-
-RUNNER_TEST(tc_security_server_request_cookie)
-{
- RUNNER_IGNORED_MSG("needs FIX, check FIXME comment");
- SLOGD("Cycling PID to %d\n", target_pid);
- cycle_pid(target_pid);
- unlink("/opt/home/root/pid_cycle");
- RUNNER_ASSERT(security_server_request_cookie((char*)new_cookie, 20) == SECURITY_SERVER_API_SUCCESS);
- SLOGD("\nTarget PID: %d, Target UID: %d\n", target_pid, target_uid);
- SLOGD("Previous cookie:\n");
- printhex(prev_cookie, 20);
- SLOGD("Newly issued cookie:\n");
- printhex(new_cookie, 20);
- RUNNER_ASSERT_MSG(memcmp(prev_cookie, new_cookie, cookie_size) != 0, "cookies are the same");
-}
-
-int main(int argc, char *argv[])
-{
- /* FIXME: proper parameters needed (these below are fake)
- * or better idea for this test case...*/
- const char *argvv[] = {argv[0], "12345", "5000", "abcdefabcdefabcdefabcdefabcdefabcdefabcd"};
-
- target_uid = getuid();
- if (target_uid != 0)
- {
- printf("Error: %s must be executed by root\n", argv[0]);
- exit(1);
- }
-
- cookie_size = security_server_get_cookie_size();
- unsigned char prev_cookie_tmp[cookie_size], new_cookie_tmp[cookie_size];
- prev_cookie = prev_cookie_tmp;
- new_cookie = new_cookie_tmp;
-
- errno = 0;
- target_uid = strtoul(argvv[1], 0, 10);
- if (errno != 0)
- {
- printf("%s\n", "cannot convert string uid to integer");
- exit(1);
- }
- SLOGD("Target UID is %d. change user...\n", target_uid);
- setuid(target_uid);
-
- errno = 0;
- target_pid = strtoul(argvv[2], 0, 10);
- if (errno != 0)
- {
- printf("%s\n", "cannot convert string pid to integer");
- exit(1);
- }
- convert_prev_cookie(argvv[0], argvv[3], prev_cookie);
- check_status();
-
- int status =
- DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
-
- return status;
-}