From 6eff371018e78925510ff71cb255a64a441a9fc8 Mon Sep 17 00:00:00 2001 From: Christopher Powell Date: Mon, 3 Dec 2001 19:54:02 +0000 Subject: Big changes including reworked cookie code, new directives, SSL logging, new formatting characters, bugfixes, etc. --- CHANGELOG | 59 +++++++++++- INSTALL | 88 ++++++++++++++---- Makefile | 40 ++++++-- README | 23 ++++- access_log.sql | 24 +++-- make_combined_log.pl | 12 +-- mod_log_sql.c | 258 +++++++++++++++++++++++++++++++++++++-------------- 7 files changed, 385 insertions(+), 119 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9f2295b..64422e0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,16 +1,69 @@ -$Id: CHANGELOG,v 1.2 2001/11/30 08:29:04 helios Stab $ +$Id: CHANGELOG,v 1.3 2001/12/03 19:54:02 helios Exp $ TODO: * Full commenting of the code. -* Bounds checking on all data prior to INSERT +* Rethink documentation flow and rewrite? CHANGES: +1.11: + +* Completely re-worked the cookie code. Now the user can instruct + mod_log_mysql which cookie (out of many available) to log. (See + the online directives documentation and FAQ.) +* New config capability: 'H' to log the request protocol + (e.g. HTTP/1.1) +* New config capability: 'm' to log the request method + (e.g. GET, PUT, etc.) +* New config capabilities: 'z' 'q' & 'Q' to log SSL_CIPHER, + SSL_CIPHER_USEKEYSIZE and SSL_CIPHER_ALGKEYSIZE. These require + openssl and glibc-devel to be installed. (See the online + directives documentation and FAQ.) +* Fixed a bug in make_combined_log.pl that caused it to generate + incorrect output on single-digit days. +* Fixed make_combined_log.pl to use the data logged by 'H' and 'm'. +* Migrated all log_error calls to the newer ap_log_error call. +* Added a DEBUG define to activate certain debugging/informational + error-log messages (for devel purposes). +* I apologize for the inconvenience this may cause: I decided to + rename the runtime configuration directives so that they would + make more sense and group together with a "MySQL" prefix. They + are now: + MySQLRefererLogTable + The MySQL table that holds the referer log + MySQLAgentLogTable + The MySQL table that holds the agent log + MySQLTransferLogTable + The MySQL table that holds the transfer log + MySQLTransferLogFormat + Instruct the module what information to log to the MySQL transfer log + MySQLRefererIgnore + List of referers to ignore, accesses that match will not be logged to MySQL + MySQLRequestIgnore + List of URIs to ignore, accesses that match will not be logged to MySQL + MySQLRemhostIgnore + List of remote hosts to ignore, accesses that match will not be logged to MySQL + MySQLDatabase + The name of the MySQL database for logging + MySQLWhichCookie + The CookieName that you want logged when using the 'c' config directive + MySQLLoginInfo + The MySQL host, user-id and password for logging + You'll need to just do a search-and-replace in your httpd.conf... + Again, I'm sorry, but it really is better this way. +* Cleaned up the summaries that get output on "httpd -L" +* Expanded the enclosed access_log.sql file to support every column type + that mod_log_mysql provides -- delete the ones that you don't need. +* Some cleanup of the Makefile - pay attention to the settings +* Made the MySQLTransferLogFormat default "AbHhmRSsTUuv" to incorporate the + new column types and sort the characters alphabetically for reading ease. + + 1.10: -* New capability: log mod_usertrack cookies. +* New config directive/capability: 'c' to log mod_usertrack cookies. * Some code cleanup and commenting. * Referer and User-Agent now set to want_orig=1 ( a very minor detail ) * Corrected mysql_escape_log to properly check for and escape strings diff --git a/INSTALL b/INSTALL index 0229879..4963123 100644 --- a/INSTALL +++ b/INSTALL @@ -1,30 +1,68 @@ -$Id: INSTALL,v 1.1 2001/11/28 05:26:54 helios Exp $ +$Id: INSTALL,v 1.2 2001/12/03 19:54:02 helios Exp $ Requirements ============ -0) I run a Red Hat 6.2 system, but these instructions should easily - adapt to any modern distro. +* I run a Red Hat 6.2 system, but these instructions should easily + adapt to any modern distro. -1) Apache 1.2.x or higher installed. (I run 1.3.22 and it works fine). - You should have already successfully compiled Apache and know what - you're doing there. In fact, you should already have any other - modules and add-ons like mod_ssl or PHP configured and installed - before you start this process. +* Apache 1.2.x or higher installed. (I run 1.3.22 and it works fine). + You should have already successfully compiled Apache and know what + you're doing there. In fact, you should already have any other + modules and add-ons like mod_ssl or PHP configured and installed + before you start this process. -2) The MySQL development headers. (I run MySQL-devel-3.23.44-1.i386.rpm). +* The MySQL development headers. (I run MySQL-devel-3.23.44-1.i386.rpm). -3) MySQL configured, installed and running on either localhost or an - accessible networked machine. You should already have a basic - understanding of MySQL and how it functions. +* MySQL configured, installed and running on either localhost or an + accessible networked machine. You should already have a basic + understanding of MySQL and how it functions. -4) Again, basic administrative skills with Apache and MySQL. I try to - make things as easy as possible in this README, but its purpose is - not to be an administrative tutorial. +* Again, basic administrative skills with Apache and MySQL. I try to + make things as easy as possible in this README, but its purpose is + not to be an administrative tutorial. -Installation -============ +* Additionally, if you want to be able to log SSL information such as + keysize or cipher, you need OpenSSL and glibc-devel installed. Both + are available as RPMs. + + +Installation (as an Apache DSO) +=============================== + +For folks interested in using this module as an Apache DSO, these +instructions are currently UNTESTED but should work. (I would be +grateful to hear back from a DSO user as to my accuracy with these +instructions.) + +0) Perform all the following steps as root so that you have install + privs, etc. + +1) Unpack the archive into a working directory. + + # tar zxf mod_log_mysql.tar.gz -C /usr/local/src + # cd /usr/local/src/mod_log_mysql + +2) Instruct apxs to compile and install the module as a DSO. (My apxs is + in /usr/local/Apache/bin, perform a "locate" to find yours...) + + # /apxs -i -a -c mod_log_mysql.c + + You should see something like this: + + gcc -fpic -DSHARED_MODULE -I/usr/local/Apache/include -c mod_log_mysql.c + ld -Bshareable -o mod_log_mysql.so mod_log_mysql.o + cp mod_log_mysql.so /mod_log_mysql.so + chmod 755 /mod_log_mysql.so + [activating module foo' in /path/to/apache/etc/httpd.conf] + +3) Now go to step (9) in the instructions below to configure httpd.conf... + + +Installation (as a static module compiled into httpd) +===================================================== +[This is what I do, FYI.] 0) Perform all the following steps as root so that you have install privs, etc. @@ -117,6 +155,15 @@ Installation + 9a) For users who have a DSO-enabled httpd: + + If you you are building mod_log_mysql as a static module BUT + your httpd is enabled for DSOs, add the following line to your + httpd.conf: + + AddModule mod_log_mysql.c + + 10) Create a database and table to hold the new log data. I log the same data as the regular "combined log" plus a little extra information that can be useful. @@ -128,8 +175,11 @@ Installation # mysql -uadmin -pmypassword mysql> create database apache; - Then I created the table called "access_log". You should use the - enclosed SQL file to do this for you. + Then create the table called "access_log". I enclosed an SQL file + that will create every column type that mod_log_mysql supports. + Unless you're just testing or playing around, this is probably NOT + what you want, so edit the file first and delete the lines that + don't pertain to you. Then: mysql> source access_log.sql diff --git a/Makefile b/Makefile index cd349d0..88b7d89 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,49 @@ -# $Id: Makefile,v 1.1 2001/11/28 05:26:54 helios Exp $ +# $Id: Makefile,v 1.2 2001/12/03 19:54:02 helios Exp $ # Verify that this points to the right place... -APACHEDIR = /usr/local/src/apache_1.3.22/src +APACHEDIR = /usr/local/src/apache_1.3.22 + +# Use the first one if you want mod_log_mysql to be able to log +# SSL variables like keysize or cipher. Use the second one if +# you don't use SSL or don't care to log it. +DEFS = -DWANT_SSL_LOGGING +#DEFS = + +# Use this one if you do WANT_SSL_LOGGING, and confirm the last two paths. +# Make "/usr/local/ssl/include" point to where your openssl/*.h files are, +# and make "/usr/include/db1" point to where ndbm.h can be found. +# +# How to find your directories: +# +# $ locate http_core.h +# /usr/local/Apache/include/http_core.h +# +# $ locate x509.h +# /usr/local/ssl/include/openssl/x509.h +# +# $ locate ndbm.h +# /usr/include/db1/ndbm.h + +CFLAGS = -fpic -O2 -Wall -I/usr/local/Apache/include -I/usr/local/ssl/include -I/usr/include/db1 + +# Use this one if you don't WANT_SSL_LOGGING: + +#CFLAGS = -fpic -O2 -Wall -I/usr/local/Apache/include -# Verify that this include directory is correct for you... -CFLAGS = -fpic -O2 -Wall -I/usr/local/Apache/include # --------------------------------------------------------- -# You shouldn't have to touch below here! +# You shouldn't have to touch below here. CC = gcc -DEFS = -DSHARED_MODULE INSTALL = /usr/bin/install -m 664 all: mod_log_mysql.o -mod_log_mysql.o: mod_log_mysql.c +mod_log_mysql.o: mod_log_mysql.c Makefile $(CC) ${CFLAGS} ${DEFS} -c mod_log_mysql.c install: all - $(INSTALL) mod_log_mysql.o ${APACHEDIR}/mod_log_mysql.o + $(INSTALL) mod_log_mysql.o ${APACHEDIR}/src/mod_log_mysql.o distro: all cd ..; tar zcf mod_log_mysql.tar.gz mod_log_mysql/; $(INSTALL) mod_log_mysql.tar.gz /usr/local/Apache/html/mod_log_mysql/; rm -f mod_log_mysql.tar.gz diff --git a/README b/README index 23b8a91..9fee671 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -$Id: README,v 1.1 2001/11/28 05:26:54 helios Exp $ +$Id: README,v 1.2 2001/12/03 19:54:02 helios Exp $ Homepage @@ -51,8 +51,11 @@ Supported directives Please see the web-based documentation for full explanation of all supported run-time directives. -http://www.grubbybaby.com/mod_log_mysql/directives.html + http://www.grubbybaby.com/mod_log_mysql/directives.html +See the FAQ for some handy examples: + + http://www.grubbybaby.com/mod_log_mysql/faq.html What gets logged by default? @@ -64,7 +67,8 @@ accept this default and employ the enclosed access_log.sql to format your table. Customize your logging format after you've had a chance to experiment with the default first. -The MySQL table looks like this if you use the enclosed access_log.sql: +If you just want to log enough data to be able to reconstruct +a Combined Log Format log, log these: +------------------+------------------+ | Field | Type | @@ -72,13 +76,14 @@ The MySQL table looks like this if you use the enclosed access_log.sql: | remote_host | varchar(50) | | remote_user | varchar(50) | | request_uri | varchar(50) | -| request_duration | smallint(6) | | virtual_host | varchar(50) | | time_stamp | int(10) unsigned | | status | smallint(6) | | bytes_sent | int(11) | | referer | varchar(255) | | agent | varchar(255) | +| request_method | varchar(6) | +| request_protocol | varchar(10) | +------------------+------------------+ remote_host: corresponds to the Apache %h directive. Contains the remote @@ -129,7 +134,15 @@ agent: corresponds to the Apache "%{User-Agent}" directive. Contains the broswer type (user agent) of the software that made the request. Example: Mozilla/3.0 (Slurp/si; slurp@inktomi.com; http://www.inktomi.com/slurp.html) - +request_method: corresponds to the Apache %m directive. Contains the type + of request sent: GET, PUT, etc. + Example: GET + +request_protocol: corresponds to the Apache %H directive. Contains the HTTP + protocol that was used. + Example: HTTP/1.1 + + Notes ----- diff --git a/access_log.sql b/access_log.sql index c38cb50..46d5a6e 100644 --- a/access_log.sql +++ b/access_log.sql @@ -1,13 +1,25 @@ create table access_log ( + agent varchar(255) not null, + bytes_sent int not null, + child_pid smallint unsigned, + cookie varchar(255), + request_file varchar(255), + referer varchar(255) not null, remote_host varchar(50) not null, + remote_logname varchar(50) not null, remote_user varchar(50) not null, - request_uri varchar(50) not null, request_duration smallint not null, - virtual_host varchar(50) not null, - time_stamp int unsigned not null, + request_line varchar(255), + request_method not null, + request_protocol not null, + request_time char(28), + request_uri varchar(50) not null, + server_port smallint unsigned, + ssl_cipher varchar(25), + ssl_keysize smallint + ssl_maxkeysize smallint, status smallint not null, - bytes_sent int not null, - referer varchar(255) not null, - agent varchar(255) not null + time_stamp int unsigned not null, + virtual_host varchar(50) not null, ) diff --git a/make_combined_log.pl b/make_combined_log.pl index d375f3a..009db42 100755 --- a/make_combined_log.pl +++ b/make_combined_log.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: make_combined_log.pl,v 1.1 2001/11/28 05:26:54 helios Exp $ +# $Id: make_combined_log.pl,v 1.2 2001/12/03 19:54:02 helios Exp $ # # make_combined_log.pl # @@ -45,7 +45,7 @@ $virthost = $ARGV[1]; # # Set up the proper variables to permit database access # -$serverName = "your.dbmachine.com"; +$serverName = "your.dbhost.com"; $serverPort = "3306"; $serverUser = "someuser"; $serverPass = "somepass"; @@ -57,8 +57,6 @@ $serverDb = "apache"; # $st_tz = "-0800"; $dt_tz = "-0700"; -$type = "GET"; -$http = "HTTP/1.1"; $now = time(); $start = $now - (86400 * $days); @@ -71,7 +69,7 @@ if (not $dbh) { die "Unable to connect to the database. Please check your connection variables. (Bad password? Incorrect perms?)"; } -$records = $dbh->prepare("select remote_host,remote_user,request_uri,request_duration,time_stamp,status,bytes_sent,referer,agent from $serverTbl where virtual_host='$virthost' and time_stamp >= $start"); +$records = $dbh->prepare("select remote_host,remote_user,request_uri,time_stamp,status,bytes_sent,referer,agent,request_method,request_protocol from $serverTbl where virtual_host='$virthost' and time_stamp >= $start"); $records->execute; if (not $records) { die "No such table or the select returned no records." @@ -94,7 +92,7 @@ while (@data = $records->fetchrow_array) { $year=$year+1900; # Create format for leading-zero formatting - if ($day < 10) { $day = "0$day"; } + if ($mday < 10) { $mday = "0$mday"; } if ($month < 10) { $month = "0$month"; } if ($hour < 10) { $hour = "0$hour"; } if ($min < 10) { $min = "0$min"; } @@ -123,7 +121,7 @@ while (@data = $records->fetchrow_array) { } else { print "$st_tz\] "; } - print "\"$type $data[2] $http\" $data[5] $data[6] \"$data[7]\" \"$data[8]\"\n"; + print "\"$data[9] $data[2] $data[10]\" $data[5] $data[6] \"$data[7]\" \"$data[8]\"\n"; } # diff --git a/mod_log_sql.c b/mod_log_sql.c index 0739372..5bb992b 100644 --- a/mod_log_sql.c +++ b/mod_log_sql.c @@ -1,4 +1,4 @@ -/* $Id: mod_log_sql.c,v 1.2 2001/11/30 08:29:04 helios Stab $ +/* $Id: mod_log_sql.c,v 1.3 2001/12/03 19:54:02 helios Exp $ * * mod_log_mysql.c * Release v 1.10 @@ -71,22 +71,41 @@ */ +/* DEFINES */ +#define MYSQL_ERROR(mysql) ((mysql)?(mysql_error(mysql)):"MySQL server has gone away") + +#define ERRLEVEL APLOG_ERR|APLOG_NOERRNO + +#undef DEBUG +#ifdef DEBUG + #define DEBUGLEVEL APLOG_INFO|APLOG_NOERRNO +#endif + + + +/* INCLUDES */ #include #include +#include #include "httpd.h" #include "http_config.h" #include "http_log.h" #include "http_core.h" #if MODULE_MAGIC_NUMBER >= 19980324 - #include "ap_compat.h" + #include "ap_compat.h" #endif +#ifdef WANT_SSL_LOGGING + #include "/usr/local/src/apache_1.3.22/src/modules/ssl/mod_ssl.h" +#endif + + + +/* DECLARATIONS */ module mysql_log_module; MYSQL log_sql_server, *mysql_log = NULL; -char *log_db_name = NULL, *db_host = NULL, *db_user = NULL, *db_pwd = NULL; - -#define MYSQL_ERROR(mysql) ((mysql)?(mysql_error(mysql)):"MySQL server has gone away") +char *log_db_name = NULL, *db_host = NULL, *db_user = NULL, *db_pwd = NULL, *cookie_name = NULL; typedef const char *(*item_key_func) (request_rec *, char *); typedef struct { @@ -97,8 +116,11 @@ typedef struct { char *transfer_log_format; } log_mysql_state; -/* Defined in /usr/local/Apache/include/ap_mmn.h, 19990320 as of this writing. */ -#if MODULE_MAGIC_NUMBER < 19970103 + + +#if MODULE_MAGIC_NUMBER < 19970103 /* Defined in /usr/local/Apache/include/ap_mmn.h, 19990320 as of this writing. */ +extern const char *log_request_protocol(request_rec *r, char *a); +extern const char *log_request_method(request_rec *r, char *a); extern const char *log_remote_host(request_rec *r, char *a); extern const char *log_remote_logname(request_rec *r, char *a); extern const char *log_remote_user(request_rec *r, char *a); @@ -118,6 +140,7 @@ extern const char *log_virtual_host(request_rec *r, char *a); extern const char *log_server_port(request_rec *r, char *a); extern const char *log_child_pid(request_rec *r, char *a); #else + static char *format_integer(pool *p, int i) { char dummy[40]; @@ -161,6 +184,69 @@ static const char *log_remote_user(request_rec *r, char *a) return rvalue; } +#ifdef WANT_SSL_LOGGING +static const char *log_ssl_keysize(request_rec *r, char *a) +{ + char *result = NULL; + + if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL) { + result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_USEKEYSIZE"); + #ifdef DEBUG + ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"mod_log_mysql: SSL_KEYSIZE: %s", result); + #endif + if (result != NULL && result[0] == '\0') + result = NULL; + return result; + } else { + return "0"; + } +} + +static const char *log_ssl_maxkeysize(request_rec *r, char *a) +{ + char *result = NULL; + + if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL) { + result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_ALGKEYSIZE"); + #ifdef DEBUG + ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"mod_log_mysql: SSL_ALGKEYSIZE: %s", result); + #endif + if (result != NULL && result[0] == '\0') + result = NULL; + return result; + } else { + return "0"; + } +} + +static const char *log_ssl_cipher(request_rec *r, char *a) +{ + char *result = NULL; + + if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL) { + result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER"); + #ifdef DEBUG + ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"mod_log_mysql: SSL_CIPHER: %s", result); + #endif + if (result != NULL && result[0] == '\0') + result = NULL; + return result; + } else { + return "0"; + } +} +#endif /* WANT_SSL_LOGGING */ + +static const char *log_request_method(request_rec *r, char *a) +{ + return r->method; +} + +static const char *log_request_protocol(request_rec *r, char *a) +{ + return r->protocol; +} + static const char *log_request_line(request_rec *r, char *a) { return r->the_request; @@ -292,49 +378,63 @@ static const char *log_cookie(request_rec *r, char *a) { const char *cookiestr; char *cookieend; + char *isvalid; + char *cookiebuf; - cookiestr = table_get(r->headers_in, "cookie"); - - /* First look for Cookie2: header */ - if ( (cookiestr = table_get(r->headers_in, "cookie2")) ) { - cookieend = strchr(cookiestr, ';'); - if (cookieend) - *cookieend = '\0'; /* Ignore anything after a ; */ - return cookiestr; + cookiestr = (char *)table_get(r->headers_in, "cookie2"); + if (cookiestr != NULL) { + #ifdef DEBUG + ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"mod_log_mysql: Cookie2: [%s]", cookiestr); + #endif + isvalid = strstr(cookiestr, cookie_name); + if (isvalid != NULL) { + isvalid += strlen(cookie_name) + 1; + cookiebuf = ap_pstrdup(r->pool, isvalid); + cookieend = strchr(cookiebuf, ';'); + if (cookieend != NULL) + *cookieend = '\0'; + return cookiebuf; + } } - /* Then try a Cookie: header */ - else if ( (cookiestr = table_get(r->headers_in, "cookie")) ) { - cookieend = strchr(cookiestr, ';'); - if (cookieend) - *cookieend = '\0'; - return cookiestr; + + cookiestr = (char *)table_get(r->headers_in, "cookie"); + if (cookiestr != NULL) { + #ifdef DEBUG + ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"mod_log_mysql: Cookie: [%s]", cookiestr); + #endif + isvalid = strstr(cookiestr, cookie_name); + if (isvalid != NULL) { + isvalid += strlen(cookie_name) + 1; + cookiebuf = ap_pstrdup(r->pool, isvalid); + cookieend = strchr(cookiebuf, ';'); + if (cookieend != NULL) + *cookieend = '\0'; + return cookiebuf; + } } - /* Still none? Use the Set-Cookie: header. I feel a little - * guilty about this, because some clients refuse cookies. The - * log will in their cases log a ton of different Set-Cookie requests - * that aren't being honored. However, it's necessary to insert this - * check so that the first request of a series doesn't log a - ... - */ - else if ( (cookiestr = table_get(r->headers_out, "set-cookie")) ) { - cookieend = strchr(cookiestr, ';'); - if (cookieend) - *cookieend = '\0'; - return cookiestr; - } - /* Okay, fine, no eligible headers. Return a - instead. - * I /could/ insert a look for the Set-Cookie2: header here, but I think - * it would be imprudent. It's apparent that the current browsers don't - * support Cookie2 cookies, so why bother logging a bunch of Set-Cookie2: - * requests that aren't even going to be honored? - */ - else { - return "-"; - } + cookiestr = table_get(r->headers_out, "set-cookie"); + if (cookiestr != NULL) { + #ifdef DEBUG + ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"mod_log_mysql: Set-Cookie: [%s]", cookiestr); + #endif + isvalid = strstr(cookiestr, cookie_name); + if (isvalid != NULL) { + isvalid += strlen(cookie_name) + 1; + cookiebuf = ap_pstrdup(r->pool, isvalid); + cookieend = strchr(cookiebuf, ';'); + if (cookieend != NULL) + *cookieend = '\0'; + return cookiebuf; + } + } + + return "-"; } - + + const char *log_request_timestamp(request_rec *r, char *a) { char tstr[32]; @@ -352,7 +452,7 @@ static const char *log_env_var(request_rec *r, char *a) { return table_get(r->subprocess_env, a); } -#endif +#endif /* MODULE_MAGIC_NUMBER */ /* End declarations of various log_ functions */ @@ -371,10 +471,12 @@ struct log_mysql_item_list { { 'c', log_cookie, "cookie", 0, 1 }, { 'e', log_env_var, "env_var", 0, 1 }, { 'f', log_request_file, "request_file", 0, 1 }, - { 'h', log_remote_host, "remote_host", 0, 1 }, + { 'H', log_request_protocol, "request_protocol", 0, 1 }, + { 'h', log_remote_host, "remote_host", 0, 1 }, { 'i', log_header_in, "header_in", 0, 1 }, { 'l', log_remote_logname, "remote_logname", 0, 1 }, - { 'n', log_note, "note", 0, 1 }, + { 'm', log_request_method, "request_method", 0, 1 }, + { 'n', log_note, "note", 0, 1 }, { 'o', log_header_out, "header_out", 0, 1 }, { 'P', log_child_pid, "child_pid", 0, 0 }, { 'p', log_server_port, "server_port", 0, 0 }, @@ -387,6 +489,11 @@ struct log_mysql_item_list { { 'u', log_remote_user, "remote_user", 0, 1 }, { 'U', log_request_uri, "request_uri", 1, 1 }, { 'v', log_virtual_host, "virtual_host", 0, 1 }, + #ifdef WANT_SSL_LOGGING + { 'q', log_ssl_keysize, "ssl_keysize", 0, 1 }, + { 'Q', log_ssl_maxkeysize, "ssl_maxkeysize", 0, 1 }, + { 'z', log_ssl_cipher, "ssl_cipher", 0, 1 }, + #endif {'\0'} }; @@ -521,6 +628,12 @@ const char *set_log_mysql_db(cmd_parms *parms, void *dummy, char *arg) return NULL; } +const char *set_log_mysql_cookie(cmd_parms *parms, void *dummy, char *arg) +{ + cookie_name = arg; + return NULL; +} + const char *set_log_mysql_info(cmd_parms *parms, void *dummy, char *host, char *user, char *pwd) { if (*host != '.') { @@ -570,32 +683,35 @@ const char *add_remhost_mysql_ignore(cmd_parms *parms, void *dummy, char *arg) } command_rec log_mysql_cmds[] = { - {"RefererLogMySQLTable", set_referer_log_mysql_table, NULL, RSRC_CONF, TAKE1, - "the table of the referer log"} + {"MySQLRefererLogTable", set_referer_log_mysql_table, NULL, RSRC_CONF, TAKE1, + "The MySQL table that holds the referer log"} + , + {"MySQLAgentLogTable", set_agent_log_mysql_table, NULL, RSRC_CONF, TAKE1, + "The MySQL table that holds the agent log"} , - {"AgentLogMySQLTable", set_agent_log_mysql_table, NULL, RSRC_CONF, TAKE1, - "the table of the agent log"} + {"MySQLTransferLogTable", set_transfer_log_mysql_table, NULL, RSRC_CONF, TAKE1, + "The MySQL table that holds the transfer log"} , - {"TransferLogMySQLTable", set_transfer_log_mysql_table, NULL, RSRC_CONF, TAKE1, - "the table of the transfer log"} + {"MySQLTransferLogFormat", set_transfer_log_format, NULL, RSRC_CONF, TAKE1, + "Instruct the module what information to log to the MySQL transfer log"} , - {"TransferLogMySQLFormat", set_transfer_log_format, NULL, RSRC_CONF, TAKE1, - "specific format for the MySQL transfer log"} + {"MySQLRefererIgnore", add_referer_mysql_ignore, NULL, RSRC_CONF, ITERATE, + "List of referers to ignore, accesses that match will not be logged to MySQL"} , - {"RefererIgnore", add_referer_mysql_ignore, NULL, RSRC_CONF, ITERATE, - "referer hostnames to ignore"} + {"MySQLRequestIgnore", add_transfer_mysql_ignore, NULL, RSRC_CONF, ITERATE, + "List of URIs to ignore, accesses that match will not be logged to MySQL"} , - {"RequestIgnore", add_transfer_mysql_ignore, NULL, RSRC_CONF, ITERATE, - "transfer log URIs to ignore"} + {"MySQLRemhostIgnore", add_remhost_mysql_ignore, NULL, RSRC_CONF, ITERATE, + "List of remote hosts to ignore, accesses that match will not be logged to MySQL"} , - {"RemhostIgnore", add_remhost_mysql_ignore, NULL, RSRC_CONF, ITERATE, - "transfer log remote hosts to ignore"} + {"MySQLDatabase", set_log_mysql_db, NULL, RSRC_CONF, TAKE1, + "The name of the MySQL database for logging"} , - {"LogMySQLDB", set_log_mysql_db, NULL, RSRC_CONF, TAKE1, - "the database of the referer log"} + {"MySQLWhichCookie", set_log_mysql_cookie, NULL, RSRC_CONF, TAKE1, + "The CookieName that you want logged when using the 'c' config directive"} , - {"LogMySQLInfo", set_log_mysql_info, NULL, RSRC_CONF, TAKE3, - "host, user and password for MySQL link"} + {"MySQLLoginInfo", set_log_mysql_info, NULL, RSRC_CONF, TAKE3, + "The MySQL host, user-id and password for logging"} , {NULL} }; @@ -622,17 +738,17 @@ int safe_mysql_query(request_rec *r, const char *query) { /* We need to restart the server link */ mysql_log = NULL; - log_error("MySQL: connection lost, attempting reconnect", r->server); + ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"MySQL: connection lost, attempting reconnect"); open_log_dblink(); if (mysql_log == NULL) { /* still unable to link */ signal(SIGPIPE, handler); - log_error("MySQL: reconnect failed.", r->server); + ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"MySQL: reconnect failed."); return error; } - log_error("MySQL: reconnect successful.", r->server); + ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"MySQL: reconnect successful."); error = mysql_query(mysql_log, query); } @@ -652,11 +768,11 @@ int safe_mysql_query(request_rec *r, const char *query) if (error) { str = pstrcat(r->pool, "MySQL query failed: ", query, NULL); - log_error(str, r->server); + ap_log_error(APLOG_MARK,ERRLEVEL,r->server,str); str = pstrcat(r->pool, "MySQL failure reason: ", MYSQL_ERROR(mysql_log), NULL); - log_error(str, r->server); + ap_log_error(APLOG_MARK,ERRLEVEL,r->server,str); } else { - log_error("MySQL: INSERT successful after a delayed retry.", r->server); + ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"MySQL: insert successful after a delayed retry."); } } return error; @@ -775,7 +891,7 @@ int log_mysql_transaction(request_rec *orig) /* If not specified by the user, use the default format */ if (cls->transfer_log_format[0] == '\0') { - cls->transfer_log_format = "huSUsbTvRA"; + cls->transfer_log_format = "AbHhmRSsTUuv"; } length = strlen(cls->transfer_log_format); -- cgit