From ccd1b379bfc208c34ad61fc42cac4a797af6d153 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Tue, 20 Jan 2004 19:38:08 +0000 Subject: moved extract_* functions to functions.h (version specific in functions(13|20).h) moves SSL logging routings to mod_log_sql_ssl.c updated changelog added AUTHORS --- AUTHORS | 5 + CHANGELOG | 3 +- apache13.h | 1 + apache20.h | 1 + functions.h | 337 ++++++++++++++++++++++++++++++++++++++++++ functions13.h | 1 + functions20.h | 1 + mod_log_sql.c | 428 +----------------------------------------------------- mod_log_sql_ssl.c | 100 +++++++++++++ 9 files changed, 453 insertions(+), 424 deletions(-) create mode 100644 AUTHORS create mode 100644 functions.h create mode 100644 mod_log_sql_ssl.c diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..b6969e7 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,5 @@ +Christopher B. Powell + Main author + +Edward Rudd + Apache 2.0 port. diff --git a/CHANGELOG b/CHANGELOG index ffb512a..5b30bcb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -$Id: CHANGELOG,v 1.6 2004/01/20 16:27:34 urkle Exp $ +$Id: CHANGELOG,v 1.7 2004/01/20 19:38:07 urkle Exp $ TODO: * Port connection portion to other DBMS? Genericize the module? Start with @@ -28,6 +28,7 @@ CHANGES: * updated configure m4 scripts to detect both apache versions at the same time and assign defines as to which version was found. * made install default to not activate module in configuration files. + (use make activate) 1.92: 2004-01-05 * fixed compilation issue with mysql 4.x where mysql_error returns const char * diff --git a/apache13.h b/apache13.h index 3b37986..25b8f44 100644 --- a/apache13.h +++ b/apache13.h @@ -1,3 +1,4 @@ +/* $Header: /home/cvs/mod_log_sql/apache13.h,v 1.2 2004/01/20 19:38:07 urkle Exp $ */ #ifndef APACHE13_H #define APACHE13_H diff --git a/apache20.h b/apache20.h index fd111d3..8a34643 100644 --- a/apache20.h +++ b/apache20.h @@ -1,3 +1,4 @@ +/* $Header: /home/cvs/mod_log_sql/apache20.h,v 1.2 2004/01/20 19:38:07 urkle Exp $ */ #ifndef APACHE20_H #define APACHE20_H diff --git a/functions.h b/functions.h new file mode 100644 index 0000000..60d08b5 --- /dev/null +++ b/functions.h @@ -0,0 +1,337 @@ +/* $Header: /home/cvs/mod_log_sql/functions.h,v 1.1 2004/01/20 19:38:08 urkle Exp $ */ +/* Begin the individual functions that, given a request r, + * extract the needed information from it and return the + * value to the calling entity. + */ + +static const char *extract_remote_host(request_rec *r, char *a) +{ + return (char *) ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL); +} + +static const char *extract_remote_logname(request_rec *r, char *a) +{ + return (char *) ap_get_remote_logname(r); +} + +static const char *extract_remote_user(request_rec *r, char *a) +{ + #ifdef WITH_APACHE13 + char *rvalue = r->connection->user; + #else + char *rvalue = r->user; + #endif + if (rvalue == NULL) { + rvalue = "-"; + } else if (strlen(rvalue) == 0) { + rvalue = "\"\""; + } + return rvalue; +} + +static const char *extract_request_method(request_rec *r, char *a) +{ + return r->method; +} + +static const char *extract_request_protocol(request_rec *r, char *a) +{ + return r->protocol; +} + +static const char *extract_request_line(request_rec *r, char *a) +{ + return r->the_request; +} + +static const char *extract_request_file(request_rec *r, char *a) +{ + return r->filename; +} + +static const char *extract_request_uri(request_rec *r, char *a) +{ + return r->uri; +} + +static const char *extract_request_args(request_rec *r, char *a) +{ + return r->args; +} + +static const char *extract_status(request_rec *r, char *a) +{ + if (r->status <= 0) { + return "-"; + } else { + return apr_psprintf(r->pool, "%d", r->status); + } +} + +static const char *extract_bytes_sent(request_rec *r, char *a) +{ + if (!r->sent_bodyct || !r->bytes_sent) { + return "-"; + } else { + return apr_psprintf(r->pool, "%" APR_OFF_T_FMT, r->bytes_sent); + } +} + +/* +static const char *extract_header_in(request_rec *r, char *a) +{ + return table_get(r->headers_in, a); +} + +static const char *extract_header_out(request_rec *r, char *a) +{ + const char *cp = table_get(r->headers_out, a); + if (!strcasecmp(a, "Content-type") && r->content_type) { + cp = r->content_type; + } + if (cp) { + return cp; + } + return table_get(r->err_headers_out, a); +} +*/ + +static const char *extract_virtual_host(request_rec *r, char *a) +{ + return apr_pstrdup(r->pool, r->server->server_hostname); +} + +static const char *extract_machine_id(request_rec *r, char *a) +{ + if (!global_config.machid) + return "-"; + else + return global_config.machid; +} + +static const char *extract_server_port(request_rec *r, char *a) +{ + return apr_psprintf(r->pool, "%u", + r->server->port ? r->server->port : ap_default_port(r)); +} + +static const char *extract_child_pid(request_rec *r, char *a) +{ + if (*a == '\0' || !strcmp(a, "pid")) { + return apr_psprintf(r->pool, "%" APR_PID_T_FMT, getpid()); + } + else if (!strcmp(a, "tid")) { +#if APR_HAS_THREADS + apr_os_thread_t tid = apr_os_thread_current(); +#else + int tid = 0; /* APR will format "0" anyway but an arg is needed */ +#endif + return apr_psprintf(r->pool, "%pT", &tid); + } + /* bogus format */ + return a; +} + +static const char *extract_referer(request_rec *r, char *a) +{ + const char *tempref; + + tempref = apr_table_get(r->headers_in, "Referer"); + if (!tempref) + { + return "-"; + } else { + return tempref; + } +} + +static const char *extract_agent(request_rec *r, char *a) +{ + const char *tempag; + + tempag = apr_table_get(r->headers_in, "User-Agent"); + if (!tempag) + { + return "-"; + } else { + return tempag; + } +} + +static const char *extract_cookie(request_rec *r, char *a) +{ + const char *cookiestr; + char *cookieend; + char *isvalid; + char *cookiebuf; + + logsql_state *cls = ap_get_module_config(r->server->module_config, + &log_sql_module); + + if (cls->cookie_name != NULL) { + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG, r->server, + "watching for cookie '%s'", cls->cookie_name); + #endif + + /* Fetch out the cookie header */ + cookiestr = (char *)apr_table_get(r->headers_in, "cookie2"); + if (cookiestr != NULL) { + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG, r->server, + "Cookie2: [%s]", cookiestr); + #endif + /* Does the cookie string contain one with our name? */ + isvalid = strstr(cookiestr, cls->cookie_name); + if (isvalid != NULL) { + /* Move past the cookie name and equal sign */ + isvalid += strlen(cls->cookie_name) + 1; + /* Duplicate it into the pool */ + cookiebuf = apr_pstrdup(r->pool, isvalid); + /* Segregate just this cookie out of the string + * with a terminating nul at the first semicolon */ + cookieend = strchr(cookiebuf, ';'); + if (cookieend != NULL) + *cookieend = '\0'; + return cookiebuf; + } + } + + cookiestr = (char *)apr_table_get(r->headers_in, "cookie"); + if (cookiestr != NULL) { + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG,r->server, + "Cookie: [%s]", cookiestr); + #endif + isvalid = strstr(cookiestr, cls->cookie_name); + if (isvalid != NULL) { + isvalid += strlen(cls->cookie_name) + 1; + cookiebuf = apr_pstrdup(r->pool, isvalid); + cookieend = strchr(cookiebuf, ';'); + if (cookieend != NULL) + *cookieend = '\0'; + return cookiebuf; + } + } + + cookiestr = apr_table_get(r->headers_out, "set-cookie"); + if (cookiestr != NULL) { + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG,r->server, + "Set-Cookie: [%s]", cookiestr); + #endif + isvalid = strstr(cookiestr, cls->cookie_name); + if (isvalid != NULL) { + isvalid += strlen(cls->cookie_name) + 1; + cookiebuf = apr_pstrdup(r->pool, isvalid); + cookieend = strchr(cookiebuf, ';'); + if (cookieend != NULL) + *cookieend = '\0'; + return cookiebuf; + } + } + } + + return "-"; +} + +static const char *extract_specific_cookie(request_rec *r, char *a) +{ + const char *cookiestr; + char *cookieend; + char *isvalid; + char *cookiebuf; + + if (a != NULL) { + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG, + r->server,"watching for cookie '%s'", a); + #endif + + /* Fetch out the cookie header */ + cookiestr = (char *)apr_table_get(r->headers_in, "cookie2"); + if (cookiestr != NULL) { + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG,r->server, + "Cookie2: [%s]", cookiestr); + #endif + /* Does the cookie string contain one with our name? */ + isvalid = strstr(cookiestr, a); + if (isvalid != NULL) { + /* Move past the cookie name and equal sign */ + isvalid += strlen(a) + 1; + /* Duplicate it into the pool */ + cookiebuf = apr_pstrdup(r->pool, isvalid); + /* Segregate just this cookie out of the string + * with a terminating nul at the first semicolon */ + cookieend = strchr(cookiebuf, ';'); + if (cookieend != NULL) + *cookieend = '\0'; + return cookiebuf; + } + } + + cookiestr = (char *)apr_table_get(r->headers_in, "cookie"); + if (cookiestr != NULL) { + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG,r->server, + "Cookie: [%s]", cookiestr); + #endif + isvalid = strstr(cookiestr, a); + if (isvalid != NULL) { + isvalid += strlen(a) + 1; + cookiebuf = apr_pstrdup(r->pool, isvalid); + cookieend = strchr(cookiebuf, ';'); + if (cookieend != NULL) + *cookieend = '\0'; + return cookiebuf; + } + } + + cookiestr = apr_table_get(r->headers_out, "set-cookie"); + if (cookiestr != NULL) { + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG,r->server, + "Set-Cookie: [%s]", cookiestr); + #endif + isvalid = strstr(cookiestr, a); + if (isvalid != NULL) { + isvalid += strlen(a) + 1; + cookiebuf = apr_pstrdup(r->pool, isvalid); + cookieend = strchr(cookiebuf, ';'); + if (cookieend != NULL) + *cookieend = '\0'; + return cookiebuf; + } + } + } + + return "-"; +} + + +/* +static const char *extract_note(request_rec *r, char *a) +{ + return apr_table_get(r->notes, a); + +} +*/ + +static const char *extract_env_var(request_rec *r, char *a) +{ + return apr_table_get(r->subprocess_env, a); +} + +static const char *extract_unique_id(request_rec *r, char *a) +{ + const char *tempid; + + tempid = apr_table_get(r->subprocess_env, "UNIQUE_ID"); + if (!tempid) + return "-"; + else + return tempid; +} + +/* End declarations of various extract_ functions */ diff --git a/functions13.h b/functions13.h index bff37f2..1b85d0e 100644 --- a/functions13.h +++ b/functions13.h @@ -1,3 +1,4 @@ +/* $Header: /home/cvs/mod_log_sql/functions13.h,v 1.2 2004/01/20 19:38:08 urkle Exp $ */ static const char *extract_request_time(request_rec *r, char *a) { int timz; diff --git a/functions20.h b/functions20.h index 9ff3a63..c8701a2 100644 --- a/functions20.h +++ b/functions20.h @@ -1,3 +1,4 @@ +/* $Header: /home/cvs/mod_log_sql/functions20.h,v 1.2 2004/01/20 19:38:08 urkle Exp $ */ /* functions */ static const char *extract_request_time_custom(request_rec *r, char *a, apr_time_exp_t *xt) diff --git a/mod_log_sql.c b/mod_log_sql.c index 02d5fd4..1ce4a44 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.7 2004/01/20 16:27:34 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.8 2004/01/20 19:38:08 urkle Exp $ */ /* --------* * DEFINES * * --------*/ @@ -44,11 +44,6 @@ #endif -#ifdef WANT_SSL_LOGGING -#include "mod_ssl.h" -#endif - - /* Configuratino Defaults */ #define DEFAULT_TRANSFER_LOG_FMT "AbHhmRSsTUuv" #define DEFAULT_NOTES_TABLE_NAME "notes" @@ -121,420 +116,13 @@ typedef struct { static int safe_create_tables(logsql_state *cls, request_rec *r); -static char *format_integer(apr_pool_t *p, int i) -{ - char dummy[40]; - apr_snprintf(dummy, sizeof(dummy), "%d", i); - return apr_pstrdup(p, dummy); -} - -static char *pfmt(apr_pool_t *p, int i) -{ - if (i <= 0) { - return "-"; - } else { - return format_integer(p, i); - } -} - -/* Begin the individual functions that, given a request r, - * extract the needed information from it and return the - * value to the calling entity. - */ - -static const char *extract_remote_host(request_rec *r, char *a) -{ - return (char *) ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL); -} - -static const char *extract_remote_logname(request_rec *r, char *a) -{ - return (char *) ap_get_remote_logname(r); -} - -static const char *extract_remote_user(request_rec *r, char *a) -{ - #ifdef WITH_APACHE13 - char *rvalue = r->connection->user; - #else - char *rvalue = r->user; - #endif - if (rvalue == NULL) { - rvalue = "-"; - } else if (strlen(rvalue) == 0) { - rvalue = "\"\""; - } - return rvalue; -} - -#ifdef WANT_SSL_LOGGING -static const char *extract_ssl_keysize(request_rec *r, char *a) -{ - char *result = NULL; - SSLConnRec *scc = myConnConfig(r->connection); - SSLSrvConfigRec *ssc = mySrvConfig(r->server); - - if (myCtxConfig(scc,ssc) != NULL) { - result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_USEKEYSIZE"); - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"SSL_KEYSIZE: %s", result); - #endif - if (result != NULL && result[0] == '\0') - result = NULL; - return result; - } else { - return "0"; - } -} - -static const char *extract_ssl_maxkeysize(request_rec *r, char *a) -{ - char *result = NULL; - SSLConnRec *scc = myConnConfig(r->connection); - SSLSrvConfigRec *ssc = mySrvConfig(r->server); - - if (myCtxConfig(scc,ssc) != NULL) { - result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_ALGKEYSIZE"); - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"SSL_ALGKEYSIZE: %s", result); - #endif - if (result != NULL && result[0] == '\0') - result = NULL; - return result; - } else { - return "0"; - } -} - -static const char *extract_ssl_cipher(request_rec *r, char *a) -{ - char *result = NULL; - SSLConnRec *scc = myConnConfig(r->connection); - SSLSrvConfigRec *ssc = mySrvConfig(r->server); - - if (myCtxConfig(scc,ssc) != NULL) { - result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER"); - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"SSL_CIPHER: %s", result); - #endif - if (result != NULL && result[0] == '\0') - result = NULL; - return result; - } else { - return "-"; - } -} -#endif /* WANT_SSL_LOGGING */ - -static const char *extract_request_method(request_rec *r, char *a) -{ - return r->method; -} - -static const char *extract_request_protocol(request_rec *r, char *a) -{ - return r->protocol; -} - -static const char *extract_request_line(request_rec *r, char *a) -{ - return r->the_request; -} - -static const char *extract_request_file(request_rec *r, char *a) -{ - return r->filename; -} - -static const char *extract_request_uri(request_rec *r, char *a) -{ - return r->uri; -} - -static const char *extract_request_args(request_rec *r, char *a) -{ - return r->args; -} - -static const char *extract_status(request_rec *r, char *a) -{ - return pfmt(r->pool, r->status); -} - -static const char *extract_bytes_sent(request_rec *r, char *a) -{ - if (!r->sent_bodyct || !r->bytes_sent) { - return "-"; - } else { - return apr_psprintf(r->pool, "%" APR_OFF_T_FMT, r->bytes_sent); - } -} - -/* -static const char *extract_header_in(request_rec *r, char *a) -{ - return table_get(r->headers_in, a); -} - -static const char *extract_header_out(request_rec *r, char *a) -{ - const char *cp = table_get(r->headers_out, a); - if (!strcasecmp(a, "Content-type") && r->content_type) { - cp = r->content_type; - } - if (cp) { - return cp; - } - return table_get(r->err_headers_out, a); -} -*/ - +/* Include all the extract functions */ +#include "functions.h" #if defined(WITH_APACHE13) -#include "functions13.h" +# include "functions13.h" #elif defined(WITH_APACHE20) -#include "functions20.h" +# include "functions20.h" #endif -static const char *extract_virtual_host(request_rec *r, char *a) -{ - return apr_pstrdup(r->pool, r->server->server_hostname); -} - -static const char *extract_machine_id(request_rec *r, char *a) -{ - if (!global_config.machid) - return "-"; - else - return global_config.machid; -} - -static const char *extract_server_port(request_rec *r, char *a) -{ - return apr_psprintf(r->pool, "%u", - r->server->port ? r->server->port : ap_default_port(r)); -} - -static const char *extract_child_pid(request_rec *r, char *a) -{ - if (*a == '\0' || !strcmp(a, "pid")) { - return apr_psprintf(r->pool, "%" APR_PID_T_FMT, getpid()); - } - else if (!strcmp(a, "tid")) { -#if APR_HAS_THREADS - apr_os_thread_t tid = apr_os_thread_current(); -#else - int tid = 0; /* APR will format "0" anyway but an arg is needed */ -#endif - return apr_psprintf(r->pool, "%pT", &tid); - } - /* bogus format */ - return a; -} - -static const char *extract_referer(request_rec *r, char *a) -{ - const char *tempref; - - tempref = apr_table_get(r->headers_in, "Referer"); - if (!tempref) - { - return "-"; - } else { - return tempref; - } -} - -static const char *extract_agent(request_rec *r, char *a) -{ - const char *tempag; - - tempag = apr_table_get(r->headers_in, "User-Agent"); - if (!tempag) - { - return "-"; - } else { - return tempag; - } -} - -static const char *extract_cookie(request_rec *r, char *a) -{ - const char *cookiestr; - char *cookieend; - char *isvalid; - char *cookiebuf; - - logsql_state *cls = ap_get_module_config(r->server->module_config, - &log_sql_module); - - if (cls->cookie_name != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG, r->server, - "watching for cookie '%s'", cls->cookie_name); - #endif - - /* Fetch out the cookie header */ - cookiestr = (char *)apr_table_get(r->headers_in, "cookie2"); - if (cookiestr != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG, r->server, - "Cookie2: [%s]", cookiestr); - #endif - /* Does the cookie string contain one with our name? */ - isvalid = strstr(cookiestr, cls->cookie_name); - if (isvalid != NULL) { - /* Move past the cookie name and equal sign */ - isvalid += strlen(cls->cookie_name) + 1; - /* Duplicate it into the pool */ - cookiebuf = apr_pstrdup(r->pool, isvalid); - /* Segregate just this cookie out of the string - * with a terminating nul at the first semicolon */ - cookieend = strchr(cookiebuf, ';'); - if (cookieend != NULL) - *cookieend = '\0'; - return cookiebuf; - } - } - - cookiestr = (char *)apr_table_get(r->headers_in, "cookie"); - if (cookiestr != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,r->server, - "Cookie: [%s]", cookiestr); - #endif - isvalid = strstr(cookiestr, cls->cookie_name); - if (isvalid != NULL) { - isvalid += strlen(cls->cookie_name) + 1; - cookiebuf = apr_pstrdup(r->pool, isvalid); - cookieend = strchr(cookiebuf, ';'); - if (cookieend != NULL) - *cookieend = '\0'; - return cookiebuf; - } - } - - cookiestr = apr_table_get(r->headers_out, "set-cookie"); - if (cookiestr != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,r->server, - "Set-Cookie: [%s]", cookiestr); - #endif - isvalid = strstr(cookiestr, cls->cookie_name); - if (isvalid != NULL) { - isvalid += strlen(cls->cookie_name) + 1; - cookiebuf = apr_pstrdup(r->pool, isvalid); - cookieend = strchr(cookiebuf, ';'); - if (cookieend != NULL) - *cookieend = '\0'; - return cookiebuf; - } - } - } - - return "-"; -} - -static const char *extract_specific_cookie(request_rec *r, char *a) -{ - const char *cookiestr; - char *cookieend; - char *isvalid; - char *cookiebuf; - - if (a != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG, - r->server,"watching for cookie '%s'", a); - #endif - - /* Fetch out the cookie header */ - cookiestr = (char *)apr_table_get(r->headers_in, "cookie2"); - if (cookiestr != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,r->server, - "Cookie2: [%s]", cookiestr); - #endif - /* Does the cookie string contain one with our name? */ - isvalid = strstr(cookiestr, a); - if (isvalid != NULL) { - /* Move past the cookie name and equal sign */ - isvalid += strlen(a) + 1; - /* Duplicate it into the pool */ - cookiebuf = apr_pstrdup(r->pool, isvalid); - /* Segregate just this cookie out of the string - * with a terminating nul at the first semicolon */ - cookieend = strchr(cookiebuf, ';'); - if (cookieend != NULL) - *cookieend = '\0'; - return cookiebuf; - } - } - - cookiestr = (char *)apr_table_get(r->headers_in, "cookie"); - if (cookiestr != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,r->server, - "Cookie: [%s]", cookiestr); - #endif - isvalid = strstr(cookiestr, a); - if (isvalid != NULL) { - isvalid += strlen(a) + 1; - cookiebuf = apr_pstrdup(r->pool, isvalid); - cookieend = strchr(cookiebuf, ';'); - if (cookieend != NULL) - *cookieend = '\0'; - return cookiebuf; - } - } - - cookiestr = apr_table_get(r->headers_out, "set-cookie"); - if (cookiestr != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,r->server, - "Set-Cookie: [%s]", cookiestr); - #endif - isvalid = strstr(cookiestr, a); - if (isvalid != NULL) { - isvalid += strlen(a) + 1; - cookiebuf = apr_pstrdup(r->pool, isvalid); - cookieend = strchr(cookiebuf, ';'); - if (cookieend != NULL) - *cookieend = '\0'; - return cookiebuf; - } - } - } - - return "-"; -} - - -/* -static const char *extract_note(request_rec *r, char *a) -{ - return apr_table_get(r->notes, a); - -} -*/ - -static const char *extract_env_var(request_rec *r, char *a) -{ - return apr_table_get(r->subprocess_env, a); -} - -static const char *extract_unique_id(request_rec *r, char *a) -{ - const char *tempid; - - tempid = apr_table_get(r->subprocess_env, "UNIQUE_ID"); - if (!tempid) - return "-"; - else - return tempid; -} - -/* End declarations of various extract_ functions */ - - struct log_sql_item_list { char ch; /* its letter code */ @@ -567,15 +155,9 @@ struct log_sql_item_list { { 'u', extract_remote_user, "remote_user", 0, 1 }, { 'U', extract_request_uri, "request_uri", 1, 1 }, { 'v', extract_virtual_host, "virtual_host", 0, 1 }, - #ifdef WANT_SSL_LOGGING - { 'q', extract_ssl_keysize, "ssl_keysize", 0, 1 }, - { 'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1 }, - { 'z', extract_ssl_cipher, "ssl_cipher", 0, 1 }, - #endif {'\0'} }; - /* Routine to escape the 'dangerous' characters that would otherwise * corrupt the INSERT string: ', \, and " */ diff --git a/mod_log_sql_ssl.c b/mod_log_sql_ssl.c new file mode 100644 index 0000000..3346d2f --- /dev/null +++ b/mod_log_sql_ssl.c @@ -0,0 +1,100 @@ +/* $Header: /home/cvs/mod_log_sql/mod_log_sql_ssl.c,v 1.1 2004/01/20 19:38:08 urkle Exp $ */ +/* mod_log_sql_ssl */ + +#if defined(WITH_APACHE20) +# include "apache20.h" +#elif defined(WITH_APACHE13) +# include "apache13.h" +#else +# error Unsupported Apache version +#endif + +#ifdef HAVE_CONFIG_H +/* Undefine these to prevent conflicts between Apache ap_config_auto.h and + * my config.h. Only really needed for Apache < 2.0.48, but it can't hurt. + */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include "config.h" +#endif + +#include "mod_ssl.h" + +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 + { + result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_USEKEYSIZE"); + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"SSL_KEYSIZE: %s", result); + #endif + if (result != NULL && result[0] == '\0') + result = NULL; + return result; + } else { + return "0"; + } +} + +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 + { + result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_ALGKEYSIZE"); + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"SSL_ALGKEYSIZE: %s", result); + #endif + if (result != NULL && result[0] == '\0') + result = NULL; + return result; + } else { + return "0"; + } +} + +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 + { + result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER"); + #ifdef DEBUG + log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"SSL_CIPHER: %s", result); + #endif + if (result != NULL && result[0] == '\0') + result = NULL; + return result; + } else { + return "-"; + } +} + +#ifdef WANT_SSL_LOGGING + { 'q', extract_ssl_keysize, "ssl_keysize", 0, 1 }, + { 'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1 }, + { 'z', extract_ssl_cipher, "ssl_cipher", 0, 1 }, +#endif -- cgit