35#define APR_WANT_STRFUNC
52#define INTYPE_ALL (char *)1
54#define OUTTYPE_UNCHANGED (char *)1
70#if APR_FILES_AS_SOCKETS
75module AP_MODULE_DECLARE_DATA ext_filter_module;
83#define ERRFN_USERDATA_KEY "EXTFILTCHILDERRFN"
110 if (
over->log_stderr != -1) {
111 a->log_stderr =
over->log_stderr;
114 a->log_stderr =
base->log_stderr;
117 if (
over->onfail != -1) {
118 a->onfail =
over->onfail;
121 a->onfail =
base->onfail;
146 "Invalid ExtFilterOptions option: ",
168 else if (**
args ==
'\\') {
174 return "Expected cmd= delimiter";
183 return "cmd= parse error";
194 if (!filter->
args[0]) {
195 return "Invalid cmd= parameter";
213 return "Filter name not found";
232 filter->
mode = OUTPUT_FILTER;
247 if (!
strcasecmp(token,
"preservescontentlength")) {
252 "mangled argument `%s'",
262 filter->
mode = OUTPUT_FILTER;
265 filter->
mode = INPUT_FILTER;
321 if (filter->
mode == OUTPUT_FILTER) {
325 else if (filter->
mode == INPUT_FILTER) {
342 "valid options: LogStderr, NoLogStderr"),
347 "Define an external filter"),
365#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \
366 defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
375#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
406 "[%s] [client %s] mod_ext_filter (%d)%pm: %s\n",
422 const char *
const *
env;
440 f->r->server->error_log,
460 apr_table_setn(
f->r->subprocess_env,
"DOCUMENT_PATH_INFO",
f->r->path_info);
470 f->r->subprocess_env);
473 ctx->filter->command,
474 (
const char *
const *)
ctx->filter->args,
480 "couldn't create child process to run `%s'",
481 ctx->filter->command);
497#if APR_FILES_AS_SOCKETS
524 "NoLogStderr" :
"LogStderr";
526 "PreservesContentLength" :
"!PreserveContentLength";
530 "(unchanged)" : filter->
outtype;
533 "ExtFilterOptions %s %s ExtFilterInType %s "
534 "ExtFilterOuttype %s",
568 "couldn't find definition of filter '%s'",
573 if (
ctx->filter->intype &&
577 if (
ctx->filter->mode == INPUT_FILTER) {
596 if (
ctx->filter->enable_env &&
601 if (
ctx->filter->disable_env &&
611 if (
ctx->filter->outtype &&
615 if (
ctx->filter->preserves_content_length != 1) {
624 "%sfiltering `%s' of type `%s' through `%s', cfg %s",
625 ctx->noop ?
"NOT " :
"",
626 f->r->uri ?
f->r->uri :
f->r->filename,
627 f->r->content_type ?
f->r->content_type :
"(unspecified)",
628 ctx->filter->command,
699#if APR_FILES_AS_SOCKETS
707 "apr_pollset_poll()");
712 "apr_pollset_poll()");
790 "apr_file_close(child input)");
800 "apr_file_pipe_timeout_set(child output)");
850 "can't initialise output filter %s: %s",
852 (
ctx->dc->onfail == 1) ?
"removing" :
"aborting");
854 if (
ctx->dc->onfail == 1) {
859 f->r->status_line =
"500 Internal Server Error";
882 "ef_unified_filter() failed");
887 "ap_pass_brigade() failed");
908 "can't initialise input filter %s: %s",
910 (
ctx->dc->onfail == 1) ?
"removing" :
"aborting");
912 if (
ctx->dc->onfail == 1) {
const char apr_size_t len
APR-UTIL Buckets/Bucket Brigades.
APR general purpose library routines.
APR Standard Headers Support.
#define ap_get_module_config(v, m)
void ap_hook_post_config(ap_HOOK_post_config_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
#define AP_DECLARE_MODULE(foo)
#define AP_INIT_ITERATE(directive, func, mconfig, where, help)
#define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help)
void ap_remove_input_filter(ap_filter_t *f)
apr_status_t ap_pass_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket)
ap_filter_rec_t * ap_register_output_filter(const char *name, ap_out_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype)
apr_status_t ap_filter_rec_t * ap_register_input_filter(const char *name, ap_in_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype)
apr_status_t ap_get_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
void ap_remove_output_filter(ap_filter_t *f)
#define ap_get_core_module_config(v)
const unsigned char * buf
void ap_set_content_type(request_rec *r, const char *ct)
#define AP_BUCKET_IS_ERROR(e)
apr_bucket * ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list)
void ap_add_common_vars(request_rec *r)
char ** ap_create_environment(apr_pool_t *p, apr_table_t *t)
void ap_add_cgi_vars(request_rec *r)
apr_status_t ap_recent_ctime(char *date_str, apr_time_t t)
#define APR_STATUS_IS_EINTR(s)
#define APR_STATUS_IS_EAGAIN(s)
#define APR_STATUS_IS_EOF(s)
#define APR_BRIGADE_INSERT_TAIL(b, e)
apr_file_t apr_off_t start
#define APR_BUCKET_NEXT(e)
#define APR_BRIGADE_CONCAT(a, b)
#define APR_BRIGADE_SENTINEL(b)
#define APR_BUCKET_IS_EOS(e)
apr_brigade_flush void * ctx
#define apr_bucket_copy(e, c)
apr_bucket apr_bucket_brigade * a
#define APR_BRIGADE_FIRST(b)
#define apr_bucket_read(e, str, len, block)
apr_dbd_transaction_t int mode
#define HTTP_INTERNAL_SERVER_ERROR
#define STANDARD20_MODULE_STUFF
char * ap_getword_white(apr_pool_t *p, const char **line)
char * ap_getword(apr_pool_t *p, const char **line, char stop)
char * ap_escape_shell_cmd(apr_pool_t *p, const char *s)
#define AP_DEBUG_ASSERT(exp)
void ap_str_tolower(char *s)
int ap_unescape_url(char *url)
const char int apr_pool_t * pool
const void apr_size_t apr_size_t * bytes_written
int strcasecmp(const char *a, const char *b)
int strncasecmp(const char *a, const char *b, size_t n)
#define APR_HASH_KEY_STRING
apr_vformatter_buff_t * c
char const *const char const *const ** env
#define apr_pcalloc(p, size)
apr_int32_t apr_int32_t apr_int32_t err
const char const char *const * args
#define apr_time_from_msec(msec)
static apr_file_t * stderr_log
static const server_rec * main_server
#define ERRFN_USERDATA_KEY
static const char * parse_cmd(apr_pool_t *p, const char **args, ef_filter_t *filter)
static apr_status_t set_resource_limits(request_rec *r, apr_procattr_t *procattr)
static void * merge_ef_dir_conf(apr_pool_t *p, void *basev, void *overridesv)
static const char * add_options(cmd_parms *cmd, void *in_dc, const char *arg)
static apr_status_t init_ext_filter_process(ap_filter_t *f)
static const char * define_filter(cmd_parms *cmd, void *dummy, const char *args)
static void * create_ef_dir_conf(apr_pool_t *p, char *dummy)
static ef_filter_t * find_filter_def(const server_rec *s, const char *fname)
static apr_status_t ef_input_filter(ap_filter_t *, apr_bucket_brigade *, ap_input_mode_t, apr_read_type_e, apr_off_t)
static void register_hooks(apr_pool_t *p)
static int ef_unified_filter(ap_filter_t *f, apr_bucket_brigade *bb)
static void child_errfn(apr_pool_t *pool, apr_status_t err, const char *description)
static apr_status_t ef_close_file(void *vfile)
static apr_status_t ef_output_filter(ap_filter_t *, apr_bucket_brigade *)
#define OUTTYPE_UNCHANGED
static apr_status_t drain_available_output(ap_filter_t *f, apr_bucket_brigade *bb)
static void * create_ef_server_conf(apr_pool_t *p, server_rec *s)
static const command_rec cmds[]
static apr_status_t pass_data_to_filter(ap_filter_t *f, const char *data, apr_size_t len, apr_bucket_brigade *bb)
static const char * get_cfg_string(ef_dir_t *dc, ef_filter_t *filter, apr_pool_t *p)
static apr_status_t init_filter_instance(ap_filter_t *f)
static int ef_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *main_s)
The representation of a filter chain.
apr_interval_time_t timeout
Structure to store things which are per connection.
Per-directory configuration.
apr_procattr_t * procattr
int preserves_content_length
enum ef_filter_t::@15 mode
A structure that represents the current request.
struct ap_conf_vector_t * per_dir_config
A structure to store information for each virtual server.
apr_interval_time_t timeout
static apr_pollset_t * pollset
ap_input_mode_t
input filtering modes
Apache date-time handling functions.