summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
-rw-r--r--apache13.h4
-rw-r--r--configure.ac2
-rw-r--r--functions.h182
-rw-r--r--functions13.h37
-rw-r--r--functions20.h25
-rw-r--r--m4/mod_ssl.m41
-rw-r--r--mod_log_sql.c7
-rw-r--r--mod_log_sql.prj5
8 files changed, 118 insertions, 145 deletions
diff --git a/apache13.h b/apache13.h
index 1c262d7..8181c43 100644
--- a/apache13.h
+++ b/apache13.h
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/apache13.h,v 1.3 2004/01/22 05:26:56 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/apache13.h,v 1.4 2004/02/05 21:59:46 urkle Exp $ */
2#ifndef APACHE13_H 2#ifndef APACHE13_H
3#define APACHE13_H 3#define APACHE13_H
4 4
@@ -41,6 +41,8 @@
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_uri_unparse ap_unparse_uri_components
45
44#define apr_pool_create(a,b) *(a) = ap_make_sub_pool(b) 46#define apr_pool_create(a,b) *(a) = ap_make_sub_pool(b)
45#define apr_palloc ap_palloc 47#define apr_palloc ap_palloc
46#define apr_pcalloc ap_pcalloc 48#define apr_pcalloc ap_pcalloc
diff --git a/configure.ac b/configure.ac
index 7e9ccb8..fb036ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
1dnl Required initializer 1dnl Required initializer
2AC_INIT(mod_log_sql, 1.94) 2AC_INIT(mod_log_sql, 1.95)
3AC_PREREQ(2.53) 3AC_PREREQ(2.53)
4AC_CONFIG_HEADERS(config.h) 4AC_CONFIG_HEADERS(config.h)
5 5
diff --git a/functions.h b/functions.h
index 60d08b5..917a1f9 100644
--- a/functions.h
+++ b/functions.h
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/functions.h,v 1.1 2004/01/20 19:38:08 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/functions.h,v 1.2 2004/02/05 21:59:46 urkle Exp $ */
2/* Begin the individual functions that, given a request r, 2/* Begin the individual functions that, given a request r,
3 * extract the needed information from it and return the 3 * extract the needed information from it and return the
4 * value to the calling entity. 4 * value to the calling entity.
@@ -9,6 +9,20 @@ static const char *extract_remote_host(request_rec *r, char *a)
9 return (char *) ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL); 9 return (char *) ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL);
10} 10}
11 11
12static const char *extract_remote_address(request_rec *r, char *a) __attribute__((unused));
13
14static const char *extract_remote_address(request_rec *r, char *a)
15{
16 return r->connection->remote_ip;
17}
18
19static const char *extract_local_address(request_rec *r, char *a) __attribute__((unused));
20
21static const char *extract_local_address(request_rec *r, char *a)
22{
23 return r->connection->local_ip;
24}
25
12static const char *extract_remote_logname(request_rec *r, char *a) 26static const char *extract_remote_logname(request_rec *r, char *a)
13{ 27{
14 return (char *) ap_get_remote_logname(r); 28 return (char *) ap_get_remote_logname(r);
@@ -29,19 +43,21 @@ static const char *extract_remote_user(request_rec *r, char *a)
29 return rvalue; 43 return rvalue;
30} 44}
31 45
32static const char *extract_request_method(request_rec *r, char *a)
33{
34 return r->method;
35}
36
37static const char *extract_request_protocol(request_rec *r, char *a)
38{
39 return r->protocol;
40}
41
42static const char *extract_request_line(request_rec *r, char *a) 46static const char *extract_request_line(request_rec *r, char *a)
43{ 47{
44 return r->the_request; 48 /* Upddated to mod_log_config logic */
49 /* NOTE: If the original request contained a password, we
50 * re-write the request line here to contain XXXXXX instead:
51 * (note the truncation before the protocol string for HTTP/0.9 requests)
52 * (note also that r->the_request contains the unmodified request)
53 */
54 return (r->parsed_uri.password)
55 ? apr_pstrcat(r->pool, r->method, " ",
56 apr_uri_unparse(r->pool,
57 &r->parsed_uri, 0),
58 r->assbackwards ? NULL : " ",
59 r->protocol, NULL)
60 : r->the_request;
45} 61}
46 62
47static const char *extract_request_file(request_rec *r, char *a) 63static const char *extract_request_file(request_rec *r, char *a)
@@ -54,47 +70,31 @@ static const char *extract_request_uri(request_rec *r, char *a)
54 return r->uri; 70 return r->uri;
55} 71}
56 72
57static const char *extract_request_args(request_rec *r, char *a) 73static const char *extract_request_method(request_rec *r, char *a)
58{
59 return r->args;
60}
61
62static const char *extract_status(request_rec *r, char *a)
63{ 74{
64 if (r->status <= 0) { 75 return r->method;
65 return "-";
66 } else {
67 return apr_psprintf(r->pool, "%d", r->status);
68 }
69} 76}
70 77
71static const char *extract_bytes_sent(request_rec *r, char *a) 78static const char *extract_request_protocol(request_rec *r, char *a)
72{ 79{
73 if (!r->sent_bodyct || !r->bytes_sent) { 80 return r->protocol;
74 return "-";
75 } else {
76 return apr_psprintf(r->pool, "%" APR_OFF_T_FMT, r->bytes_sent);
77 }
78} 81}
79 82
80/* 83static const char *extract_request_query(request_rec *r, char *a)
81static const char *extract_header_in(request_rec *r, char *a)
82{ 84{
83 return table_get(r->headers_in, a); 85 return (r->args) ? apr_pstrcat(r->pool, "?",
86 r->args, NULL)
87 : "";
84} 88}
85 89
86static const char *extract_header_out(request_rec *r, char *a) 90static const char *extract_status(request_rec *r, char *a)
87{ 91{
88 const char *cp = table_get(r->headers_out, a); 92 if (r->status <= 0) {
89 if (!strcasecmp(a, "Content-type") && r->content_type) { 93 return "-";
90 cp = r->content_type; 94 } else {
91 } 95 return apr_psprintf(r->pool, "%d", r->status);
92 if (cp) {
93 return cp;
94 } 96 }
95 return table_get(r->err_headers_out, a);
96} 97}
97*/
98 98
99static const char *extract_virtual_host(request_rec *r, char *a) 99static const char *extract_virtual_host(request_rec *r, char *a)
100{ 100{
@@ -115,6 +115,15 @@ static const char *extract_server_port(request_rec *r, char *a)
115 r->server->port ? r->server->port : ap_default_port(r)); 115 r->server->port ? r->server->port : ap_default_port(r));
116} 116}
117 117
118/* This respects the setting of UseCanonicalName so that
119 * the dynamic mass virtual hosting trick works better.
120 */
121static const char *log_server_name(request_rec *r, char *a) __attribute__((unused));
122static const char *log_server_name(request_rec *r, char *a)
123{
124 return ap_get_server_name(r);
125}
126
118static const char *extract_child_pid(request_rec *r, char *a) 127static const char *extract_child_pid(request_rec *r, char *a)
119{ 128{
120 if (*a == '\0' || !strcmp(a, "pid")) { 129 if (*a == '\0' || !strcmp(a, "pid")) {
@@ -158,83 +167,6 @@ static const char *extract_agent(request_rec *r, char *a)
158 } 167 }
159} 168}
160 169
161static const char *extract_cookie(request_rec *r, char *a)
162{
163 const char *cookiestr;
164 char *cookieend;
165 char *isvalid;
166 char *cookiebuf;
167
168 logsql_state *cls = ap_get_module_config(r->server->module_config,
169 &log_sql_module);
170
171 if (cls->cookie_name != NULL) {
172 #ifdef DEBUG
173 log_error(APLOG_MARK,APLOG_DEBUG, r->server,
174 "watching for cookie '%s'", cls->cookie_name);
175 #endif
176
177 /* Fetch out the cookie header */
178 cookiestr = (char *)apr_table_get(r->headers_in, "cookie2");
179 if (cookiestr != NULL) {
180 #ifdef DEBUG
181 log_error(APLOG_MARK,APLOG_DEBUG, r->server,
182 "Cookie2: [%s]", cookiestr);
183 #endif
184 /* Does the cookie string contain one with our name? */
185 isvalid = strstr(cookiestr, cls->cookie_name);
186 if (isvalid != NULL) {
187 /* Move past the cookie name and equal sign */
188 isvalid += strlen(cls->cookie_name) + 1;
189 /* Duplicate it into the pool */
190 cookiebuf = apr_pstrdup(r->pool, isvalid);
191 /* Segregate just this cookie out of the string
192 * with a terminating nul at the first semicolon */
193 cookieend = strchr(cookiebuf, ';');
194 if (cookieend != NULL)
195 *cookieend = '\0';
196 return cookiebuf;
197 }
198 }
199
200 cookiestr = (char *)apr_table_get(r->headers_in, "cookie");
201 if (cookiestr != NULL) {
202 #ifdef DEBUG
203 log_error(APLOG_MARK,APLOG_DEBUG,r->server,
204 "Cookie: [%s]", cookiestr);
205 #endif
206 isvalid = strstr(cookiestr, cls->cookie_name);
207 if (isvalid != NULL) {
208 isvalid += strlen(cls->cookie_name) + 1;
209 cookiebuf = apr_pstrdup(r->pool, isvalid);
210 cookieend = strchr(cookiebuf, ';');
211 if (cookieend != NULL)
212 *cookieend = '\0';
213 return cookiebuf;
214 }
215 }
216
217 cookiestr = apr_table_get(r->headers_out, "set-cookie");
218 if (cookiestr != NULL) {
219 #ifdef DEBUG
220 log_error(APLOG_MARK,APLOG_DEBUG,r->server,
221 "Set-Cookie: [%s]", cookiestr);
222 #endif
223 isvalid = strstr(cookiestr, cls->cookie_name);
224 if (isvalid != NULL) {
225 isvalid += strlen(cls->cookie_name) + 1;
226 cookiebuf = apr_pstrdup(r->pool, isvalid);
227 cookieend = strchr(cookiebuf, ';');
228 if (cookieend != NULL)
229 *cookieend = '\0';
230 return cookiebuf;
231 }
232 }
233 }
234
235 return "-";
236}
237
238static const char *extract_specific_cookie(request_rec *r, char *a) 170static const char *extract_specific_cookie(request_rec *r, char *a)
239{ 171{
240 const char *cookiestr; 172 const char *cookiestr;
@@ -309,18 +241,12 @@ static const char *extract_specific_cookie(request_rec *r, char *a)
309 return "-"; 241 return "-";
310} 242}
311 243
312 244static const char *extract_cookie(request_rec *r, char *a)
313/*
314static const char *extract_note(request_rec *r, char *a)
315{ 245{
316 return apr_table_get(r->notes, a); 246 logsql_state *cls = ap_get_module_config(r->server->module_config,
317 247 &log_sql_module);
318}
319*/
320 248
321static const char *extract_env_var(request_rec *r, char *a) 249 return extract_specific_cookie(r, (char *)cls->cookie_name);
322{
323 return apr_table_get(r->subprocess_env, a);
324} 250}
325 251
326static const char *extract_unique_id(request_rec *r, char *a) 252static const char *extract_unique_id(request_rec *r, char *a)
diff --git a/functions13.h b/functions13.h
index 1b85d0e..7fe8850 100644
--- a/functions13.h
+++ b/functions13.h
@@ -1,4 +1,17 @@
1/* $Header: /home/cvs/mod_log_sql/functions13.h,v 1.2 2004/01/20 19:38:08 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/functions13.h,v 1.3 2004/02/05 21:59:46 urkle Exp $ */
2
3static const char *extract_bytes_sent(request_rec *r, char *a)
4{
5 if (!r->sent_bodyct) {
6 return "-";
7 }
8 else {
9 long int bs;
10 ap_bgetopt(r->connection->client, BO_BYTECT, &bs);
11 return ap_psprintf(r->pool, "%ld", bs);
12 }
13}
14
2static const char *extract_request_time(request_rec *r, char *a) 15static const char *extract_request_time(request_rec *r, char *a)
3{ 16{
4 int timz; 17 int timz;
@@ -24,16 +37,22 @@ static const char *extract_request_time(request_rec *r, char *a)
24 37
25static const char *extract_request_duration(request_rec *r, char *a) 38static const char *extract_request_duration(request_rec *r, char *a)
26{ 39{
27 char duration[22]; /* Long enough for 2^64 */ 40 return ap_psprintf(r->pool, "%ld", time(NULL) - r->request_time);
28
29 ap_snprintf(duration, sizeof(duration), "%ld", (long) time(NULL) - r->request_time);
30 return ap_pstrdup(r->pool, duration);
31} 41}
32 42
33static const char *extract_request_timestamp(request_rec *r, char *a) 43static const char *extract_request_timestamp(request_rec *r, char *a)
34{ 44{
35 char tstr[32]; 45 return ap_psprintf(r->pool, "%ld", (long) time(NULL));
36 46}
37 ap_snprintf(tstr, 32, "%ld", (long) time(NULL)); 47static const char *extract_connection_status(request_rec *r, char *a) __attribute__((unused));
38 return ap_pstrdup(r->pool, tstr); 48static const char *extract_connection_status(request_rec *r, char *a)
49{
50 if (r->connection->aborted)
51 return "X";
52
53 if ((r->connection->keepalive) &&
54 ((r->server->keep_alive_max - r->connection->keepalives) > 0)) {
55 return "+";
56 }
57 return "-";
39} 58}
diff --git a/functions20.h b/functions20.h
index c8701a2..31d9e4b 100644
--- a/functions20.h
+++ b/functions20.h
@@ -1,5 +1,14 @@
1/* $Header: /home/cvs/mod_log_sql/functions20.h,v 1.2 2004/01/20 19:38:08 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/functions20.h,v 1.3 2004/02/05 21:59:46 urkle Exp $ */
2/* functions */ 2/* functions */
3static const char *extract_bytes_sent(request_rec *r, char *a)
4{
5 if (!r->sent_bodyct || !r->bytes_sent) {
6 return "-";
7 } else {
8 return apr_psprintf(r->pool, "%" APR_OFF_T_FMT, r->bytes_sent);
9 }
10}
11
3static const char *extract_request_time_custom(request_rec *r, char *a, 12static const char *extract_request_time_custom(request_rec *r, char *a,
4 apr_time_exp_t *xt) 13 apr_time_exp_t *xt)
5{ 14{
@@ -91,3 +100,17 @@ static const char *extract_request_timestamp(request_rec *r, char *a)
91{ 100{
92 return apr_psprintf(r->pool, "%"APR_TIME_T_FMT, apr_time_sec(apr_time_now())); 101 return apr_psprintf(r->pool, "%"APR_TIME_T_FMT, apr_time_sec(apr_time_now()));
93} 102}
103
104static const char *extract_connection_status(request_rec *r, char *a) __attribute__((unused));
105static const char *extract_connection_status(request_rec *r, char *a)
106{
107 if (r->connection->aborted)
108 return "X";
109
110 if (r->connection->keepalive == AP_CONN_KEEPALIVE &&
111 (!r->server->keep_alive_max ||
112 (r->server->keep_alive_max - r->connection->keepalives) > 0)) {
113 return "+";
114 }
115 return "-";
116}
diff --git a/m4/mod_ssl.m4 b/m4/mod_ssl.m4
index a8c6103..c431bce 100644
--- a/m4/mod_ssl.m4
+++ b/m4/mod_ssl.m4
@@ -18,6 +18,7 @@ AC_ARG_WITH(
18 db-inc, 18 db-inc,
19 [AC_HELP_STRING([--with-db-inc=DIR],[Location of DB header files])], 19 [AC_HELP_STRING([--with-db-inc=DIR],[Location of DB header files])],
20 db_incdir="$withval", 20 db_incdir="$withval",
21 db_incdir="/usr/include/db1"
21 ) 22 )
22 23
23 if test "x$ssl_val" = "xyes"; then 24 if test "x$ssl_val" = "xyes"; then
diff --git a/mod_log_sql.c b/mod_log_sql.c
index f4b8c16..7320f66 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.13 2004/02/04 02:16:33 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.14 2004/02/05 21:59:46 urkle Exp $ */
2/* --------* 2/* --------*
3 * DEFINES * 3 * DEFINES *
4 * --------*/ 4 * --------*/
@@ -717,12 +717,13 @@ static void log_sql_module_init(server_rec *s, apr_pool_t *p)
717 if (!global_config.tcpport) 717 if (!global_config.tcpport)
718 global_config.tcpport = 3306; 718 global_config.tcpport = 3306;
719 719
720 /* TODO: Add local_address, remote_address, server_name, connection_status */
720 /* Register handlers */ 721 /* Register handlers */
721 log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1); 722 log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1);
722 log_sql_register_item(s,p,'a', extract_request_args, "request_args", 1, 1); 723 log_sql_register_item(s,p,'a', extract_request_query, "request_args", 1, 1);
723 log_sql_register_item(s,p,'b', extract_bytes_sent, "bytes_sent", 0, 0); 724 log_sql_register_item(s,p,'b', extract_bytes_sent, "bytes_sent", 0, 0);
724 log_sql_register_item(s,p,'c', extract_cookie, "cookie", 0, 1); 725 log_sql_register_item(s,p,'c', extract_cookie, "cookie", 0, 1);
725 log_sql_register_item(s,p,'e', extract_env_var, "env_var", 0, 1); 726 /* TODO: Document */
726 log_sql_register_item(s,p,'f', extract_request_file, "request_file", 0, 1); 727 log_sql_register_item(s,p,'f', extract_request_file, "request_file", 0, 1);
727 log_sql_register_item(s,p,'H', extract_request_protocol, "request_protocol", 0, 1); 728 log_sql_register_item(s,p,'H', extract_request_protocol, "request_protocol", 0, 1);
728 log_sql_register_item(s,p,'h', extract_remote_host, "remote_host", 0, 1); 729 log_sql_register_item(s,p,'h', extract_remote_host, "remote_host", 0, 1);
diff --git a/mod_log_sql.prj b/mod_log_sql.prj
index 9193940..ad294d5 100644
--- a/mod_log_sql.prj
+++ b/mod_log_sql.prj
@@ -52,7 +52,7 @@ anjuta.program.arguments=
52 52
53module.include.name=. 53module.include.name=.
54module.include.type= 54module.include.type=
55module.include.expanded=0 55module.include.expanded=1
56module.include.files=\ 56module.include.files=\
57 apache13.h\ 57 apache13.h\
58 apache20.h\ 58 apache20.h\
@@ -98,7 +98,8 @@ module.doc.files=\
98 INSTALL\ 98 INSTALL\
99 Documentation/documentation.lyx\ 99 Documentation/documentation.lyx\
100 CHANGELOG\ 100 CHANGELOG\
101 LICENSE 101 LICENSE\
102 AUTHORS
102 103
103module.po.expanded=0 104module.po.expanded=0
104module.po.files= 105module.po.files=