| 69 | } |
| 70 | |
| 71 | static int open_log(server_rec *s, apr_pool_t *p) |
| 72 | { |
| 73 | fcfg *cfg = ap_get_module_config(s->module_config, &log_forensic_module); |
| 74 | |
| 75 | if (!cfg->logname || cfg->fd) |
| 76 | return 1; |
| 77 | |
| 78 | if (*cfg->logname == '|') { |
| 79 | piped_log *pl; |
| 80 | const char *pname = ap_server_root_relative(p, cfg->logname + 1); |
| 81 | |
| 82 | pl = ap_open_piped_log(p, pname); |
| 83 | if (pl == NULL) { |
| 84 | ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00650) |
| 85 | "couldn't spawn forensic log pipe %s", cfg->logname); |
| 86 | return 0; |
| 87 | } |
| 88 | cfg->fd = ap_piped_log_write_fd(pl); |
| 89 | } |
| 90 | else { |
| 91 | const char *fname = ap_server_root_relative(p, cfg->logname); |
| 92 | apr_status_t rv; |
| 93 | |
| 94 | if ((rv = apr_file_open(&cfg->fd, fname, |
| 95 | APR_WRITE | APR_APPEND | APR_CREATE, |
| 96 | APR_OS_DEFAULT, p)) != APR_SUCCESS) { |
| 97 | ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00651) |
| 98 | "could not open forensic log file %s.", fname); |
| 99 | return 0; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | return 1; |
| 104 | } |
| 105 | |
| 106 | static int log_init(apr_pool_t *pc, apr_pool_t *p, apr_pool_t *pt, |
| 107 | server_rec *s) |
no test coverage detected