Modify mount-related logic 60/318060/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 24 Sep 2024 06:21:14 +0000 (15:21 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 24 Sep 2024 06:21:14 +0000 (15:21 +0900)
- Check whether the source directory exists or not
- Remove extra datas related to mount from the bundle object

Change-Id: Iea25ce22cbbb05c673eb879abb6df0556784446f
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/app_executor.cc
src/lib/launchpad-core/util.cc
src/lib/launchpad/step_prepare_execution.cc
src/lib/launchpad/step_prepare_execution.hh

index 7f43b37820b9ef58b01f4c7905601a733d796939..20d9f43cc2c3817f8964ef910105bf8d2bbb1138 100644 (file)
 namespace launchpad {
 namespace fs = std::filesystem;
 
+namespace {
+
+void RemoveAulKeys(tizen_base::Bundle* b) {
+  b->Delete(kAulSdk);
+  b->Delete(kAulMountGlobalResDir);
+  b->Delete(kAulMountAllowedResDir);
+  b->Delete(kAulMountLibDir);
+  b->Delete(kAulMountGadgetPaths);
+  b->Delete(kAulMountGadgetPkgIds);
+}
+
+}  // namespace
+
 AppExecutor::AppExecutor() {
   LauncherInfoInflator inflator;
   launcher_infos_ = inflator.Inflate("/usr/share/aul");
@@ -56,8 +69,10 @@ pid_t AppExecutor::Execute(const AppInfo* app_info) {
   auto& b = const_cast<tizen_base::Bundle&>(app_info->GetBundle());
   Debug::GetInst().PrepareDebugger(b);
 
+  auto cloned_b = tizen_base::Bundle(b);
+  RemoveAulKeys(&cloned_b);
   auto app_args =
-      CreateAppArgv(app_info->GetAppPath(), b, app_info->GetAppType());
+      CreateAppArgv(app_info->GetAppPath(), cloned_b, app_info->GetAppType());
   b.Add(kAulAppArgs, app_args);
   b.Add(kAulLuxCmd, std::to_string(static_cast<int>(LuxCmd::ExecuteApp)));
 
index e1f2b37ae6a8f4bdc06ec6b8465af4d06d4d6971..379dfac8f7115928563138138b6df4c701abc0e9 100644 (file)
@@ -382,6 +382,21 @@ std::vector<std::string> ValidateAndModifyGadgetPaths(
   return paths;
 }
 
+std::vector<std::string> ModifyDirectories(
+    std::vector<std::string> sources) {
+  std::vector<std::string> res;
+  for (auto& source : sources) {
+    if (access(source.c_str(), F_OK) != 0) {
+      SECURE_LOGD("No such directory. path=%s", source.c_str());
+      continue;
+    }
+
+    res.push_back(std::move(source));
+  }
+
+  return res;
+}
+
 }  // namespace
 
 void Util::SetEnvironments(const AppInfo* app_info) {
@@ -480,11 +495,13 @@ int Util::EnableExternalPackage(const AppInfo* app_info) {
 int Util::MountResourceDirectories(const AppInfo* app_info) {
   auto& root_path = app_info->GetRootPath();
   auto& b = app_info->GetBundle();
-  auto global_res_dir = b.GetStringArray(kAulMountGlobalResDir);
+  auto global_res_dir =
+      ModifyDirectories(b.GetStringArray(kAulMountGlobalResDir));
   if (!global_res_dir.empty())
     MountDirectories(global_res_dir, root_path + "/res/mount/global");
 
-  auto allowed_res_dir = b.GetStringArray(kAulMountAllowedResDir);
+  auto allowed_res_dir =
+      ModifyDirectories(b.GetStringArray(kAulMountAllowedResDir));
   if (!allowed_res_dir.empty())
     MountDirectories(allowed_res_dir, root_path + "/res/mount/allowed");
 
@@ -492,7 +509,7 @@ int Util::MountResourceDirectories(const AppInfo* app_info) {
 }
 
 int Util::MountLibraryDirectories(const tizen_base::Bundle& b) {
-  auto lib_dir = b.GetStringArray(kAulMountLibDir);
+  auto lib_dir = ModifyDirectories(b.GetStringArray(kAulMountLibDir));
   if (!lib_dir.empty()) {
     auto root_path = b.GetString(kAulRootPath);
     MountDirectories(lib_dir, root_path + "/lib/");
@@ -502,7 +519,7 @@ int Util::MountLibraryDirectories(const tizen_base::Bundle& b) {
 }
 
 int Util::MountGadgetDirectories(const tizen_base::Bundle& b) {
-  auto gadget_paths = b.GetStringArray(kAulMountGadgetPaths);
+  auto gadget_paths = ModifyDirectories(b.GetStringArray(kAulMountGadgetPaths));
   if (!gadget_paths.empty()) {
     gadget_paths = ValidateAndModifyGadgetPaths(gadget_paths);
     auto root_path = b.GetString(kAulRootPath);
index c9262a9c423edbbcf7d576e0a2501a0f1e8bc262..83339abc557daf5fb37e77c118c3ed806ad3d7b2 100644 (file)
@@ -63,6 +63,8 @@ StepPrepareExecution::StepPrepareExecution() {
         std::placeholders::_1),
     std::bind(&StepPrepareExecution::SendStartupSignal, this,
         std::placeholders::_1),
+    std::bind(&StepPrepareExecution::RemoveAulkeys, this,
+        std::placeholders::_1),
   };
 }
 
@@ -196,4 +198,15 @@ int StepPrepareExecution::SendStartupSignal(AppInfo* app_info) {
   return 0;
 }
 
+int StepPrepareExecution::RemoveAulkeys(AppInfo* app_info) {
+  auto& b = const_cast<tizen_base::Bundle&>(app_info->GetBundle());
+  b.Delete(kAulSdk);
+  b.Delete(kAulMountGlobalResDir);
+  b.Delete(kAulMountAllowedResDir);
+  b.Delete(kAulMountLibDir);
+  b.Delete(kAulMountGadgetPaths);
+  b.Delete(kAulMountGadgetPkgIds);
+  return 0;
+}
+
 }  // namespace launchpad
index f95514b86c8f0846f318091b5905d8c00cf5339a..097f85663e429e21e561452a2e19964409ad0627 100644 (file)
@@ -44,6 +44,7 @@ class StepPrepareExecution {
   int PrepareAppSocket(AppInfo* app_info);
   int PrepareIdFile(AppInfo* app_info);
   int SendStartupSignal(AppInfo* app_info);
+  int RemoveAulkeys(AppInfo* app_info);
 
  private:
   std::vector<std::function<int(AppInfo*)>> steps_;