[Messaging] Fixed permissions of temporary file used for messaging 47/175047/1
authorRafal Walczyna <r.walczyna@partner.samsung.com>
Fri, 6 Apr 2018 07:19:43 +0000 (09:19 +0200)
committerRafal Walczyna <r.walczyna@partner.samsung.com>
Fri, 6 Apr 2018 07:23:24 +0000 (09:23 +0200)
File created by mkstemp() gives permissions only for user,
that's why msg-service could not read from file and body of message was empty.

[Verification] 100% passrate on TM1

Change-Id: I290277294459ca96392b9a97adccded1664a426d
Signed-off-by: Rafal Walczyna <r.walczyna@partner.samsung.com>
src/messaging/message.cc

index ba6aaa6..5fdbbc6 100644 (file)
@@ -346,6 +346,11 @@ PlatformResult saveToTempFile(const std::string& data, std::string* file_name) {
   if (-1 == file_descriptor) {
     return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Temp file creation failed");
   }
+  // Change permision of file to -rw-r--r--
+  int ret_fchmod = fchmod(file_descriptor, 0644);
+  if (-1 == ret_fchmod) {
+    return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Permission changing failed");
+  }
 
   std::string tmp_name = buf;