SM: Use TzPlatformConfig for global app dir
[platform/core/test/security-tests.git] / src / security-manager-tests / common / sm_commons.cpp
index 71aeb89..53013d4 100644 (file)
@@ -78,7 +78,7 @@ std::string generatePkgLabel(const std::string &pkgId)
 static std::string genPath(int app_num, const char *postfix) {
     char buf[16];
     sprintf(buf, "%02d", app_num);
-    return std::string("/opt/usr/globalapps/sm_test_") + std::string(buf) + std::string("_pkg_id_full/") + std::string(postfix);
+    return TzPlatformConfig::globalAppDir() + "/sm_test_" + std::string(buf) + "_pkg_id_full/" + std::string(postfix);
 }
 
 std::string genRWPath(int app_num) {
@@ -210,7 +210,7 @@ int nftw_remove_labels(const char *fpath, const struct stat* /*sb*/,
     return 0;
 }
 
-static const char *const SM_DENIED_PATH = "/opt/usr/globalapps/non_app_dir";
+static const std::string SM_DENIED_PATH = TzPlatformConfig::globalAppDir() + "/non_app_dir";
 
 void check_app_permissions(const char *const app_id, const char *const pkg_id,
                            const char *const user, const privileges_t &allowed_privs,
@@ -334,7 +334,7 @@ void check_app_path_after_install(int app_num, const char *pkgId, bool others_en
     result = nftw(SM_PUBLIC_RO_PATH.c_str(), &nftw_check_sm_labels, FTW_MAX_FDS, FTW_PHYS);
     RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for " << SM_PUBLIC_RO_PATH);
 
-    result = nftw(SM_DENIED_PATH, &nftw_check_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS);
+    result = nftw(SM_DENIED_PATH.c_str(), &nftw_check_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS);
     RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for " << SM_DENIED_PATH);
 
     // owner RW, others RO
@@ -436,7 +436,7 @@ static void prepare_app_path(int app_num, bool others_enabled = false)
         RUNNER_ASSERT_MSG(result == 0, "Unable to clean Smack labels in " << SM_OWNER_RW_OTHERS_RO_PATH);
     }
 
-    result = nftw(SM_DENIED_PATH, &nftw_set_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS);
+    result = nftw(SM_DENIED_PATH.c_str(), &nftw_set_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS);
     RUNNER_ASSERT_MSG(result == 0, "Unable to set Smack labels in " << SM_DENIED_PATH);
 }