IIS: no lock on ProcessRequest. No reload of config. (#24)

IIS: no lock on ProcessRequest. No reload of config.
This commit is contained in:
Allan Boll 2018-06-06 20:08:03 -07:00 committed by Felipe Zimmerle
parent 6bc838eeaf
commit 51a9717601
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
3 changed files with 26 additions and 46 deletions

View File

@ -466,11 +466,8 @@ MODSECURITY_STORED_CONTEXT::~MODSECURITY_STORED_CONTEXT()
MODSECURITY_STORED_CONTEXT::MODSECURITY_STORED_CONTEXT():
m_bIsEnabled ( FALSE ),
m_pszPath( NULL ),
m_Config( NULL ),
m_dwLastCheck( 0 )
m_Config( NULL )
{
m_LastChange.dwLowDateTime = 0;
m_LastChange.dwHighDateTime = 0;
}
DWORD

View File

@ -68,8 +68,6 @@ class MODSECURITY_STORED_CONTEXT : public IHttpStoredContext
USHORT* pdwLengthDestination );
void* m_Config;
DWORD m_dwLastCheck;
FILETIME m_LastChange;
private:
HRESULT

View File

@ -818,11 +818,7 @@ CMyHttpModule::OnBeginRequest(
goto Finished;
}
// every 3 seconds we check for changes in config file
//
DWORD ctime = GetTickCount();
if(pConfig->m_Config == NULL || (ctime - pConfig->m_dwLastCheck) > 3000)
if(pConfig->m_Config == NULL)
{
char *path;
USHORT pathlen;
@ -835,55 +831,42 @@ CMyHttpModule::OnBeginRequest(
goto Finished;
}
WIN32_FILE_ATTRIBUTE_DATA fdata;
BOOL ret;
pConfig->m_Config = modsecGetDefaultConfig();
ret = GetFileAttributesEx(path, GetFileExInfoStandard, &fdata);
PCWSTR servpath = pHttpContext->GetApplication()->GetApplicationPhysicalPath();
char *apppath;
USHORT apppathlen;
pConfig->m_dwLastCheck = ctime;
hr = pConfig->GlobalWideCharToMultiByte((WCHAR *)servpath, wcslen(servpath), &apppath, &apppathlen);
if(pConfig->m_Config == NULL || (ret != 0 && (pConfig->m_LastChange.dwLowDateTime != fdata.ftLastWriteTime.dwLowDateTime ||
pConfig->m_LastChange.dwHighDateTime != fdata.ftLastWriteTime.dwHighDateTime)))
if ( FAILED( hr ) )
{
pConfig->m_LastChange.dwLowDateTime = fdata.ftLastWriteTime.dwLowDateTime;
pConfig->m_LastChange.dwHighDateTime = fdata.ftLastWriteTime.dwHighDateTime;
delete path;
hr = E_UNEXPECTED;
goto Finished;
}
pConfig->m_Config = modsecGetDefaultConfig();
if(path[0] != 0)
{
const char * err = modsecProcessConfig((directory_config *)pConfig->m_Config, path, apppath);
PCWSTR servpath = pHttpContext->GetApplication()->GetApplicationPhysicalPath();
char *apppath;
USHORT apppathlen;
hr = pConfig->GlobalWideCharToMultiByte((WCHAR *)servpath, wcslen(servpath), &apppath, &apppathlen);
if ( FAILED( hr ) )
if(err != NULL)
{
WriteEventViewerLog(err, EVENTLOG_ERROR_TYPE);
delete apppath;
delete path;
hr = E_UNEXPECTED;
goto Finished;
}
if(path[0] != 0)
modsecReportRemoteLoadedRules();
if (this->status_call_already_sent == false)
{
const char * err = modsecProcessConfig((directory_config *)pConfig->m_Config, path, apppath);
if(err != NULL)
{
WriteEventViewerLog(err, EVENTLOG_ERROR_TYPE);
delete apppath;
delete path;
goto Finished;
}
modsecReportRemoteLoadedRules();
if (this->status_call_already_sent == false)
{
this->status_call_already_sent = true;
modsecStatusEngineCall();
}
this->status_call_already_sent = true;
modsecStatusEngineCall();
}
delete apppath;
}
delete apppath;
delete path;
}
@ -1140,7 +1123,9 @@ CMyHttpModule::OnBeginRequest(
#endif
c->remote_host = NULL;
LeaveCriticalSection(&m_csLock);
int status = modsecProcessRequest(r);
EnterCriticalSection(&m_csLock);
if(status != DECLINED)
{