diff options
author | Edward Rudd | 2004-04-29 21:19:30 +0000 |
---|---|---|
committer | Edward Rudd | 2004-04-29 21:19:30 +0000 |
commit | 7c378cc1fac4e9fec1ca32d8d314ea86761a7404 (patch) | |
tree | bc82e7e864ce3978904bc1cb9d9eb6fa52e95dde /mod_log_sql.c | |
parent | be0fe66bcd84e4660b9dba4c1f1f20a649b66c61 (diff) |
win32 updates and build script
added LogSQLDisablePreserve
set default of preserve file to root_relative logs/mod_log_sql-preserve
Diffstat (limited to 'mod_log_sql.c')
-rw-r--r-- | mod_log_sql.c | 64 |
1 files changed, 55 insertions, 9 deletions
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 | ||
282 | static 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 | |||
275 | static const char *set_logformat_slot(cmd_parms *cmd, | 303 | static 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 "driver://user:password@hostname:port/database"") |
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 | , |