Check source directory existence 26/319726/2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 31 Oct 2024 04:15:52 +0000 (13:15 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 31 Oct 2024 04:26:54 +0000 (13:26 +0900)
Before mounting the resource directories to the directory of the application,
the process checks whether the directory exists or not.

Change-Id: I264c17c855a56f4cdbb52d2ac6803b5afb0dde53
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/launchpad-core/util.cc

index f75c6dadef53a7be4afbf8d3cb455a74f07ce852..4ccde5da7cff10115ae17b4da928870f2c27cf84 100644 (file)
@@ -373,10 +373,17 @@ std::vector<std::string> ValidateAndModifyGadgetPaths(
     const std::vector<std::string> gadget_paths) {
   std::vector<std::string> paths;
   for (const auto& path : gadget_paths) {
-    if (access(path.c_str(), F_OK) == 0)
+    if (access(path.c_str(), F_OK) == 0) {
       paths.push_back(path);
-    else
-      paths.push_back(fs::path(path).parent_path().string());
+    } else {
+      auto parent_path = fs::path(path).parent_path().string();
+      if (access(parent_path.c_str(), F_OK) != 0) {
+        SECURE_LOGE("Failed to access directory(%s), errno(%d)",
+                    parent_path.c_str(), errno);
+      } else {
+        paths.push_back(std::move(parent_path));
+      }
+    }
   }
 
   return paths;
@@ -387,7 +394,8 @@ std::vector<std::string> ModifyDirectories(
   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());
+      SECURE_LOGE("Failed to access directory(%s), errno(%d)", source.c_str(),
+                  errno);
       continue;
     }