]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Add mod_log_forensic.
authorBen Laurie <ben@apache.org>
Sun, 11 Apr 2004 18:36:58 +0000 (18:36 +0000)
committerBen Laurie <ben@apache.org>
Sun, 11 Apr 2004 18:36:58 +0000 (18:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@103347 13f79535-47bb-0310-9956-ffa450edef68

modules/loggers/config.m4
modules/loggers/mod_log_forensic.c
server/gen_test_char.c

index 4e383cd30634b6134e083ae14a2dd3921c8600e4..8efc14c3ad47afafb7ff6d347f7b92844e240fe2 100644 (file)
@@ -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
index 649d52cf11b5952d4cfc29758e821c86efdcd070..a40810c03da946e9706659c5b9cd649d4ca2d10e 100644 (file)
@@ -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);
 
index bc4cebf6b3eb1a54761ae1cc36bd327cf2ce50f6..18eeaf684d815bd40ba3234e7b24da70498e00a6 100644 (file)
@@ -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) ? ',' : ' ');
     }