$NetBSD: patch-ae,v 1.8 2008/02/23 05:16:34 obache Exp $ --- src/modules/standard/mod_include.c.orig 2006-07-12 08:16:05.000000000 +0000 +++ src/modules/standard/mod_include.c @@ -51,7 +51,10 @@ #include "http_log.h" #include "http_main.h" #include "util_script.h" +#include "ap_include_extern.h" +#include "ap_hook.h" #endif +#define parse_string ap_include_parse_string #define STARTING_SEQUENCE "" @@ -448,7 +451,8 @@ static int get_directive(FILE *in, char /* * Do variable substitution on strings */ -static void parse_string(request_rec *r, const char *in, char *out, +API_EXPORT(void) +ap_include_parse_string(request_rec *r, const char *in, char *out, size_t length, int leave_name) { char ch; @@ -646,7 +650,8 @@ static int handle_include(FILE *in, requ parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0); if (tag[0] == 'f') { /* be safe; only files in this directory or below allowed */ - if (!is_only_below(parsed_string)) { + if ((ap_allow_options(r) & OPT_INCNOEXEC) && + !is_only_below(parsed_string)) { error_fmt = "unable to include file \"%s\" " "in parsed file %s"; } @@ -1058,7 +1063,8 @@ static int find_file(request_rec *r, con "in parsed file %s"; } else { - ap_getparents(tag_val); /* get rid of any nasties */ + if (ap_allow_options(r) & OPT_INCNOEXEC) + ap_getparents(tag_val); /* get rid of any nasties */ rr = ap_sub_req_lookup_file(tag_val, r); if (rr->status == HTTP_OK && rr->finfo.st_mode != 0) { @@ -2141,6 +2147,16 @@ static int handle_printenv(FILE *in, req } } +API_EXPORT(int) +ap_include_register_extern(const char *cmd, ap_include_extern_func func) { + char cmdbuf[40] = "include::"; + + strncat(cmdbuf, cmd, 30); + ap_hook_configure(cmdbuf, AP_HOOK_SIG5(int,ptr,ptr,ptr,ptr), AP_HOOK_TOPMOST); + ap_hook_register(cmdbuf, func, NULL); + + return 0; +} /* -------------------------- The main function --------------------------- */ @@ -2276,6 +2292,13 @@ static void send_parsed_content(FILE *f, } #endif else { + char cmdbuf[40] = "include::"; + + strncat(cmdbuf, directive, 30); + if ((ap_hook_status(cmdbuf) >= AP_HOOK_STATE_CONFIGURED) && + (ap_hook_call(cmdbuf, &ret, f, r, error, timefmt) == TRUE)) + continue; + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unknown directive \"%s\" " "in parsed doc %s",