Fix Prevent issue
authorZbigniew Kostrzewa <z.kostrzewa@samsung.com>
Mon, 7 Oct 2013 08:41:53 +0000 (10:41 +0200)
committerSoo-Hyun Choi <sh9.choi@samsung.com>
Tue, 8 Oct 2013 09:16:57 +0000 (18:16 +0900)
[Issue#]   CID: 30986
[Problem]  Unchecked return value
[Cause]    Returned value from a function is not checked
[Solution] Check return value

[Verification] Build repository

Change-Id: I512a0848ea5325bf1a7a8d6aa487346f486e19ee

src/jobs/widget_install/directory_api.cpp

index 9ca0980..806e078 100644 (file)
@@ -20,6 +20,7 @@
  * @brief   directory api - implementation file
  */
 
+#include <cerrno>
 #include <directory_api.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -27,6 +28,8 @@
 #include <fstream>
 #include <dpl/foreach.h>
 #include <dpl/utils/wrt_utility.h>
+#include <dpl/errno_string.h>
+#include <installer_log.h>
 
 namespace DirectoryApi {
 bool DirectoryCopy(std::string source, std::string dest)
@@ -72,7 +75,13 @@ bool DirectoryCopy(std::string source, std::string dest)
             outfile.close();
             infile.close();
 
-            chown(destFile.c_str(), statInfo.st_uid, statInfo.st_gid);
+            errno = 0
+            if (-1 == TEMP_FAILURE_RETRY(chown(destFile.c_str(),
+                                               statInfo.st_uid,
+                                               statInfo.st_gid))) {
+                int error = errno;
+                _E("Failed to change owner [%s]", DPL::GetErrnoString(error).c_str());
+            }
         }
     } while (dEntryResult != NULL && return_code == 0);
     closedir(dir);