1
2 #include "httpd.h"
3 #include "http_config.h"
4 #include "http_core.h"
5 #include "http_log.h"
6 #include "http_request.h"
7 #include "util_filter.h"
8 #include <ctype.h>
9 #include "util_md5.h"
10
11 /* there seems to be no function protoype for this */
12 const char *ap_run_http_scheme(const request_rec *r);
13 /* ridiculous prototype for AP_DECLARE_HOOK entries */
14 void ap_hook_check_user_id(int (*)(request_rec *),
15 const char * const *,
16 const char * const *,
17 int);
18
19 /* there seems to be no function protoype for this */
20 const char *ap_run_http_scheme(const request_rec *r);
21 /* ridiculous prototype for AP_DECLARE_HOOK entries */
22 void ap_hook_check_user_id(int (*)(request_rec *),
23 const char * const *,
24 const char * const *,
25 int);
26
ap_add_input_filter(const char * name,void * ctx,request_rec * r,conn_rec * c)27 AP_DECLARE(ap_filter_t *) ap_add_input_filter(const char *name, void *ctx,
28 request_rec *r, conn_rec *c) {
29
30 return NULL;
31 }
32
ap_auth_type(request_rec * r)33 AP_DECLARE(const char *) ap_auth_type(request_rec *r) {
34 return "CAS";
35 }
36
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)37 AP_DECLARE(apr_status_t) ap_get_brigade(ap_filter_t *filter,
38 apr_bucket_brigade *bucket,
39 ap_input_mode_t mode,
40 apr_read_type_e block,
41 apr_off_t readbytes) {
42 return APR_EGENERAL;
43 }
44
ap_getword(apr_pool_t * p,const char ** line,char stop)45 AP_DECLARE(char *) ap_getword(apr_pool_t *p, const char **line, char stop) {
46
47 return "";
48 }
49
ap_hook_check_user_id(int (* pf)(request_rec *),const char * const * c1,const char * const * c2,int nOrder)50 void ap_hook_check_user_id(int (*pf)(request_rec *),
51 const char * const *c1,
52 const char * const *c2,
53 int nOrder) {
54 return;
55 }
56
ap_is_initial_req(request_rec * r)57 AP_DECLARE(int) ap_is_initial_req(request_rec *r) {
58 return 0;
59 }
60
61 #if MODULE_MAGIC_NUMBER_MAJOR >= 20120211
62
ap_log_error_(const char * file,int line,int module_index,int level,apr_status_t status,const server_rec * s,const char * fmt,...)63 AP_DECLARE(void) ap_log_error_(const char *file, int line, int module_index,
64 int level, apr_status_t status,
65 const server_rec *s, const char *fmt, ...) {
66 }
67
ap_log_rerror_(const char * file,int line,int module_index,int level,apr_status_t status,const request_rec * r,const char * fmt,...)68 AP_DECLARE(void) ap_log_rerror_(const char *file, int line, int module_index,
69 int level, apr_status_t status,
70 const request_rec *r, const char *fmt, ...) {
71 }
72 #else
73
ap_log_error(const char * file,int line,int level,apr_status_t status,const server_rec * s,const char * fmt,...)74 AP_DECLARE(void) ap_log_error(const char *file, int line, int level,
75 apr_status_t status, const server_rec *s,
76 const char *fmt, ...) {
77
78 }
79
ap_log_rerror(const char * file,int line,int level,apr_status_t status,const request_rec * s,const char * fmt,...)80 AP_DECLARE(void) ap_log_rerror(const char *file, int line, int level,
81 apr_status_t status, const request_rec *s,
82 const char *fmt, ...) {
83
84 }
85 #endif
86
ap_md5_binary(apr_pool_t * a,const unsigned char * buf,int len)87 AP_DECLARE(char *) ap_md5_binary(apr_pool_t *a, const unsigned char *buf,
88 int len)
89 {
90
91 return "md5";
92 }
93
94 APR_HOOK_STRUCT(APR_HOOK_LINK(post_config))
95 AP_IMPLEMENT_HOOK_RUN_ALL(int, post_config,
96 (apr_pool_t *pconf, apr_pool_t *plog,
97 apr_pool_t *ptemp, server_rec *s),
98 (pconf, plog, ptemp, s), OK, DECLINED)
99
AP_DECLARE(ap_filter_rec_t *)100 AP_DECLARE(ap_filter_rec_t *) ap_register_input_filter(const char *name,
101 ap_in_filter_func
102 filter_func,
103 ap_init_filter_func
104 filter_init,
105 ap_filter_type ftype) {
106 return NULL;
107 }
108
ap_run_http_scheme(const request_rec * r)109 const char *ap_run_http_scheme(const request_rec *r) {
110 char *rv;
111 apr_pool_userdata_get((void **) &rv, "scheme", r->pool);
112 return (const char *) rv;
113 }
114
ap_set_string_slot(cmd_parms * cmd,void * struct_ptr,const char * arg)115 AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
116 void *struct_ptr,
117 const char *arg) {
118
119 return "";
120 }
121
ap_unescape_url(char * url)122 AP_DECLARE(int) ap_unescape_url(char *url) {
123
124 return 0;
125 }
126
ap_hook_auth_checker(int (* pf)(request_rec *),const char * const * c1,const char * const * c2,int nOrder)127 void ap_hook_auth_checker(int (*pf)(request_rec *),
128 const char * const *c1,
129 const char * const *c2,
130 int nOrder) {
131 }
132
133 /* Perhaps this is the top of a slippery slope, but pulling these in
134 * allowed us to test most of the authz functions fairly thoroughly.
135 */
136 #define apr_isspace(c) (isspace(((unsigned char)(c))))
137
ap_getword_white(apr_pool_t * p,const char ** line)138 AP_DECLARE(char *) ap_getword_white(apr_pool_t *p, const char **line) {
139
140 const char *pos = *line;
141 int len;
142 char *res;
143
144 while (!apr_isspace(*pos) && *pos) {
145 ++pos;
146 }
147
148 len = pos - *line;
149 res = calloc(1, len + 1);
150 memcpy(res, *line, len);
151 res[len] = 0;
152
153 while (apr_isspace(*pos)) {
154 ++pos;
155 }
156
157 *line = pos;
158
159 return res;
160 }
161
substring_conf(apr_pool_t * p,const char * start,int len,char quote)162 static char *substring_conf(apr_pool_t *p, const char *start, int len,
163 char quote)
164 {
165 char *result = calloc(sizeof(char), len + 2);
166 char *resp = result;
167 int i;
168
169 for (i = 0; i < len; ++i) {
170 if (start[i] == '\\' && (start[i + 1] == '\\'
171 || (quote && start[i + 1] == quote)))
172 *resp++ = start[++i];
173 else
174 *resp++ = start[i];
175 }
176
177 *resp++ = '\0';
178 return result;
179 }
180
ap_getword_conf(apr_pool_t * p,const char ** line)181 AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line) {
182
183 const char *str = *line, *strend;
184 char *res;
185 char quote;
186
187 while (*str && apr_isspace(*str))
188 ++str;
189
190 if (!*str) {
191 *line = str;
192 return "";
193 }
194
195 if ((quote = *str) == '"' || quote == '\'') {
196 strend = str + 1;
197 while (*strend && *strend != quote) {
198 if (*strend == '\\' && strend[1] &&
199 (strend[1] == quote || strend[1] == '\\')) {
200 strend += 2;
201 }
202 else {
203 ++strend;
204 }
205 }
206 res = substring_conf(p, str + 1, strend - str - 1, quote);
207
208 if (*strend == quote)
209 ++strend;
210 }
211 else {
212 strend = str;
213 while (*strend && !apr_isspace(*strend))
214 ++strend;
215
216 res = substring_conf(p, str, strend - str, 0);
217 }
218
219 while (*strend && apr_isspace(*strend))
220 ++strend;
221 *line = strend;
222 return res;
223 }
224
225 #if MODULE_MAGIC_NUMBER_MAJOR >= 20120211
226
ap_hook_check_access(ap_HOOK_access_checker_t * pf,const char * const * aszPre,const char * const * aszSucc,int nOrder,int type)227 AP_DECLARE(void) ap_hook_check_access(ap_HOOK_access_checker_t *pf,
228 const char * const *aszPre,
229 const char * const *aszSucc,
230 int nOrder, int type) {
231 }
232
ap_hook_check_authn(ap_HOOK_access_checker_t * pf,const char * const * aszPre,const char * const * aszSucc,int nOrder,int type)233 AP_DECLARE(void) ap_hook_check_authn(ap_HOOK_access_checker_t *pf,
234 const char * const *aszPre,
235 const char * const *aszSucc,
236 int nOrder, int type) {
237 }
238
ap_register_auth_provider(apr_pool_t * pool,const char * provider_group,const char * provider_name,const char * provider_version,const void * provider,int type)239 AP_DECLARE(apr_status_t) ap_register_auth_provider(apr_pool_t *pool,
240 const char *provider_group,
241 const char *provider_name,
242 const char *provider_version,
243 const void *provider,
244 int type) {
245 return APR_SUCCESS;
246 }
247 #else
248
ap_note_auth_failure(request_rec * r)249 AP_DECLARE(void) ap_note_auth_failure(request_rec *r) {
250
251 return;
252 }
253
ap_requires(request_rec * r)254 AP_DECLARE(const apr_array_header_t *) ap_requires(request_rec *r) {
255
256 return NULL;
257 }
258 #endif
259