#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)
#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
ADD_LIBRARY(${TARGET_TEF_SIMULATOR_LOG} ${LOG_SOURCES})
INSTALL(TARGETS ${TARGET_TEF_SIMULATOR_LOG} DESTINATION ${LIB_DIR})
+INSTALL(DIRECTORY DESTINATION ${BUILD_ROOT}${TALOG_DIR})
%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
# 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} \
%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
%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
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})
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;
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;
}
}
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;
}
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
[Socket]
-ListenStream=/tmp/simdaemon
+ListenStream=/var/run/simdaemon
SocketMode=0777
SmackLabelIPIn=*
SmackLabelIPOut=@