From: Ben Laurie Date: Sun, 11 Apr 2004 18:36:58 +0000 (+0000) Subject: Add mod_log_forensic. X-Git-Tag: 2.0.50~217 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c47f3fab6b5a35dbf7ac2f4c4bb19249abfa6e62;p=thirdparty%2Fapache%2Fhttpd.git Add mod_log_forensic. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@103347 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/loggers/config.m4 b/modules/loggers/config.m4 index 4e383cd3063..8efc14c3ad4 100644 --- a/modules/loggers/config.m4 +++ b/modules/loggers/config.m4 @@ -6,6 +6,13 @@ APACHE_MODPATH_INIT(loggers) APACHE_MODULE(log_config, logging configuration, , , yes) +APACHE_MODULE(log_forensic, forensic logging) + +if test "x$enable_log_forensic" != "xno"; then + # mod_log_forensic needs test_char.h + APR_ADDTO(INCLUDES, [-I\$(top_builddir)/server]) +fi + APACHE_MODULE(logio, input and output logging, , , no) APACHE_MODPATH_FINISH diff --git a/modules/loggers/mod_log_forensic.c b/modules/loggers/mod_log_forensic.c index 649d52cf11b..a40810c03da 100644 --- a/modules/loggers/mod_log_forensic.c +++ b/modules/loggers/mod_log_forensic.c @@ -41,8 +41,6 @@ typedef struct fcfg { apr_file_t *fd; } fcfg; -static apr_uint32_t next_id; - static void *make_forensic_log_scfg(apr_pool_t *p, server_rec *s) { fcfg *cfg = apr_pcalloc(p, sizeof *cfg); @@ -192,8 +190,9 @@ static int log_before(request_rec *r) if (!(id = apr_table_get(r->subprocess_env, "UNIQUE_ID"))) { /* we make the assumption that we can't go through all the PIDs in under 1 second */ - id = apr_psprintf(r->pool, "%x:%lx:%x", getpid(), time(NULL), - apr_atomic_inc32(&next_id)); + ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, + "mod_log_forensic: mod_unique_id must also be active"); + return DECLINED; } ap_set_module_config(r->request_config, &log_forensic_module, (char *)id); diff --git a/server/gen_test_char.c b/server/gen_test_char.c index bc4cebf6b3e..18eeaf684d8 100644 --- a/server/gen_test_char.c +++ b/server/gen_test_char.c @@ -31,6 +31,7 @@ #define T_OS_ESCAPE_PATH (0x04) #define T_HTTP_TOKEN_STOP (0x08) #define T_ESCAPE_LOGITEM (0x10) +#define T_ESCAPE_FORENSIC (0x20) int main(int argc, char *argv[]) { @@ -44,6 +45,7 @@ int main(int argc, char *argv[]) "#define T_OS_ESCAPE_PATH (%u)\n" "#define T_HTTP_TOKEN_STOP (%u)\n" "#define T_ESCAPE_LOGITEM (%u)\n" + "#define T_ESCAPE_FORENSIC (%u)\n" "\n" "static const unsigned char test_char_table[256] = {\n" " 0,", @@ -51,7 +53,8 @@ int main(int argc, char *argv[]) T_ESCAPE_PATH_SEGMENT, T_OS_ESCAPE_PATH, T_HTTP_TOKEN_STOP, - T_ESCAPE_LOGITEM); + T_ESCAPE_LOGITEM, + T_ESCAPE_FORENSIC); /* we explicitly dealt with NUL above * in case some strchr() do bogosity with it */ @@ -104,6 +107,14 @@ int main(int argc, char *argv[]) flags |= T_ESCAPE_LOGITEM; } + /* For forensic logging, escape all control characters, top bit set, + * :, | (used as delimiters) and % (used for escaping). + */ + if (!apr_isprint(c) || c == ':' || c == '|' || c == '%' + || apr_iscntrl(c) || !c) { + flags |= T_ESCAPE_FORENSIC; + } + printf("%u%c", flags, (c < 255) ? ',' : ' '); }