Add res pkgids to bundle for launching
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 18 Nov 2022 07:10:48 +0000 (16:10 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 2 Feb 2023 04:02:15 +0000 (04:02 +0000)
Change-Id: I13ba0b971c815613f545dc5a2593ffc3fff841fb
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/lib/amd_res_info.cc
src/lib/amd_res_info.h
src/lib/launch/step_prepare_starting_app.cc
src/lib/res_info/res_app_info.cc
src/lib/res_info/res_app_info.hh

index 19be0b0e8d0418c263adb2a5d159def8e3dd0dc2..14a5dd4ea0591ca95eb71fa2a30a404fcf43c827 100644 (file)
@@ -330,10 +330,10 @@ int _resinfo_init(void) {
   return 0;
 }
 
-int _resinfo_get_res_package_paths(const char* appid, uid_t uid,
-    GList** allowed_paths, GList** global_paths) {
+int _resinfo_get_res_packages_info(const char* appid, uid_t uid,
+    GList** pkgids, GList** allowed_paths, GList** global_paths) {
   amd::ResInfoManager& manager = amd::ResInfoManager::GetInst();
-  std::vector<std::string> allowed_p, global_p;
+  std::vector<std::string> pkgid_v, allowed_p, global_p;
 
   std::shared_ptr<amd::ResInfo> resinfo = manager.GetUserResInfo(uid);
   if (!resinfo)
@@ -345,7 +345,10 @@ int _resinfo_get_res_package_paths(const char* appid, uid_t uid,
 
   res_appinfo->ClearResControlMountInfo();
   res_appinfo->UpdateResControlMountInfo(resinfo->GetResPkgs());
-  res_appinfo->GetMountPackagePaths(&allowed_p, &global_p);
+  res_appinfo->GetMountPackagesInfo(&pkgid_v, &allowed_p, &global_p);
+
+  for (const std::string& pkgid : pkgid_v)
+    *pkgids = g_list_append(*pkgids, strdup(pkgid.c_str()));
 
   for (const std::string& root_path : allowed_p) {
     std::string p = root_path + "/res/allowed/";
index 48be7b1cd4d5216698fe3b404fd36c443f84d724..6a2191bfadcbf33d9aa43992e39fd96afd28a2f5 100644 (file)
@@ -25,8 +25,8 @@ extern "C" {
 
 int _resinfo_init(void);
 
-int _resinfo_get_res_package_paths(const char *appid, uid_t uid,
-               GList **allowed_paths, GList **global_paths);
+int _resinfo_get_res_packages_info(const char *appid, uid_t uid,
+               GList **pkgids, GList **allowed_paths, GList **global_paths);
 
 #ifdef __cplusplus
 }
index 886ed4f3edda25c14d8745fc747af440e455728b..b717bd0027b0237c008140398818938f30a5362a 100644 (file)
@@ -44,7 +44,7 @@ namespace {
 constexpr const char OSP_K_LAUNCH_TYPE[] = "__OSP_LAUNCH_TYPE__";
 constexpr const char OSP_V_LAUNCH_TYPE_DATACONTROL[] = "datacontrol";
 
-void AddResPaths(GList* list, bundle* b, const char* key) {
+void AddDataToBundle(GList* list, bundle* b, const char* key) {
   bundle_del(b, key);
   guint length = g_list_length(list);
   if (length == 0)
@@ -586,16 +586,22 @@ int StepPrepareStartingApp::CheckAndSetCallerInfo(LaunchContext* context) {
 }
 
 int StepPrepareStartingApp::SetResPackagePaths(LaunchContext* context) {
+  GList* res_pkgids = nullptr;
   GList* allowed_paths = nullptr;
   GList* global_paths = nullptr;
-  if (_resinfo_get_res_package_paths(context->GetAppId().c_str(),
-        context->GetTargetUid(), &allowed_paths, &global_paths) < 0) {
+  if (_resinfo_get_res_packages_info(context->GetAppId().c_str(),
+        context->GetTargetUid(), &res_pkgids, &allowed_paths,
+        &global_paths) < 0) {
     _E("Failed to get res package paths");
     return -1;
   }
 
-  AddResPaths(allowed_paths, context->GetBundle(), AUL_K_MOUNT_ALLOWED_RES_DIR);
-  AddResPaths(global_paths, context->GetBundle(), AUL_K_MOUNT_GLOBAL_RES_DIR);
+  AddDataToBundle(res_pkgids, context->GetBundle(), AUL_K_MOUNT_RES_PKGIDS);
+  AddDataToBundle(allowed_paths, context->GetBundle(),
+      AUL_K_MOUNT_ALLOWED_RES_DIR);
+  AddDataToBundle(global_paths, context->GetBundle(),
+      AUL_K_MOUNT_GLOBAL_RES_DIR);
+  g_list_free_full(res_pkgids, free);
   g_list_free_full(allowed_paths, free);
   g_list_free_full(global_paths, free);
   return 0;
index 61d63e680c93317006a9625f8eb95d572adb33f1..809758458309b1fc83eb13eda4a053a8e45e7822 100644 (file)
@@ -190,13 +190,18 @@ void ResAppInfo::UpdateResControlMountInfo(
   }
 }
 
-void ResAppInfo::GetMountPackagePaths(std::vector<std::string>* allowed_paths,
+void ResAppInfo::GetMountPackagesInfo(std::vector<std::string>* pkgids,
+      std::vector<std::string>* allowed_paths,
       std::vector<std::string>* global_paths) {
   for (const auto& res_control : res_control_list_) {
-    if (res_control.allowed_package)
+    if (res_control.allowed_package) {
+      pkgids->push_back(res_control.allowed_package->GetPkgId());
       allowed_paths->push_back(res_control.allowed_package->GetRootPath());
-    if (res_control.global_package)
+    }
+    if (res_control.global_package) {
+      pkgids->push_back(res_control.global_package->GetPkgId());
       global_paths->push_back(res_control.global_package->GetRootPath());
+    }
   }
 }
 
index f15cd6158035f3de6e83babd150b3a9fbec95e35..51f519f601197181c980008f56a93cebbb360cce 100644 (file)
@@ -73,7 +73,8 @@ class ResAppInfo {
       const std::unordered_map<std::string,
           std::shared_ptr<ResPkgInfo>>& res_pkgs);
   void UpdateResControlMountInfo(std::shared_ptr<ResPkgInfo> res_pkginfo);
-  void GetMountPackagePaths(std::vector<std::string>* allowed_paths,
+  void GetMountPackagesInfo(std::vector<std::string>* pkgids,
+      std::vector<std::string>* allowed_paths,
       std::vector<std::string>* global_paths);
 
  private: