Support UID Sandbox feature 08/319608/6
authorJihoi Kim <jihoi.kim@samsung.com>
Thu, 13 Feb 2025 10:56:50 +0000 (19:56 +0900)
committerJihoi Kim <jihoi.kim@samsung.com>
Wed, 26 Feb 2025 02:01:37 +0000 (11:01 +0900)
- Change app socket path info /run/aul/apps/{pid}
- Change function name for readability,
  Using unified expression: 'socket path' and 'socket directory path'

Change-Id: Iff0f496e7d88c44f61ffae89becdb16c4bdf1d0f
Signed-off-by: Jihoi Kim <jihoi.kim@samsung.com>
packaging/launchpad-process-pool.service
src/launchpad-process-pool/app_executor.cc
src/launchpad-process-pool/loader_context.cc
src/launchpad-process-pool/signal_manager.cc
src/lib/launchpad-core/util.cc
src/lib/launchpad-core/util.hh

index c3a2ab0535f4a3c6eb30610b136f347f308811b4..be53b51de35ec2e5aab9651a0eee6f93658d77fc 100644 (file)
@@ -11,8 +11,6 @@ After=enlightenment-user.service
 [Service]
 ExecStartPre=-/usr/bin/mkdir -p /run/aul/daemons/%U
 ExecStartPre=-/usr/bin/chmod 0777 /run/aul/daemons/%U
-ExecStartPre=-/usr/bin/mkdir -p /run/aul/apps/%U
-ExecStartPre=-/usr/bin/chmod 0700 /run/aul/apps/%U
 ExecStartPre=-/usr/bin/mkdir -p /run/aul/dbspace/%U
 ExecStartPre=-/usr/bin/chmod 0701 /run/aul/dbspace/%U
 ExecStartPre=-/usr/bin/mkdir -p /run/aul/log/widget/%U
index 318e01567506f36a5547a5bf3329b22a93333edc..9e62e5626b99286c0c70df54a10cf16b44843edc 100644 (file)
@@ -140,7 +140,7 @@ void AppExecutor::OnExecution() {
       app_info_->GetAppId());
   CheckAndPrepareDebugging();
   SigchldManager::UnblockSigchld();
-  Util::DeleteSocketPath(getpid(), getuid());
+  Util::DeleteSocketDirectory(getpid());
 
   int ret = Prepare();
   if (ret < 0) {
index 5079225e0e538d0f0182b654be17532d30ee4301..a0137f9876a021270f990d7ec8b6b1ee219a88d4 100644 (file)
@@ -214,7 +214,6 @@ void LoaderContext::Dispose() {
     on_boot_timer_ = 0;
   }
 
-  
   client_channel_.reset();
   if (client_socket_) {
     ProcessPool::RemoveFdFromCloseableFds(client_socket_->GetFd());
@@ -252,7 +251,7 @@ pid_t LoaderContext::Deploy(const AppInfo* app_info) {
       _E("Failed to attach resources to loader process");
   }
 
-  Util::DeleteSocketPath(pid_, getuid());
+  Util::DeleteSocketDirectory(pid_);
   tizen_base::Parcel parcel;
   parcel.WriteParcelable(*app_info);
   size_t data_size = parcel.GetDataSize();
index 12fc88f2d7a3f73a0a2507d1ce33b9640215e3d2..6efcee9671063970c4e9a87b5cb4b510460b6b2d 100644 (file)
@@ -42,9 +42,9 @@ class GarbageCollector {
   void DoAtFork() {
     _W("pid: %d", pid_);
     try {
-      std::string path = "/run/aul/apps/" + std::to_string(getuid()) + "/" +
-                         std::to_string(pid_);
-      DeleteSocketPath(fs::path(path));
+      std::string dir_path = "/run/aul/apps/" + std::to_string(pid_);
+      DeleteDirectory(fs::path(dir_path));
+
       DeleteUnusedFiles();
       _W("Delete done");
     } catch (const std::filesystem::filesystem_error& e) {
@@ -53,7 +53,7 @@ class GarbageCollector {
   }
 
  private:
-  void DeleteSocketPath(const fs::path& path) {
+  void DeleteDirectory(const fs::path& path) {
     try {
       fs::remove_all(path);
     } catch (const fs::filesystem_error& e) {
@@ -62,12 +62,12 @@ class GarbageCollector {
   }
 
   void SocketGarbadgeCollector() {
-    std::string path = "/run/aul/apps/" + std::to_string(getuid());
+    std::string path = "/run/aul/apps/";
     for (const auto& entry : fs::directory_iterator(path)) {
       if (!isdigit(entry.path().filename().string()[0])) continue;
 
       std::string proc_path = "/proc/" + entry.path().filename().string();
-      if (!fs::exists(proc_path)) DeleteSocketPath(entry.path());
+      if (!fs::exists(proc_path)) DeleteDirectory(entry.path());
     }
   }
 
index 671216c95e4bdc8468cac889b1ca40fe59870004..1ef8754c2d6d0d96635525f02ce3bc4a0fd5661e 100644 (file)
@@ -486,9 +486,8 @@ void Util::SetEnvironments(const AppInfo* app_info) {
   SetGadgetPkgIdsEnvironments(b);
 }
 
-void Util::DeleteSocketPath(pid_t pid, uid_t uid) {
-  std::string path ="/run/aul/apps/" + std::to_string(uid) + "/" +
-      std::to_string(pid);
+void Util::DeleteSocketDirectory(pid_t pid) {
+  std::string path ="/run/aul/apps/" + std::to_string(pid);
   if (!fs::exists(path))
     return;
 
@@ -624,15 +623,14 @@ void Util::CloseAllFds(const std::vector<int>& except_fds) {
 int Util::PrepareAppSocket() {
   try {
     std::error_code ec;
-    std::string path = "/run/aul/apps/" + std::to_string(getuid()) + "/" +
-        std::to_string(getpid());
+    std::string path = "/run/aul/apps/" + std::to_string(getpid());
 
     if(access(path.c_str(), F_OK) == 0 && fs::remove_all(path, ec)) {
       _E("Directory exist, but failed to remove it. path=%s, error_code=%d(%s)",
           path.c_str(), ec.value(), ec.message().c_str());
       return -1;
     }
-    if (!fs::create_directory(path, ec)) {
+    if (!fs::create_directories(path, ec)) {
       _E("Failed to create directory. path=%s, error_code=%d(%s)",
           path.c_str(), ec.value(), ec.message().c_str());
       return -1;
@@ -656,8 +654,8 @@ int Util::PrepareAppSocket() {
 }
 
 int Util::PrepareAppIdFile(const AppInfo* app_info) {
-  std::string path = "/run/aul/apps/" + std::to_string(getuid()) + "/" +
-      std::to_string(getpid()) + "/" + app_info->GetAppId();
+  std::string path = std::format("/run/aul/apps/{}/{}",
+      getpid(), app_info->GetAppId());
   std::ofstream stream(path);
   stream.close();
   return 0;
index 44af3254a4db32b7e985329d8e864eac4a904642..21534fa3324fa084e39c2510d9399adb0bb2cee4 100644 (file)
@@ -55,7 +55,7 @@ int operator&(int a, E b) {
 class EXPORT_API Util {
  public:
   static void SetEnvironments(const AppInfo* app_info);
-  static void DeleteSocketPath(pid_t pid, uid_t uid);
+  static void DeleteSocketDirectory(pid_t pid);
   static int EnableExternalPackage(const AppInfo* app_info);
   static int MountResourceDirectories(const AppInfo* app_info);
   static int MountGadgetDirectories(const tizen_base::Bundle& b);