Separate extract path support 32/170132/3
authorKrzysztof Dynowski <k.dynowski@samsung.com>
Tue, 13 Feb 2018 09:15:32 +0000 (10:15 +0100)
committerKrzysztof Dynowski <k.dynowski@samsung.com>
Wed, 21 Feb 2018 15:26:19 +0000 (16:26 +0100)
Change-Id: I0741a959e01858941e3e5a23e5f032f237af2a33

CMakeLists.txt
TEEStub/PropertyAccess/PropertyApi.cpp
include/include/config.h
packaging/tef-simulator.spec
simulatordaemon/CMakeLists.txt
simulatordaemon/src/TABinaryManager/TABinaryManager.cpp
simulatordaemon/src/TABinaryManager/TAUnpack.cpp
simulatordaemon/src/TABinaryManager/TAUnpack.h

index 5e3144b..147e771 100644 (file)
@@ -50,6 +50,7 @@ ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
 
 ADD_DEFINITIONS("-D_ARCH_=${ARCH}")
 ADD_DEFINITIONS(-DTEE_TASTORE_ROOT="${TASTORE_DIR}/")
+ADD_DEFINITIONS(-DTEE_EXTRACT_ROOT="${EXTRACT_DIR}/")
 ADD_DEFINITIONS(-DTEE_SS_ROOT="${STORAGE_DIR}/")
 ADD_DEFINITIONS(-DTEE_TALOG_ROOT="${TALOG_DIR}/")
 
index 50e3a99..da9da5e 100644 (file)
@@ -326,7 +326,7 @@ void TEE_StartPropertyEnumerator(TEE_PropSetHandle enumerator,
        switch ((uintptr_t)propSet) {\r
                case TEE_PROPSET_CURRENT_TA: {\r
                        newEnumHandle->property = new TAProperty(\r
-                           string(TEE_TASTORE_ROOT) + thisTAUUIDGlobal + "-ext/"\r
+                           string(TEE_EXTRACT_ROOT) + thisTAUUIDGlobal + "-ext/"\r
                                + thisTAUUIDGlobal + ".manifest");\r
                        break;\r
                }\r
index a037025..97abb4b 100644 (file)
 #endif
 #endif
 
+#ifndef TEE_EXTRACT_ROOT
+#define TEE_EXTRACT_ROOT "/opt/usr/apps/ta_sdk/extract/"
+#endif
+
 #ifndef TEE_SS_ROOT
 #define TEE_SS_ROOT "/opt/usr/apps/ta_sdk/data/"
 #endif
@@ -41,6 +45,7 @@
 #define TEE_TALOG_ROOT "/var/log/ta/"
 #endif
 
+
 //keep in sync with systemd/tef-simulator.socket
 #define SIMDAEMON_SOCK_PATH "/var/run/simdaemon"
 
index 33645b4..8cab70e 100644 (file)
@@ -32,6 +32,7 @@ PreReq: tef-libteec
 %define tastore_dir /opt/usr/apps/ta_sdk/tee
 %endif
 %define storage_dir /opt/usr/apps/ta_sdk/data
+%define extract_dir /opt/usr/apps/ta_sdk/extract
 %define talog_dir /var/log/ta
 
 %define build_bin_dir %{buildroot}%{bin_dir}
@@ -85,6 +86,7 @@ cmake . \
         -DDATA_DIR=%{build_data_dir} \
         -DINCLUDE_DIR=%{build_include_dir} \
         -DTASTORE_DIR=%{tastore_dir} \
+        -DEXTRACT_DIR=%{extract_dir} \
         -DSTORAGE_DIR=%{storage_dir} \
         -DTALOG_DIR=%{talog_dir} \
         -DSYSTEMD_UNIT_DIR=%{build_unit_dir} \
@@ -132,6 +134,7 @@ fi
 %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}
+%attr(770,root,security_fw) %{extract_dir}
 
 %files -n %{name}-devkit
 %license LICENSE
index e57cc44..f330065 100644 (file)
@@ -105,4 +105,5 @@ TARGET_LINK_LIBRARIES(${TARGET_TEF_SIMULATOR_DAEMON}
 INSTALL(TARGETS ${TARGET_TEF_SIMULATOR_DAEMON} DESTINATION ${BIN_DIR})
 
 INSTALL(DIRECTORY DESTINATION ${BUILD_ROOT}${TASTORE_DIR})
+INSTALL(DIRECTORY DESTINATION ${BUILD_ROOT}${EXTRACT_DIR})
 INSTALL(DIRECTORY DESTINATION ${BUILD_ROOT}${STORAGE_DIR})
index 52fba75..c609831 100644 (file)
@@ -252,11 +252,11 @@ void TABinaryManager::decryptImage(StructBinaryInfo& info) {
 bool TABinaryManager::unpackBinary(const string &uuid, StructBinaryInfo& info) {
        TAUnpack* unpacker = TAUnpack::getInstance();
        bool ret = false;
-       if (0 == unpacker->unpackTA(string(TEE_TASTORE_ROOT), uuid)) {
+       if (0 == unpacker->unpackTA(TEE_TASTORE_ROOT, uuid)) {
                LOGD(SIM_DAEMON, "Unpacked, filling info");
                // 1. Set binary info
                info.path = string(TEE_TASTORE_ROOT) + uuid;
-               info.extractpath = string(TEE_TASTORE_ROOT) + uuid + "-ext/";
+               info.extractpath = string(TEE_EXTRACT_ROOT) + uuid + "-ext/";
                info.imagePath = info.extractpath + uuid + ".image";
                info.manifestPath = info.extractpath + uuid + ".manifest";
                // 2. Parse manifest and store results
index cce3913..28c906a 100644 (file)
@@ -61,15 +61,13 @@ TAUnpack* TAUnpack::getInstance() {
  * @param uuid uuid of package
  * @return -1 on error otherwise 0
  */
-int TAUnpack::unpackTA(string path, string uuid) {
+int TAUnpack::unpackTA(const string& path, const string& uuid) {
        LOGD(SIM_DAEMON, "");
        TAPackageHeaderV2 packageHeader;
        memset(&packageHeader, 0, sizeof(TAPackageHeaderV2));
-       // Open file
-       string path_to_file = path + uuid;
-       ifstream tapackage(path_to_file.c_str(), ios::in | ios::binary);
-       // Create directory for UUID
-       string extract_dir_path = path + uuid + "-ext/";
+
+       // Create directory for TA extracted files
+       string extract_dir_path = TEE_EXTRACT_ROOT + uuid + "-ext/";
        struct stat info;
        if (stat(extract_dir_path.c_str(), &info) != 0) {
                if (0 != mkdir(extract_dir_path.c_str(), 0777)) {
@@ -78,8 +76,11 @@ int TAUnpack::unpackTA(string path, string uuid) {
                }
        }
 
+       // Open TA package file
+       string path_to_file = path + uuid;
+       ifstream tapackage(path_to_file.c_str(), ios::in | ios::binary);
        if (!tapackage.is_open()) {
-               LOGE(SIM_DAEMON, "Already open - failed");
+               LOGE(SIM_DAEMON, "Cannot open ta: %s", path_to_file.c_str());
                return -1; //> unable to open file
        }
        // 1. Read header
index a598e0a..b701d67 100644 (file)
@@ -78,7 +78,7 @@ private:
            unsigned int paddedSize);
 public:
        static TAUnpack* getInstance();
-       int unpackTA(string path, string uuid);
+       int unpackTA(const string& path, const string& uuid);
        virtual ~TAUnpack();
 };