summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Edward Rudd 2004-01-22 05:26:56 +0000
committerGravatar Edward Rudd 2004-01-22 05:26:56 +0000
commitf230d2468cdc8ee3d290d34a36593b154f51aee1 (patch)
treed823f819136bd34dfa5bb0cba94c6c8c03e852d6
parentb19a5851171395e196ed686977482d79d7140cfd (diff)
SSL support working under 1.3 and 2.0 as a separate module
preparsing of logformat completed. updated configure scripts to detect mod_ssl.h for 1.3 (mostly)
-rw-r--r--AUTHORS10
-rw-r--r--CHANGELOG9
-rw-r--r--Makefile.in40
-rw-r--r--apache13.h3
-rw-r--r--configure.ac10
-rw-r--r--m4/apache.m45
-rw-r--r--m4/mod_ssl.m413
-rw-r--r--mod_log_sql.c181
-rw-r--r--mod_log_sql.h7
-rw-r--r--mod_log_sql.prj5
-rw-r--r--mod_log_sql_ssl.c56
11 files changed, 202 insertions, 137 deletions
diff --git a/AUTHORS b/AUTHORS
index b6969e7..887bda6 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,5 +1,11 @@
1Christopher B. Powell 1The Apache Foundation
2 Main author 2 standard apache logging module for which this module is based on
3
4Zeev Suraski <bourbon at netvision.net dot il>
5 Adding the mysql routines (intial revisions)
6
7Christopher B. Powell <chris at grubbybabby dot com>
8 Maintainer since version 1.06
3 9
4Edward Rudd <eddie at omegaware dot com> 10Edward Rudd <eddie at omegaware dot com>
5 Apache 2.0 port. 11 Apache 2.0 port.
diff --git a/CHANGELOG b/CHANGELOG
index eb3bafc..fbe49b5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,4 @@
1$Id: CHANGELOG,v 1.8 2004/01/21 04:34:21 urkle Exp $ 1$Id: CHANGELOG,v 1.9 2004/01/22 05:26:56 urkle Exp $
2 2
3TODO: 3TODO:
4* Port connection portion to other DBMS? Genericize the module? Start with 4* Port connection portion to other DBMS? Genericize the module? Start with
@@ -14,14 +14,17 @@ TODO:
14* Directive to yes/no create ancillary tables (or just access table) 14* Directive to yes/no create ancillary tables (or just access table)
15* break module into separate code files 15* break module into separate code files
16 separate DB implimentation into sub-modules via provider mechanism 16 separate DB implimentation into sub-modules via provider mechanism
17 separate module for SSL support 17* convert documentation to docbook
18 apache version specific code already split into separate files.
19* add document building to Makefile.in 18* add document building to Makefile.in
20* investigate thread safety issues (libmysqlclient_r) 19* investigate thread safety issues (libmysqlclient_r)
21 Add thread locks if using standard mysqlclient 20 Add thread locks if using standard mysqlclient
22* rewrite main core logging function to optimize for speed. 21* rewrite main core logging function to optimize for speed.
23 22
24CHANGES: 23CHANGES:
241.94: ?
25* ssl loggin back in as separate module under 1.3 and 2.0
26* preparsing of format tags is now done to speed up main logging loop.
27
251.93: 2004-01-20 281.93: 2004-01-20
26* Compiles for apache 1.3 AND 2.0 29* Compiles for apache 1.3 AND 2.0
27* split apache version specific functions to seperate header files 30* split apache version specific functions to seperate header files
diff --git a/Makefile.in b/Makefile.in
index ce99082..1ff939c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -18,10 +18,20 @@ INCLUDES = @MYSQL_CFLAGS@
18 18
19LDADD = @MYSQL_LDFLAGS@ @MYSQL_LIBS@ 19LDADD = @MYSQL_LDFLAGS@ @MYSQL_LIBS@
20 20
21EXTRA_DIST = INSTALL LICENSE CHANGELOG make_combined_log.pl 21EXTRA_DIST = AUTHORS INSTALL LICENSE CHANGELOG make_combined_log.pl
22 22
23TARGET = @PACKAGE_NAME@@APXS_EXTENSION@ 23TARGET = @PACKAGE_NAME@@APXS_EXTENSION@
24 24
25sslSOURCES = mod_log_sql_ssl.c
26
27sslTARGET = @PACKAGE_NAME@_ssl@APXS_EXTENSION@
28
29ifeq (@WANT_SSL_MOD@,1)
30TARGETS = $(TARGET) $(sslTARGET)
31else
32TARGETS = $(TARGET)
33endif
34
25#Don't modify anything below here 35#Don't modify anything below here
26 36
27PROVIDERS_SUBDIRS = @subdirs@ 37PROVIDERS_SUBDIRS = @subdirs@
@@ -29,11 +39,11 @@ PROVIDERS_SUBDIRS = @subdirs@
29srcdir = @abs_srcdir@ 39srcdir = @abs_srcdir@
30builddir = @abs_builddir@ 40builddir = @abs_builddir@
31 41
32OBJ = $(SOURCES:.c=.o) 42OBJ = $(SOURCES:.c=.o) $(sslSOURCES:.c=.o)
33 43
34LO = $(SOURCES:.c=.lo) 44LO = $(SOURCES:.c=.lo) $(sslSOURCES:.c=.lo)
35 45
36SLO = $(SOURCES:.c=.slo) 46SLO = $(SOURCES:.c=.slo) $(sslSOURCES:.c=.slo)
37 47
38STD_DIST = install-sh \ 48STD_DIST = install-sh \
39 config.sub \ 49 config.sub \
@@ -47,7 +57,7 @@ STD_DIST = install-sh \
47 57
48DISTFILES = $(STD_DIST) $(EXTRA_DIST) $(SOURCES) $(HEADERS) 58DISTFILES = $(STD_DIST) $(EXTRA_DIST) $(SOURCES) $(HEADERS)
49 59
50all: $(TARGET) all-subdirs 60all: $(TARGETS) all-subdirs
51 61
52all-subdirs install-subdirs activate-subdirs clean-subdirs distclean-subdirs: 62all-subdirs install-subdirs activate-subdirs clean-subdirs distclean-subdirs:
53 @otarget=`echo $@|sed s/-subdirs//`; \ 63 @otarget=`echo $@|sed s/-subdirs//`; \
@@ -65,21 +75,31 @@ all-subdirs install-subdirs activate-subdirs clean-subdirs distclean-subdirs:
65 done; 75 done;
66 76
67$(TARGET): $(SOURCES) $(HEADERS) 77$(TARGET): $(SOURCES) $(HEADERS)
68 @@APXS_BIN@ -c -o $(TARGET) $(INCLUDES) @MOD_SSL_CFLAGS@ $(CFLAGS) \ 78 @@APXS_BIN@ -c -o $(TARGET) $(INCLUDES) $(CFLAGS) \
69 $(LDADD) @DEFS@ @APACHE_DEFS@ $(SOURCES) 79 $(LDADD) @DEFS@ @APACHE_DEFS@ $(SOURCES)
70 80
81$(sslTARGET): $(sslSOURCES) $(HEADERS)
82 @@APXS_BIN@ -c -o $(sslTARGET) $(INCLUDES) @MOD_SSL_CFLAGS@ $(CFLAGS) \
83 @DEFS@ @APACHE_DEFS@ $(sslSOURCES)
84
71include: 85include:
72 rm -rf include 86 rm -rf include
73 ln -s @APACHE_INCDIR@ include 87 ln -s @APACHE_INCDIR@ include
74 88
75install: install-subdirs 89install: $(TARGETS) install-subdirs
76 @@APXS_BIN@ -i $(TARGET) 90 @@APXS_BIN@ -i $(TARGET); \
91 if test @WANT_SSL_MOD@ -eq 1; then \
92 @APXS_BIN@ -i $(sslTARGET); \
93 fi
77 94
78activate: activate-subdirs 95activate: activate-subdirs
79 @@APXS_BIN@ -i -a $(TARGET) 96 @@APXS_BIN@ -i -a $(TARGET); \
97 if test @WANT_SSL_MOD@ -eq 1; then \
98 @APXS_BIN@ -i -a $(sslTARGET); \
99 fi
80 100
81clean: clean-subdirs 101clean: clean-subdirs
82 $(RM) $(OBJ) $(SLO) $(LO) $(TARGET) 102 $(RM) $(OBJ) $(SLO) $(LO) $(TARGETS)
83 $(RM) -r .libs 103 $(RM) -r .libs
84 104
85distclean: clean distclean-subdirs 105distclean: clean distclean-subdirs
diff --git a/apache13.h b/apache13.h
index 25b8f44..1c262d7 100644
--- a/apache13.h
+++ b/apache13.h
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/apache13.h,v 1.2 2004/01/20 19:38:07 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/apache13.h,v 1.3 2004/01/22 05:26:56 urkle Exp $ */
2#ifndef APACHE13_H 2#ifndef APACHE13_H
3#define APACHE13_H 3#define APACHE13_H
4 4
@@ -41,6 +41,7 @@
41/* Functions */ 41/* Functions */
42#define ap_get_remote_host(a,b,c,d) ap_get_remote_host(a,b,c) 42#define ap_get_remote_host(a,b,c,d) ap_get_remote_host(a,b,c)
43 43
44#define apr_pool_create(a,b) *(a) = ap_make_sub_pool(b)
44#define apr_palloc ap_palloc 45#define apr_palloc ap_palloc
45#define apr_pcalloc ap_pcalloc 46#define apr_pcalloc ap_pcalloc
46#define apr_pstrdup ap_pstrdup 47#define apr_pstrdup ap_pstrdup
diff --git a/configure.ac b/configure.ac
index 808d1fc..7e9ccb8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
1dnl Required initializer 1dnl Required initializer
2AC_INIT(mod_log_sql, 1.93) 2AC_INIT(mod_log_sql, 1.94)
3AC_PREREQ(2.53) 3AC_PREREQ(2.53)
4AC_CONFIG_HEADERS(config.h) 4AC_CONFIG_HEADERS(config.h)
5 5
@@ -24,10 +24,12 @@ CHECK_PATH_MYSQL(:,
24 24
25CHECK_PATH_MOD_SSL( 25CHECK_PATH_MOD_SSL(
26 AC_DEFINE(WANT_SSL_LOGGING,,[Define if we want to compile in SSL support.]) 26 AC_DEFINE(WANT_SSL_LOGGING,,[Define if we want to compile in SSL support.])
27 conf_SSL=1, 27 WANT_SSL_MOD=1,
28 conf_SSL=0 28 WANT_SSL_MOD=0
29 ) 29 )
30 30
31AC_SUBST(WANT_SSL_MOD)
32
31AC_CHECK_HEADERS(limits.h) 33AC_CHECK_HEADERS(limits.h)
32 34
33AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) 35AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
@@ -38,7 +40,7 @@ AC_OUTPUT(Makefile Documentation/Makefile)
38 40
39AC_MSG_RESULT([------------------------------------]) 41AC_MSG_RESULT([------------------------------------])
40AC_MSG_RESULT([Apache version : $APACHE_VERSION]) 42AC_MSG_RESULT([Apache version : $APACHE_VERSION])
41if test $conf_SSL -eq 1; then 43if test $WANT_SSL_MOD -eq 1; then
42 AC_MSG_RESULT([SSL Support : yes]) 44 AC_MSG_RESULT([SSL Support : yes])
43else 45else
44 AC_MSG_RESULT([SSL Support : no]) 46 AC_MSG_RESULT([SSL Support : no])
diff --git a/m4/apache.m4 b/m4/apache.m4
index a72343c..3d76b72 100644
--- a/m4/apache.m4
+++ b/m4/apache.m4
@@ -129,7 +129,8 @@ AC_ARG_ENABLE(
129 AC_MSG_ERROR([*** your path, or use the --with-apxs configure option]) 129 AC_MSG_ERROR([*** your path, or use the --with-apxs configure option])
130 else 130 else
131 APACHE_INCDIR=`$APXS_BIN -q INCLUDEDIR` 131 APACHE_INCDIR=`$APXS_BIN -q INCLUDEDIR`
132 APACHE_CFLAGS=-I$APACHE_INCDIR 132 APACHE_CPPFLAGS=`$APXS_BIN -q CFLAGS`
133 APACHE_CFLAGS="-I$APACHE_INCDIR"
133 APACHE_MODDIR=`$APXS_BIN -q LIBEXECDIR` 134 APACHE_MODDIR=`$APXS_BIN -q LIBEXECDIR`
134 135
135 if test "x$enable_apachetest" = "xyes" ; then 136 if test "x$enable_apachetest" = "xyes" ; then
@@ -155,6 +156,7 @@ AC_ARG_ENABLE(
155 AC_DEFINE(WITH_APACHE13,1,[Define to 1 if we are compiling with Apache 1.3.x]) 156 AC_DEFINE(WITH_APACHE13,1,[Define to 1 if we are compiling with Apache 1.3.x])
156 APACHE_VERSION="13" 157 APACHE_VERSION="13"
157 APXS_EXTENSION=.so 158 APXS_EXTENSION=.so
159 APACHE_CFLAGS="-g $APACHE_CFLAGS"
158 APACHE_DEFS="-DWITH_APACHE13" 160 APACHE_DEFS="-DWITH_APACHE13"
159 ifelse([$3], , , $3), 161 ifelse([$3], , , $3),
160 AC_MSG_RESULT(no) 162 AC_MSG_RESULT(no)
@@ -164,6 +166,7 @@ AC_ARG_ENABLE(
164 fi 166 fi
165 AC_SUBST(APACHE_DEFS) 167 AC_SUBST(APACHE_DEFS)
166 AC_SUBST(APACHE_CFLAGS) 168 AC_SUBST(APACHE_CFLAGS)
169 AC_SUBST(APACHE_CPPFLAGS)
167 AC_SUBST(APACHE_INCDIR) 170 AC_SUBST(APACHE_INCDIR)
168 AC_SUBST(APACHE_MODDIR) 171 AC_SUBST(APACHE_MODDIR)
169 AC_SUBST(APACHE_VERSION) 172 AC_SUBST(APACHE_VERSION)
diff --git a/m4/mod_ssl.m4 b/m4/mod_ssl.m4
index 6a852b9..a8c6103 100644
--- a/m4/mod_ssl.m4
+++ b/m4/mod_ssl.m4
@@ -14,6 +14,11 @@ AC_ARG_WITH(
14 [AC_HELP_STRING([--with-ssl-inc=DIR],[Location of SSL header files])], 14 [AC_HELP_STRING([--with-ssl-inc=DIR],[Location of SSL header files])],
15 ssl_incdir="$withval", 15 ssl_incdir="$withval",
16 ) 16 )
17AC_ARG_WITH(
18 db-inc,
19 [AC_HELP_STRING([--with-db-inc=DIR],[Location of DB header files])],
20 db_incdir="$withval",
21 )
17 22
18 if test "x$ssl_val" = "xyes"; then 23 if test "x$ssl_val" = "xyes"; then
19 ac_save_CFLAGS=$CFLAGS 24 ac_save_CFLAGS=$CFLAGS
@@ -22,9 +27,11 @@ AC_ARG_WITH(
22 if test "x$ssl_incdir" != "x"; then 27 if test "x$ssl_incdir" != "x"; then
23 MOD_SSL_CFLAGS="-I$ssl_incdir -I$ssl_incdir/openssl $MOD_SSL_CFLAGS" 28 MOD_SSL_CFLAGS="-I$ssl_incdir -I$ssl_incdir/openssl $MOD_SSL_CFLAGS"
24 fi 29 fi
25 30 if test "x$db_incdir" != "x"; then
26 CFLAGS="-I$APACHE_INCDIR $MOD_SSL_CFLAGS $CFLAGS" 31 MOD_SSL_CFLAGS="-I$db_incdir $MOD_SSL_CFLAGS"
27 CPPFLAGS="-I$APACHE_INCDIR $MOD_SSL_CFLAGS $CPPFLAGS" 32 fi
33 CFLAGS="$APACHE_CFLAGS $APACHE_CPPFLAGS $MOD_SSL_CFLAGS $CFLAGS"
34 CPPFLAGS="$APACHE_CFLAGS $APACHE_CPPFLAGS $MOD_SSL_CFLAGS $CPPFLAGS"
28 AC_CHECK_HEADERS([mod_ssl.h], 35 AC_CHECK_HEADERS([mod_ssl.h],
29 mod_ssl_h=yes 36 mod_ssl_h=yes
30 ) 37 )
diff --git a/mod_log_sql.c b/mod_log_sql.c
index abebd04..68c1e98 100644
--- a/mod_log_sql.c
+++ b/mod_log_sql.c
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.11 2004/01/21 04:34:21 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.12 2004/01/22 05:26:56 urkle Exp $ */
2/* --------* 2/* --------*
3 * DEFINES * 3 * DEFINES *
4 * --------*/ 4 * --------*/
@@ -84,6 +84,15 @@ typedef struct {
84 84
85static global_config_t global_config; 85static global_config_t global_config;
86 86
87/* structure to hold helper function info */
88typedef struct {
89 char key; /* item letter character */
90 log_sql_item_func *func; /* its extraction function */
91 const char *sql_field_name; /* its column in SQL */
92 int want_orig_default; /* if it requires the original request prior to internal redirection */
93 int string_contents; /* if it returns a string */
94} log_sql_item;
95
87/* But the contents of this structure will vary by virtual server. 96/* But the contents of this structure will vary by virtual server.
88 * This permits each virtual server to vary its configuration slightly 97 * This permits each virtual server to vary its configuration slightly
89 * for per-server customization. 98 * for per-server customization.
@@ -98,14 +107,16 @@ typedef struct {
98 apr_array_header_t *hout_list; 107 apr_array_header_t *hout_list;
99 apr_array_header_t *hin_list; 108 apr_array_header_t *hin_list;
100 apr_array_header_t *cookie_list; 109 apr_array_header_t *cookie_list;
101 char *notes_table_name; 110 const char *notes_table_name;
102 char *hout_table_name; 111 const char *hout_table_name;
103 char *hin_table_name; 112 const char *hin_table_name;
104 char *cookie_table_name; 113 const char *cookie_table_name;
105 char *transfer_table_name; 114 const char *transfer_table_name;
106 char *transfer_log_format; 115 const char *transfer_log_format;
107 char *preserve_file; 116 apr_pool_t *parsed_pool;
108 char *cookie_name; 117 log_sql_item **parsed_log_format;
118 const char *preserve_file;
119 const char *cookie_name;
109} logsql_state; 120} logsql_state;
110 121
111 122
@@ -115,39 +126,39 @@ typedef struct {
115 126
116static int safe_create_tables(logsql_state *cls, request_rec *r); 127static int safe_create_tables(logsql_state *cls, request_rec *r);
117 128
118typedef struct {
119 char key; /* item letter character */
120 log_sql_item_func *func; /* its extraction function */
121 const char *sql_field_name; /* its column in SQL */
122 int want_orig_default; /* if it requires the original request prior to internal redirection */
123 int string_contents; /* if it returns a string */
124} log_sql_item;
125
126static apr_array_header_t *log_sql_item_list; 129static apr_array_header_t *log_sql_item_list;
127 130
128/* Registration Function for extract functions */ 131/* Registration Function for extract functions *
129LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char key, 132 * and update parse cache for transfer_log_format *
130 log_sql_item_func *func, const char *sql_field_name, 133 * this is exported from the module */
134LOGSQL_DECLARE(void) log_sql_register_item(server_rec *s, apr_pool_t *p,
135 char key, log_sql_item_func *func, const char *sql_field_name,
131 int want_orig_default, int string_contents) 136 int want_orig_default, int string_contents)
132{ 137{
133 log_sql_item *item = apr_array_push(log_sql_item_list); 138 server_rec *ts;
139 log_sql_item *item;
140 if (!log_sql_item_list)
141 log_sql_item_list = apr_array_make(p,10, sizeof(log_sql_item));
142
143 item= apr_array_push(log_sql_item_list);
134 item->key = key; 144 item->key = key;
135 item->func = func; 145 item->func = func;
136 item->sql_field_name = sql_field_name; 146 item->sql_field_name = sql_field_name;
137 item->want_orig_default = want_orig_default; 147 item->want_orig_default = want_orig_default;
138 item->string_contents = string_contents; 148 item->string_contents = string_contents;
139} 149 /* some voodoo here to post parse logitems in all servers *
140 150 * so a "cached" list is used in the main logging loop for speed */
141/* Search through item array */ 151 for (ts = s; ts; ts = ts->next) {
142static inline log_sql_item *log_sql_get_item(char key) 152 logsql_state *cfg = ap_get_module_config(ts->module_config,
143{ 153 &log_sql_module);
144 int itr; 154 char *pos;
145 for(itr=0; itr<log_sql_item_list->nelts; itr++) { 155
146 if (((log_sql_item *)log_sql_item_list->elts)[itr].key == key) { 156 if (cfg->transfer_log_format) {
147 return &((log_sql_item *)log_sql_item_list->elts)[itr]; 157 if ( (pos = strchr(cfg->transfer_log_format,key))!=NULL) {
158 cfg->parsed_log_format[pos - cfg->transfer_log_format] = item;
159 }
148 } 160 }
149 } 161 }
150 return NULL;
151} 162}
152 163
153/* Include all the extract functions */ 164/* Include all the extract functions */
@@ -570,6 +581,19 @@ static const char *set_server_string_slot(cmd_parms *cmd,
570 return NULL; 581 return NULL;
571} 582}
572 583
584static const char *set_logformat_slot(cmd_parms *cmd,
585 void *struct_ptr,
586 const char *arg)
587{
588 logsql_state *cfg = ap_get_module_config(cmd->server->module_config,
589 &log_sql_module);
590
591 cfg->transfer_log_format = arg;
592/* apr_pool_clear(cfg->parsed_pool);*/
593 cfg->parsed_log_format = apr_pcalloc(cfg->parsed_pool,
594 strlen(arg) * sizeof(log_sql_item *));
595 return NULL;
596}
573 597
574static const char *set_server_nmv_string_slot(cmd_parms *parms, 598static const char *set_server_nmv_string_slot(cmd_parms *parms,
575 void *struct_ptr, 599 void *struct_ptr,
@@ -681,9 +705,9 @@ void *log_sql_initializer(server_rec *main_server, apr_pool_t *p)
681 705
682} 706}
683 */ 707 */
684 708/* post_config / module_init */
685#if defined(WITH_APACHE20) 709#if defined(WITH_APACHE20)
686static int log_sql_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) 710static int log_sql_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
687#elif defined(WITH_APACHE13) 711#elif defined(WITH_APACHE13)
688static void log_sql_module_init(server_rec *s, apr_pool_t *p) 712static void log_sql_module_init(server_rec *s, apr_pool_t *p)
689#endif 713#endif
@@ -693,41 +717,38 @@ static void log_sql_module_init(server_rec *s, apr_pool_t *p)
693 global_config.socketfile = "/tmp/mysql.sock"; 717 global_config.socketfile = "/tmp/mysql.sock";
694 if (!global_config.tcpport) 718 if (!global_config.tcpport)
695 global_config.tcpport = 3306; 719 global_config.tcpport = 3306;
696 if (!log_sql_item_list)
697 log_sql_item_list = apr_array_make(p,10,sizeof(log_sql_item));
698 720
699 /* Register handlers */ 721 /* Register handlers */
700 log_sql_register_item(p,'A', extract_agent, "agent", 1, 1); 722 log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1);
701 log_sql_register_item(p,'a', extract_request_args, "request_args", 1, 1); 723 log_sql_register_item(s,p,'a', extract_request_args, "request_args", 1, 1);
702 log_sql_register_item(p,'b', extract_bytes_sent, "bytes_sent", 0, 0); 724 log_sql_register_item(s,p,'b', extract_bytes_sent, "bytes_sent", 0, 0);
703 log_sql_register_item(p,'c', extract_cookie, "cookie", 0, 1); 725 log_sql_register_item(s,p,'c', extract_cookie, "cookie", 0, 1);
704 log_sql_register_item(p,'e', extract_env_var, "env_var", 0, 1); 726 log_sql_register_item(s,p,'e', extract_env_var, "env_var", 0, 1);
705 log_sql_register_item(p,'f', extract_request_file, "request_file", 0, 1); 727 log_sql_register_item(s,p,'f', extract_request_file, "request_file", 0, 1);
706 log_sql_register_item(p,'H', extract_request_protocol, "request_protocol", 0, 1); 728 log_sql_register_item(s,p,'H', extract_request_protocol, "request_protocol", 0, 1);
707 log_sql_register_item(p,'h', extract_remote_host, "remote_host", 0, 1); 729 log_sql_register_item(s,p,'h', extract_remote_host, "remote_host", 0, 1);
708 log_sql_register_item(p,'I', extract_unique_id, "id", 0, 1); 730 log_sql_register_item(s,p,'I', extract_unique_id, "id", 0, 1);
709 log_sql_register_item(p,'l', extract_remote_logname, "remote_logname", 0, 1); 731 log_sql_register_item(s,p,'l', extract_remote_logname, "remote_logname", 0, 1);
710 log_sql_register_item(p,'m', extract_request_method, "request_method", 0, 1); 732 log_sql_register_item(s,p,'m', extract_request_method, "request_method", 0, 1);
711 log_sql_register_item(p,'M', extract_machine_id, "machine_id", 0, 1); 733 log_sql_register_item(s,p,'M', extract_machine_id, "machine_id", 0, 1);
712 log_sql_register_item(p,'P', extract_child_pid, "child_pid", 0, 0); 734 log_sql_register_item(s,p,'P', extract_child_pid, "child_pid", 0, 0);
713 log_sql_register_item(p,'p', extract_server_port, "server_port", 0, 0); 735 log_sql_register_item(s,p,'p', extract_server_port, "server_port", 0, 0);
714 log_sql_register_item(p,'R', extract_referer, "referer", 1, 1); 736 log_sql_register_item(s,p,'R', extract_referer, "referer", 1, 1);
715 log_sql_register_item(p,'r', extract_request_line, "request_line", 1, 1); 737 log_sql_register_item(s,p,'r', extract_request_line, "request_line", 1, 1);
716 log_sql_register_item(p,'S', extract_request_timestamp, "time_stamp", 0, 0); 738 log_sql_register_item(s,p,'S', extract_request_timestamp, "time_stamp", 0, 0);
717 log_sql_register_item(p,'s', extract_status, "status", 1, 0); 739 log_sql_register_item(s,p,'s', extract_status, "status", 1, 0);
718 log_sql_register_item(p,'T', extract_request_duration, "request_duration", 1, 0); 740 log_sql_register_item(s,p,'T', extract_request_duration, "request_duration", 1, 0);
719 log_sql_register_item(p,'t', extract_request_time, "request_time", 0, 1); 741 log_sql_register_item(s,p,'t', extract_request_time, "request_time", 0, 1);
720 log_sql_register_item(p,'u', extract_remote_user, "remote_user", 0, 1); 742 log_sql_register_item(s,p,'u', extract_remote_user, "remote_user", 0, 1);
721 log_sql_register_item(p,'U', extract_request_uri, "request_uri", 1, 1); 743 log_sql_register_item(s,p,'U', extract_request_uri, "request_uri", 1, 1);
722 log_sql_register_item(p,'v', extract_virtual_host, "virtual_host", 0, 1); 744 log_sql_register_item(s,p,'v', extract_virtual_host, "virtual_host", 0, 1);
723 745
724#if defined(WITH_APACHE20) 746#if defined(WITH_APACHE20)
725 return OK; 747 return OK;
726#endif 748#endif
727} 749}
728 750
729/* 751/* This function gets called to create a per-server configuration
730 * This function gets called to create a per-server configuration
731 * record. It will always be called for the main server and 752 * record. It will always be called for the main server and
732 * for each virtual server that is established. Each server maintains 753 * for each virtual server that is established. Each server maintains
733 * its own state that is separate from the others' states. 754 * its own state that is separate from the others' states.
@@ -741,6 +762,9 @@ static void *log_sql_make_state(apr_pool_t *p, server_rec *s)
741 762
742 /* These defaults are overridable in the httpd.conf file. */ 763 /* These defaults are overridable in the httpd.conf file. */
743 cls->transfer_log_format = DEFAULT_TRANSFER_LOG_FMT; 764 cls->transfer_log_format = DEFAULT_TRANSFER_LOG_FMT;
765 apr_pool_create(&cls->parsed_pool, p);
766 cls->parsed_log_format = apr_pcalloc(cls->parsed_pool,
767 strlen(cls->transfer_log_format) * sizeof(log_sql_item *));
744 cls->notes_table_name = DEFAULT_NOTES_TABLE_NAME; 768 cls->notes_table_name = DEFAULT_NOTES_TABLE_NAME;
745 cls->hin_table_name = DEFAULT_HIN_TABLE_NAME; 769 cls->hin_table_name = DEFAULT_HIN_TABLE_NAME;
746 cls->hout_table_name = DEFAULT_HOUT_TABLE_NAME; 770 cls->hout_table_name = DEFAULT_HOUT_TABLE_NAME;
@@ -773,8 +797,12 @@ static void *log_sql_merge_state(apr_pool_t *p, void *basev, void *addv)
773 /* No default for transfer_table_name because we want its absence 797 /* No default for transfer_table_name because we want its absence
774 * to disable logging. */ 798 * to disable logging. */
775 799
776 if (child->transfer_log_format == DEFAULT_TRANSFER_LOG_FMT) 800 if (child->transfer_log_format == DEFAULT_TRANSFER_LOG_FMT) {
777 child->transfer_log_format = parent->transfer_log_format; 801 child->transfer_log_format = parent->transfer_log_format;
802 /*apr_pool_clear(child->parsed_pool);*/
803 child->parsed_log_format = apr_pcalloc(child->parsed_pool,
804 strlen(child->transfer_log_format) * sizeof(log_sql_item *));
805 }
778 806
779 if (child->preserve_file == DEFAULT_PRESERVE_FILE) 807 if (child->preserve_file == DEFAULT_PRESERVE_FILE)
780 child->preserve_file = parent->preserve_file; 808 child->preserve_file = parent->preserve_file;
@@ -827,11 +855,11 @@ static int log_sql_transaction(request_rec *orig)
827 logsql_state *cls = ap_get_module_config(orig->server->module_config, &log_sql_module); 855 logsql_state *cls = ap_get_module_config(orig->server->module_config, &log_sql_module);
828 const char *access_query; 856 const char *access_query;
829 request_rec *r; 857 request_rec *r;
830 char *transfer_tablename = cls->transfer_table_name; 858 const char *transfer_tablename = cls->transfer_table_name;
831 char *notes_tablename = cls->notes_table_name; 859 const char *notes_tablename = cls->notes_table_name;
832 char *hout_tablename = cls->hout_table_name; 860 const char *hout_tablename = cls->hout_table_name;
833 char *hin_tablename = cls->hin_table_name; 861 const char *hin_tablename = cls->hin_table_name;
834 char *cookie_tablename = cls->cookie_table_name; 862 const char *cookie_tablename = cls->cookie_table_name;
835 863
836 /* We handle mass virtual hosting differently. Dynamically determine the name 864 /* We handle mass virtual hosting differently. Dynamically determine the name
837 * of the table from the virtual server's name, and flag it for creation. 865 * of the table from the virtual server's name, and flag it for creation.
@@ -882,8 +910,7 @@ static int log_sql_transaction(request_rec *orig)
882 char *cookie_query = NULL; 910 char *cookie_query = NULL;
883 const char *unique_id; 911 const char *unique_id;
884 const char *formatted_item; 912 const char *formatted_item;
885 char *s; 913 int i,length;
886 int i;
887 int proceed; 914 int proceed;
888 915
889 for (r = orig; r->next; r = r->next) { 916 for (r = orig; r->next; r = r->next) {
@@ -932,9 +959,14 @@ static int log_sql_transaction(request_rec *orig)
932 959
933 /* Iterate through the format characters and set up the INSERT string according to 960 /* Iterate through the format characters and set up the INSERT string according to
934 * what the user has configured. */ 961 * what the user has configured. */
935 i = 0; 962 length = strlen(cls->transfer_log_format);
936 for (s = cls->transfer_log_format; *s != '\0' ; s++) { 963 for (i = 0; i<length; i++) {
937 log_sql_item *item = log_sql_get_item(*s); 964 log_sql_item *item = cls->parsed_log_format[i];
965 if (item==NULL) {
966 log_error(APLOG_MARK, APLOG_ERR, orig->server,
967 "Log Format '%c' unknown",cls->transfer_log_format[i]);
968 continue;
969 }
938 970
939 /* Yes, this key is one of the configured keys. 971 /* Yes, this key is one of the configured keys.
940 * Call the key's function and put the returned value into 'formatted_item' */ 972 * Call the key's function and put the returned value into 'formatted_item' */
@@ -956,7 +988,6 @@ static int log_sql_transaction(request_rec *orig)
956 (item->string_contents ? "'" : ""), 988 (item->string_contents ? "'" : ""),
957 escape_query(formatted_item, r->pool), 989 escape_query(formatted_item, r->pool),
958 (item->string_contents ? "'" : ""), NULL); 990 (item->string_contents ? "'" : ""), NULL);
959 i = 1;
960 } 991 }
961 992
962 /* Work through the list of notes defined by LogSQLWhichNotes */ 993 /* Work through the list of notes defined by LogSQLWhichNotes */
@@ -1188,8 +1219,8 @@ static const command_rec log_sql_cmds[] = {
1188 (void *)APR_OFFSETOF(logsql_state, cookie_table_name), RSRC_CONF, 1219 (void *)APR_OFFSETOF(logsql_state, cookie_table_name), RSRC_CONF,
1189 "The database table that holds the cookie info") 1220 "The database table that holds the cookie info")
1190 , 1221 ,
1191 AP_INIT_TAKE1("LogSQLTransferLogFormat", set_server_string_slot, 1222 AP_INIT_TAKE1("LogSQLTransferLogFormat", set_logformat_slot,
1192 (void *)APR_OFFSETOF(logsql_state,transfer_log_format), RSRC_CONF, 1223 NULL, RSRC_CONF,
1193 "Instruct the module what information to log to the database transfer log") 1224 "Instruct the module what information to log to the database transfer log")
1194 , 1225 ,
1195 AP_INIT_TAKE1("LogSQLMachineID", set_global_string_slot, 1226 AP_INIT_TAKE1("LogSQLMachineID", set_global_string_slot,
@@ -1271,7 +1302,7 @@ static const command_rec log_sql_cmds[] = {
1271/* The configuration array that sets up the hooks into the module. */ 1302/* The configuration array that sets up the hooks into the module. */
1272#if defined(WITH_APACHE20) 1303#if defined(WITH_APACHE20)
1273static void register_hooks(apr_pool_t *p) { 1304static void register_hooks(apr_pool_t *p) {
1274 ap_hook_pre_config(log_sql_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST); 1305 ap_hook_post_config(log_sql_post_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
1275 ap_hook_child_init(log_sql_child_init, NULL, NULL, APR_HOOK_MIDDLE); 1306 ap_hook_child_init(log_sql_child_init, NULL, NULL, APR_HOOK_MIDDLE);
1276 ap_hook_open_logs(log_sql_open, NULL, NULL, APR_HOOK_MIDDLE); 1307 ap_hook_open_logs(log_sql_open, NULL, NULL, APR_HOOK_MIDDLE);
1277 ap_hook_log_transaction(log_sql_transaction, NULL, NULL, APR_HOOK_MIDDLE); 1308 ap_hook_log_transaction(log_sql_transaction, NULL, NULL, APR_HOOK_MIDDLE);
diff --git a/mod_log_sql.h b/mod_log_sql.h
index 8093cee..f54ab54 100644
--- a/mod_log_sql.h
+++ b/mod_log_sql.h
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.h,v 1.2 2004/01/21 04:34:21 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.h,v 1.3 2004/01/22 05:26:56 urkle Exp $ */
2#ifndef MOD_LOG_SQL_H 2#ifndef MOD_LOG_SQL_H
3#define MOD_LOG_SQL_H 3#define MOD_LOG_SQL_H
4 4
@@ -26,8 +26,7 @@
26typedef const char *log_sql_item_func(request_rec *r, char *a); 26typedef const char *log_sql_item_func(request_rec *r, char *a);
27 27
28/* Registration Function for extract functions */ 28/* Registration Function for extract functions */
29LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char key, 29LOGSQL_DECLARE(void) log_sql_register_item(server_rec *s, apr_pool_t *p,
30 log_sql_item_func *func, const char *sql_field_name, 30 char key, log_sql_item_func *func, const char *sql_field_name,
31 int want_orig_default, int string_contents); 31 int want_orig_default, int string_contents);
32
33#endif /* MOD_LOG_SQL_H */ 32#endif /* MOD_LOG_SQL_H */
diff --git a/mod_log_sql.prj b/mod_log_sql.prj
index 571d182..9193940 100644
--- a/mod_log_sql.prj
+++ b/mod_log_sql.prj
@@ -29,7 +29,7 @@ anjuta.compatibility.level=1
29project.name=mod_log_sql 29project.name=mod_log_sql
30project.type=GENERIC 30project.type=GENERIC
31project.target.type=EXECUTABLE 31project.target.type=EXECUTABLE
32project.version=1.90 32project.version=1.94
33project.author=Edward Rudd 33project.author=Edward Rudd
34project.source.target=unknown 34project.source.target=unknown
35project.has.gettext=0 35project.has.gettext=0
@@ -67,7 +67,8 @@ module.source.expanded=1
67module.source.files=\ 67module.source.files=\
68 mod_log_sql.c\ 68 mod_log_sql.c\
69 make_combined_log.pl\ 69 make_combined_log.pl\
70 contrib/mysql_import_combined_log.pl 70 contrib/mysql_import_combined_log.pl\
71 mod_log_sql_ssl.c
71 72
72module.pixmap.name=. 73module.pixmap.name=.
73module.pixmap.type= 74module.pixmap.type=
diff --git a/mod_log_sql_ssl.c b/mod_log_sql_ssl.c
index 92e0684..c874a2b 100644
--- a/mod_log_sql_ssl.c
+++ b/mod_log_sql_ssl.c
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/mod_log_sql_ssl.c,v 1.3 2004/01/21 04:34:21 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql_ssl.c,v 1.4 2004/01/22 05:26:56 urkle Exp $ */
2/* mod_log_sql_ssl */ 2/* mod_log_sql_ssl */
3 3
4#if defined(WITH_APACHE20) 4#if defined(WITH_APACHE20)
@@ -22,18 +22,19 @@
22#include "config.h" 22#include "config.h"
23#endif 23#endif
24 24
25#include "mod_log_sql.h"
25#include "mod_ssl.h" 26#include "mod_ssl.h"
26 27
28#if defined(WITH_APACHE20)
29# define TEST_SSL(r) myConnConfig(r->connection)
30#elif defined(WITH_APACHE13)
31# define TEST_SSL(r) ap_ctx_get(r->connection->client->ctx, "ssl")
32#endif
33
27static const char *extract_ssl_keysize(request_rec *r, char *a) 34static const char *extract_ssl_keysize(request_rec *r, char *a)
28{ 35{
29 char *result = NULL; 36 char *result = NULL;
30#if defined(APACHE20) 37 if (TEST_SSL(r) != NULL)
31 SSLConnRec *scc = myConnConfig(r->connection);
32 SSLSrvConfigRec *ssc = mySrvConfig(r->server);
33 if (myCtxConfig(scc,ssc) != NULL
34#elif defined(APACHE13)
35 if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL)
36#endif
37 { 38 {
38 result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_USEKEYSIZE"); 39 result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_USEKEYSIZE");
39 #ifdef DEBUG 40 #ifdef DEBUG
@@ -50,13 +51,7 @@ static const char *extract_ssl_keysize(request_rec *r, char *a)
50static const char *extract_ssl_maxkeysize(request_rec *r, char *a) 51static const char *extract_ssl_maxkeysize(request_rec *r, char *a)
51{ 52{
52 char *result = NULL; 53 char *result = NULL;
53#if defined(APACHE20) 54 if (TEST_SSL(r) != NULL)
54 SSLConnRec *scc = myConnConfig(r->connection);
55 SSLSrvConfigRec *ssc = mySrvConfig(r->server);
56 if (myCtxConfig(scc,ssc) != NULL
57#elif defined(APACHE13)
58 if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL)
59#endif
60 { 55 {
61 result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_ALGKEYSIZE"); 56 result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_ALGKEYSIZE");
62 #ifdef DEBUG 57 #ifdef DEBUG
@@ -73,13 +68,7 @@ static const char *extract_ssl_maxkeysize(request_rec *r, char *a)
73static const char *extract_ssl_cipher(request_rec *r, char *a) 68static const char *extract_ssl_cipher(request_rec *r, char *a)
74{ 69{
75 char *result = NULL; 70 char *result = NULL;
76#if defined(APACHE20) 71 if (TEST_SSL(r) != NULL)
77 SSLConnRec *scc = myConnConfig(r->connection);
78 SSLSrvConfigRec *ssc = mySrvConfig(r->server);
79 if (myCtxConfig(scc,ssc) != NULL
80#elif defined(APACHE13)
81 if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL)
82#endif
83 { 72 {
84 result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER"); 73 result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER");
85 #ifdef DEBUG 74 #ifdef DEBUG
@@ -94,23 +83,26 @@ static const char *extract_ssl_cipher(request_rec *r, char *a)
94} 83}
95 84
96#if defined(WITH_APACHE20) 85#if defined(WITH_APACHE20)
97static int pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) 86static int post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
98#elif defined(WITH_APACHE13) 87#elif defined(WITH_APACHE13)
99static void module_init(server_rec *s, apr_pool_t *p) 88static void module_init(server_rec *s, apr_pool_t *p)
100#endif 89#endif
101{ 90{
102 log_sql_register_item(p,'q', extract_ssl_keysize, "ssl_keysize", 0, 1); 91 log_sql_register_item(s,p,'q', extract_ssl_keysize, "ssl_keysize", 0, 1);
103 log_sql_register_item(p,'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1); 92 log_sql_register_item(s,p,'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1);
104 log_sql_register_item(p,'z', extract_ssl_cipher, "ssl_cipher", 0, 1); 93 log_sql_register_item(s,p,'z', extract_ssl_cipher, "ssl_cipher", 0, 1);
94#if defined(WITH_APACHE20)
95 return OK;
96#endif
105} 97}
106 98
107/* The configuration array that sets up the hooks into the module. */ 99/* The configuration array that sets up the hooks into the module. */
108#if defined(WITH_APACHE20) 100#if defined(WITH_APACHE20)
109static void register_hooks(apr_pool_t *p) { 101static void register_hooks(apr_pool_t *p) {
110 ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST); 102 ap_hook_post_config(post_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
111} 103}
112 104
113module AP_MODULE_DECLARE_DATA log_sql_module = { 105module AP_MODULE_DECLARE_DATA log_sql_ssl_module = {
114 STANDARD20_MODULE_STUFF, 106 STANDARD20_MODULE_STUFF,
115 NULL, /* create per-directory config structures */ 107 NULL, /* create per-directory config structures */
116 NULL, /* merge per-directory config structures */ 108 NULL, /* merge per-directory config structures */
@@ -127,7 +119,7 @@ module log_sql_ssl_module = {
127 NULL, /* merge per-dir config */ 119 NULL, /* merge per-dir config */
128 NULL, /* create server config */ 120 NULL, /* create server config */
129 NULL, /* merge server config */ 121 NULL, /* merge server config */
130 log_sql_cmds, /* config directive table */ 122 NULL, /* config directive table */
131 NULL, /* [9] content handlers */ 123 NULL, /* [9] content handlers */
132 NULL, /* [2] URI-to-filename translation */ 124 NULL, /* [2] URI-to-filename translation */
133 NULL, /* [5] check/validate user_id */ 125 NULL, /* [5] check/validate user_id */
@@ -135,11 +127,11 @@ module log_sql_ssl_module = {
135 NULL, /* [4] check access by host */ 127 NULL, /* [4] check access by host */
136 NULL, /* [7] MIME type checker/setter */ 128 NULL, /* [7] MIME type checker/setter */
137 NULL, /* [8] fixups */ 129 NULL, /* [8] fixups */
138 log_sql_transaction, /* [10] logger */ 130 NULL, /* [10] logger */
139 NULL /* [3] header parser */ 131 NULL /* [3] header parser */
140#if MODULE_MAGIC_NUMBER >= 19970728 /* 1.3-dev or later support these additionals... */ 132#if MODULE_MAGIC_NUMBER >= 19970728 /* 1.3-dev or later support these additionals... */
141 ,log_sql_child_init, /* child process initializer */ 133 ,NULL, /* child process initializer */
142 log_sql_child_exit, /* process exit/cleanup */ 134 NULL, /* process exit/cleanup */
143 NULL /* [1] post read-request */ 135 NULL /* [1] post read-request */
144#endif 136#endif
145 137