Change sock/log to /var/{run,log}, tastore/storage to /opt/usr/apps/ta_sdk/{tee,data} 03/167403/5
authorKrzysztof Dynowski <k.dynowski@samsung.com>
Tue, 16 Jan 2018 11:28:37 +0000 (12:28 +0100)
committerKrzysztof Dynowski <k.dynowski@samsung.com>
Mon, 12 Feb 2018 16:12:39 +0000 (17:12 +0100)
Change-Id: Ieb32041f41e71db5e8f6b8bf39d2287a43a5c4c7

CMakeLists.txt
include/include/config.h
log/CMakeLists.txt
packaging/tef-simulator.spec
simulatordaemon/CMakeLists.txt
simulatordaemon/src/TABinaryManager/TABinaryManager.cpp
simulatordaemon/src/TABinaryManager/TAUnpack.cpp
simulatordaemon/src/TAFactory.cpp
simulatordaemon/src/TAInstance.cpp
systemd/tef-simulator.socket

index d0f1ceb1d40344ce2858aab66b8acd72a4e2c5db..5e3144bab47c0f0dda8ad1433f28bed0c1f89eb3 100644 (file)
@@ -49,6 +49,9 @@ ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
 #ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
 
 ADD_DEFINITIONS("-D_ARCH_=${ARCH}")
+ADD_DEFINITIONS(-DTEE_TASTORE_ROOT="${TASTORE_DIR}/")
+ADD_DEFINITIONS(-DTEE_SS_ROOT="${STORAGE_DIR}/")
+ADD_DEFINITIONS(-DTEE_TALOG_ROOT="${TALOG_DIR}/")
 
 # Enable tizen-specific preprocessor defines
 IF(DEFINED TIZEN)
index 07404a1a674d4a725e2ff4d2e9ff80a3601c51a3..a037025b75e29b139c1dcea1a16fd6a8ab667d8d 100644 (file)
 #ifndef INCLUDE_CONFIG_H_
 #define INCLUDE_CONFIG_H_
 
-//this is ln -s to /usr/lib/tastore or /usr/lib64/tastore (see spec file)
-#define TEE_TASTORE_ROOT "/opt/tastore/"
-#define TEE_SS_ROOT "/opt/tastore/"
+#ifndef TEE_TASTORE_ROOT
+//keep in sync ln -s to /usr/lib/tastore or /usr/lib64/tastore in packaging/tef-simulator.spec
+#if _ARCH_ == 32
+       #define TEE_TASTORE_ROOT "/opt/usr/apps/ta_sdk/tee/"
+#elif _ARCH_ == 64
+       #define TEE_TASTORE_ROOT "/opt/usr/apps/ta_sdk/tee64/"
+#else
+       #error "Invalid architecture was set!"
+#endif
+#endif
+
+#ifndef TEE_SS_ROOT
+#define TEE_SS_ROOT "/opt/usr/apps/ta_sdk/data/"
+#endif
+
+#ifndef TEE_TALOG_ROOT
+#define TEE_TALOG_ROOT "/var/log/ta/"
+#endif
+
+//keep in sync with systemd/tef-simulator.socket
+#define SIMDAEMON_SOCK_PATH "/var/run/simdaemon"
 
-#define SIMDAEMON_SOCK_PATH "/tmp/simdaemon"
 //TEEStub must have write access in this directory (creating socket per TA)
-#define TEE_TASOCK_ROOT "/tmp/"
-#define TEE_TALOG_ROOT "/tmp/"
+#define TEE_TASOCK_ROOT "/var/run/"
 
 // from manpages: For portable use, a shared memory object
 // should be identified by a name of the form /somename
index 1a67c566ee4e7cd86be071336f529166041d0145..81382ecaea5489e5ae3252cfd46a3ca31537223d 100644 (file)
@@ -24,3 +24,4 @@ SET(LOG_SOURCES
 ADD_LIBRARY(${TARGET_TEF_SIMULATOR_LOG} ${LOG_SOURCES})
 
 INSTALL(TARGETS ${TARGET_TEF_SIMULATOR_LOG} DESTINATION ${LIB_DIR})
+INSTALL(DIRECTORY DESTINATION ${BUILD_ROOT}${TALOG_DIR})
index 83a8df97adfe4cb75caa4efbea6ac887c2baa517..33645b4d78b7160705f6a787ed886a966d7725a5 100644 (file)
@@ -25,14 +25,19 @@ PreReq: tef-libteec
 %define lib_dir %{?TZ_SYS_LIB:%TZ_SYS_LIB}%{!?TZ_SYS_LIB:%_libdir}
 %define data_dir %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:%_datadir}
 %define include_dir %{?TZ_SYS_INCLUDE:%TZ_SYS_INCLUDE}%{!?TZ_SYS_INCLUDE:%_includedir}
-%define tastore_dir %{lib_dir}/tastore
-%define link_tastore_dir /opt/tastore
+%define link_tastore_dir %{lib_dir}/tastore
+%if %{__isa_bits} == 64
+%define tastore_dir /opt/usr/apps/ta_sdk/tee64
+%else
+%define tastore_dir /opt/usr/apps/ta_sdk/tee
+%endif
+%define storage_dir /opt/usr/apps/ta_sdk/data
+%define talog_dir /var/log/ta
 
 %define build_bin_dir %{buildroot}%{bin_dir}
 %define build_lib_dir %{buildroot}%{lib_dir}
-%define build_data_dir %{buildroot}%{data_dir}
 %define build_include_dir %{buildroot}%{include_dir}
-%define build_tastore_dir %{buildroot}%{tastore_dir}
+%define build_data_dir %{buildroot}%{data_dir}
 %define build_unit_dir %{buildroot}%{_unitdir}
 
 %define smack_domain_name System
@@ -74,11 +79,14 @@ cp %{SOURCE1} .
 # cannot call cmake rpmbuild macro because of scripts removing libTEEStub.a, which is a part of devkit
 cmake . \
         -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
+        -DBUILD_ROOT=%{buildroot} \
         -DBIN_DIR=%{build_bin_dir} \
         -DLIB_DIR=%{build_lib_dir} \
         -DDATA_DIR=%{build_data_dir} \
         -DINCLUDE_DIR=%{build_include_dir} \
-        -DTASTORE_DIR=%{build_tastore_dir} \
+        -DTASTORE_DIR=%{tastore_dir} \
+        -DSTORAGE_DIR=%{storage_dir} \
+        -DTALOG_DIR=%{talog_dir} \
         -DSYSTEMD_UNIT_DIR=%{build_unit_dir} \
         -DSYSTEMD_CFG_BIN_DIR=%{bin_dir} \
         -DPKGCFG_LIB_DIR=%{lib_dir} \
@@ -97,9 +105,9 @@ cp include/include/LICENSE LICENSE.BSD
 %pre
 
 %post
-rm -f %{link_tastore_dir}
-mkdir -p %{link_tastore_dir}
-rmdir %{link_tastore_dir}
+systemctl stop tef-simulator
+rm -rf %{link_tastore_dir}
+mkdir -p `dirname %{link_tastore_dir}`
 ln -sf %{tastore_dir} %{link_tastore_dir}
 tef-update.sh simulator
 systemctl enable tef-simulator
@@ -122,6 +130,8 @@ fi
 %attr(444,security_fw,security_fw) %{_unitdir}/tef-simulator.service
 %attr(444,security_fw,security_fw) %{_unitdir}/tef-simulator.socket
 %attr(755,security_fw,security_fw) %{lib_dir}/tef/simulator/libteec.so
+%attr(770,root,security_fw) %{talog_dir}
+%attr(770,root,security_fw) %{storage_dir}
 
 %files -n %{name}-devkit
 %license LICENSE
index 077442910b1ab361210c09f54517b25b973f6e7c..e57cc44e225d17d6d9f327824ae4d7a3916b431f 100644 (file)
@@ -104,4 +104,5 @@ TARGET_LINK_LIBRARIES(${TARGET_TEF_SIMULATOR_DAEMON}
 
 INSTALL(TARGETS ${TARGET_TEF_SIMULATOR_DAEMON} DESTINATION ${BIN_DIR})
 
-INSTALL(DIRECTORY DESTINATION ${TASTORE_DIR})
+INSTALL(DIRECTORY DESTINATION ${BUILD_ROOT}${TASTORE_DIR})
+INSTALL(DIRECTORY DESTINATION ${BUILD_ROOT}${STORAGE_DIR})
index dbb6b1e6fa0b464638b4f81df7dd386c84086df5..52fba751da859adcc2b3a516be527fcd5bf2b80b 100644 (file)
@@ -177,6 +177,8 @@ bool TABinaryManager::initTA(const string &uuid) {
                        res = false;
                }
                pthread_mutex_unlock(&taLock);
+       } else {
+               LOGD(SIM_DAEMON, "TA not exist %s", (TEE_TASTORE_ROOT + uuid).c_str());
        }
        pthread_rwlock_unlock(&binaryMapLock);
        return res;
index 52790244c4fdf98dabd7cb3b83f9a7f9d4c367c3..cce39133438ad47023eeb9a2b0d65be0c9d6d081 100644 (file)
@@ -73,7 +73,7 @@ int TAUnpack::unpackTA(string path, string uuid) {
        struct stat info;
        if (stat(extract_dir_path.c_str(), &info) != 0) {
                if (0 != mkdir(extract_dir_path.c_str(), 0777)) {
-                       LOGE(SIM_DAEMON, "mkdir failed");
+                       LOGE(SIM_DAEMON, "mkdir failed %s %s", extract_dir_path.c_str(), strerror(errno));
                        return -1;
                }
        }
index 0ab006723438b3ece82e98f3cc48407be44cc9a6..272b912e841974fd3b60bc21e9a5c81d00a9f358 100644 (file)
@@ -422,13 +422,15 @@ bool TAFactory::launchTA(string TAUUID, std::stringstream& str, bool debug,
                        return false;
                }
 
+               LOGD(SIM_DAEMON, "spawn TA %s %s", argv[0], argv[1]);
                // Spawn TA
                result = posix_spawn(&pid, argv[0], &child_fd_actions, NULL, argv, envp);
                if (result == 0) {
                        LOGD(SIM_DAEMON, "TA pid: %i\n", pid);
                        LOGD(SIM_DAEMON, "Launched Trusted Application");
                } else {
-                       LOGE(SIM_DAEMON, "Launching Trusted Application FAILED");
+                       ret = errno;
+                       LOGE(SIM_DAEMON, "Launching Trusted Application FAILED %s(%d)", strerror(ret), ret);
                        pthread_mutex_unlock(&TABin->taLock);
                        return false;
                }
index 15da04e4d9a78635b037f953bcbbecfa92973cc4..8eca0103429a23fc0bb00c9e56844d7216af4eee 100644 (file)
@@ -178,9 +178,10 @@ TEEC_Result TAInstance::connecttoTA(std::stringstream& str) {
        unsigned long int retry_count = 0;
        try {
                boost::system::error_code error = boost::asio::error::host_not_found;
-               stream_protocol::endpoint ep(string(TEE_TASOCK_ROOT) + str.str());
+               string tasock = string(TEE_TASOCK_ROOT) + str.str();
+               stream_protocol::endpoint ep(tasock);
 
-               LOGD(SIM_DAEMON, "Connect to TEEStub %s", str.str().c_str());
+               LOGD(SIM_DAEMON, "Connect to TEEStub %s", tasock.c_str());
                // Try to connect to TA RETRY_COUNT number of times
                while (error && (retry_count < RETRY_COUNT)) {
 #if 0
index 09ecd71d6e95487b745fb6ff7cc960066e0a9bfe..f4295d2ca6e88530e832ed6bee0c237ea4913a89 100644 (file)
@@ -1,5 +1,5 @@
 [Socket]
-ListenStream=/tmp/simdaemon
+ListenStream=/var/run/simdaemon
 SocketMode=0777
 SmackLabelIPIn=*
 SmackLabelIPOut=@