mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 03:34:29 +03:00
Added missing functions to make non-Apache versions compile with Apache 2.4.
This commit is contained in:
@@ -1,25 +1 @@
|
|||||||
/* Some APR files define PACKAGE* constants, which may conflict
|
/* This file is left empty for building on Windows. */
|
||||||
* so this is here to prevent that by removing them.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Undefine all these so there are no conflicts */
|
|
||||||
#undef PACKAGE
|
|
||||||
#undef PACKAGE_BUGREPORT
|
|
||||||
#undef PACKAGE_NAME
|
|
||||||
#undef PACKAGE_STRING
|
|
||||||
#undef PACKAGE_TARNAME
|
|
||||||
#undef PACKAGE_URL
|
|
||||||
#undef PACKAGE_VERSION
|
|
||||||
|
|
||||||
/* Include the real autoconf header */
|
|
||||||
#include "modsecurity_config_auto.h"
|
|
||||||
|
|
||||||
/* Undefine all these (again) so there are no conflicts */
|
|
||||||
#undef PACKAGE
|
|
||||||
#undef PACKAGE_BUGREPORT
|
|
||||||
#undef PACKAGE_NAME
|
|
||||||
#undef PACKAGE_STRING
|
|
||||||
#undef PACKAGE_TARNAME
|
|
||||||
#undef PACKAGE_URL
|
|
||||||
#undef PACKAGE_VERSION
|
|
||||||
|
|
||||||
|
@@ -4,17 +4,17 @@
|
|||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
# Path to Apache httpd installation
|
# Path to Apache httpd installation
|
||||||
BASE = C:\Apache2
|
BASE = C:\Apache22
|
||||||
|
|
||||||
# Paths to required libraries
|
# Paths to required libraries
|
||||||
PCRE = C:\work\pcre-7.0-lib
|
PCRE = C:\work\pcre-8.30
|
||||||
CURL = C:\work\libcurl-7.19.3-win32-ssl-msvc
|
CURL = C:\work\curl-7.24.0
|
||||||
|
|
||||||
# Linking libraries
|
# Linking libraries
|
||||||
LIBS = $(BASE)\lib\libapr-1.lib \
|
LIBS = $(BASE)\lib\libapr-1.lib \
|
||||||
$(BASE)\lib\libaprutil-1.lib \
|
$(BASE)\lib\libaprutil-1.lib \
|
||||||
$(PCRE)\lib\pcre.lib \
|
$(PCRE)\pcre.lib \
|
||||||
$(CURL)\lib\Release\curllib.lib \
|
$(CURL)\libcurl_imp.lib \
|
||||||
wsock32.lib
|
wsock32.lib
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
@@ -28,7 +28,7 @@ DEFS = /nologo /O2 /W3 -DWIN32 -DWINNT -Dinline=APR_INLINE -D_CONSOLE
|
|||||||
|
|
||||||
EXE = mlogc.exe
|
EXE = mlogc.exe
|
||||||
|
|
||||||
INCLUDES = -I. -I.. \
|
INCLUDES = -I. -I..\apache2 \
|
||||||
-I$(PCRE)\include -I$(PCRE) \
|
-I$(PCRE)\include -I$(PCRE) \
|
||||||
-I$(CURL)\include -I$(CURL) \
|
-I$(CURL)\include -I$(CURL) \
|
||||||
-I$(BASE)\include
|
-I$(BASE)\include
|
||||||
|
@@ -146,9 +146,13 @@ server_rec *modsecInit() {
|
|||||||
|
|
||||||
ap_server_config_defines = apr_array_make(pool, 1, sizeof(char *));
|
ap_server_config_defines = apr_array_make(pool, 1, sizeof(char *));
|
||||||
|
|
||||||
|
// here we should add scoreboard handling for multiple processes and threads
|
||||||
|
//
|
||||||
ap_scoreboard_image = (scoreboard *)apr_palloc(pool, sizeof(scoreboard));
|
ap_scoreboard_image = (scoreboard *)apr_palloc(pool, sizeof(scoreboard));
|
||||||
|
|
||||||
// here we should probably fill scoreboard and later keep it updated somewhere
|
memset(ap_scoreboard_image, 0, sizeof(scoreboard));
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
|
||||||
security2_module.module_index = 0;
|
security2_module.module_index = 0;
|
||||||
|
|
||||||
|
@@ -212,6 +212,123 @@ AP_DECLARE(int) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
static apr_status_t ap_cfg_getline_core(char *buf, apr_size_t bufsize,
|
||||||
|
ap_configfile_t *cfp)
|
||||||
|
{
|
||||||
|
apr_status_t rc;
|
||||||
|
/* If a "get string" function is defined, use it */
|
||||||
|
if (cfp->getstr != NULL) {
|
||||||
|
char *cp;
|
||||||
|
char *cbuf = buf;
|
||||||
|
apr_size_t cbufsize = bufsize;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
++cfp->line_number;
|
||||||
|
rc = cfp->getstr(cbuf, cbufsize, cfp->param);
|
||||||
|
if (rc == APR_EOF) {
|
||||||
|
if (cbuf != buf) {
|
||||||
|
*cbuf = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return APR_EOF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rc != APR_SUCCESS) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* check for line continuation,
|
||||||
|
* i.e. match [^\\]\\[\r]\n only
|
||||||
|
*/
|
||||||
|
cp = cbuf;
|
||||||
|
cp += strlen(cp);
|
||||||
|
if (cp > cbuf && cp[-1] == LF) {
|
||||||
|
cp--;
|
||||||
|
if (cp > cbuf && cp[-1] == CR)
|
||||||
|
cp--;
|
||||||
|
if (cp > cbuf && cp[-1] == '\\') {
|
||||||
|
cp--;
|
||||||
|
/*
|
||||||
|
* line continuation requested -
|
||||||
|
* then remove backslash and continue
|
||||||
|
*/
|
||||||
|
cbufsize -= (cp-cbuf);
|
||||||
|
cbuf = cp;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cp - buf >= bufsize - 1) {
|
||||||
|
return APR_ENOSPC;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* No "get string" function defined; read character by character */
|
||||||
|
apr_size_t i = 0;
|
||||||
|
|
||||||
|
if (bufsize < 2) {
|
||||||
|
/* too small, assume caller is crazy */
|
||||||
|
return APR_EINVAL;
|
||||||
|
}
|
||||||
|
buf[0] = '\0';
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
char c;
|
||||||
|
rc = cfp->getch(&c, cfp->param);
|
||||||
|
if (rc == APR_EOF) {
|
||||||
|
if (i > 0)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
return APR_EOF;
|
||||||
|
}
|
||||||
|
if (rc != APR_SUCCESS)
|
||||||
|
return rc;
|
||||||
|
if (c == LF) {
|
||||||
|
++cfp->line_number;
|
||||||
|
/* check for line continuation */
|
||||||
|
if (i > 0 && buf[i-1] == '\\') {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i >= bufsize - 2) {
|
||||||
|
return APR_ENOSPC;
|
||||||
|
}
|
||||||
|
buf[i] = c;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
buf[i] = '\0';
|
||||||
|
}
|
||||||
|
return APR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cfg_trim_line(char *buf)
|
||||||
|
{
|
||||||
|
char *start, *end;
|
||||||
|
/*
|
||||||
|
* Leading and trailing white space is eliminated completely
|
||||||
|
*/
|
||||||
|
start = buf;
|
||||||
|
while (apr_isspace(*start))
|
||||||
|
++start;
|
||||||
|
/* blast trailing whitespace */
|
||||||
|
end = &start[strlen(start)];
|
||||||
|
while (--end >= start && apr_isspace(*end))
|
||||||
|
*end = '\0';
|
||||||
|
/* Zap leading whitespace by shifting */
|
||||||
|
if (start != buf)
|
||||||
|
memmove(buf, start, end - start + 2);
|
||||||
|
#ifdef DEBUG_CFG_LINES
|
||||||
|
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL, APLOGNO(00555) "Read config: '%s'", buf);
|
||||||
|
#endif
|
||||||
|
return end - start + 1;
|
||||||
|
}
|
||||||
|
|
||||||
AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize,
|
AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize,
|
||||||
ap_configfile_t *cfp)
|
ap_configfile_t *cfp)
|
||||||
{
|
{
|
||||||
|
@@ -265,6 +265,12 @@ AP_DECLARE(void) ap_log_error(const char *file, int line, int level,
|
|||||||
apr_status_t status, const server_rec *s,
|
apr_status_t status, const server_rec *s,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
// __attribute__((format(printf,6,7)))
|
// __attribute__((format(printf,6,7)))
|
||||||
|
#else
|
||||||
|
AP_DECLARE(void) ap_log_error_(const char *file, int line, int module_index,
|
||||||
|
int level, apr_status_t status,
|
||||||
|
const server_rec *s, const char *fmt, ...)
|
||||||
|
// __attribute__((format(printf,7,8)))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char errstr[MAX_STRING_LEN];
|
char errstr[MAX_STRING_LEN];
|
||||||
@@ -279,10 +285,16 @@ AP_DECLARE(void) ap_log_error(const char *file, int line, int level,
|
|||||||
modsecLogHook(modsecLogObj, level, errstr);
|
modsecLogHook(modsecLogObj, level, errstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER < 3
|
||||||
AP_DECLARE(void) ap_log_perror(const char *file, int line, int level,
|
AP_DECLARE(void) ap_log_perror(const char *file, int line, int level,
|
||||||
apr_status_t status, apr_pool_t *p,
|
apr_status_t status, apr_pool_t *p,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
// __attribute__((format(printf,6,7)))
|
// __attribute__((format(printf,6,7)))
|
||||||
|
#else
|
||||||
|
AP_DECLARE(void) ap_log_perror_(const char *file, int line, int module_index,
|
||||||
|
int level, apr_status_t status, apr_pool_t *p,
|
||||||
|
const char *fmt, ...)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char errstr[MAX_STRING_LEN];
|
char errstr[MAX_STRING_LEN];
|
||||||
@@ -296,7 +308,6 @@ AP_DECLARE(void) ap_log_perror(const char *file, int line, int level,
|
|||||||
if(modsecLogHook != NULL)
|
if(modsecLogHook != NULL)
|
||||||
modsecLogHook(modsecLogObj, level, errstr);
|
modsecLogHook(modsecLogObj, level, errstr);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
AP_DECLARE(module *) ap_find_linked_module(const char *name)
|
AP_DECLARE(module *) ap_find_linked_module(const char *name)
|
||||||
{
|
{
|
||||||
@@ -330,6 +341,25 @@ AP_DECLARE(worker_score *) ap_get_scoreboard_worker(int x, int y)
|
|||||||
}
|
}
|
||||||
return &ap_scoreboard_image->servers[x][y];
|
return &ap_scoreboard_image->servers[x][y];
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
AP_DECLARE(worker_score *) ap_get_scoreboard_worker_from_indexes(int x, int y)
|
||||||
|
{
|
||||||
|
if (((x < 0) || (x >= server_limit)) ||
|
||||||
|
((y < 0) || (y >= thread_limit))) {
|
||||||
|
return(NULL); /* Out of range */
|
||||||
|
}
|
||||||
|
return &ap_scoreboard_image->servers[x][y];
|
||||||
|
}
|
||||||
|
|
||||||
|
AP_DECLARE(worker_score *) ap_get_scoreboard_worker(ap_sb_handle_t *sbh)
|
||||||
|
{
|
||||||
|
//if (!sbh)
|
||||||
|
// return NULL;
|
||||||
|
|
||||||
|
//return ap_get_scoreboard_worker_from_indexes(sbh->child_num,
|
||||||
|
// sbh->thread_num);
|
||||||
|
return ap_get_scoreboard_worker_from_indexes(0, 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
|
AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
|
||||||
@@ -533,6 +563,11 @@ AP_DECLARE(piped_log *) ap_open_piped_log(apr_pool_t *p, const char *program)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AP_DECLARE(apr_file_t *) ap_piped_log_write_fd(piped_log *pl)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t)
|
AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t)
|
||||||
{
|
{
|
||||||
const apr_array_header_t *env_arr = apr_table_elts(t);
|
const apr_array_header_t *env_arr = apr_table_elts(t);
|
||||||
|
Reference in New Issue
Block a user