|
Line 0
Link Here
|
|
|
1 |
--- mod_encoding.c.orig 2002-06-11 18:07:14.000000000 +0900 |
| 2 |
+++ mod_encoding.c 2008-08-26 02:25:59.000000000 +0900 |
| 3 |
@@ -1,8 +1,72 @@ |
| 4 |
/* -*- mode: c -*- |
| 5 |
* |
| 6 |
- * $Id: mod_encoding.c,v 1.10 2002/06/11 09:07:14 tai Exp $ |
| 7 |
+ * $Id: mod_encoding.c,v 1.6 2001/12/11 12:55:38 tai Exp $ |
| 8 |
* |
| 9 |
*/ |
| 10 |
+/* |
| 11 |
+ * mod_encoding core module test implementation for Apache2. |
| 12 |
+ * by Kunio Miyamoto (wakatono@todo.gr.jp) |
| 13 |
+ * Original security fix port 2002/06/06 |
| 14 |
+ * by Kunio Miyamoto (wakatono@todo.gr.jp) |
| 15 |
+ * Port new function of 20020611a |
| 16 |
+ * by Kunio Miyamoto (wakatono@todo.gr.jp) |
| 17 |
+ * Port new function of 20020611a |
| 18 |
+ * by Kunio Miyamoto (wakatono@todo.gr.jp) |
| 19 |
+ * Add COPYING statement for redistribute only this code. |
| 20 |
+ * by Kunio Miyamoto (wakatono@todo.gr.jp) |
| 21 |
+ */ |
| 22 |
+/* |
| 23 |
+ |
| 24 |
+ |
| 25 |
+Copyright (c) 2000-2004 |
| 26 |
+Internet Initiative Japan Inc. and Kunio Miyamoto All rights reserved. |
| 27 |
+ |
| 28 |
+Redistribution and use in source and binary forms, with or without |
| 29 |
+modification, are permitted provided that the following conditions |
| 30 |
+are met: |
| 31 |
+ |
| 32 |
+1. Redistributions of source code must retain the above copyright |
| 33 |
+ notice, this list of conditions and the following disclaimer. |
| 34 |
+ |
| 35 |
+2. Redistributions in binary form must reproduce the above copyright |
| 36 |
+ notice, this list of conditions and the following disclaimer in |
| 37 |
+ the documentation and/or other materials provided with the |
| 38 |
+ distribution. |
| 39 |
+ |
| 40 |
+3. All advertising materials mentioning features or use of this |
| 41 |
+ software must display the following acknowledgment: |
| 42 |
+ |
| 43 |
+ This product includes software developed by Internet |
| 44 |
+ Initiative Japan Inc. and Kunio Miyamoto for use in the |
| 45 |
+ mod_encoding module for Apache2. |
| 46 |
+ |
| 47 |
+4. Products derived from this software may not be called "mod_encoding" |
| 48 |
+ nor may "mod_encoding" appear in their names without prior written |
| 49 |
+ permission of Internet Initiative Japan Inc. For written permission, |
| 50 |
+ please contact tai@iij.ad.jp (Taisuke Yamada). |
| 51 |
+ |
| 52 |
+5. Redistributions of any form whatsoever must retain the following |
| 53 |
+ acknowledgment: |
| 54 |
+ |
| 55 |
+ This product includes software developed by Internet |
| 56 |
+ Initiative Japan Inc. and Kunio Miyamoto for use in the |
| 57 |
+ mod_encoding module for Apache2 (http://www.apache.org/). |
| 58 |
+ |
| 59 |
+THIS SOFTWARE IS PROVIDED BY INTERNET INITIATIVE JAPAN INC. AND KUNIO |
| 60 |
+MIYAMOTO ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, |
| 61 |
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 62 |
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 63 |
+INTERNET INITIATIVE JAPAN INC., KUNIO MIYAMOTO OR ITS CONTRIBUTORS |
| 64 |
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
| 65 |
+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 66 |
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 67 |
+BUSINESS INTERRUPTION) |
| 68 |
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 69 |
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 70 |
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 71 |
+OF THE POSSIBILITY OF SUCH DAMAGE. |
| 72 |
+ |
| 73 |
+*/ |
| 74 |
|
| 75 |
#include <httpd.h> |
| 76 |
#include <http_config.h> |
| 77 |
@@ -10,8 +74,10 @@ |
| 78 |
#include <http_log.h> |
| 79 |
#include <http_protocol.h> |
| 80 |
#include <http_request.h> |
| 81 |
+/* #include <ap_compat.h> */ |
| 82 |
|
| 83 |
#include <iconv.h> |
| 84 |
+#include <ap_regex.h> |
| 85 |
|
| 86 |
/** |
| 87 |
* Core part of the module. |
| 88 |
@@ -33,13 +99,7 @@ |
| 89 |
|
| 90 |
#define DBG(expr) if (MOD_ENCODING_DEBUG) { expr; } |
| 91 |
|
| 92 |
-#ifdef __GNUC__ |
| 93 |
-#define LOG(level, server, args...) \ |
| 94 |
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|level, server, ##args) |
| 95 |
-#else |
| 96 |
-#define LOG(level, server, ...) \ |
| 97 |
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|level, server, __VA_ARGS__) |
| 98 |
-#endif |
| 99 |
+/* FIXME: remove gcc-dependency */ |
| 100 |
|
| 101 |
#define ENABLE_FLAG_UNSET 0 |
| 102 |
#define ENABLE_FLAG_OFF 1 |
| 103 |
@@ -55,13 +115,13 @@ |
| 104 |
typedef struct { |
| 105 |
int enable_function; /* flag to enable this module */ |
| 106 |
char *server_encoding; /* server-side filesystem encoding */ |
| 107 |
- array_header *client_encoding; /* useragent-to-encoding-list sets */ |
| 108 |
- array_header *default_encoding; /* useragent-to-encoding-list sets */ |
| 109 |
+ apr_array_header_t *client_encoding; /* useragent-to-encoding-list sets */ |
| 110 |
+ apr_array_header_t *default_encoding; /* useragent-to-encoding-list sets */ |
| 111 |
|
| 112 |
- int strip_msaccount; /* normalize wierd WinXP username */ |
| 113 |
+ int strip_msaccount; /* normalize wierd WinXP username */ |
| 114 |
} encoding_config; |
| 115 |
|
| 116 |
-module MODULE_VAR_EXPORT encoding_module; |
| 117 |
+module AP_MODULE_DECLARE_DATA encoding_module; |
| 118 |
|
| 119 |
/*************************************************************************** |
| 120 |
* utility methods |
| 121 |
@@ -83,22 +143,19 @@ |
| 122 |
size_t outlen; |
| 123 |
|
| 124 |
if (srclen == 0) { |
| 125 |
- LOG(APLOG_DEBUG, r->server, "iconv_string: skipping zero-length input"); |
| 126 |
return srcbuf; |
| 127 |
} |
| 128 |
|
| 129 |
/* Allocate space for conversion. Note max bloat factor is 4 of UCS-4 */ |
| 130 |
- marker = outbuf = (char *)ap_palloc(r->pool, outlen = srclen * 4 + 1); |
| 131 |
+ marker = outbuf = (char *)apr_palloc(r->pool, outlen = srclen * 4 + 1); |
| 132 |
|
| 133 |
if (outbuf == NULL) { |
| 134 |
- LOG(APLOG_WARNING, r->server, "iconv_string: no more memory"); |
| 135 |
return NULL; |
| 136 |
} |
| 137 |
|
| 138 |
/* Convert every character within input string. */ |
| 139 |
while (srclen > 0) { |
| 140 |
- if (iconv(cd, &srcbuf, &srclen, &outbuf, &outlen) == (size_t)(-1)) { |
| 141 |
- LOG(APLOG_DEBUG, r->server, "iconv_string: conversion error"); |
| 142 |
+ if (iconv(cd, (const char **)&srcbuf, &srclen, &outbuf, &outlen) == (size_t)(-1)) { |
| 143 |
return NULL; |
| 144 |
} |
| 145 |
} |
| 146 |
@@ -140,11 +197,11 @@ |
| 147 |
|
| 148 |
/* Normalize encoding in HTTP request header(s) */ |
| 149 |
for (i = 0 ; keys[i] ; i++) { |
| 150 |
- if ((buff = (char *)ap_table_get(r->headers_in, keys[i])) != NULL) { |
| 151 |
+ if ((buff = (char *)apr_table_get(r->headers_in, keys[i])) != NULL) { |
| 152 |
ap_unescape_url(buff); |
| 153 |
if ((buff = iconv_string(r, cd, buff, strlen(buff))) == NULL) |
| 154 |
return -1; |
| 155 |
- ap_table_set(r->headers_in, keys[i], buff); |
| 156 |
+ apr_table_set(r->headers_in, keys[i], buff); |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
@@ -159,33 +216,29 @@ |
| 161 |
* @param encmap Table of UA-to-encoding(s) |
| 162 |
* @param lookup Name of the useragent to look for |
| 163 |
*/ |
| 164 |
-static array_header * |
| 165 |
+static apr_array_header_t * |
| 166 |
get_client_encoding(request_rec *r, |
| 167 |
- array_header *encmap, const char *lookup) { |
| 168 |
+ apr_array_header_t *encmap, const char *lookup) { |
| 169 |
void **list = (void **)encmap->elts; |
| 170 |
- array_header *encs = ap_make_array(r->pool, 1, sizeof(char *)); |
| 171 |
+ apr_array_header_t *encs = apr_array_make(r->pool, 1, sizeof(char *)); |
| 172 |
|
| 173 |
int i; |
| 174 |
|
| 175 |
- LOG(APLOG_DEBUG, r->server, "get_client_encoding: entered"); |
| 176 |
|
| 177 |
/* push UTF-8 as the first candidate of expected encoding */ |
| 178 |
- *((char **)ap_push_array(encs)) = ap_pstrdup(r->pool, "UTF-8"); |
| 179 |
+ *((char **)apr_array_push(encs)) = apr_pstrdup(r->pool, "UTF-8"); |
| 180 |
|
| 181 |
if (! lookup) |
| 182 |
return encs; |
| 183 |
|
| 184 |
- LOG(APLOG_DEBUG, r->server, "get_client_encoding: lookup == %s", lookup); |
| 185 |
|
| 186 |
for (i = 0 ; i < encmap->nelts ; i += 2) { |
| 187 |
- if (ap_regexec((regex_t *)list[i], lookup, 0, NULL, 0) == 0) { |
| 188 |
- LOG(APLOG_DEBUG, r->server, "get_client_encoding: entry found"); |
| 189 |
- ap_array_cat(encs, (array_header *)list[i + 1]); |
| 190 |
+ if (ap_regexec((ap_regex_t *)list[i], lookup, 0, NULL, 0) == 0) { |
| 191 |
+ apr_array_cat(encs, (apr_array_header_t *)list[i + 1]); |
| 192 |
return encs; |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
- LOG(APLOG_DEBUG, r->server, "get_client_encoding: entry not found"); |
| 197 |
return encs; |
| 198 |
} |
| 199 |
|
| 200 |
@@ -194,8 +247,6 @@ |
| 201 |
*/ |
| 202 |
static const char * |
| 203 |
set_encoding_engine(cmd_parms *cmd, encoding_config *conf, int flag) { |
| 204 |
- LOG(APLOG_DEBUG, cmd->server, "set_encoding_engine: entered"); |
| 205 |
- LOG(APLOG_DEBUG, cmd->server, "set_encoding_engine: flag == %d", flag); |
| 206 |
|
| 207 |
if (! cmd->path) { |
| 208 |
conf = ap_get_module_config(cmd->server->module_config, &encoding_module); |
| 209 |
@@ -210,13 +261,11 @@ |
| 210 |
*/ |
| 211 |
static const char * |
| 212 |
set_server_encoding(cmd_parms *cmd, encoding_config *conf, char *arg) { |
| 213 |
- LOG(APLOG_DEBUG, cmd->server, "set_server_encoding: entered"); |
| 214 |
- LOG(APLOG_DEBUG, cmd->server, "set_server_encoding: arg == %s", arg); |
| 215 |
|
| 216 |
if (! cmd->path) { |
| 217 |
conf = ap_get_module_config(cmd->server->module_config, &encoding_module); |
| 218 |
} |
| 219 |
- conf->server_encoding = ap_pstrdup(cmd->pool, arg); |
| 220 |
+ conf->server_encoding = apr_pstrdup(cmd->pool, arg); |
| 221 |
|
| 222 |
return NULL; |
| 223 |
} |
| 224 |
@@ -229,31 +278,27 @@ |
| 225 |
*/ |
| 226 |
static const char * |
| 227 |
add_client_encoding(cmd_parms *cmd, encoding_config *conf, char *args) { |
| 228 |
- array_header *encs; |
| 229 |
+ apr_array_header_t *encs; |
| 230 |
char *arg; |
| 231 |
|
| 232 |
- LOG(APLOG_DEBUG, cmd->server, "add_client_encoding: entered"); |
| 233 |
- LOG(APLOG_DEBUG, cmd->server, "add_client_encoding: args == %s", args); |
| 234 |
|
| 235 |
if (! cmd->path) { |
| 236 |
conf = ap_get_module_config(cmd->server->module_config, &encoding_module); |
| 237 |
} |
| 238 |
|
| 239 |
- encs = ap_make_array(cmd->pool, 1, sizeof(void *)); |
| 240 |
+ encs = apr_array_make(cmd->pool, 1, sizeof(void *)); |
| 241 |
|
| 242 |
/* register useragent with UserAgent: pattern */ |
| 243 |
if (*args && (arg = ap_getword_conf_nc(cmd->pool, &args))) { |
| 244 |
- LOG(APLOG_DEBUG, cmd->server, "add_client_encoding: agent: %s", arg); |
| 245 |
- *(void **)ap_push_array(conf->client_encoding) = |
| 246 |
- ap_pregcomp(cmd->pool, arg, REG_EXTENDED|REG_ICASE|REG_NOSUB); |
| 247 |
+ *(void **)apr_array_push(conf->client_encoding) = |
| 248 |
+ ap_pregcomp(cmd->pool, arg, AP_REG_EXTENDED|AP_REG_ICASE|AP_REG_NOSUB); |
| 249 |
} |
| 250 |
|
| 251 |
/* register list of possible encodings from above useragent */ |
| 252 |
while (*args && (arg = ap_getword_conf_nc(cmd->pool, &args))) { |
| 253 |
- LOG(APLOG_DEBUG, cmd->server, "add_client_encoding: encname: %s", arg); |
| 254 |
- *(void **)ap_push_array(encs) = ap_pstrdup(cmd->pool, arg); |
| 255 |
+ *(void **)apr_array_push(encs) = apr_pstrdup(cmd->pool, arg); |
| 256 |
} |
| 257 |
- *(void **)ap_push_array(conf->client_encoding) = encs; |
| 258 |
+ *(void **)apr_array_push(conf->client_encoding) = encs; |
| 259 |
|
| 260 |
return NULL; |
| 261 |
} |
| 262 |
@@ -267,20 +312,17 @@ |
| 263 |
default_client_encoding(cmd_parms *cmd, encoding_config *conf, char *args) { |
| 264 |
char *arg; |
| 265 |
|
| 266 |
- LOG(APLOG_DEBUG, cmd->server, "default_client_encoding: entered"); |
| 267 |
- LOG(APLOG_DEBUG, cmd->server, "default_client_encoding: args == %s", args); |
| 268 |
|
| 269 |
if (! cmd->path) { |
| 270 |
conf = ap_get_module_config(cmd->server->module_config, &encoding_module); |
| 271 |
} |
| 272 |
|
| 273 |
- conf->default_encoding = ap_make_array(cmd->pool, 1, sizeof(char *)); |
| 274 |
+ conf->default_encoding = apr_array_make(cmd->pool, 1, sizeof(char *)); |
| 275 |
|
| 276 |
/* register list of possible encodings as a default */ |
| 277 |
while (*args && (arg = ap_getword_conf_nc(cmd->pool, &args))) { |
| 278 |
- LOG(APLOG_DEBUG, cmd->server, "default_client_encoding: encname: %s", arg); |
| 279 |
- *(void **)ap_push_array(conf->default_encoding) |
| 280 |
- = ap_pstrdup(cmd->pool, arg); |
| 281 |
+ *(void **)apr_array_push(conf->default_encoding) |
| 282 |
+ = apr_pstrdup(cmd->pool, arg); |
| 283 |
} |
| 284 |
|
| 285 |
return NULL; |
| 286 |
@@ -294,8 +336,6 @@ |
| 287 |
*/ |
| 288 |
static const char * |
| 289 |
set_normalize_username(cmd_parms *cmd, encoding_config *conf, int flag) { |
| 290 |
- LOG(APLOG_DEBUG, cmd->server, "set_normalize_username: entered"); |
| 291 |
- LOG(APLOG_DEBUG, cmd->server, "set_normalize_username: flag == %d", flag); |
| 292 |
|
| 293 |
if (! cmd->path) { |
| 294 |
conf = ap_get_module_config(cmd->server->module_config, &encoding_module); |
| 295 |
@@ -343,15 +383,15 @@ |
| 296 |
* Setup server-level module internal data strcuture. |
| 297 |
*/ |
| 298 |
static void * |
| 299 |
-server_setup(pool *p, server_rec *s) { |
| 300 |
+server_setup(apr_pool_t *p, server_rec *s) { |
| 301 |
encoding_config *conf; |
| 302 |
|
| 303 |
DBG(fprintf(stderr, "server_setup: entered\n")); |
| 304 |
|
| 305 |
- conf = (encoding_config *)ap_pcalloc(p, sizeof(encoding_config)); |
| 306 |
+ conf = (encoding_config *)apr_pcalloc(p, sizeof(encoding_config)); |
| 307 |
conf->enable_function = ENABLE_FLAG_UNSET; |
| 308 |
conf->server_encoding = NULL; |
| 309 |
- conf->client_encoding = ap_make_array(p, 2, sizeof(void *)); |
| 310 |
+ conf->client_encoding = apr_array_make(p, 2, sizeof(void *)); |
| 311 |
conf->default_encoding = NULL; |
| 312 |
conf->strip_msaccount = STRIP_FLAG_UNSET; |
| 313 |
|
| 314 |
@@ -362,7 +402,7 @@ |
| 315 |
* Setup folder-level module internal data strcuture. |
| 316 |
*/ |
| 317 |
static void * |
| 318 |
-folder_setup(pool *p, char *dir) { |
| 319 |
+folder_setup(apr_pool_t *p, char *dir) { |
| 320 |
DBG(fprintf(stderr, "folder_setup: entered\n")); |
| 321 |
return server_setup(p, NULL); |
| 322 |
} |
| 323 |
@@ -371,14 +411,14 @@ |
| 324 |
* Merge configuration. |
| 325 |
*/ |
| 326 |
static void * |
| 327 |
-config_merge(pool *p, void *base, void *override) { |
| 328 |
+config_merge(apr_pool_t *p, void *base, void *override) { |
| 329 |
encoding_config *parent = base; |
| 330 |
encoding_config *child = override; |
| 331 |
encoding_config *merge; |
| 332 |
|
| 333 |
DBG(fprintf(stderr, "config_merge: entered\n")); |
| 334 |
|
| 335 |
- merge = (encoding_config *)ap_pcalloc(p, sizeof(encoding_config)); |
| 336 |
+ merge = (encoding_config *)apr_pcalloc(p, sizeof(encoding_config)); |
| 337 |
|
| 338 |
if (child->enable_function != ENABLE_FLAG_UNSET) |
| 339 |
merge->enable_function = child->enable_function; |
| 340 |
@@ -388,13 +428,14 @@ |
| 341 |
DBG(fprintf(stderr, |
| 342 |
"merged: enable_function == %d\n", merge->enable_function)); |
| 343 |
|
| 344 |
+ |
| 345 |
if (child->strip_msaccount != STRIP_FLAG_UNSET) |
| 346 |
merge->strip_msaccount = child->strip_msaccount; |
| 347 |
else |
| 348 |
merge->strip_msaccount = parent->strip_msaccount; |
| 349 |
|
| 350 |
DBG(fprintf(stderr, |
| 351 |
- "merged: strip_msaccount == %d\n", merge->strip_msaccount)); |
| 352 |
+ "merged: strip_msaccount == %d\n", merge->strip_msaccount)); |
| 353 |
|
| 354 |
if (child->server_encoding) |
| 355 |
merge->server_encoding = child->server_encoding; |
| 356 |
@@ -410,7 +451,7 @@ |
| 357 |
merge->default_encoding = parent->default_encoding; |
| 358 |
|
| 359 |
merge->client_encoding = |
| 360 |
- ap_append_arrays(p, child->client_encoding, parent->client_encoding); |
| 361 |
+ apr_array_append(p, child->client_encoding, parent->client_encoding); |
| 362 |
|
| 363 |
return merge; |
| 364 |
} |
| 365 |
@@ -424,17 +465,16 @@ |
| 366 |
*/ |
| 367 |
static int |
| 368 |
mod_enc_convert(request_rec *r) { |
| 369 |
- encoding_config *conf, *dconf, *sconf; |
| 370 |
+ encoding_config *conf, *dconf, *sconf; |
| 371 |
|
| 372 |
const char *oenc; /* server-side encoding */ |
| 373 |
- array_header *ienc; /* list of possible encodings */ |
| 374 |
+ apr_array_header_t *ienc; /* list of possible encodings */ |
| 375 |
void **list; /* same as above (for iteration) */ |
| 376 |
|
| 377 |
iconv_t cd; /* conversion descriptor */ |
| 378 |
|
| 379 |
int i; |
| 380 |
|
| 381 |
- LOG(APLOG_DEBUG, r->server, "mod_enc_convert: entered"); |
| 382 |
|
| 383 |
sconf = ap_get_module_config(r->server->module_config, &encoding_module); |
| 384 |
dconf = ap_get_module_config(r->per_dir_config, &encoding_module); |
| 385 |
@@ -446,19 +486,16 @@ |
| 386 |
|
| 387 |
oenc = conf->server_encoding ? conf->server_encoding : "UTF-8"; |
| 388 |
ienc = get_client_encoding(r, conf->client_encoding, |
| 389 |
- ap_table_get(r->headers_in, "User-Agent")); |
| 390 |
+ apr_table_get(r->headers_in, "User-Agent")); |
| 391 |
|
| 392 |
if (conf->default_encoding) |
| 393 |
- ap_array_cat(ienc, conf->default_encoding); |
| 394 |
+ apr_array_cat(ienc, conf->default_encoding); |
| 395 |
|
| 396 |
list = (void **)ienc->elts; |
| 397 |
|
| 398 |
- LOG(APLOG_DEBUG, r->server, "mod_enc_convert: oenc == %s", oenc); |
| 399 |
|
| 400 |
/* try specified encodings in order */ |
| 401 |
for (i = 0 ; i < ienc->nelts ; i++) { |
| 402 |
- LOG(APLOG_DEBUG, |
| 403 |
- r->server, "mod_enc_convert: ienc <> %s", (char *)list[i]); |
| 404 |
|
| 405 |
/* pick appropriate converter module */ |
| 406 |
if ((cd = iconv_open(oenc, list[i])) == (iconv_t)(-1)) |
| 407 |
@@ -466,8 +503,6 @@ |
| 408 |
|
| 409 |
/* conversion tryout */ |
| 410 |
if (iconv_header(r, cd) == 0) { |
| 411 |
- LOG(APLOG_DEBUG, |
| 412 |
- r->server, "mod_enc_convert: ienc == %s", (char *)list[i]); |
| 413 |
iconv_close(cd); |
| 414 |
return DECLINED; |
| 415 |
} |
| 416 |
@@ -476,7 +511,6 @@ |
| 417 |
iconv_close(cd); |
| 418 |
} |
| 419 |
|
| 420 |
- LOG(APLOG_WARNING, r->server, "mod_enc_convert: no conversion done"); |
| 421 |
|
| 422 |
return DECLINED; |
| 423 |
} |
| 424 |
@@ -495,8 +529,6 @@ |
| 425 |
char *user; |
| 426 |
char *buff; |
| 427 |
|
| 428 |
- LOG(APLOG_DEBUG, r->server, "mod_enc_parse: entered"); |
| 429 |
- |
| 430 |
sconf = ap_get_module_config(r->server->module_config, &encoding_module); |
| 431 |
dconf = ap_get_module_config(r->per_dir_config, &encoding_module); |
| 432 |
conf = config_merge(r->pool, sconf, dconf); |
| 433 |
@@ -513,15 +545,15 @@ |
| 434 |
return DECLINED; |
| 435 |
|
| 436 |
/* Is this username broken? */ |
| 437 |
- if ((user = index(r->connection->user, '\\')) == NULL) |
| 438 |
+ if ((user = index(r->user, '\\')) == NULL) |
| 439 |
return DECLINED; |
| 440 |
|
| 441 |
/* Re-generate authorization header */ |
| 442 |
if (*(user + 1)) { |
| 443 |
buff = ap_pbase64encode(r->pool, |
| 444 |
- ap_psprintf(r->pool, "%s:%s", user + 1, pass)); |
| 445 |
- ap_table_set(r->headers_in, "Authorization", |
| 446 |
- ap_pstrcat(r->pool, "Basic ", buff, NULL)); |
| 447 |
+ apr_psprintf(r->pool, "%s:%s", user + 1, pass)); |
| 448 |
+ apr_table_set(r->headers_in, "Authorization", |
| 449 |
+ apr_pstrcat(r->pool, "Basic ", buff, NULL)); |
| 450 |
|
| 451 |
ap_get_basic_auth_pw(r, &pass); /* update */ |
| 452 |
} |
| 453 |
@@ -530,28 +562,25 @@ |
| 454 |
return DECLINED; |
| 455 |
} |
| 456 |
|
| 457 |
+static void register_hooks(apr_pool_t *p) |
| 458 |
+{ |
| 459 |
+ /* filename-to-URI translation */ |
| 460 |
+/* ap_hook_translate_name(mod_enc_convert,NULL,NULL,APR_HOOK_FIRST); */ |
| 461 |
+ ap_hook_post_read_request(mod_enc_convert,NULL,NULL,APR_HOOK_FIRST); |
| 462 |
+ ap_hook_header_parser(mod_enc_parse,NULL,NULL,APR_HOOK_FIRST); |
| 463 |
+} |
| 464 |
+ |
| 465 |
/*************************************************************************** |
| 466 |
* exported module structure |
| 467 |
***************************************************************************/ |
| 468 |
|
| 469 |
-module MODULE_VAR_EXPORT encoding_module = { |
| 470 |
- STANDARD_MODULE_STUFF, |
| 471 |
- NULL, /* initializer */ |
| 472 |
- folder_setup, /* dir config */ |
| 473 |
- config_merge, /* dir config merger */ |
| 474 |
- server_setup, /* server config */ |
| 475 |
- config_merge, /* server config merger */ |
| 476 |
- mod_enc_commands, /* command table */ |
| 477 |
- NULL, /* handlers */ |
| 478 |
- NULL, /* filename translation */ |
| 479 |
- NULL, /* check_user_id */ |
| 480 |
- NULL, /* check auth */ |
| 481 |
- NULL, /* check access */ |
| 482 |
- NULL, /* type_checker */ |
| 483 |
- NULL, /* fixups */ |
| 484 |
- NULL, /* logger */ |
| 485 |
- mod_enc_parse, /* header parser */ |
| 486 |
- NULL, /* child_init */ |
| 487 |
- NULL, /* child_exit */ |
| 488 |
- mod_enc_convert, /* post read-request */ |
| 489 |
+module AP_MODULE_DECLARE_DATA encoding_module = { |
| 490 |
+ STANDARD20_MODULE_STUFF, |
| 491 |
+ folder_setup, /* create per-directory config structure */ |
| 492 |
+ config_merge, /* merge per-directory(?) config str */ |
| 493 |
+ server_setup, /* create per-server config structure */ |
| 494 |
+ config_merge, /* merge per-server config ...*/ |
| 495 |
+ mod_enc_commands, /* command handlers */ |
| 496 |
+ register_hooks |
| 497 |
}; |
| 498 |
+ |
| 499 |
--- Makefile.in.orig 2002-06-11 17:46:39.000000000 +0900 |
| 500 |
+++ Makefile.in 2008-08-30 16:18:36.000000000 +0900 |
| 501 |
@@ -250,16 +250,16 @@ |
| 502 |
maintainer-clean-generic clean mostlyclean distclean maintainer-clean |
| 503 |
|
| 504 |
|
| 505 |
-all-local: mod_encoding.so |
| 506 |
+all-local: mod_encoding.la |
| 507 |
|
| 508 |
-mod_encoding.so: mod_encoding.c |
| 509 |
+mod_encoding.la: mod_encoding.c |
| 510 |
$(APXS) -c $(CPPFLAGS) $(APXSFLAGS) $(LIBS) $< |
| 511 |
|
| 512 |
install-exec-local: |
| 513 |
- $(APXS) -i mod_encoding.so |
| 514 |
+ $(APXS) -i -n mod_encoding mod_encoding.la |
| 515 |
|
| 516 |
clean-local: |
| 517 |
- rm -f *~ *.o *.so |
| 518 |
+ rm -f *~ *.o *.so *.la |
| 519 |
|
| 520 |
# Tell versions [3.59,3.63) of GNU make to not export all variables. |
| 521 |
# Otherwise a system limit (for SysV at least) may be exceeded. |
| 522 |
--- Makefile.am.orig 2002-06-11 17:46:39.000000000 +0900 |
| 523 |
+++ Makefile.am 2008-08-30 16:19:25.000000000 +0900 |
| 524 |
@@ -4,13 +4,13 @@ |
| 525 |
|
| 526 |
EXTRA_DIST = mod_encoding.c Makefile.simple |
| 527 |
|
| 528 |
-all-local: mod_encoding.so |
| 529 |
+all-local: mod_encoding.la |
| 530 |
|
| 531 |
-mod_encoding.so: mod_encoding.c |
| 532 |
+mod_encoding.la: mod_encoding.c |
| 533 |
$(APXS) -c $(CPPFLAGS) $(APXSFLAGS) $(LIBS) $< |
| 534 |
|
| 535 |
install-exec-local: |
| 536 |
- $(APXS) -i mod_encoding.so |
| 537 |
+ $(APXS) -i -n mod_encoding mod_encoding.la |
| 538 |
|
| 539 |
clean-local: |
| 540 |
- rm -f *~ *.o *.so |
| 541 |
+ rm -f *~ *.o *.so *.la |
| 0 |
<how to correct or work around the problem, if known (multiple lines)> |
542 |
<how to correct or work around the problem, if known (multiple lines)> |