summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Edward Rudd 2004-04-29 21:19:30 +0000
committerGravatar Edward Rudd 2004-04-29 21:19:30 +0000
commit7c378cc1fac4e9fec1ca32d8d314ea86761a7404 (patch)
treebc82e7e864ce3978904bc1cb9d9eb6fa52e95dde
parentbe0fe66bcd84e4660b9dba4c1f1f20a649b66c61 (diff)
win32 updates and build script
added LogSQLDisablePreserve set default of preserve file to root_relative logs/mod_log_sql-preserve
-rw-r--r--CHANGELOG9
-rw-r--r--build-apache2.bat40
-rw-r--r--mod_log_sql.c64
-rw-r--r--mod_log_sql_mysql.c30
-rw-r--r--winconfig.h25
5 files changed, 137 insertions, 31 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f0540f8..4beccec 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,12 @@
11.98: 2004-04-?
2* re-fixed apache.m4 to better detect APR and APU code
3* fixed for win32 compilation under apache 2
4* lowered minumum required apache 2 version to 2.0.40 (RH9)
5* Added LogSQLDisablePreserve to disable the preserve file.
6* Changed default preserve file location to logs/mod_log_sql-preserve
7 And made LogSQLPreserveFile root relative.
8* fixed bug where preserve file wouldn't be created in apache 2
9
11.97: 2004-04-08 101.97: 2004-04-08
2* fixed apache.m4 to work with apache 2 setups with different include 11* fixed apache.m4 to work with apache 2 setups with different include
3 directories for APR and APU then core Apache 12 directories for APR and APU then core Apache
diff --git a/build-apache2.bat b/build-apache2.bat
new file mode 100644
index 0000000..f44109c
--- /dev/null
+++ b/build-apache2.bat
@@ -0,0 +1,40 @@
1@echo off
2rem path to Microsoft SDK installation
3SET DIR_MSSDK=C:\Program Files\Microsoft SDK
4rem path to apache2 installation
5SET DIR_APACHE=C:\Program Files\Apache Group\Apache2
6rem path to mysql 4.0 installation
7SET DIR_MYSQL=C:\MySQL
8rem Can be set to opt or debug
9SET LIB_MYSQL=opt
10
11copy /Y winconfig.h config.h
12mkdir Release
13cd Release
14Rem Compile all the source code
15echo /MD /W3 /Zi /O2 /DNDEBUG /D_WINDOWS /DWIN32 > RESP_c.txt
16echo /Fd"mod_log_sql" /FD >> RESP_c.txt
17echo /DHAVE_CONFIG_H /DWITH_APACHE20 /DLOGSQL_DECLARE_EXPORT >> RESP_c.txt
18echo /I.. >> RESP_c.txt
19echo /I"%DIR_MSSDK%\Include" >> RESP_c.txt
20echo /I"%DIR_APACHE%\Include" >> RESP_c.txt
21echo /I"%DIR_MYSQL%\Include" >> RESP_c.txt
22cl @RESP_c.txt /c ..\mod_log_sql.c ..\mod_log_sql_mysql.c
23
24rem link main module
25echo /MACHINE:I386 /SUBSYSTEM:windows > RESP_l.txt
26echo /OUT:mod_log_sql.so /DLL /OPT:REF /DEBUG >> RESP_l.txt
27echo /LIBPATH:"%DIR_APACHE%\lib" >> RESP_l.txt
28echo libapr.lib libaprutil.lib libhttpd.lib >> RESP_l.txt
29link @RESP_l.txt mod_log_sql.obj
30
31rem link mysql module
32echo /MACHINE:I386 /SUBSYSTEM:windows > RESP_l.txt
33echo /OUT:mod_log_sql_mysql.so /DLL /OPT:REF /DEBUG >> RESP_l.txt
34echo /LIBPATH:"%DIR_APACHE%\lib" >> RESP_l.txt
35echo /LIBPATH:"%DIR_MYSQL%\lib\%LIB_MYSQL%" >> RESP_l.txt
36echo /NODEFAULTLIB:LIBCMT.lib >> RESP_l.txt
37echo libapr.lib libaprutil.lib libhttpd.lib >> RESP_l.txt
38echo libmysql.lib mod_log_sql.lib >> RESP_l.txt
39link @RESP_l.txt mod_log_sql_mysql.obj
40cd ..
diff --git a/mod_log_sql.c b/mod_log_sql.c
index 83a303a..0ba1bf6 100644
--- a/mod_log_sql.c
+++ b/mod_log_sql.c
@@ -36,7 +36,7 @@
36#define DEFAULT_HIN_TABLE_NAME "headers_in" 36#define DEFAULT_HIN_TABLE_NAME "headers_in"
37#define DEFAULT_HOUT_TABLE_NAME "headers_out" 37#define DEFAULT_HOUT_TABLE_NAME "headers_out"
38#define DEFAULT_COOKIE_TABLE_NAME "cookies" 38#define DEFAULT_COOKIE_TABLE_NAME "cookies"
39#define DEFAULT_PRESERVE_FILE "/tmp/sql-preserve" 39#define DEFAULT_PRESERVE_FILE "logs/mod_log_sql-preserve"
40 40
41/* -------------* 41/* -------------*
42 * DECLARATIONS * 42 * DECLARATIONS *
@@ -54,6 +54,7 @@ typedef struct {
54 int massvirtual; 54 int massvirtual;
55 int createtables; 55 int createtables;
56 int forcepreserve; 56 int forcepreserve;
57 int disablepreserve;
57 char *machid; 58 char *machid;
58 int announce; 59 int announce;
59 logsql_dbconnection db; 60 logsql_dbconnection db;
@@ -193,14 +194,20 @@ static void preserve_entry(request_rec *r, const char *query)
193 #if defined(WITH_APACHE20) 194 #if defined(WITH_APACHE20)
194 apr_file_t *fp; 195 apr_file_t *fp;
195 apr_status_t result; 196 apr_status_t result;
196 result = apr_file_open(&fp, cls->preserve_file,APR_APPEND, APR_OS_DEFAULT, r->pool);
197 #elif defined(WITH_APACHE13) 197 #elif defined(WITH_APACHE13)
198 FILE *fp; 198 FILE *fp;
199 int result; 199 int result;
200 #endif
201 /* If preserve file is disabled bail out */
202 if (global_config.disablepreserve)
203 return;
204 #if defined(WITH_APACHE20)
205 result = apr_file_open(&fp, cls->preserve_file,APR_APPEND | APR_WRITE | APR_CREATE, APR_OS_DEFAULT, r->pool);
206 #elif defined(WITH_APACHE13)
200 fp = ap_pfopen(r->pool, cls->preserve_file, "a"); 207 fp = ap_pfopen(r->pool, cls->preserve_file, "a");
201 result = (fp)?0:errno; 208 result = (fp)?0:errno;
202 #endif 209 #endif
203 if (result != APR_SUCCESS) { 210 if (result != APR_SUCCESS) {
204 log_error(APLOG_MARK, APLOG_ERR, result, r->server, 211 log_error(APLOG_MARK, APLOG_ERR, result, r->server,
205 "attempted append of local preserve file '%s' but failed.",cls->preserve_file); 212 "attempted append of local preserve file '%s' but failed.",cls->preserve_file);
206 } else { 213 } else {
@@ -272,6 +279,27 @@ static const char *set_server_string_slot(cmd_parms *cmd,
272 return NULL; 279 return NULL;
273} 280}
274 281
282static const char *set_server_file_slot(cmd_parms *cmd,
283 void *struct_ptr,
284 const char *arg)
285{
286 void *ptr = ap_get_module_config(cmd->server->module_config,
287 &log_sql_module);
288 int offset = (int)(long)cmd->info;
289 const char *path;
290
291 path = ap_server_root_relative(cmd->pool, arg);
292
293 if (!path) {
294 return apr_pstrcat(cmd->pool, "Invalid file path ",
295 arg, NULL);
296 }
297
298 *(const char **)((char*)ptr + offset) = path;
299
300 return NULL;
301}
302
275static const char *set_logformat_slot(cmd_parms *cmd, 303static const char *set_logformat_slot(cmd_parms *cmd,
276 void *struct_ptr, 304 void *struct_ptr,
277 const char *arg) 305 const char *arg)
@@ -325,6 +353,7 @@ static const char *set_log_sql_info(cmd_parms *cmd, void *dummy,
325 const char *host, const char *user, const char *pwd) 353 const char *host, const char *user, const char *pwd)
326{ 354{
327 if (!user) { /* user is null, so only one arg passed */ 355 if (!user) { /* user is null, so only one arg passed */
356 /* TODO: to more error checking/force all params to be set */
328 apr_uri_t uri; 357 apr_uri_t uri;
329 apr_uri_parse(cmd->pool, host, &uri); 358 apr_uri_parse(cmd->pool, host, &uri);
330 if (uri.scheme) { 359 if (uri.scheme) {
@@ -372,7 +401,7 @@ static const char *add_server_string_slot(cmd_parms *cmd,
372 void *ptr = ap_get_module_config(cmd->server->module_config, 401 void *ptr = ap_get_module_config(cmd->server->module_config,
373 &log_sql_module); 402 &log_sql_module);
374 int offset = (int)(long)cmd->info; 403 int offset = (int)(long)cmd->info;
375 apr_array_header_t *ary = *(apr_array_header_t **)(ptr + offset); 404 apr_array_header_t *ary = *(apr_array_header_t **)((char *)ptr + offset);
376 addme = apr_array_push(ary); 405 addme = apr_array_push(ary);
377 *addme = apr_pstrdup(ary->pool, arg); 406 *addme = apr_pstrdup(ary->pool, arg);
378 407
@@ -464,7 +493,17 @@ static void log_sql_module_init(server_rec *s, apr_pool_t *p)
464 if (global_config.announce) { 493 if (global_config.announce) {
465 ap_add_version_component(p, PACKAGE_NAME"/"PACKAGE_VERSION); 494 ap_add_version_component(p, PACKAGE_NAME"/"PACKAGE_VERSION);
466 } 495 }
467 496 /* ap_server_root_relative any default preserve file locations */
497 {
498 server_rec *cur_s;
499 const char *default_p = ap_server_root_relative(p, DEFAULT_PRESERVE_FILE);
500 for (cur_s = s; cur_s != NULL; cur_s= cur_s->next) {
501 logsql_state *cls = ap_get_module_config(cur_s->module_config,
502 &log_sql_module);
503 if (cls->preserve_file == DEFAULT_PRESERVE_FILE)
504 cls->preserve_file = default_p;
505 }
506 }
468#if defined(WITH_APACHE20) 507#if defined(WITH_APACHE20)
469 return OK; 508 return OK;
470#endif 509#endif
@@ -693,7 +732,10 @@ static void *log_sql_merge_state(apr_pool_t *p, void *basev, void *addv)
693 732
694 if (child->preserve_file == DEFAULT_PRESERVE_FILE) 733 if (child->preserve_file == DEFAULT_PRESERVE_FILE)
695 child->preserve_file = parent->preserve_file; 734 child->preserve_file = parent->preserve_file;
696 735 /* server_root_relative the preserve file location */
736 if (child->preserve_file == DEFAULT_PRESERVE_FILE)
737 child->preserve_file = ap_server_root_relative(p, DEFAULT_PRESERVE_FILE);
738
697 if (child->notes_table_name == DEFAULT_NOTES_TABLE_NAME) 739 if (child->notes_table_name == DEFAULT_NOTES_TABLE_NAME)
698 child->notes_table_name = parent->notes_table_name; 740 child->notes_table_name = parent->notes_table_name;
699 741
@@ -1070,7 +1112,7 @@ static const command_rec log_sql_cmds[] = {
1070 , 1112 ,
1071 /* DB connection parameters */ 1113 /* DB connection parameters */
1072 AP_INIT_TAKE13("LogSQLLoginInfo", set_log_sql_info, NULL, RSRC_CONF, 1114 AP_INIT_TAKE13("LogSQLLoginInfo", set_log_sql_info, NULL, RSRC_CONF,
1073 "The database connection URI in the form<br>driver://user:password@hostname:port/database") 1115 "The database connection URI in the form &quot;driver://user:password@hostname:port/database&quot;")
1074 , 1116 ,
1075 AP_INIT_TAKE2("LogSQLDBParam", set_dbparam, NULL, RSRC_CONF, 1117 AP_INIT_TAKE2("LogSQLDBParam", set_dbparam, NULL, RSRC_CONF,
1076 "First argument is the DB parameter, second is the value to assign") 1118 "First argument is the DB parameter, second is the value to assign")
@@ -1079,7 +1121,11 @@ static const command_rec log_sql_cmds[] = {
1079 (void *)APR_OFFSETOF(global_config_t, forcepreserve), RSRC_CONF, 1121 (void *)APR_OFFSETOF(global_config_t, forcepreserve), RSRC_CONF,
1080 "Forces logging to preserve file and bypasses database") 1122 "Forces logging to preserve file and bypasses database")
1081 , 1123 ,
1082 AP_INIT_TAKE1("LogSQLPreserveFile", set_server_string_slot, 1124 AP_INIT_FLAG("LogSQLDisablePreserve", set_global_flag_slot,
1125 (void *)APR_OFFSETOF(global_config_t, disablepreserve), RSRC_CONF,
1126 "Completely disables use of the preserve file")
1127 ,
1128 AP_INIT_TAKE1("LogSQLPreserveFile", set_server_file_slot,
1083 (void *)APR_OFFSETOF(logsql_state,preserve_file), RSRC_CONF, 1129 (void *)APR_OFFSETOF(logsql_state,preserve_file), RSRC_CONF,
1084 "Name of the file to use for data preservation during database downtime") 1130 "Name of the file to use for data preservation during database downtime")
1085 , 1131 ,
diff --git a/mod_log_sql_mysql.c b/mod_log_sql_mysql.c
index 3749d64..e8a149e 100644
--- a/mod_log_sql_mysql.c
+++ b/mod_log_sql_mysql.c
@@ -109,13 +109,22 @@ static const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p,
109 return from_str; 109 return from_str;
110 } 110 }
111} 111}
112 112#if defined(WIN32)
113#define SIGNAL_GRAB
114#define SIGNAL_RELEASE
115#define SIGNAL_VAR
116#else
117#define SIGNAL_VAR void (*handler) (int)
118#define SIGNAL_GRAB handler = signal(SIGPIPE, SIG_IGN)
119#define SIGNAL_RELEASE signal(SIGPIPE, handler);
120#endif
113/* Run a mysql insert query and return a categorized error or success */ 121/* Run a mysql insert query and return a categorized error or success */
114static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *db, 122static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *db,
115 const char *query) 123 const char *query)
116{ 124{
117 int retval; 125 int retval;
118 void (*handler) (int); 126 SIGNAL_VAR
127
119 unsigned int real_error = 0; 128 unsigned int real_error = 0;
120 /*const char *real_error_str = NULL;*/ 129 /*const char *real_error_str = NULL;*/
121 130
@@ -124,12 +133,13 @@ static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *
124 if (!dblink) { 133 if (!dblink) {
125 return LOGSQL_QUERY_NOLINK; 134 return LOGSQL_QUERY_NOLINK;
126 } 135 }
136
127 /* A failed mysql_query() may send a SIGPIPE, so we ignore that signal momentarily. */ 137 /* A failed mysql_query() may send a SIGPIPE, so we ignore that signal momentarily. */
128 handler = signal(SIGPIPE, SIG_IGN); 138 SIGNAL_GRAB
129 139
130 /* Run the query */ 140 /* Run the query */
131 if (!(retval = mysql_query(dblink, query))) { 141 if (!(retval = mysql_query(dblink, query))) {
132 signal(SIGPIPE, handler); 142 SIGNAL_RELEASE
133 return LOGSQL_QUERY_SUCCESS; 143 return LOGSQL_QUERY_SUCCESS;
134 } 144 }
135 /* Check to see if the error is "nonexistent table" */ 145 /* Check to see if the error is "nonexistent table" */
@@ -138,12 +148,12 @@ static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *
138 if (real_error == ER_NO_SUCH_TABLE) { 148 if (real_error == ER_NO_SUCH_TABLE) {
139 log_error(APLOG_MARK,APLOG_ERR,0, r->server,"table does not exist, preserving query"); 149 log_error(APLOG_MARK,APLOG_ERR,0, r->server,"table does not exist, preserving query");
140 /* Restore SIGPIPE to its original handler function */ 150 /* Restore SIGPIPE to its original handler function */
141 signal(SIGPIPE, handler); 151 SIGNAL_RELEASE
142 return LOGSQL_QUERY_NOTABLE; 152 return LOGSQL_QUERY_NOTABLE;
143 } 153 }
144 154
145 /* Restore SIGPIPE to its original handler function */ 155 /* Restore SIGPIPE to its original handler function */
146 signal(SIGPIPE, handler); 156 SIGNAL_RELEASE
147 return LOGSQL_QUERY_FAIL; 157 return LOGSQL_QUERY_FAIL;
148} 158}
149 159
@@ -153,7 +163,7 @@ static logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection
153{ 163{
154 int retval; 164 int retval;
155 const char *tabletype = apr_table_get(db->parms,"tabletype"); 165 const char *tabletype = apr_table_get(db->parms,"tabletype");
156 void (*handler) (int); 166 SIGNAL_VAR
157 char *type_suffix = NULL; 167 char *type_suffix = NULL;
158 168
159 char *create_prefix = "create table if not exists `"; 169 char *create_prefix = "create table if not exists `";
@@ -220,16 +230,16 @@ static logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection
220 return LOGSQL_QUERY_NOLINK; 230 return LOGSQL_QUERY_NOLINK;
221 } 231 }
222 /* A failed mysql_query() may send a SIGPIPE, so we ignore that signal momentarily. */ 232 /* A failed mysql_query() may send a SIGPIPE, so we ignore that signal momentarily. */
223 handler = signal(SIGPIPE, SIG_IGN); 233 SIGNAL_GRAB
224 234
225 /* Run the create query */ 235 /* Run the create query */
226 if ((retval = mysql_query(dblink, create_sql))) { 236 if ((retval = mysql_query(dblink, create_sql))) {
227 log_error(APLOG_MARK,APLOG_ERR,0, r->server,"failed to create table: %s", 237 log_error(APLOG_MARK,APLOG_ERR,0, r->server,"failed to create table: %s",
228 table_name); 238 table_name);
229 signal(SIGPIPE, handler); 239 SIGNAL_RELEASE
230 return LOGSQL_TABLE_FAIL; 240 return LOGSQL_TABLE_FAIL;
231 } 241 }
232 signal(SIGPIPE, handler); 242 SIGNAL_RELEASE
233 return LOGSQL_TABLE_SUCCESS; 243 return LOGSQL_TABLE_SUCCESS;
234} 244}
235 245
diff --git a/winconfig.h b/winconfig.h
index 89d1b24..107cb7d 100644
--- a/winconfig.h
+++ b/winconfig.h
@@ -2,16 +2,16 @@
2/* config.h.in. Generated from configure.ac by autoheader. */ 2/* config.h.in. Generated from configure.ac by autoheader. */
3 3
4/* Define to 1 if you have the <inttypes.h> header file. */ 4/* Define to 1 if you have the <inttypes.h> header file. */
5#define HAVE_INTTYPES_H 1 5/* #undef HAVE_INTTYPES_H */
6 6
7/* Define to 1 if you have the `m' library (-lm). */ 7/* Define to 1 if you have the `m' library (-lm). */
8#define HAVE_LIBM 1 8/* #undef HAVE_LIBM */
9 9
10/* Define to 1 if you have the `mysqlclient' library (-lmysqlclient). */ 10/* Define to 1 if you have the `mysqlclient' library (-lmysqlclient). */
11#define HAVE_LIBMYSQLCLIENT 1 11#define HAVE_LIBMYSQLCLIENT 1
12 12
13/* Define to 1 if you have the `z' library (-lz). */ 13/* Define to 1 if you have the `z' library (-lz). */
14#define HAVE_LIBZ 1 14/* #undef HAVE_LIBZ */
15 15
16/* Define to 1 if you have the <limits.h> header file. */ 16/* Define to 1 if you have the <limits.h> header file. */
17#define HAVE_LIMITS_H 1 17#define HAVE_LIMITS_H 1
@@ -20,31 +20,31 @@
20#define HAVE_MEMORY_H 1 20#define HAVE_MEMORY_H 1
21 21
22/* Define to 1 if you have the <mod_ssl.h> header file. */ 22/* Define to 1 if you have the <mod_ssl.h> header file. */
23#define HAVE_MOD_SSL_H 1 23/* #undef HAVE_MOD_SSL_H */
24 24
25/* Define to 1 if you have the `mysql_real_escape_string' function. */ 25/* Define to 1 if you have the `mysql_real_escape_string' function. */
26#define HAVE_MYSQL_REAL_ESCAPE_STRING 1 26#define HAVE_MYSQL_REAL_ESCAPE_STRING 1
27 27
28/* Define to 1 if you have the <stdint.h> header file. */ 28/* Define to 1 if you have the <stdint.h> header file. */
29#define HAVE_STDINT_H 1 29/* #undef HAVE_STDINT_H */
30 30
31/* Define to 1 if you have the <stdlib.h> header file. */ 31/* Define to 1 if you have the <stdlib.h> header file. */
32#define HAVE_STDLIB_H 1 32/* #undef HAVE_STDLIB_H 1
33 33
34/* Define to 1 if you have the <strings.h> header file. */ 34/* Define to 1 if you have the <strings.h> header file. */
35#define HAVE_STRINGS_H 1 35/* #undef HAVE_STRINGS_H */
36 36
37/* Define to 1 if you have the <string.h> header file. */ 37/* Define to 1 if you have the <string.h> header file. */
38#define HAVE_STRING_H 1 38/* #undef HAVE_STRING_H */
39 39
40/* Define to 1 if you have the <sys/stat.h> header file. */ 40/* Define to 1 if you have the <sys/stat.h> header file. */
41#define HAVE_SYS_STAT_H 1 41/* #undef HAVE_SYS_STAT_H */
42 42
43/* Define to 1 if you have the <sys/types.h> header file. */ 43/* Define to 1 if you have the <sys/types.h> header file. */
44#define HAVE_SYS_TYPES_H 1 44/* #undef HAVE_SYS_TYPES_H */
45 45
46/* Define to 1 if you have the <unistd.h> header file. */ 46/* Define to 1 if you have the <unistd.h> header file. */
47#define HAVE_UNISTD_H 1 47/* #undef HAVE_UNISTD_H */
48 48
49/* Define to the address where bug reports for this package should be sent. */ 49/* Define to the address where bug reports for this package should be sent. */
50#define PACKAGE_BUGREPORT "" 50#define PACKAGE_BUGREPORT ""
@@ -65,7 +65,7 @@
65/* #undef STDC_HEADERS */ 65/* #undef STDC_HEADERS */
66 66
67/* Define if we want to compile in SSL support. */ 67/* Define if we want to compile in SSL support. */
68#define WANT_SSL_LOGGING 68/* #undef WANT_SSL_LOGGING */
69 69
70/* Define to 1 if we are compiling with Apache 1.3.x */ 70/* Define to 1 if we are compiling with Apache 1.3.x */
71/* #undef WITH_APACHE13 */ 71/* #undef WITH_APACHE13 */
@@ -75,3 +75,4 @@
75 75
76/* Define to 1 if we are compiling with mysql */ 76/* Define to 1 if we are compiling with mysql */
77#define WITH_MYSQL 1 77#define WITH_MYSQL 1
78