#include <klay/exception.h>
#include <klay/filesystem.h>
-#include <klay/audit/logger.h>
+#include "logger.h"
#include "file-footer.h"
#include "key-manager/key-generator.h"
const std::string getFileName(const std::string &key)
{
- KeyGenerator::data hash = KeyGenerator::MD5(KeyGenerator::data(key.begin(), key.end()));
+ BinaryData hash = KeyGenerator::SHA256(BinaryData(key.begin(), key.end()));
std::stringstream fileName;
fileName << "/opt/etc/.ode_";
{
std::string fileName(getFileName(key));
- INFO("Footer file : " + fileName);
+ INFO(SINK, "Footer file : " + fileName);
runtime::File file(fileName);
return file.exists();
}
-const FileFooter::data FileFooter::read(const std::string &key)
+const BinaryData FileFooter::read(const std::string &key)
{
std::string fileName(getFileName(key));
- INFO("Footer file : " + fileName);
+ INFO(SINK, "Footer file : " + fileName);
runtime::File file(fileName);
- data value(file.size());
+ BinaryData value(file.size());
file.open(O_RDONLY);
file.read(value.data(), value.size());
return value;
}
-void FileFooter::write(const std::string &key, const data &value)
+void FileFooter::write(const std::string &key, const BinaryData &value)
{
std::string fileName(getFileName(key));
- INFO("Footer file : " + fileName);
+ INFO(SINK, "Footer file : " + fileName);
runtime::File file(fileName);
- file.create(0600);
+ if (!file.exists()) {
+ file.create(S_IRUSR | S_IWUSR);
+ } else {
+ file.open(O_RDWR);
+ }
+
file.write(value.data(), value.size());
}
{
std::string fileName(getFileName(key));
- INFO("Footer file : " + fileName);
+ INFO(SINK, "Footer file : " + fileName);
runtime::File file(fileName);