Flush files with security server passwords data
authorJan Cybulski <j.cybulski@samsung.com>
Fri, 22 Nov 2013 17:14:24 +0000 (18:14 +0100)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 6 Feb 2014 16:13:23 +0000 (17:13 +0100)
[Issue#]       SSDWSSP-683
[Bug/Feature]  Information about putting password attempts was not flushed.
[Solution]     Flush that information to file. Test shown, that only using
               fsynch gives proper result.
[Veryfication] Build, install, run tests.

Change-Id: I96ee50186253d3efd1c74f3e2821dbc4f845a056

src/server/service/password-file-buffer.cpp
src/server/service/password-file.cpp

index eb97897..d52f447 100644 (file)
@@ -32,6 +32,8 @@
 #include <security-server.h>
 #include <password-exception.h>
 
+#include <fcntl.h>
+
 namespace SecurityServer
 {
     PasswordFileBuffer::PasswordFileBuffer(): m_bufferReadBytes(0) {}
@@ -78,6 +80,8 @@ namespace SecurityServer
             LogError("Failed to write data.");
             Throw(PasswordException::FStreamWriteError);
         }
+        file.close();
+        int fd = open(path.c_str(), O_WRONLY | O_APPEND); fsync(fd); close(fd);
     }
 
     void PasswordFileBuffer::Load(const std::string &path)
index 5f20fc2..1532e3f 100644 (file)
@@ -37,6 +37,8 @@
 #include <password-exception.h>
 #include <password-file-buffer.h>
 
+#include <fcntl.h>
+
 const std::string DATA_DIR = "/opt/data/security-server";
 const std::string PASSWORD_FILE = "password.pwd";
 const std::string ATTEMPT_FILE = "attempt";
@@ -190,6 +192,8 @@ namespace SecurityServer
             LogError("Failed to write attempt count.");
             Throw(PasswordException::FStreamWriteError);
         }
+        attemptFile.close();
+        int fd = open((DATA_DIR + "/" + ATTEMPT_FILE).c_str(), O_WRONLY | O_APPEND); fsync(fd); close(fd);
     }
 
     bool PasswordFile::isPasswordActive() const