//TEEStub must have write access in this directory (creating socket per TA)
#define TEE_TASOCK_ROOT "/tmp/"
+#define TEE_TALOG_ROOT "/tmp/"
#define SHM_PATH "/tmp/shm"
#define SIMDAEMON_SOCK_PATH "/tmp/simdaemon"
argv[2] = NULL;
envp[0] = NULL;
+ // redirect TA output to file
+ posix_spawn_file_actions_t child_fd_actions;
+ int ret = posix_spawn_file_actions_init(&child_fd_actions);
+ if (ret != 0) {
+ LOGE(SIM_DAEMON, "posix_spawn_file_actions_init failed");
+ return false;
+ }
+
+ ret = posix_spawn_file_actions_addopen(&child_fd_actions, 1,
+ (TEE_TALOG_ROOT + TAUUID + ".log").c_str(),
+ O_WRONLY | O_CREAT | O_APPEND | O_SYNC, 0644);
+ if (ret != 0) {
+ LOGE(SIM_DAEMON, "posix_spawn_file_actions_addopen failed");
+ return false;
+ }
+
+ ret = posix_spawn_file_actions_adddup2(&child_fd_actions, 1, 2);
+ if (ret != 0) {
+ LOGE(SIM_DAEMON, "posix_spawn_file_actions_adddup2 failed");
+ return false;
+ }
+
// Spawn TA
- result = posix_spawn(&pid, argv[0], NULL, NULL, argv, envp);
+ 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");