From 46cab80b4b74a3d99bf73ca4f667536528099d83 Mon Sep 17 00:00:00 2001 From: "sangwan.kwon" Date: Thu, 30 Mar 2017 15:59:43 +0900 Subject: [PATCH] Add smack label to test programs Change-Id: I4dd5cc9677b6425e629935632bf022c856c2c296 Signed-off-by: sangwan.kwon --- packaging/trust-anchor.spec | 6 ++---- tests/CMakeLists.txt | 13 +++++++++---- tests/script/pre-test.sh.in | 23 ++++++++++++++--------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/packaging/trust-anchor.spec b/packaging/trust-anchor.spec index ad51802..3afeae3 100644 --- a/packaging/trust-anchor.spec +++ b/packaging/trust-anchor.spec @@ -22,7 +22,6 @@ Requires(postun): /sbin/ldconfig %global smack_label System %global tanchor_base %{TZ_SYS_DATA}/%{lib_name} -%global tanchor_res %{tanchor_base}/res %global tanchor_usr %{tanchor_base}/usr %global tanchor_global %{tanchor_base}/global %global tanchor_bundle %{tanchor_base}/ca-bundle.pem @@ -37,6 +36,7 @@ SSL root certificates for its HTTPS communication. %license LICENSE %{_libdir}/lib%{lib_name}.so.0 %{_libdir}/lib%{lib_name}.so.%{version} +%dir %attr(770, %{user_name}, %{group_name}) %{tanchor_base} %dir %attr(-, %{user_name}, %{group_name}) %{tanchor_usr} %dir %attr(-, %{user_name}, %{group_name}) %{tanchor_global} %attr(-, %{user_name}, %{group_name}) %{tanchor_bundle} @@ -59,7 +59,6 @@ SSL root certificates for its HTTPS communication. -DGROUP_NAME=%{group_name} \ -DSMACK_LABEL=%{smack_label} \ -DTANCHOR_BASE=%{tanchor_base} \ - -DTANCHOR_RES=%{tanchor_res} \ -DTANCHOR_USR=%{tanchor_usr} \ -DTANCHOR_GLOBAL=%{tanchor_global} \ -DTANCHOR_BUNDLE=%{tanchor_bundle} \ @@ -74,7 +73,6 @@ make %{?_smp_mflags} %install %make_install -mkdir -p %{buildroot}%{tanchor_res} mkdir -p %{buildroot}%{tanchor_usr} mkdir -p %{buildroot}%{tanchor_global} @@ -111,7 +109,7 @@ Testcases for trust anchor library %files -n trust-anchor-test %{_bindir}/%{lib_name}-test-installer %{_bindir}/%{lib_name}-test-launcher -%{_bindir}/%{lib_name}-test-capi-launcher +%{_bindir}/%{lib_name}-test-clauncher %{_bindir}/%{lib_name}-test-internal %{TZ_SYS_DATA}/%{lib_name}/test %{TZ_SYS_DATA}/%{lib_name}/test/certs diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 536635c..0a8da00 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -54,10 +54,15 @@ SET(CAPI_LAUNCHER_SRCS main.cpp SET(INTERNAL_SRCS main.cpp test-certificate.cpp) -BUILD_TEST("${TARGET_TANCHOR_TEST}-installer" "${INSTALLER_SRCS}") -BUILD_TEST("${TARGET_TANCHOR_TEST}-launcher" "${LAUNCHER_SRCS}") -BUILD_TEST("${TARGET_TANCHOR_TEST}-capi-launcher" "${CAPI_LAUNCHER_SRCS}") -BUILD_TEST("${TARGET_TANCHOR_TEST}-internal" "${INTERNAL_SRCS}") +SET(TEST_INSTALLER ${TARGET_TANCHOR_TEST}-installer) +SET(TEST_LAUNCHER ${TARGET_TANCHOR_TEST}-launcher) +SET(TEST_CLAUNCHER ${TARGET_TANCHOR_TEST}-clauncher) +SET(TEST_INTERNAL ${TARGET_TANCHOR_TEST}-internal) + +BUILD_TEST(${TEST_INSTALLER} "${INSTALLER_SRCS}") +BUILD_TEST(${TEST_LAUNCHER} "${LAUNCHER_SRCS}") +BUILD_TEST(${TEST_CLAUNCHER} "${CAPI_LAUNCHER_SRCS}") +BUILD_TEST(${TEST_INTERNAL} "${INTERNAL_SRCS}") ADD_SUBDIRECTORY(res) ADD_SUBDIRECTORY(script) diff --git a/tests/script/pre-test.sh.in b/tests/script/pre-test.sh.in index e77e52b..c03974b 100755 --- a/tests/script/pre-test.sh.in +++ b/tests/script/pre-test.sh.in @@ -20,17 +20,22 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin # @brief Set permission script for test # -CLAUNCHER=@BIN_INSTALL_DIR@/@TARGET_TANCHOR_TEST@-capi-launcher -CPPLAUNCHER=@BIN_INSTALL_DIR@/@TARGET_TANCHOR_TEST@-launcher +INSTALLER=@BIN_INSTALL_DIR@/@TEST_INSTALLER@ +LAUNCHER=@BIN_INSTALL_DIR@/@TEST_LAUNCHER@ +CLAUNCHER=@BIN_INSTALL_DIR@/@TEST_CLAUNCHER@ +INTERNAL=@BIN_INSTALL_DIR@/@TEST_INTERNAL@ -# change owner to system -chown @USER_NAME@:@GROUP_NAME@ $CLAUNCHER -chown @USER_NAME@:@GROUP_NAME@ $CPPLAUNCHER +declare -a TESTS=("$INSTALLER $LAUNCHER $CLAUNCER $INTERNAL") -# run test program as owner -chmod 4755 $CLAUNCHER -chmod 4755 $CPPLAUNCHER +for t in "${TESTS[@]}" + do + # change owner to system + chown @USER_NAME@:@GROUP_NAME@ $t + # run test program as owner + chmod 4755 $t + chsmack -e "@SMACK_LABEL@" $t +done # launch() needs CAP_SYS_ADMIN +setcap cap_sys_admin+ep $LAUNCHER setcap cap_sys_admin+ep $CLAUNCHER -setcap cap_sys_admin+ep $CPPLAUNCHER -- 2.34.1