Log errno when stat() fails 17/324617/3
authorZofia Abramowska <z.abramowska@samsung.com>
Thu, 15 May 2025 13:06:57 +0000 (15:06 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Mon, 2 Jun 2025 09:39:42 +0000 (09:39 +0000)
Change-Id: Ib1ea8050bd17ac7b00f33b4c4ec4a49bd397e258

src/client/client-security-manager.cpp

index f1cbb16152f036de13e3f51432c3348abb1372a8..dd0731c1162ca2ac4eaf1a492d9eb13a3a71538b 100644 (file)
@@ -39,6 +39,7 @@
 #include "group2gid.h"
 #include "mount-namespace.h"
 #include "protocols.h"
+#include "security-manager-types.h"
 #include "security-manager.h"
 #include "service_impl.h"
 #include "smack-check.h"
@@ -46,6 +47,7 @@
 #include "tzplatform-config.h"
 #include "utils.h"
 
+#include <errno.h>
 #include <atomic>
 #include <cassert>
 #include <cstdio>
@@ -1340,7 +1342,11 @@ static int pidToUid(pid_t pid, uid_t &puid)
 
     int ret = stat(path.c_str(), &st);
     if (ret < 0) {
-        LogError("Access to " << path << " failed with : " << ret);
+        auto statErrno = errno;
+        LogErrno("Access to " << path);
+        if (statErrno == ENOENT) {
+            return SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT;
+        }
         return SECURITY_MANAGER_ERROR_UNKNOWN;
     }
     puid = st.st_uid;
@@ -1989,7 +1995,7 @@ int security_manager_identify_app_from_pid(pid_t pid, char **pkg_name, char **ap
                 if (app_name)
                     *app_name = appName;
             }
-            return SECURITY_MANAGER_SUCCESS;
+            return request.getStatus();
         });
     });
 }