Adds support the Parallel audit log index creation

The index is now being generated.
This commit is contained in:
Felipe Zimmerle
2015-07-13 16:48:57 -03:00
parent 96a777a5cf
commit f13a1bd880
8 changed files with 157 additions and 2 deletions

View File

@@ -27,10 +27,22 @@
#include "src/audit_log.h"
#include "modsecurity/assay.h"
#include "src/utils.h"
#include "utils/md5.h"
namespace ModSecurity {
AuditLogWriterParallel::~AuditLogWriterParallel() {
if (log1.is_open()) {
log1.close();
}
if (log2.is_open()) {
log2.close();
}
}
inline std::string AuditLogWriterParallel::logFilePath(time_t *t,
int part) {
struct tm timeinfo;
@@ -65,6 +77,15 @@ inline std::string AuditLogWriterParallel::logFilePath(time_t *t,
bool AuditLogWriterParallel::init() {
/** TODO:: Check if the directory exists. */
/** TODO:: Checking if we have permission to write in the target dir */
if (!m_audit->m_path1.empty()) {
log1.open(m_audit->m_path1, std::fstream::out | std::fstream::app);
}
if (!m_audit->m_path2.empty()) {
log2.open(m_audit->m_path2, std::fstream::out | std::fstream::app);
}
return true;
}
@@ -100,7 +121,21 @@ bool AuditLogWriterParallel::write(Assay *assay, int parts) {
fwrite(log.c_str(), log.length(), 1, fp);
fclose(fp);
if (log1.is_open() && log2.is_open()) {
log2 << assay->toOldAuditLogFormatIndex(fileName, log.length(),
md5(log));
}
if (log1.is_open() && !log2.is_open()) {
log1 << assay->toOldAuditLogFormatIndex(fileName, log.length(),
md5(log));
}
if (!log1.is_open() && log2.is_open()) {
log2 << assay->toOldAuditLogFormatIndex(fileName, log.length(),
md5(log));
}
return true;
}
} // namespace ModSecurity