From f230d2468cdc8ee3d290d34a36593b154f51aee1 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Thu, 22 Jan 2004 05:26:56 +0000 Subject: 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) --- AUTHORS | 10 ++- CHANGELOG | 9 ++- Makefile.in | 40 +++++++++--- apache13.h | 3 +- configure.ac | 10 +-- m4/apache.m4 | 5 +- m4/mod_ssl.m4 | 13 +++- mod_log_sql.c | 181 ++++++++++++++++++++++++++++++++---------------------- mod_log_sql.h | 7 +-- mod_log_sql.prj | 5 +- mod_log_sql_ssl.c | 56 ++++++++--------- 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 @@ -Christopher B. Powell - Main author +The Apache Foundation + standard apache logging module for which this module is based on + +Zeev Suraski + Adding the mysql routines (intial revisions) + +Christopher B. Powell + Maintainer since version 1.06 Edward Rudd Apache 2.0 port. diff --git a/CHANGELOG b/CHANGELOG index eb3bafc..fbe49b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -$Id: CHANGELOG,v 1.8 2004/01/21 04:34:21 urkle Exp $ +$Id: CHANGELOG,v 1.9 2004/01/22 05:26:56 urkle Exp $ TODO: * Port connection portion to other DBMS? Genericize the module? Start with @@ -14,14 +14,17 @@ TODO: * Directive to yes/no create ancillary tables (or just access table) * break module into separate code files separate DB implimentation into sub-modules via provider mechanism - separate module for SSL support - apache version specific code already split into separate files. +* convert documentation to docbook * add document building to Makefile.in * investigate thread safety issues (libmysqlclient_r) Add thread locks if using standard mysqlclient * rewrite main core logging function to optimize for speed. CHANGES: +1.94: ? +* ssl loggin back in as separate module under 1.3 and 2.0 +* preparsing of format tags is now done to speed up main logging loop. + 1.93: 2004-01-20 * Compiles for apache 1.3 AND 2.0 * 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@ LDADD = @MYSQL_LDFLAGS@ @MYSQL_LIBS@ -EXTRA_DIST = INSTALL LICENSE CHANGELOG make_combined_log.pl +EXTRA_DIST = AUTHORS INSTALL LICENSE CHANGELOG make_combined_log.pl TARGET = @PACKAGE_NAME@@APXS_EXTENSION@ +sslSOURCES = mod_log_sql_ssl.c + +sslTARGET = @PACKAGE_NAME@_ssl@APXS_EXTENSION@ + +ifeq (@WANT_SSL_MOD@,1) +TARGETS = $(TARGET) $(sslTARGET) +else +TARGETS = $(TARGET) +endif + #Don't modify anything below here PROVIDERS_SUBDIRS = @subdirs@ @@ -29,11 +39,11 @@ PROVIDERS_SUBDIRS = @subdirs@ srcdir = @abs_srcdir@ builddir = @abs_builddir@ -OBJ = $(SOURCES:.c=.o) +OBJ = $(SOURCES:.c=.o) $(sslSOURCES:.c=.o) -LO = $(SOURCES:.c=.lo) +LO = $(SOURCES:.c=.lo) $(sslSOURCES:.c=.lo) -SLO = $(SOURCES:.c=.slo) +SLO = $(SOURCES:.c=.slo) $(sslSOURCES:.c=.slo) STD_DIST = install-sh \ config.sub \ @@ -47,7 +57,7 @@ STD_DIST = install-sh \ DISTFILES = $(STD_DIST) $(EXTRA_DIST) $(SOURCES) $(HEADERS) -all: $(TARGET) all-subdirs +all: $(TARGETS) all-subdirs all-subdirs install-subdirs activate-subdirs clean-subdirs distclean-subdirs: @otarget=`echo $@|sed s/-subdirs//`; \ @@ -65,21 +75,31 @@ all-subdirs install-subdirs activate-subdirs clean-subdirs distclean-subdirs: done; $(TARGET): $(SOURCES) $(HEADERS) - @@APXS_BIN@ -c -o $(TARGET) $(INCLUDES) @MOD_SSL_CFLAGS@ $(CFLAGS) \ + @@APXS_BIN@ -c -o $(TARGET) $(INCLUDES) $(CFLAGS) \ $(LDADD) @DEFS@ @APACHE_DEFS@ $(SOURCES) +$(sslTARGET): $(sslSOURCES) $(HEADERS) + @@APXS_BIN@ -c -o $(sslTARGET) $(INCLUDES) @MOD_SSL_CFLAGS@ $(CFLAGS) \ + @DEFS@ @APACHE_DEFS@ $(sslSOURCES) + include: rm -rf include ln -s @APACHE_INCDIR@ include -install: install-subdirs - @@APXS_BIN@ -i $(TARGET) +install: $(TARGETS) install-subdirs + @@APXS_BIN@ -i $(TARGET); \ + if test @WANT_SSL_MOD@ -eq 1; then \ + @APXS_BIN@ -i $(sslTARGET); \ + fi activate: activate-subdirs - @@APXS_BIN@ -i -a $(TARGET) + @@APXS_BIN@ -i -a $(TARGET); \ + if test @WANT_SSL_MOD@ -eq 1; then \ + @APXS_BIN@ -i -a $(sslTARGET); \ + fi clean: clean-subdirs - $(RM) $(OBJ) $(SLO) $(LO) $(TARGET) + $(RM) $(OBJ) $(SLO) $(LO) $(TARGETS) $(RM) -r .libs distclean: 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 @@ -/* $Header: /home/cvs/mod_log_sql/apache13.h,v 1.2 2004/01/20 19:38:07 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/apache13.h,v 1.3 2004/01/22 05:26:56 urkle Exp $ */ #ifndef APACHE13_H #define APACHE13_H @@ -41,6 +41,7 @@ /* Functions */ #define ap_get_remote_host(a,b,c,d) ap_get_remote_host(a,b,c) +#define apr_pool_create(a,b) *(a) = ap_make_sub_pool(b) #define apr_palloc ap_palloc #define apr_pcalloc ap_pcalloc #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 @@ dnl Required initializer -AC_INIT(mod_log_sql, 1.93) +AC_INIT(mod_log_sql, 1.94) AC_PREREQ(2.53) AC_CONFIG_HEADERS(config.h) @@ -24,10 +24,12 @@ CHECK_PATH_MYSQL(:, CHECK_PATH_MOD_SSL( AC_DEFINE(WANT_SSL_LOGGING,,[Define if we want to compile in SSL support.]) - conf_SSL=1, - conf_SSL=0 + WANT_SSL_MOD=1, + WANT_SSL_MOD=0 ) +AC_SUBST(WANT_SSL_MOD) + AC_CHECK_HEADERS(limits.h) AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) @@ -38,7 +40,7 @@ AC_OUTPUT(Makefile Documentation/Makefile) AC_MSG_RESULT([------------------------------------]) AC_MSG_RESULT([Apache version : $APACHE_VERSION]) -if test $conf_SSL -eq 1; then +if test $WANT_SSL_MOD -eq 1; then AC_MSG_RESULT([SSL Support : yes]) else 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( AC_MSG_ERROR([*** your path, or use the --with-apxs configure option]) else APACHE_INCDIR=`$APXS_BIN -q INCLUDEDIR` - APACHE_CFLAGS=-I$APACHE_INCDIR + APACHE_CPPFLAGS=`$APXS_BIN -q CFLAGS` + APACHE_CFLAGS="-I$APACHE_INCDIR" APACHE_MODDIR=`$APXS_BIN -q LIBEXECDIR` if test "x$enable_apachetest" = "xyes" ; then @@ -155,6 +156,7 @@ AC_ARG_ENABLE( AC_DEFINE(WITH_APACHE13,1,[Define to 1 if we are compiling with Apache 1.3.x]) APACHE_VERSION="13" APXS_EXTENSION=.so + APACHE_CFLAGS="-g $APACHE_CFLAGS" APACHE_DEFS="-DWITH_APACHE13" ifelse([$3], , , $3), AC_MSG_RESULT(no) @@ -164,6 +166,7 @@ AC_ARG_ENABLE( fi AC_SUBST(APACHE_DEFS) AC_SUBST(APACHE_CFLAGS) + AC_SUBST(APACHE_CPPFLAGS) AC_SUBST(APACHE_INCDIR) AC_SUBST(APACHE_MODDIR) 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( [AC_HELP_STRING([--with-ssl-inc=DIR],[Location of SSL header files])], ssl_incdir="$withval", ) +AC_ARG_WITH( + db-inc, + [AC_HELP_STRING([--with-db-inc=DIR],[Location of DB header files])], + db_incdir="$withval", + ) if test "x$ssl_val" = "xyes"; then ac_save_CFLAGS=$CFLAGS @@ -22,9 +27,11 @@ AC_ARG_WITH( if test "x$ssl_incdir" != "x"; then MOD_SSL_CFLAGS="-I$ssl_incdir -I$ssl_incdir/openssl $MOD_SSL_CFLAGS" fi - - CFLAGS="-I$APACHE_INCDIR $MOD_SSL_CFLAGS $CFLAGS" - CPPFLAGS="-I$APACHE_INCDIR $MOD_SSL_CFLAGS $CPPFLAGS" + if test "x$db_incdir" != "x"; then + MOD_SSL_CFLAGS="-I$db_incdir $MOD_SSL_CFLAGS" + fi + CFLAGS="$APACHE_CFLAGS $APACHE_CPPFLAGS $MOD_SSL_CFLAGS $CFLAGS" + CPPFLAGS="$APACHE_CFLAGS $APACHE_CPPFLAGS $MOD_SSL_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS([mod_ssl.h], mod_ssl_h=yes ) 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 @@ -/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.11 2004/01/21 04:34:21 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.12 2004/01/22 05:26:56 urkle Exp $ */ /* --------* * DEFINES * * --------*/ @@ -84,6 +84,15 @@ typedef struct { static global_config_t global_config; +/* structure to hold helper function info */ +typedef struct { + char key; /* item letter character */ + log_sql_item_func *func; /* its extraction function */ + const char *sql_field_name; /* its column in SQL */ + int want_orig_default; /* if it requires the original request prior to internal redirection */ + int string_contents; /* if it returns a string */ +} log_sql_item; + /* But the contents of this structure will vary by virtual server. * This permits each virtual server to vary its configuration slightly * for per-server customization. @@ -98,14 +107,16 @@ typedef struct { apr_array_header_t *hout_list; apr_array_header_t *hin_list; apr_array_header_t *cookie_list; - char *notes_table_name; - char *hout_table_name; - char *hin_table_name; - char *cookie_table_name; - char *transfer_table_name; - char *transfer_log_format; - char *preserve_file; - char *cookie_name; + const char *notes_table_name; + const char *hout_table_name; + const char *hin_table_name; + const char *cookie_table_name; + const char *transfer_table_name; + const char *transfer_log_format; + apr_pool_t *parsed_pool; + log_sql_item **parsed_log_format; + const char *preserve_file; + const char *cookie_name; } logsql_state; @@ -115,39 +126,39 @@ typedef struct { static int safe_create_tables(logsql_state *cls, request_rec *r); -typedef struct { - char key; /* item letter character */ - log_sql_item_func *func; /* its extraction function */ - const char *sql_field_name; /* its column in SQL */ - int want_orig_default; /* if it requires the original request prior to internal redirection */ - int string_contents; /* if it returns a string */ -} log_sql_item; - static apr_array_header_t *log_sql_item_list; -/* Registration Function for extract functions */ -LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char key, - log_sql_item_func *func, const char *sql_field_name, +/* Registration Function for extract functions * + * and update parse cache for transfer_log_format * + * this is exported from the module */ +LOGSQL_DECLARE(void) log_sql_register_item(server_rec *s, apr_pool_t *p, + char key, log_sql_item_func *func, const char *sql_field_name, int want_orig_default, int string_contents) { - log_sql_item *item = apr_array_push(log_sql_item_list); + server_rec *ts; + log_sql_item *item; + if (!log_sql_item_list) + log_sql_item_list = apr_array_make(p,10, sizeof(log_sql_item)); + + item= apr_array_push(log_sql_item_list); item->key = key; item->func = func; item->sql_field_name = sql_field_name; item->want_orig_default = want_orig_default; item->string_contents = string_contents; -} - -/* Search through item array */ -static inline log_sql_item *log_sql_get_item(char key) -{ - int itr; - for(itr=0; itrnelts; itr++) { - if (((log_sql_item *)log_sql_item_list->elts)[itr].key == key) { - return &((log_sql_item *)log_sql_item_list->elts)[itr]; + /* some voodoo here to post parse logitems in all servers * + * so a "cached" list is used in the main logging loop for speed */ + for (ts = s; ts; ts = ts->next) { + logsql_state *cfg = ap_get_module_config(ts->module_config, + &log_sql_module); + char *pos; + + if (cfg->transfer_log_format) { + if ( (pos = strchr(cfg->transfer_log_format,key))!=NULL) { + cfg->parsed_log_format[pos - cfg->transfer_log_format] = item; + } } } - return NULL; } /* Include all the extract functions */ @@ -570,6 +581,19 @@ static const char *set_server_string_slot(cmd_parms *cmd, return NULL; } +static const char *set_logformat_slot(cmd_parms *cmd, + void *struct_ptr, + const char *arg) +{ + logsql_state *cfg = ap_get_module_config(cmd->server->module_config, + &log_sql_module); + + cfg->transfer_log_format = arg; +/* apr_pool_clear(cfg->parsed_pool);*/ + cfg->parsed_log_format = apr_pcalloc(cfg->parsed_pool, + strlen(arg) * sizeof(log_sql_item *)); + return NULL; +} static const char *set_server_nmv_string_slot(cmd_parms *parms, void *struct_ptr, @@ -681,9 +705,9 @@ void *log_sql_initializer(server_rec *main_server, apr_pool_t *p) } */ - +/* post_config / module_init */ #if defined(WITH_APACHE20) -static int log_sql_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) +static int log_sql_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) #elif defined(WITH_APACHE13) static void log_sql_module_init(server_rec *s, apr_pool_t *p) #endif @@ -693,41 +717,38 @@ static void log_sql_module_init(server_rec *s, apr_pool_t *p) global_config.socketfile = "/tmp/mysql.sock"; if (!global_config.tcpport) global_config.tcpport = 3306; - if (!log_sql_item_list) - log_sql_item_list = apr_array_make(p,10,sizeof(log_sql_item)); /* Register handlers */ - log_sql_register_item(p,'A', extract_agent, "agent", 1, 1); - log_sql_register_item(p,'a', extract_request_args, "request_args", 1, 1); - log_sql_register_item(p,'b', extract_bytes_sent, "bytes_sent", 0, 0); - log_sql_register_item(p,'c', extract_cookie, "cookie", 0, 1); - log_sql_register_item(p,'e', extract_env_var, "env_var", 0, 1); - log_sql_register_item(p,'f', extract_request_file, "request_file", 0, 1); - log_sql_register_item(p,'H', extract_request_protocol, "request_protocol", 0, 1); - log_sql_register_item(p,'h', extract_remote_host, "remote_host", 0, 1); - log_sql_register_item(p,'I', extract_unique_id, "id", 0, 1); - log_sql_register_item(p,'l', extract_remote_logname, "remote_logname", 0, 1); - log_sql_register_item(p,'m', extract_request_method, "request_method", 0, 1); - log_sql_register_item(p,'M', extract_machine_id, "machine_id", 0, 1); - log_sql_register_item(p,'P', extract_child_pid, "child_pid", 0, 0); - log_sql_register_item(p,'p', extract_server_port, "server_port", 0, 0); - log_sql_register_item(p,'R', extract_referer, "referer", 1, 1); - log_sql_register_item(p,'r', extract_request_line, "request_line", 1, 1); - log_sql_register_item(p,'S', extract_request_timestamp, "time_stamp", 0, 0); - log_sql_register_item(p,'s', extract_status, "status", 1, 0); - log_sql_register_item(p,'T', extract_request_duration, "request_duration", 1, 0); - log_sql_register_item(p,'t', extract_request_time, "request_time", 0, 1); - log_sql_register_item(p,'u', extract_remote_user, "remote_user", 0, 1); - log_sql_register_item(p,'U', extract_request_uri, "request_uri", 1, 1); - log_sql_register_item(p,'v', extract_virtual_host, "virtual_host", 0, 1); + log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1); + log_sql_register_item(s,p,'a', extract_request_args, "request_args", 1, 1); + log_sql_register_item(s,p,'b', extract_bytes_sent, "bytes_sent", 0, 0); + log_sql_register_item(s,p,'c', extract_cookie, "cookie", 0, 1); + log_sql_register_item(s,p,'e', extract_env_var, "env_var", 0, 1); + log_sql_register_item(s,p,'f', extract_request_file, "request_file", 0, 1); + log_sql_register_item(s,p,'H', extract_request_protocol, "request_protocol", 0, 1); + log_sql_register_item(s,p,'h', extract_remote_host, "remote_host", 0, 1); + log_sql_register_item(s,p,'I', extract_unique_id, "id", 0, 1); + log_sql_register_item(s,p,'l', extract_remote_logname, "remote_logname", 0, 1); + log_sql_register_item(s,p,'m', extract_request_method, "request_method", 0, 1); + log_sql_register_item(s,p,'M', extract_machine_id, "machine_id", 0, 1); + log_sql_register_item(s,p,'P', extract_child_pid, "child_pid", 0, 0); + log_sql_register_item(s,p,'p', extract_server_port, "server_port", 0, 0); + log_sql_register_item(s,p,'R', extract_referer, "referer", 1, 1); + log_sql_register_item(s,p,'r', extract_request_line, "request_line", 1, 1); + log_sql_register_item(s,p,'S', extract_request_timestamp, "time_stamp", 0, 0); + log_sql_register_item(s,p,'s', extract_status, "status", 1, 0); + log_sql_register_item(s,p,'T', extract_request_duration, "request_duration", 1, 0); + log_sql_register_item(s,p,'t', extract_request_time, "request_time", 0, 1); + log_sql_register_item(s,p,'u', extract_remote_user, "remote_user", 0, 1); + log_sql_register_item(s,p,'U', extract_request_uri, "request_uri", 1, 1); + log_sql_register_item(s,p,'v', extract_virtual_host, "virtual_host", 0, 1); #if defined(WITH_APACHE20) return OK; #endif } -/* - * This function gets called to create a per-server configuration +/* This function gets called to create a per-server configuration * record. It will always be called for the main server and * for each virtual server that is established. Each server maintains * 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) /* These defaults are overridable in the httpd.conf file. */ cls->transfer_log_format = DEFAULT_TRANSFER_LOG_FMT; + apr_pool_create(&cls->parsed_pool, p); + cls->parsed_log_format = apr_pcalloc(cls->parsed_pool, + strlen(cls->transfer_log_format) * sizeof(log_sql_item *)); cls->notes_table_name = DEFAULT_NOTES_TABLE_NAME; cls->hin_table_name = DEFAULT_HIN_TABLE_NAME; 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) /* No default for transfer_table_name because we want its absence * to disable logging. */ - if (child->transfer_log_format == DEFAULT_TRANSFER_LOG_FMT) + if (child->transfer_log_format == DEFAULT_TRANSFER_LOG_FMT) { child->transfer_log_format = parent->transfer_log_format; + /*apr_pool_clear(child->parsed_pool);*/ + child->parsed_log_format = apr_pcalloc(child->parsed_pool, + strlen(child->transfer_log_format) * sizeof(log_sql_item *)); + } if (child->preserve_file == DEFAULT_PRESERVE_FILE) child->preserve_file = parent->preserve_file; @@ -827,11 +855,11 @@ static int log_sql_transaction(request_rec *orig) logsql_state *cls = ap_get_module_config(orig->server->module_config, &log_sql_module); const char *access_query; request_rec *r; - char *transfer_tablename = cls->transfer_table_name; - char *notes_tablename = cls->notes_table_name; - char *hout_tablename = cls->hout_table_name; - char *hin_tablename = cls->hin_table_name; - char *cookie_tablename = cls->cookie_table_name; + const char *transfer_tablename = cls->transfer_table_name; + const char *notes_tablename = cls->notes_table_name; + const char *hout_tablename = cls->hout_table_name; + const char *hin_tablename = cls->hin_table_name; + const char *cookie_tablename = cls->cookie_table_name; /* We handle mass virtual hosting differently. Dynamically determine the name * 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) char *cookie_query = NULL; const char *unique_id; const char *formatted_item; - char *s; - int i; + int i,length; int proceed; for (r = orig; r->next; r = r->next) { @@ -932,9 +959,14 @@ static int log_sql_transaction(request_rec *orig) /* Iterate through the format characters and set up the INSERT string according to * what the user has configured. */ - i = 0; - for (s = cls->transfer_log_format; *s != '\0' ; s++) { - log_sql_item *item = log_sql_get_item(*s); + length = strlen(cls->transfer_log_format); + for (i = 0; iparsed_log_format[i]; + if (item==NULL) { + log_error(APLOG_MARK, APLOG_ERR, orig->server, + "Log Format '%c' unknown",cls->transfer_log_format[i]); + continue; + } /* Yes, this key is one of the configured keys. * 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) (item->string_contents ? "'" : ""), escape_query(formatted_item, r->pool), (item->string_contents ? "'" : ""), NULL); - i = 1; } /* Work through the list of notes defined by LogSQLWhichNotes */ @@ -1188,8 +1219,8 @@ static const command_rec log_sql_cmds[] = { (void *)APR_OFFSETOF(logsql_state, cookie_table_name), RSRC_CONF, "The database table that holds the cookie info") , - AP_INIT_TAKE1("LogSQLTransferLogFormat", set_server_string_slot, - (void *)APR_OFFSETOF(logsql_state,transfer_log_format), RSRC_CONF, + AP_INIT_TAKE1("LogSQLTransferLogFormat", set_logformat_slot, + NULL, RSRC_CONF, "Instruct the module what information to log to the database transfer log") , AP_INIT_TAKE1("LogSQLMachineID", set_global_string_slot, @@ -1271,7 +1302,7 @@ static const command_rec log_sql_cmds[] = { /* The configuration array that sets up the hooks into the module. */ #if defined(WITH_APACHE20) static void register_hooks(apr_pool_t *p) { - ap_hook_pre_config(log_sql_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST); + ap_hook_post_config(log_sql_post_config, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_child_init(log_sql_child_init, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_open_logs(log_sql_open, NULL, NULL, APR_HOOK_MIDDLE); 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 @@ -/* $Header: /home/cvs/mod_log_sql/mod_log_sql.h,v 1.2 2004/01/21 04:34:21 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/mod_log_sql.h,v 1.3 2004/01/22 05:26:56 urkle Exp $ */ #ifndef MOD_LOG_SQL_H #define MOD_LOG_SQL_H @@ -26,8 +26,7 @@ typedef const char *log_sql_item_func(request_rec *r, char *a); /* Registration Function for extract functions */ -LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char key, - log_sql_item_func *func, const char *sql_field_name, +LOGSQL_DECLARE(void) log_sql_register_item(server_rec *s, apr_pool_t *p, + char key, log_sql_item_func *func, const char *sql_field_name, int want_orig_default, int string_contents); - #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 project.name=mod_log_sql project.type=GENERIC project.target.type=EXECUTABLE -project.version=1.90 +project.version=1.94 project.author=Edward Rudd project.source.target=unknown project.has.gettext=0 @@ -67,7 +67,8 @@ module.source.expanded=1 module.source.files=\ mod_log_sql.c\ make_combined_log.pl\ - contrib/mysql_import_combined_log.pl + contrib/mysql_import_combined_log.pl\ + mod_log_sql_ssl.c module.pixmap.name=. module.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 @@ -/* $Header: /home/cvs/mod_log_sql/mod_log_sql_ssl.c,v 1.3 2004/01/21 04:34:21 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/mod_log_sql_ssl.c,v 1.4 2004/01/22 05:26:56 urkle Exp $ */ /* mod_log_sql_ssl */ #if defined(WITH_APACHE20) @@ -22,18 +22,19 @@ #include "config.h" #endif +#include "mod_log_sql.h" #include "mod_ssl.h" +#if defined(WITH_APACHE20) +# define TEST_SSL(r) myConnConfig(r->connection) +#elif defined(WITH_APACHE13) +# define TEST_SSL(r) ap_ctx_get(r->connection->client->ctx, "ssl") +#endif + static const char *extract_ssl_keysize(request_rec *r, char *a) { char *result = NULL; -#if defined(APACHE20) - SSLConnRec *scc = myConnConfig(r->connection); - SSLSrvConfigRec *ssc = mySrvConfig(r->server); - if (myCtxConfig(scc,ssc) != NULL -#elif defined(APACHE13) - if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL) -#endif + if (TEST_SSL(r) != NULL) { result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_USEKEYSIZE"); #ifdef DEBUG @@ -50,13 +51,7 @@ static const char *extract_ssl_keysize(request_rec *r, char *a) static const char *extract_ssl_maxkeysize(request_rec *r, char *a) { char *result = NULL; -#if defined(APACHE20) - SSLConnRec *scc = myConnConfig(r->connection); - SSLSrvConfigRec *ssc = mySrvConfig(r->server); - if (myCtxConfig(scc,ssc) != NULL -#elif defined(APACHE13) - if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL) -#endif + if (TEST_SSL(r) != NULL) { result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_ALGKEYSIZE"); #ifdef DEBUG @@ -73,13 +68,7 @@ static const char *extract_ssl_maxkeysize(request_rec *r, char *a) static const char *extract_ssl_cipher(request_rec *r, char *a) { char *result = NULL; -#if defined(APACHE20) - SSLConnRec *scc = myConnConfig(r->connection); - SSLSrvConfigRec *ssc = mySrvConfig(r->server); - if (myCtxConfig(scc,ssc) != NULL -#elif defined(APACHE13) - if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL) -#endif + if (TEST_SSL(r) != NULL) { result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER"); #ifdef DEBUG @@ -94,23 +83,26 @@ static const char *extract_ssl_cipher(request_rec *r, char *a) } #if defined(WITH_APACHE20) -static int pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) +static int post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) #elif defined(WITH_APACHE13) static void module_init(server_rec *s, apr_pool_t *p) #endif { - log_sql_register_item(p,'q', extract_ssl_keysize, "ssl_keysize", 0, 1); - log_sql_register_item(p,'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1); - log_sql_register_item(p,'z', extract_ssl_cipher, "ssl_cipher", 0, 1); + log_sql_register_item(s,p,'q', extract_ssl_keysize, "ssl_keysize", 0, 1); + log_sql_register_item(s,p,'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1); + log_sql_register_item(s,p,'z', extract_ssl_cipher, "ssl_cipher", 0, 1); +#if defined(WITH_APACHE20) + return OK; +#endif } /* The configuration array that sets up the hooks into the module. */ #if defined(WITH_APACHE20) static void register_hooks(apr_pool_t *p) { - ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST); + ap_hook_post_config(post_config, NULL, NULL, APR_HOOK_REALLY_FIRST); } -module AP_MODULE_DECLARE_DATA log_sql_module = { +module AP_MODULE_DECLARE_DATA log_sql_ssl_module = { STANDARD20_MODULE_STUFF, NULL, /* create per-directory config structures */ NULL, /* merge per-directory config structures */ @@ -127,7 +119,7 @@ module log_sql_ssl_module = { NULL, /* merge per-dir config */ NULL, /* create server config */ NULL, /* merge server config */ - log_sql_cmds, /* config directive table */ + NULL, /* config directive table */ NULL, /* [9] content handlers */ NULL, /* [2] URI-to-filename translation */ NULL, /* [5] check/validate user_id */ @@ -135,11 +127,11 @@ module log_sql_ssl_module = { NULL, /* [4] check access by host */ NULL, /* [7] MIME type checker/setter */ NULL, /* [8] fixups */ - log_sql_transaction, /* [10] logger */ + NULL, /* [10] logger */ NULL /* [3] header parser */ #if MODULE_MAGIC_NUMBER >= 19970728 /* 1.3-dev or later support these additionals... */ - ,log_sql_child_init, /* child process initializer */ - log_sql_child_exit, /* process exit/cleanup */ + ,NULL, /* child process initializer */ + NULL, /* process exit/cleanup */ NULL /* [1] post read-request */ #endif -- cgit