[United Service App] Set service packages enviornments 37/319637/3
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 14 Feb 2025 01:14:33 +0000 (10:14 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 14 Mar 2025 10:21:31 +0000 (19:21 +0900)
Before executing an application, the launchpad sets the service packages
to the environment variables.

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

index 9e62e5626b99286c0c70df54a10cf16b44843edc..363782e4a5f207d5680f095202e3feefb3071dc4 100644 (file)
@@ -241,6 +241,12 @@ int AppExecutor::StepMountResDir() {
     return ret;
   }
 
+  ret = Util::MountServiceDirectories(app_info_->GetBundle());
+  if (ret != 0) {
+    _E("Failed to mount service resources");
+    return ret;
+  }
+
   ret = Util::MountLibraryDirectories(app_info_->GetBundle());
   if (ret != 0) {
     _E("Failed to mount library resources");
index 7fa12d1b237070768a1505fb6d5b07498ba9be9b..90de0ceb5e9aab6e8902b703f4f91ca7408fc49d 100644 (file)
@@ -81,6 +81,7 @@ int LoaderMount::Mount(pid_t pid, const AppInfo* app_info) {
   int ret = ChangeMountNamespace(pid);
   if (ret == 0) {
     ret = Util::MountGadgetDirectories(b);
+    ret |= Util::MountServiceDirectories(b);
     ret |= Util::MountLibraryDirectories(b);
     ChangeMountNamespace(launchpad_ppid_);
   }
index f54b7ded4466bdf4f90f9567a3811f413eae25fa..63d71c16d715f0fec4199c0706f25634f56df2d7 100644 (file)
@@ -65,6 +65,8 @@ constexpr const char kAulTizenAsanActivation[] =
 constexpr const char kAulEnvLang[] = "__AUL_ENV_LANG__";
 constexpr const char kAulEnvRegionFormat[] = "__AUL_ENV_REGION_FORMAT__";
 constexpr const char kAulRequestId[] = "__AUL_REQUEST_ID__";
+constexpr const char kAulMountServicePkgIds[] = "__AUL_MOUNT_SERVICE_PKGIDS__";
+constexpr const char kAulMountServicePaths[] = "__AUL_MOUNT_SERVICE_PATHS__";
 
 }  // namespace launchpad
 
index 1ef8754c2d6d0d96635525f02ce3bc4a0fd5661e..b7f1810793d47f54f0f8d84682ce4086ee32497b 100644 (file)
@@ -115,6 +115,20 @@ void SetGadgetPkgIdsEnvironments(const tizen_base::Bundle& b) {
   setenv("GADGET_PKGIDS", pkgids.c_str(), 1);
 }
 
+void SetServicePkgIdsEnvironments(const tizen_base::Bundle& b) {
+  auto service_pkgids = b.GetStringArray(kAulMountServicePkgIds);
+  if (service_pkgids.empty()) return;
+
+  std::string pkgids;
+  for (auto& pkgid : service_pkgids) {
+    if (!pkgids.empty()) pkgids += ":";
+
+    pkgids += pkgid;
+  }
+
+  setenv("SERVICE_PACKAGES", pkgids.c_str(), 1);
+}
+
 #ifdef TIZEN_FEATURE_SET_PERSONALITY_32
 static void SetExecutionDomain() {
   int ret = personality(PER_LINUX32);
@@ -484,6 +498,7 @@ void Util::SetEnvironments(const AppInfo* app_info) {
   setenv("GCOV_PREFIX", "/tmp", 1);
   setenv("DALI_DISABLE_PARTIAL_UPDATE", "0", 1);
   SetGadgetPkgIdsEnvironments(b);
+  SetServicePkgIdsEnvironments(b);
 }
 
 void Util::DeleteSocketDirectory(pid_t pid) {
@@ -533,8 +548,8 @@ int Util::MountResourceDirectories(const AppInfo* app_info) {
 }
 
 int Util::MountGadgetDirectories(const tizen_base::Bundle& b) {
-  auto gadget_paths =
-      ValidateAndModifyGadgetPaths(b.GetStringArray(kAulMountGadgetPaths));
+  auto gadget_paths = ValidateAndModifyGadgetPaths(
+        b.GetStringArray(kAulMountGadgetPaths));
   if (gadget_paths.empty()) return 0;
 
   auto app_type = b.GetString(kAulAppType);
@@ -562,6 +577,25 @@ int Util::MountLibraryDirectories(const tizen_base::Bundle& b) {
   return MountDirectories(lib_paths, dest);
 }
 
+int Util::MountServiceDirectories(const tizen_base::Bundle& b) {
+  auto service_paths =
+      ModifyDirectories(b.GetStringArray(kAulMountServicePaths));
+
+  if (service_paths.empty()) return 0;
+
+  auto root_path = b.GetString(kAulRootPath);
+  auto app_type = b.GetString(kAulAppType);
+  if (app_type.find("dotnet") != std::string::npos) {
+    auto dest = GetDestPath(root_path, "service");
+    return MountDirectories(service_paths, dest);
+  }
+
+  if (service_paths.empty()) return 0;
+
+  auto dest = root_path + "/bin/";
+  return MountDirectories(service_paths, dest);
+}
+
 int Util::WaitTepMount(const AppInfo* app_info) {
   if (app_info->GetBundle().GetType(kAulTepPath) == BUNDLE_TYPE_NONE)
     return 0;
index 21534fa3324fa084e39c2510d9399adb0bb2cee4..ff94aed95058750db0edb994f3cc4e2091b3fef1 100644 (file)
@@ -60,6 +60,7 @@ class EXPORT_API Util {
   static int MountResourceDirectories(const AppInfo* app_info);
   static int MountGadgetDirectories(const tizen_base::Bundle& b);
   static int MountLibraryDirectories(const tizen_base::Bundle& b);
+  static int MountServiceDirectories(const tizen_base::Bundle& b);
   static int WaitTepMount(const AppInfo* app_info);
   static std::string GetLibDirectory(const std::string& app_path);
   static void CloseAllFds(const std::vector<int>& except_fds = {});
index 95fad2d9cb14253a62edef5e873094333e251af2..1779c056163c44d6d56cb21ecc373aae78160b52 100644 (file)
@@ -104,6 +104,11 @@ int StepPrepareExecution::MountResourceDirectories(AppInfo* app_info) {
       return -1;
     }
 
+    if (Util::MountServiceDirectories(app_info->GetBundle()) != 0) {
+      _E("Failed to mount service resources");
+      return -1;
+    }
+
     if (Util::MountLibraryDirectories(app_info->GetBundle()) != 0) {
       _E("Failed to mount library resources");
       return -1;