Use access() instead of std::filesystem::exists 76/302876/2
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 15 Dec 2023 03:34:17 +0000 (12:34 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Fri, 15 Dec 2023 04:22:25 +0000 (04:22 +0000)
The std::filesystem::exists uses stat() internally. The read permission
is needed to use stat(). It can cause the smack issues.
This patch changes the implementation to using access() with F_OK option.

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

index c330f5d..2e79382 100644 (file)
@@ -519,11 +519,11 @@ int Util::PrepareAppSocket() {
   try {
     std::string path = "/run/aul/apps/" + std::to_string(getuid()) + "/" +
         std::to_string(getpid());
-    ServerSocket socket;
-    if (!fs::exists(path))
+    if (access(path.c_str(), F_OK) != 0)
       fs::create_directory(path);
 
     path += "/.app-sock";
+    ServerSocket socket;
     socket.Bind(path);
     socket.Listen(128);
     socket.SetReceiveBufferSize(Socket::kSocketMaxBufferSize);