Added missing functions to make non-Apache versions compile with Apache 2.4.

This commit is contained in:
gregwroblewski
2012-08-29 23:53:23 +00:00
parent 9eaa6a9a41
commit 092559a585
5 changed files with 165 additions and 33 deletions

View File

@@ -1,25 +1 @@
/* Some APR files define PACKAGE* constants, which may conflict
* 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
/* This file is left empty for building on Windows. */

View File

@@ -4,17 +4,17 @@
###########################################################################
# Path to Apache httpd installation
BASE = C:\Apache2
BASE = C:\Apache22
# Paths to required libraries
PCRE = C:\work\pcre-7.0-lib
CURL = C:\work\libcurl-7.19.3-win32-ssl-msvc
PCRE = C:\work\pcre-8.30
CURL = C:\work\curl-7.24.0
# Linking libraries
LIBS = $(BASE)\lib\libapr-1.lib \
$(BASE)\lib\libaprutil-1.lib \
$(PCRE)\lib\pcre.lib \
$(CURL)\lib\Release\curllib.lib \
$(PCRE)\pcre.lib \
$(CURL)\libcurl_imp.lib \
wsock32.lib
###########################################################################
@@ -28,7 +28,7 @@ DEFS = /nologo /O2 /W3 -DWIN32 -DWINNT -Dinline=APR_INLINE -D_CONSOLE
EXE = mlogc.exe
INCLUDES = -I. -I.. \
INCLUDES = -I. -I..\apache2 \
-I$(PCRE)\include -I$(PCRE) \
-I$(CURL)\include -I$(CURL) \
-I$(BASE)\include

View File

@@ -146,9 +146,13 @@ server_rec *modsecInit() {
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));
// here we should probably fill scoreboard and later keep it updated somewhere
memset(ap_scoreboard_image, 0, sizeof(scoreboard));
// ----------
security2_module.module_index = 0;

View File

@@ -212,6 +212,123 @@ AP_DECLARE(int) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp)
}
}
#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_configfile_t *cfp)
{

View File

@@ -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,
const char *fmt, ...)
// __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;
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);
}
#if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER < 3
AP_DECLARE(void) ap_log_perror(const char *file, int line, int level,
apr_status_t status, apr_pool_t *p,
const char *fmt, ...)
// __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;
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)
modsecLogHook(modsecLogObj, level, errstr);
}
#endif
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];
}
#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
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;
}
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)
{
const apr_array_header_t *env_arr = apr_table_elts(t);