1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
$NetBSD: patch-af,v 1.1.1.1 1999/07/23 17:53:30 itojun Exp $
--- src/modules/standard/mod_include.c.orig Thu Sep 24 10:06:42 1998
+++ src/modules/standard/mod_include.c Mon Dec 7 11:17:39 1998
@@ -92,7 +92,11 @@
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
+#include "ap_include_extern.h"
+#include "ap_hook.h"
#endif
+#define get_tag ap_include_get_tag
+#define parse_string ap_include_parse_string
#define STARTING_SEQUENCE "<!--#"
#define ENDING_SEQUENCE "-->"
@@ -354,7 +358,8 @@
* the tag value is html decoded if dodecode is non-zero
*/
-static char *get_tag(pool *p, FILE *in, char *tag, int tagbuf_len, int dodecode)
+API_EXPORT(char *)
+ap_include_get_tag(pool *p, FILE *in, char *tag, int tagbuf_len, int dodecode)
{
char *t = tag, *tag_val, c, term;
@@ -473,7 +478,7 @@
/*
* 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;
@@ -666,7 +671,8 @@
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";
}
@@ -1010,7 +1016,8 @@
int ret=0;
if (!strcmp(tag, "file")) {
- 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);
@@ -2090,6 +2097,16 @@
}
}
+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 --------------------------- */
@@ -2214,6 +2231,13 @@
}
#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,
"httpd: unknown directive \"%s\" "
"in parsed doc %s",
|