Fix implementation and rename FstreamHelper to FstreamAccessros.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Wed, 12 Feb 2014 14:19:50 +0000 (15:19 +0100)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Wed, 12 Feb 2014 18:09:40 +0000 (19:09 +0100)
[Issue#]    N/A
[Bug]       FstreamHelper always inherited from fstream::__filebuf but it gets
            as param ofstream and should inherits from
            ofstream::__filebuf.
[Cause]     Name FstreamHelper was miningless.
[Solution]  N/A

[Verfication] Build, run tests.

Change-Id: I2a884860032d84f7cac05084dab4d3e3a2a5bbe9

src/server/dpl/core/include/dpl/fstream-helper.h [deleted file]
src/server/dpl/core/include/dpl/fstream_accessors.h [new file with mode: 0644]
src/server/dpl/log/src/audit-smack-log.cpp
src/server/service/password-file-buffer.cpp
src/server/service/password-file.cpp

diff --git a/src/server/dpl/core/include/dpl/fstream-helper.h b/src/server/dpl/core/include/dpl/fstream-helper.h
deleted file mode 100644 (file)
index 9de8237..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- *
- * @file        fstream-helper.h
- * @author      Marek Smolinski (m.smolinski@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of fstream-helper
- *
- */
-
-#ifndef __FSTREAM_HELPER__
-#define __FSTREAM_HELPER__
-
-#include <fstream>
-
-namespace DPL {
-
-/*
- * Bypass lack of public member function to get file
- * descriptor from fstream objects in std
- * This feature is needed for flushing data from kernel space buffer to
- * physical device [fsync(int fd) - syscall] on opened fstream object
-*/
-
-struct FstreamHelper : std::fstream::__filebuf_type {
-    template<typename T>
-    static int getFd(T &strm) {
-        return static_cast<FstreamHelper *>(strm.rdbuf())->_M_file.fd();
-    }
-};
-
-} // namespace DPL
-
-#endif // __FSTREAM_HELPER__
diff --git a/src/server/dpl/core/include/dpl/fstream_accessors.h b/src/server/dpl/core/include/dpl/fstream_accessors.h
new file mode 100644 (file)
index 0000000..1c595b6
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Bumjin Im <bj.im@samsung.com>
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ *
+ * @file        fstream-helper.h
+ * @author      Marek Smolinski (m.smolinski@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of fstream-helper
+ *
+ */
+
+#ifndef SECURITY_SERVER_FSTREAM_ACCESSORS_H
+#define SECURITY_SERVER_FSTREAM_ACCESSORS_H
+
+namespace DPL {
+
+/*
+ * Bypass lack of public member function to get file
+ * descriptor from fstream objects in std
+ * This feature is needed for flushing data from kernel space buffer to
+ * physical device [fsync(int fd) - syscall] on opened fstream object
+*/
+
+template<typename T>
+class FstreamAccessors : T::__filebuf_type {
+    typedef FstreamAccessors<T> MyType;
+public:
+    static int GetFd(T &strm) {
+        return static_cast<MyType *>(strm.rdbuf())->_M_file.fd();
+    }
+};
+
+} // namespace DPL
+
+#endif // SECURITY_SERVER_FSTREAM_ACCESSORS_H
index dbd328e8b99752fe06670a0446eb4f8e2b5ec377..d3a704c726ad615fee317c648f5a0d8a4f5bbe4c 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <dpl/log/audit-smack-log.h>
 #include <dpl/log/log.h>
-#include <dpl/fstream-helper.h>
+#include <dpl/fstream_accessors.h>
 
 #define UNUSED __attribute__((unused))
 
@@ -136,7 +136,7 @@ void AuditSmackLog::HandleWrite(const char *message,
         std::string("] ") << function << std::string("(): ") <<
         message << std::endl;
 
-    fsync(DPL::FstreamHelper::getFd(m_outputStream)); // flush kernel space buffer
+    fsync(DPL::FstreamAccessors<std::ofstream>::GetFd(m_outputStream)); // flush kernel space buffer
 }
 
 int AuditSmackLog::CreateLogFile()
index 41720717338f9af07677fac7f42a0249d483c461..8ce8adeac65bef3fc431a84ff027a9506a703f9e 100644 (file)
@@ -28,7 +28,7 @@
 #include <iterator>
 
 #include <dpl/log/log.h>
-#include <dpl/fstream-helper.h>
+#include <dpl/fstream_accessors.h>
 
 #include <security-server.h>
 #include <password-exception.h>
@@ -85,7 +85,7 @@ namespace SecurityServer
         }
 
         file.flush();
-        fsync(DPL::FstreamHelper::getFd(file)); // flush kernel space buffer
+        fsync(DPL::FstreamAccessors<std::ofstream>::GetFd(file)); // flush kernel space buffer
         file.close();
     }
 
index 960c52348b4ec997aea348303ad0c08a10b7c322..79cc5496bde0892f13a479c5e23d8a3511e69529 100644 (file)
@@ -37,7 +37,7 @@
 #include <openssl/sha.h>
 
 #include <dpl/log/log.h>
-#include <dpl/fstream-helper.h>
+#include <dpl/fstream_accessors.h>
 
 #include <security-server.h>
 #include <protocols.h>
@@ -362,7 +362,7 @@ namespace SecurityServer
         }
 
         attemptFile.flush();
-        fsync(DPL::FstreamHelper::getFd(attemptFile)); // flush kernel space buffer
+        fsync(DPL::FstreamAccessors<std::ofstream>::GetFd(attemptFile)); // flush kernel space buffer
         attemptFile.close();
     }