1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * mod_ext_filter allows Unix-style filters to filter http content.
22 #include "http_config.h"
24 #include "http_protocol.h"
26 #include "http_core.h"
27 #include "apr_buckets.h"
28 #include "util_filter.h"
29 #include "util_script.h"
30 #include "util_time.h"
31 #include "apr_strings.h"
35 #define APR_WANT_STRFUNC
38 typedef struct ef_server_t {
43 typedef struct ef_filter_t {
45 enum {INPUT_FILTER=1, OUTPUT_FILTER} mode;
48 const char *enable_env;
49 const char *disable_env;
51 const char *intype; /* list of IMTs we process (well, just one for now) */
52 #define INTYPE_ALL (char *)1
53 const char *outtype; /* IMT of filtered output */
54 #define OUTTYPE_UNCHANGED (char *)1
55 int preserves_content_length;
58 typedef struct ef_dir_t {
63 typedef struct ef_ctx_t {
66 apr_procattr_t *procattr;
70 #if APR_FILES_AS_SOCKETS
71 apr_pollset_t *pollset;
75 module AP_MODULE_DECLARE_DATA ext_filter_module;
76 static const server_rec *main_server;
78 static apr_status_t ef_output_filter(ap_filter_t *, apr_bucket_brigade *);
79 static apr_status_t ef_input_filter(ap_filter_t *, apr_bucket_brigade *,
80 ap_input_mode_t, apr_read_type_e,
83 #define DBGLVL_SHOWOPTIONS 1
84 #define DBGLVL_ERRORCHECK 2
87 #define ERRFN_USERDATA_KEY "EXTFILTCHILDERRFN"
89 static void *create_ef_dir_conf(apr_pool_t *p, char *dummy)
91 ef_dir_t *dc = (ef_dir_t *)apr_pcalloc(p, sizeof(ef_dir_t));
99 static void *create_ef_server_conf(apr_pool_t *p, server_rec *s)
103 conf = (ef_server_t *)apr_pcalloc(p, sizeof(ef_server_t));
105 conf->h = apr_hash_make(conf->p);
109 static void *merge_ef_dir_conf(apr_pool_t *p, void *basev, void *overridesv)
111 ef_dir_t *a = (ef_dir_t *)apr_pcalloc (p, sizeof(ef_dir_t));
112 ef_dir_t *base = (ef_dir_t *)basev, *over = (ef_dir_t *)overridesv;
114 if (over->debug != -1) { /* if admin coded something... */
115 a->debug = over->debug;
118 a->debug = base->debug;
121 if (over->log_stderr != -1) { /* if admin coded something... */
122 a->log_stderr = over->log_stderr;
125 a->log_stderr = base->log_stderr;
131 static const char *add_options(cmd_parms *cmd, void *in_dc,
134 ef_dir_t *dc = in_dc;
136 if (!strncasecmp(arg, "DebugLevel=", 11)) {
137 dc->debug = atoi(arg + 11);
139 else if (!strcasecmp(arg, "LogStderr")) {
142 else if (!strcasecmp(arg, "NoLogStderr")) {
146 return apr_pstrcat(cmd->temp_pool,
147 "Invalid ExtFilterOptions option: ",
155 static const char *parse_cmd(apr_pool_t *p, const char **args, ef_filter_t *filter)
158 const char *start = *args + 1;
163 ++*args; /* move past leading " */
164 /* find true end of args string (accounting for escaped quotes) */
165 while (**args && (**args != '"' || (**args == '"' && escaping))) {
169 else if (**args == '\\') {
175 return "Expected cmd= delimiter";
177 /* copy *just* the arg string for parsing, */
178 parms = apr_pstrndup(p, start, *args - start);
179 ++*args; /* move past trailing " */
181 /* parse and tokenize the args. */
182 rv = apr_tokenize_to_argv(parms, &(filter->args), p);
183 if (rv != APR_SUCCESS) {
184 return "cmd= parse error";
190 /* Allocate space for two argv pointers and parse the args. */
191 filter->args = (char **)apr_palloc(p, 2 * sizeof(char *));
192 filter->args[0] = ap_getword_white(p, args);
193 filter->args[1] = NULL; /* end of args */
195 if (!filter->args[0]) {
196 return "Invalid cmd= parameter";
198 filter->command = filter->args[0];
203 static const char *define_filter(cmd_parms *cmd, void *dummy, const char *args)
205 ef_server_t *conf = ap_get_module_config(cmd->server->module_config,
209 char *normalized_name;
212 name = ap_getword_white(cmd->pool, &args);
214 return "Filter name not found";
217 /* During request processing, we find information about the filter
218 * by looking up the filter name provided by core server in our
219 * hash table. But the core server has normalized the filter
220 * name by converting it to lower case. Thus, when adding the
221 * filter to our hash table we have to use lower case as well.
223 normalized_name = apr_pstrdup(cmd->pool, name);
224 ap_str_tolower(normalized_name);
226 if (apr_hash_get(conf->h, normalized_name, APR_HASH_KEY_STRING)) {
227 return apr_psprintf(cmd->pool, "ExtFilter %s is already defined",
231 filter = (ef_filter_t *)apr_pcalloc(conf->p, sizeof(ef_filter_t));
233 filter->mode = OUTPUT_FILTER;
234 filter->ftype = AP_FTYPE_RESOURCE;
235 apr_hash_set(conf->h, normalized_name, APR_HASH_KEY_STRING, filter);
238 while (apr_isspace(*args)) {
242 /* Nasty parsing... I wish I could simply use ap_getword_white()
243 * here and then look at the token, but ap_getword_white() doesn't
244 * do the right thing when we have cmd="word word word"
246 if (!strncasecmp(args, "preservescontentlength", 22)) {
247 token = ap_getword_white(cmd->pool, &args);
248 if (!strcasecmp(token, "preservescontentlength")) {
249 filter->preserves_content_length = 1;
252 return apr_psprintf(cmd->pool,
253 "mangled argument `%s'",
259 if (!strncasecmp(args, "mode=", 5)) {
261 token = ap_getword_white(cmd->pool, &args);
262 if (!strcasecmp(token, "output")) {
263 filter->mode = OUTPUT_FILTER;
265 else if (!strcasecmp(token, "input")) {
266 filter->mode = INPUT_FILTER;
269 return apr_psprintf(cmd->pool, "Invalid mode: `%s'",
275 if (!strncasecmp(args, "ftype=", 6)) {
277 token = ap_getword_white(cmd->pool, &args);
278 filter->ftype = atoi(token);
282 if (!strncasecmp(args, "enableenv=", 10)) {
284 token = ap_getword_white(cmd->pool, &args);
285 filter->enable_env = token;
289 if (!strncasecmp(args, "disableenv=", 11)) {
291 token = ap_getword_white(cmd->pool, &args);
292 filter->disable_env = token;
296 if (!strncasecmp(args, "intype=", 7)) {
298 filter->intype = ap_getword_white(cmd->pool, &args);
302 if (!strncasecmp(args, "outtype=", 8)) {
304 filter->outtype = ap_getword_white(cmd->pool, &args);
308 if (!strncasecmp(args, "cmd=", 4)) {
310 if ((token = parse_cmd(cmd->pool, &args, filter))) {
316 return apr_psprintf(cmd->pool, "Unexpected parameter: `%s'",
320 /* parsing is done... register the filter
322 if (filter->mode == OUTPUT_FILTER) {
323 /* XXX need a way to ensure uniqueness among all filters */
324 ap_register_output_filter(filter->name, ef_output_filter, NULL, filter->ftype);
326 else if (filter->mode == INPUT_FILTER) {
327 /* XXX need a way to ensure uniqueness among all filters */
328 ap_register_input_filter(filter->name, ef_input_filter, NULL, filter->ftype);
331 ap_assert(1 != 1); /* we set the field wrong somehow */
337 static const command_rec cmds[] =
339 AP_INIT_ITERATE("ExtFilterOptions",
342 ACCESS_CONF, /* same as SetInputFilter/SetOutputFilter */
343 "valid options: DebugLevel=n, LogStderr, NoLogStderr"),
344 AP_INIT_RAW_ARGS("ExtFilterDefine",
348 "Define an external filter"),
352 static int ef_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *main_s)
354 main_server = main_s;
358 static void register_hooks(apr_pool_t *p)
360 ap_hook_post_config(ef_init, NULL, NULL, APR_HOOK_MIDDLE);
363 static apr_status_t set_resource_limits(request_rec *r,
364 apr_procattr_t *procattr)
366 #if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \
367 defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
368 core_dir_config *conf =
369 (core_dir_config *)ap_get_module_config(r->per_dir_config,
374 rv = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, conf->limit_cpu);
375 ap_assert(rv == APR_SUCCESS); /* otherwise, we're out of sync with APR */
377 #if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
378 rv = apr_procattr_limit_set(procattr, APR_LIMIT_MEM, conf->limit_mem);
379 ap_assert(rv == APR_SUCCESS); /* otherwise, we're out of sync with APR */
382 rv = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC, conf->limit_nproc);
383 ap_assert(rv == APR_SUCCESS); /* otherwise, we're out of sync with APR */
386 #endif /* if at least one limit defined */
391 static apr_status_t ef_close_file(void *vfile)
393 return apr_file_close(vfile);
396 static void child_errfn(apr_pool_t *pool, apr_status_t err, const char *description)
400 apr_file_t *stderr_log;
402 char time_str[APR_CTIME_LEN];
404 apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, pool);
406 apr_file_open_stderr(&stderr_log, pool);
407 ap_recent_ctime(time_str, apr_time_now());
408 apr_file_printf(stderr_log,
409 "[%s] [client %s] mod_ext_filter (%d)%s: %s\n",
411 r->connection->remote_ip,
413 apr_strerror(err, errbuf, sizeof(errbuf)),
417 /* init_ext_filter_process: get the external filter process going
418 * This is per-filter-instance (i.e., per-request) initialization.
420 static apr_status_t init_ext_filter_process(ap_filter_t *f)
422 ef_ctx_t *ctx = f->ctx;
424 ef_dir_t *dc = ctx->dc;
425 const char * const *env;
427 ctx->proc = apr_pcalloc(ctx->p, sizeof(*ctx->proc));
429 rc = apr_procattr_create(&ctx->procattr, ctx->p);
430 ap_assert(rc == APR_SUCCESS);
432 rc = apr_procattr_io_set(ctx->procattr,
436 ap_assert(rc == APR_SUCCESS);
438 rc = set_resource_limits(f->r, ctx->procattr);
439 ap_assert(rc == APR_SUCCESS);
441 if (dc->log_stderr > 0) {
442 rc = apr_procattr_child_err_set(ctx->procattr,
443 f->r->server->error_log, /* stderr in child */
445 ap_assert(rc == APR_SUCCESS);
448 rc = apr_procattr_child_errfn_set(ctx->procattr, child_errfn);
449 ap_assert(rc == APR_SUCCESS);
450 apr_pool_userdata_set(f->r, ERRFN_USERDATA_KEY, apr_pool_cleanup_null, ctx->p);
452 if (dc->debug >= DBGLVL_ERRORCHECK) {
453 rc = apr_procattr_error_check_set(ctx->procattr, 1);
454 ap_assert(rc == APR_SUCCESS);
457 /* add standard CGI variables as well as DOCUMENT_URI, DOCUMENT_PATH_INFO,
458 * and QUERY_STRING_UNESCAPED
460 ap_add_cgi_vars(f->r);
461 ap_add_common_vars(f->r);
462 apr_table_setn(f->r->subprocess_env, "DOCUMENT_URI", f->r->uri);
463 apr_table_setn(f->r->subprocess_env, "DOCUMENT_PATH_INFO", f->r->path_info);
465 /* QUERY_STRING is added by ap_add_cgi_vars */
466 char *arg_copy = apr_pstrdup(f->r->pool, f->r->args);
467 ap_unescape_url(arg_copy);
468 apr_table_setn(f->r->subprocess_env, "QUERY_STRING_UNESCAPED",
469 ap_escape_shell_cmd(f->r->pool, arg_copy));
472 env = (const char * const *) ap_create_environment(ctx->p,
473 f->r->subprocess_env);
475 rc = apr_proc_create(ctx->proc,
476 ctx->filter->command,
477 (const char * const *)ctx->filter->args,
478 env, /* environment */
481 if (rc != APR_SUCCESS) {
482 ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, f->r,
483 "couldn't create child process to run `%s'",
484 ctx->filter->command);
488 apr_pool_note_subprocess(ctx->p, ctx->proc, APR_KILL_AFTER_TIMEOUT);
490 /* We don't want the handle to the child's stdin inherited by any
491 * other processes created by httpd. Otherwise, when we close our
492 * handle, the child won't see EOF because another handle will still
496 apr_pool_cleanup_register(ctx->p, ctx->proc->in,
497 apr_pool_cleanup_null, /* other mechanism */
500 #if APR_FILES_AS_SOCKETS
502 apr_pollfd_t pfd = { 0 };
504 rc = apr_pollset_create(&ctx->pollset, 2, ctx->p, 0);
505 ap_assert(rc == APR_SUCCESS);
508 pfd.desc_type = APR_POLL_FILE;
509 pfd.reqevents = APR_POLLOUT;
510 pfd.desc.f = ctx->proc->in;
511 rc = apr_pollset_add(ctx->pollset, &pfd);
512 ap_assert(rc == APR_SUCCESS);
514 pfd.reqevents = APR_POLLIN;
515 pfd.desc.f = ctx->proc->out;
516 rc = apr_pollset_add(ctx->pollset, &pfd);
517 ap_assert(rc == APR_SUCCESS);
524 static const char *get_cfg_string(ef_dir_t *dc, ef_filter_t *filter, apr_pool_t *p)
526 const char *debug_str = dc->debug == -1 ?
527 "DebugLevel=0" : apr_psprintf(p, "DebugLevel=%d", dc->debug);
528 const char *log_stderr_str = dc->log_stderr < 1 ?
529 "NoLogStderr" : "LogStderr";
530 const char *preserve_content_length_str = filter->preserves_content_length ?
531 "PreservesContentLength" : "!PreserveContentLength";
532 const char *intype_str = !filter->intype ?
533 "*/*" : filter->intype;
534 const char *outtype_str = !filter->outtype ?
535 "(unchanged)" : filter->outtype;
537 return apr_psprintf(p,
538 "ExtFilterOptions %s %s %s ExtFilterInType %s "
539 "ExtFilterOuttype %s",
540 debug_str, log_stderr_str, preserve_content_length_str,
541 intype_str, outtype_str);
544 static ef_filter_t *find_filter_def(const server_rec *s, const char *fname)
549 sc = ap_get_module_config(s->module_config, &ext_filter_module);
550 f = apr_hash_get(sc->h, fname, APR_HASH_KEY_STRING);
551 if (!f && s != main_server) {
553 sc = ap_get_module_config(s->module_config, &ext_filter_module);
554 f = apr_hash_get(sc->h, fname, APR_HASH_KEY_STRING);
559 static apr_status_t init_filter_instance(ap_filter_t *f)
565 f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(ef_ctx_t));
566 dc = ap_get_module_config(f->r->per_dir_config,
569 /* look for the user-defined filter */
570 ctx->filter = find_filter_def(f->r->server, f->frec->name);
572 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, f->r,
573 "couldn't find definition of filter '%s'",
578 if (ctx->filter->intype &&
579 ctx->filter->intype != INTYPE_ALL) {
582 if (ctx->filter->mode == INPUT_FILTER) {
583 ctypes = apr_table_get(f->r->headers_in, "Content-Type");
586 ctypes = f->r->content_type;
590 const char *ctype = ap_getword(f->r->pool, &ctypes, ';');
592 if (strcasecmp(ctx->filter->intype, ctype)) {
593 /* wrong IMT for us; don't mess with the output */
601 if (ctx->filter->enable_env &&
602 !apr_table_get(f->r->subprocess_env, ctx->filter->enable_env)) {
603 /* an environment variable that enables the filter isn't set; bail */
606 if (ctx->filter->disable_env &&
607 apr_table_get(f->r->subprocess_env, ctx->filter->disable_env)) {
608 /* an environment variable that disables the filter is set; bail */
612 rv = init_ext_filter_process(f);
613 if (rv != APR_SUCCESS) {
616 if (ctx->filter->outtype &&
617 ctx->filter->outtype != OUTTYPE_UNCHANGED) {
618 ap_set_content_type(f->r, ctx->filter->outtype);
620 if (ctx->filter->preserves_content_length != 1) {
621 /* nasty, but needed to avoid confusing the browser
623 apr_table_unset(f->r->headers_out, "Content-Length");
627 if (dc->debug >= DBGLVL_SHOWOPTIONS) {
628 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r,
629 "%sfiltering `%s' of type `%s' through `%s', cfg %s",
630 ctx->noop ? "NOT " : "",
631 f->r->uri ? f->r->uri : f->r->filename,
632 f->r->content_type ? f->r->content_type : "(unspecified)",
633 ctx->filter->command,
634 get_cfg_string(dc, ctx->filter, f->r->pool));
640 /* drain_available_output():
642 * if any data is available from the filter, read it and append it
643 * to the the bucket brigade
645 static apr_status_t drain_available_output(ap_filter_t *f,
646 apr_bucket_brigade *bb)
648 request_rec *r = f->r;
649 conn_rec *c = r->connection;
650 ef_ctx_t *ctx = f->ctx;
651 ef_dir_t *dc = ctx->dc;
659 rv = apr_file_read(ctx->proc->out,
662 if ((rv && !APR_STATUS_IS_EAGAIN(rv)) ||
663 dc->debug >= DBGLVL_GORY) {
664 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r,
665 "apr_file_read(child output), len %" APR_SIZE_T_FMT,
668 if (rv != APR_SUCCESS) {
671 b = apr_bucket_heap_create(buf, len, NULL, c->bucket_alloc);
672 APR_BRIGADE_INSERT_TAIL(bb, b);
675 /* we should never get here; if we do, a bogus error message would be
676 * the least of our problems
678 return APR_ANONYMOUS;
681 static apr_status_t pass_data_to_filter(ap_filter_t *f, const char *data,
682 apr_size_t len, apr_bucket_brigade *bb)
684 ef_ctx_t *ctx = f->ctx;
685 ef_dir_t *dc = ctx->dc;
687 apr_size_t bytes_written = 0;
691 tmplen = len - bytes_written;
692 rv = apr_file_write(ctx->proc->in,
693 (const char *)data + bytes_written,
695 bytes_written += tmplen;
696 if (rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv)) {
697 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r,
698 "apr_file_write(child input), len %" APR_SIZE_T_FMT,
702 if (APR_STATUS_IS_EAGAIN(rv)) {
703 /* XXX handle blocking conditions here... if we block, we need
704 * to read data from the child process and pass it down to the
707 rv = drain_available_output(f, bb);
708 if (APR_STATUS_IS_EAGAIN(rv)) {
709 #if APR_FILES_AS_SOCKETS
711 const apr_pollfd_t *pdesc;
713 rv = apr_pollset_poll(ctx->pollset, f->r->server->timeout,
714 &num_events, &pdesc);
715 if (rv || dc->debug >= DBGLVL_GORY) {
716 ap_log_rerror(APLOG_MARK, APLOG_DEBUG,
717 rv, f->r, "apr_pollset_poll()");
719 if (rv != APR_SUCCESS && !APR_STATUS_IS_EINTR(rv)) {
720 /* some error such as APR_TIMEUP */
723 #else /* APR_FILES_AS_SOCKETS */
724 /* Yuck... I'd really like to wait until I can read
725 * or write, but instead I have to sleep and try again
727 apr_sleep(100000); /* 100 milliseconds */
728 if (dc->debug >= DBGLVL_GORY) {
729 ap_log_rerror(APLOG_MARK, APLOG_DEBUG,
730 0, f->r, "apr_sleep()");
732 #endif /* APR_FILES_AS_SOCKETS */
734 else if (rv != APR_SUCCESS) {
738 } while (bytes_written < len);
742 /* ef_unified_filter:
744 * runs the bucket brigade bb through the filter and puts the result into
745 * bb, dropping the previous content of bb (the input)
748 static int ef_unified_filter(ap_filter_t *f, apr_bucket_brigade *bb)
750 request_rec *r = f->r;
751 conn_rec *c = r->connection;
752 ef_ctx_t *ctx = f->ctx;
759 apr_bucket *eos = NULL;
760 apr_bucket_brigade *bb_tmp;
763 bb_tmp = apr_brigade_create(r->pool, c->bucket_alloc);
765 for (b = APR_BRIGADE_FIRST(bb);
766 b != APR_BRIGADE_SENTINEL(bb);
767 b = APR_BUCKET_NEXT(b))
769 if (APR_BUCKET_IS_EOS(b)) {
774 rv = apr_bucket_read(b, &data, &len, APR_BLOCK_READ);
775 if (rv != APR_SUCCESS) {
776 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "apr_bucket_read()");
780 /* Good cast, we just tested len isn't negative */
782 (rv = pass_data_to_filter(f, data, (apr_size_t)len, bb_tmp))
788 apr_brigade_cleanup(bb);
789 APR_BRIGADE_CONCAT(bb, bb_tmp);
790 apr_brigade_destroy(bb_tmp);
793 /* close the child's stdin to signal that no more data is coming;
794 * that will cause the child to finish generating output
796 if ((rv = apr_file_close(ctx->proc->in)) != APR_SUCCESS) {
797 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
798 "apr_file_close(child input)");
801 /* since we've seen eos and closed the child's stdin, set the proper pipe
802 * timeout; we don't care if we don't return from apr_file_read() for a while...
804 rv = apr_file_pipe_timeout_set(ctx->proc->out,
807 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
808 "apr_file_pipe_timeout_set(child output)");
815 rv = apr_file_read(ctx->proc->out,
818 if ((rv && !APR_STATUS_IS_EOF(rv) && !APR_STATUS_IS_EAGAIN(rv)) ||
819 dc->debug >= DBGLVL_GORY) {
820 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r,
821 "apr_file_read(child output), len %" APR_SIZE_T_FMT,
824 if (APR_STATUS_IS_EAGAIN(rv)) {
826 /* should not occur, because we have an APR timeout in place */
827 AP_DEBUG_ASSERT(1 != 1);
832 if (rv == APR_SUCCESS) {
833 b = apr_bucket_heap_create(buf, len, NULL, c->bucket_alloc);
834 APR_BRIGADE_INSERT_TAIL(bb, b);
836 } while (rv == APR_SUCCESS);
838 if (!APR_STATUS_IS_EOF(rv)) {
843 b = apr_bucket_eos_create(c->bucket_alloc);
844 APR_BRIGADE_INSERT_TAIL(bb, b);
850 static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
852 request_rec *r = f->r;
853 ef_ctx_t *ctx = f->ctx;
857 if ((rv = init_filter_instance(f)) != APR_SUCCESS) {
863 ap_remove_output_filter(f);
864 return ap_pass_brigade(f->next, bb);
867 rv = ef_unified_filter(f, bb);
868 if (rv != APR_SUCCESS) {
869 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
870 "ef_unified_filter() failed");
873 if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) {
874 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
875 "ap_pass_brigade() failed");
880 static int ef_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
881 ap_input_mode_t mode, apr_read_type_e block,
884 ef_ctx_t *ctx = f->ctx;
888 if ((rv = init_filter_instance(f)) != APR_SUCCESS) {
895 ap_remove_input_filter(f);
896 return ap_get_brigade(f->next, bb, mode, block, readbytes);
899 rv = ap_get_brigade(f->next, bb, mode, block, readbytes);
900 if (rv != APR_SUCCESS) {
904 rv = ef_unified_filter(f, bb);
908 module AP_MODULE_DECLARE_DATA ext_filter_module =
910 STANDARD20_MODULE_STUFF,
913 create_ef_server_conf,