Refectoring on the DebugLog mechanism

The DebugLog implementation was modified to use shared memory
to keep the information about the opened files and file handles.
The modification was necessary to avoid race-conditions. This
commit also closes the issue SpiderLabs/ModSecurity-nginx#17
This commit is contained in:
Felipe Zimmerle
2016-10-18 18:43:51 -03:00
parent f3bbcfc7ef
commit 678a97d0f7
9 changed files with 266 additions and 93 deletions

View File

@@ -42,7 +42,7 @@ class DebugLog {
bool isLogFileSet();
bool isLogLevelSet();
void setDebugLogLevel(int level);
void setDebugLogFile(const std::string &fileName);
void setDebugLogFile(const std::string &fileName, std::string *error);
const std::string& getDebugLogFile();
int getDebugLogLevel();

View File

@@ -330,10 +330,23 @@ class RulesProperties {
if (from->m_debugLog && to->m_debugLog &&
from->m_debugLog->isLogFileSet()) {
std::string error;
to->m_debugLog->setDebugLogFile(
from->m_debugLog->getDebugLogFile());
from->m_debugLog->getDebugLogFile(),
&error);
if (error.size() > 0) {
*err << error;
return -1;
}
}
if (from->m_debugLog && to->m_debugLog &&
from->m_debugLog->isLogLevelSet()) {
to->m_debugLog->setDebugLogLevel(
from->m_debugLog->getDebugLogLevel());
}
return amount_of_rules;
}