cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
mjc 00/01/16 10:06:33 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: The recent fix to allow ProxyPass directories to be protected with user authentication did not work when using mod_rewrite to do the mirror proxying. This fixes it. Revision ChangesPath 1.1500+2 -2 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1499 retrieving revision 1.1500 diff -u -r1.1499 -r1.1500 --- CHANGES 2000/01/15 16:40:40 1.1499 +++ CHANGES 2000/01/16 18:06:25 1.1500 @@ -23,8 +23,8 @@ work. Fixed. [Manoj Kasichainula, Ben Laurie] - *) ProxyPass erroneously converted authentication requests to proxy - authentication requests. Fixed. + *) ProxyPass and mod_rewrite's proxy mode erroneously converted + authentication requests to proxy authentication requests. [Ben Laurie] *) Reverse a patch which broke HPUX shared builds. Basically 1.155 +2 -2 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.154 retrieving revision 1.155 diff -u -r1.154 -r1.155 --- mod_rewrite.c 2000/01/12 15:23:25 1.154 +++ mod_rewrite.c 2000/01/16 18:06:30 1.155 @@ -1123,7 +1123,7 @@ } /* now make sure the request gets handled by the proxy handler */ -r-proxyreq = STD_PROXY; +r-proxyreq = PROXY_PASS; r-handler = proxy-server; rewritelog(r, 1, go-ahead with proxy request %s [OK], @@ -1387,7 +1387,7 @@ } /* now make sure the request gets handled by the proxy handler */ -r-proxyreq = STD_PROXY; +r-proxyreq = PROXY_PASS; r-handler = proxy-server; rewritelog(r, 1, [per-dir %s] go-ahead with proxy request
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 99/12/04 03:43:19 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Fixed a recently introduced off-by-one-character bug in mod_rewrite's expansion of expression back-references. Submitted by: Cliff Woolley [EMAIL PROTECTED] Reviewed by: Ralf S. Engelschall PR: 4766, 5389 Revision ChangesPath 1.1469+4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1468 retrieving revision 1.1469 diff -u -r1.1468 -r1.1469 --- CHANGES 1999/12/01 22:10:39 1.1468 +++ CHANGES 1999/12/04 11:43:12 1.1469 @@ -1,5 +1,9 @@ Changes with Apache 1.3.10 + *) Fixed a recently introduced off-by-one-character bug in + mod_rewrite's expansion of expression back-references. + [Cliff Woolley [EMAIL PROTECTED]] PR#4766 PR#5389 + *) Add IndexOptions DescriptionWidth so that the width of the description field in fancy-indexed directory listings can be specified. 1.153 +1 -1 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.152 retrieving revision 1.153 diff -u -r1.152 -r1.153 --- mod_rewrite.c 1999/11/26 19:43:50 1.152 +++ mod_rewrite.c 1999/12/04 11:43:17 1.153 @@ -2513,7 +2513,7 @@ /* now apply the standard regex substitution function */ ap_cpystrn(buf, ap_pregsub(p, buf, bri-source, - bri-nsub+0, bri-regmatch), nbuf); + bri-nsub+1, bri-regmatch), nbuf); /* restore the original $N and backrefs */ for (i = 0; buf[i] != '\0' i nbuf; i++) {
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
gstein 99/11/26 11:31:23 Modified:src/modules/standard mod_rewrite.c Log: The floating point rounding performed by the ap_snprintf() was throwing off the distribution of the random value. The much simpler forms works just as well, and provides a normal distribution. Revision ChangesPath 1.151 +1 -9 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.150 retrieving revision 1.151 diff -u -r1.150 -r1.151 --- mod_rewrite.c 1999/10/27 09:13:17 1.150 +++ mod_rewrite.c 1999/11/26 19:31:21 1.151 @@ -3047,16 +3047,8 @@ static int rewrite_rand(int l, int h) { -int i; -char buf[50]; - rewrite_rand_init(); -ap_snprintf(buf, sizeof(buf), %.0f, -(((double)(rand()%RAND_MAX)/RAND_MAX)*(h-l))); -i = atoi(buf)+1; -if (i l) i = l; -if (i h) i = h; -return i; +return rand() % (h - l + 1) + l; } static char *select_random_value_part(request_rec *r, char *value)
Re: cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
[EMAIL PROTECTED] wrote: gstein 99/11/26 11:31:23 Modified:src/modules/standard mod_rewrite.c Log: The floating point rounding performed by the ap_snprintf() was throwing off the distribution of the random value. Nah, what threw it off was that it was just plain wrong. Cheers, Ben. -- http://www.apache-ssl.org/ben.html My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there. - Indira Gandhi
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 99/10/27 00:56:24 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Make sure mod_rewrite matches URL schemes case-insensitive and also allow additional (commonly used) URL schemes ldap:, news: and mailto:. Requested by: Klaus Johannes Rusch [EMAIL PROTECTED] Submitted by: Ralf S. Engelschall Reviewed by: Ralf S. Engelschall PR: 3140 Revision ChangesPath 1.1440+4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1439 retrieving revision 1.1440 diff -u -r1.1439 -r1.1440 --- CHANGES 1999/10/27 07:38:45 1.1439 +++ CHANGES 1999/10/27 07:56:17 1.1440 @@ -1,5 +1,9 @@ Changes with Apache 1.3.10 + *) Make sure mod_rewrite matches URL schemes case-insensitive and also allow + additional (commonly used) URL schemes ldap:, news: and mailto:. + [Ralf S. Engelschall, Klaus Johannes Rusch [EMAIL PROTECTED]] PR#3140 + *) Overhauled ApacheBench (ab) manpage ab.8. [Simon Baldwin [EMAIL PROTECTED]] PR#5139 1.146 +37 -16apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.145 retrieving revision 1.146 diff -u -r1.145 -r1.146 --- mod_rewrite.c 1999/10/21 20:45:36 1.145 +++ mod_rewrite.c 1999/10/27 07:56:22 1.146 @@ -1131,13 +1131,19 @@ return OK; } else if ( (strlen(r-filename) 7 -strncasecmp(r-filename, http://;, 7) == 0) +strncasecmp(r-filename, http://;, 7) == 0) || (strlen(r-filename) 8 -strncasecmp(r-filename, https://;, 8) == 0) +strncasecmp(r-filename, https://;, 8) == 0) || (strlen(r-filename) 9 strncasecmp(r-filename, gopher://;, 9) == 0) || (strlen(r-filename) 6 -strncasecmp(r-filename, ftp://;, 6) == 0)) { +strncasecmp(r-filename, ftp://;,6) == 0) +|| (strlen(r-filename) 5 +strncasecmp(r-filename, ldap:, 5) == 0) +|| (strlen(r-filename) 5 +strncasecmp(r-filename, news:;, 5) == 0) +|| (strlen(r-filename) 7 +strncasecmp(r-filename, mailto:;, 7) == 0)) { /* it was finally rewritten to a remote URL */ /* skip 'scheme:' */ @@ -1391,13 +1397,19 @@ return OK; } else if ( (strlen(r-filename) 7 -strncmp(r-filename, http://;, 7) == 0) +strncasecmp(r-filename, http://;, 7) == 0) || (strlen(r-filename) 8 -strncmp(r-filename, https://;, 8) == 0) +strncasecmp(r-filename, https://;, 8) == 0) || (strlen(r-filename) 9 -strncmp(r-filename, gopher://;, 9) == 0) +strncasecmp(r-filename, gopher://;, 9) == 0) || (strlen(r-filename) 6 -strncmp(r-filename, ftp://;, 6) == 0)) { +strncasecmp(r-filename, ftp://;,6) == 0) +|| (strlen(r-filename) 5 +strncasecmp(r-filename, ldap:, 5) == 0) +|| (strlen(r-filename) 5 +strncasecmp(r-filename, news:;, 5) == 0) +|| (strlen(r-filename) 7 +strncasecmp(r-filename, mailto:;, 7) == 0)) { /* it was finally rewritten to a remote URL */ /* because we are in a per-dir context @@ -2005,10 +2017,13 @@ i = strlen(r-filename); if ( prefixstrip !( r-filename[0] == '/' - || ( (i 7 strncasecmp(r-filename, http://;, 7) == 0) - || (i 8 strncasecmp(r-filename, https://;, 8) == 0) + || ( (i 7 strncasecmp(r-filename, http://;, 7) == 0) + || (i 8 strncasecmp(r-filename, https://;, 8) == 0) || (i 9 strncasecmp(r-filename, gopher://;, 9) == 0) - || (i 6 strncasecmp(r-filename, ftp://;, 6) == 0 { + || (i 6 strncasecmp(r-filename, ftp://;,6) == 0) + || (i 5 strncasecmp(r-filename, ldap:, 5) == 0) + || (i 5 strncasecmp(r-filename, news:;, 5) == 0) + || (i 7 strncasecmp(r-filename, mailto:;, 7) == 0 { rewritelog(r, 3, [per-dir %s] add per-dir prefix: %s - %s%s,
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 99/10/27 01:10:12 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Make sure mod_rewrite escapes QUERY_STRINGS on redirects. Submitted by: Klaus Johannes Rusch [EMAIL PROTECTED] Reviewed by: Ralf S. Engelschall PR: 4734 Revision ChangesPath 1.1441+3 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1440 retrieving revision 1.1441 diff -u -r1.1440 -r1.1441 --- CHANGES 1999/10/27 07:56:17 1.1440 +++ CHANGES 1999/10/27 08:10:06 1.1441 @@ -1,5 +1,8 @@ Changes with Apache 1.3.10 + *) Make sure mod_rewrite escapes QUERY_STRINGS on redirects. + [Klaus Johannes Rusch [EMAIL PROTECTED]] PR#4734 + *) Make sure mod_rewrite matches URL schemes case-insensitive and also allow additional (commonly used) URL schemes ldap:, news: and mailto:. [Ralf S. Engelschall, Klaus Johannes Rusch [EMAIL PROTECTED]] PR#3140 1.147 +4 -4 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.146 retrieving revision 1.147 diff -u -r1.146 -r1.147 --- mod_rewrite.c 1999/10/27 07:56:22 1.146 +++ mod_rewrite.c 1999/10/27 08:10:10 1.147 @@ -1163,8 +1163,8 @@ /* append the QUERY_STRING part */ if (r-args != NULL) { - r-filename = ap_pstrcat(r-pool, r-filename, -?, r-args, NULL); +r-filename = ap_pstrcat(r-pool, r-filename, ?, + ap_escape_uri(r-pool, r-args), NULL); } /* determine HTTP redirect response code */ @@ -1458,8 +1458,8 @@ /* append the QUERY_STRING part */ if (r-args != NULL) { -r-filename = ap_pstrcat(r-pool, r-filename, - ?, r-args, NULL); +r-filename = ap_pstrcat(r-pool, r-filename, ?, + ap_escape_uri(r-pool, r-args), NULL); } /* determine HTTP redirect response code */
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 99/10/27 01:19:01 Modified:src/modules/standard mod_rewrite.c Log: Indentation cleanup Revision ChangesPath 1.148 +10 -10apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.147 retrieving revision 1.148 diff -u -r1.147 -r1.148 --- mod_rewrite.c 1999/10/27 08:10:10 1.147 +++ mod_rewrite.c 1999/10/27 08:18:58 1.148 @@ -1859,7 +1859,7 @@ /* One condition is false, but another can be * still true, so we have to continue... */ - ap_table_unset(r-notes, VARY_KEY_THIS); +ap_table_unset(r-notes, VARY_KEY_THIS); continue; } else { @@ -1885,11 +1885,11 @@ break; } } - vary = ap_table_get(r-notes, VARY_KEY_THIS); - if (vary != NULL) { - ap_table_merge(r-notes, VARY_KEY, vary); - ap_table_unset(r-notes, VARY_KEY_THIS); - } +vary = ap_table_get(r-notes, VARY_KEY_THIS); +if (vary != NULL) { +ap_table_merge(r-notes, VARY_KEY, vary); +ap_table_unset(r-notes, VARY_KEY_THIS); +} } /* if any condition fails the complete rule fails */ if (failed) { @@ -1905,7 +1905,7 @@ */ if ((vary = ap_table_get(r-notes, VARY_KEY)) != NULL) { ap_table_merge(r-headers_out, Vary, vary); - ap_table_unset(r-notes, VARY_KEY); +ap_table_unset(r-notes, VARY_KEY); } /* @@ -2513,7 +2513,7 @@ /* now apply the pregsub() function */ ap_cpystrn(buf, ap_pregsub(p, buf, bri-source, - bri-nsub+1, bri-regmatch), nbuf); + bri-nsub+0, bri-regmatch), nbuf); if (c != '$') { /* restore the original $N backrefs */ @@ -3640,7 +3640,7 @@ } else if (strcasecmp(var, API_VERSION) == 0) { /* non-standard */ ap_snprintf(resultbuf, sizeof(resultbuf), %d:%d, - MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); +MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); result = resultbuf; } @@ -3792,7 +3792,7 @@ continue; } if (strcasecmp(hdrs[i].key, name) == 0) { - ap_table_merge(r-notes, VARY_KEY_THIS, name); +ap_table_merge(r-notes, VARY_KEY_THIS, name); return hdrs[i].val; } }
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 99/10/27 02:03:00 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Overhauled mod_rewrite's general substitution function (expand_backref_inbuffer): 1. The `$0' backreference is now officially allowed and documented and references the while pattern space; 2. the ampersamp () backreference (which is equal to $0) is no longer expanded, because it was never documented and only leads to confusion with QUERY_STRINGS; 3. backslashes (\) are honored correctly, that is `\$N' now really forces the dollar to be an ordinary character and $N is not expanded. Submitted by: Ralf S. Engelschall PR: 4766 4161 Revision ChangesPath 1.1442+10 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1441 retrieving revision 1.1442 diff -u -r1.1441 -r1.1442 --- CHANGES 1999/10/27 08:10:06 1.1441 +++ CHANGES 1999/10/27 09:02:43 1.1442 @@ -1,5 +1,15 @@ Changes with Apache 1.3.10 + *) Overhauled mod_rewrite's general substitution function + (expand_backref_inbuffer): 1. The `$0' backreference is now officially + allowed and documented and references the while pattern space; 2. the + ampersamp () backreference (which is equal to $0) is no longer expanded, + because it was never documented and only leads to confusion with + QUERY_STRINGS; 3. backslashes (\) are honored correctly, that is `\$N' + now really forces the dollar to be an ordinary character and $N is + not expanded. + [Ralf S. Engelschall] PR#4766 PR#4161 + *) Make sure mod_rewrite escapes QUERY_STRINGS on redirects. [Klaus Johannes Rusch [EMAIL PROTECTED]] PR#4734 1.149 +24 -21apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.148 retrieving revision 1.149 diff -u -r1.148 -r1.149 --- mod_rewrite.c 1999/10/27 08:18:58 1.148 +++ mod_rewrite.c 1999/10/27 09:02:49 1.149 @@ -2493,34 +2493,37 @@ static void expand_backref_inbuffer(pool *p, char *buf, int nbuf, backrefinfo *bri, char c) { -int i; +register int i; -if (bri-nsub 1) { -return; -} - -if (c != '$') { -/* safe existing $N backrefs and replace cN with $N backrefs */ -for (i = 0; buf[i] != '\0' i nbuf; i++) { -if (buf[i] == '$' (buf[i+1] = '0' buf[i+1] = '9')) { -buf[i++] = '\001'; -} -else if (buf[i] == c (buf[i+1] = '0' buf[i+1] = '9')) { -buf[i++] = '$'; -} +/* protect existing $N and backrefs and replace cN with $N backrefs */ +for (i = 0; buf[i] != '\0' i nbuf; i++) { +if (buf[i] == '\\' (buf[i+1] != '\0' i (nbuf-1))) { +i++; /* protect next */ +} +else if (buf[i] == '') { +buf[i] = '\001'; } +else if (c != '$' buf[i] == '$' (buf[i+1] = '0' buf[i+1] = '9')) { +buf[i] = '\002'; +i++; /* speedup */ +} +else if (buf[i] == c (buf[i+1] = '0' buf[i+1] = '9')) { +buf[i] = '$'; +i++; /* speedup */ +} } -/* now apply the pregsub() function */ +/* now apply the standard regex substitution function */ ap_cpystrn(buf, ap_pregsub(p, buf, bri-source, bri-nsub+0, bri-regmatch), nbuf); -if (c != '$') { -/* restore the original $N backrefs */ -for (i = 0; buf[i] != '\0' i nbuf; i++) { -if (buf[i] == '\001' (buf[i+1] = '0' buf[i+1] = '9')) { -buf[i++] = '$'; -} +/* restore the original $N and backrefs */ +for (i = 0; buf[i] != '\0' i nbuf; i++) { +if (buf[i] == '\001') { +buf[i] = ''; +} +else if (buf[i] == '\002') { +buf[i] = '$'; } } }
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 99/10/27 02:13:21 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Fixed QUERY_STRING handling for `RewriteRule ... [P]' in per-directory context. Submitted by: Martin Zeh [EMAIL PROTECTED] Reviewed by: Ralf S. Engelschall PR: 5073 Revision ChangesPath 1.1443+4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1442 retrieving revision 1.1443 diff -u -r1.1442 -r1.1443 --- CHANGES 1999/10/27 09:02:43 1.1442 +++ CHANGES 1999/10/27 09:13:09 1.1443 @@ -1,4 +1,8 @@ Changes with Apache 1.3.10 + + *) Fixed QUERY_STRING handling for `RewriteRule ... [P]' + in per-directory context. + [Martin Zeh [EMAIL PROTECTED]] PR#5073 *) Overhauled mod_rewrite's general substitution function (expand_backref_inbuffer): 1. The `$0' backreference is now officially 1.150 +1 -3 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.149 retrieving revision 1.150 diff -u -r1.149 -r1.150 --- mod_rewrite.c 1999/10/27 09:02:49 1.149 +++ mod_rewrite.c 1999/10/27 09:13:17 1.150 @@ -1381,9 +1381,7 @@ * (r-path_info was already appended by the * rewriting engine because of the per-dir context!) */ -if (r-args != NULL - r-uri == r-unparsed_uri) { -/* see proxy_http:proxy_http_canon() */ +if (r-args != NULL) { r-filename = ap_pstrcat(r-pool, r-filename, ?, r-args, NULL); }
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
dgaudet 99/08/03 02:27:42 Modified:src CHANGES src/modules/standard mod_rewrite.c mod_rewrite.h Log: This patch includes fix for rewritelock in vhost problem and makes program map writes atomic if writev is available. -Dima PR: 3874 Submitted by: Dmitry Khrustalev [EMAIL PROTECTED] Revision ChangesPath 1.1409+4 -1 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1408 retrieving revision 1.1409 diff -u -r1.1408 -r1.1409 --- CHANGES 1999/08/02 10:48:11 1.1408 +++ CHANGES 1999/08/03 09:27:25 1.1409 @@ -1,6 +1,9 @@ Changes with Apache 1.3.8 - * Support for compaq/tandem/com. + *) RewriteLock/RewriteMap didn't work properly with virtual hosts. + [Dmitry Khrustalev [EMAIL PROTECTED]] PR#3874 + + *) Support for compaq/tandem/com. [Ottati, Michael [EMAIL PROTECTED], dirkx] *) Added SHA1 password encryption support to easy migration from 1.144 +35 -49apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.143 retrieving revision 1.144 diff -u -r1.143 -r1.144 --- mod_rewrite.c 1999/07/29 17:54:06 1.143 +++ mod_rewrite.c 1999/08/03 09:27:33 1.144 @@ -91,6 +91,10 @@ #include mod_rewrite.h +#ifndef NO_WRITEV +#include sys/types.h +#include sys/uio.h +#endif /* ** +---+ @@ -208,6 +212,8 @@ /* whether proxy module is available or not */ static int proxy_available; +static char *lockname; +static int lockfd = -1; /* ** +---+ @@ -234,8 +240,6 @@ a-rewritelogfile = NULL; a-rewritelogfp= -1; a-rewriteloglevel = 0; -a-rewritelockfile = NULL; -a-rewritelockfp = -1; a-rewritemaps = ap_make_array(p, 2, sizeof(rewritemap_entry)); a-rewriteconds= ap_make_array(p, 2, sizeof(rewritecond_entry)); a-rewriterules= ap_make_array(p, 2, sizeof(rewriterule_entry)); @@ -270,12 +274,6 @@ a-rewritelogfp= overrides-rewritelogfp != -1 ? overrides-rewritelogfp : base-rewritelogfp; -a-rewritelockfile = overrides-rewritelockfile != NULL - ? overrides-rewritelockfile - : base-rewritelockfile; -a-rewritelockfp = overrides-rewritelockfp != -1 - ? overrides-rewritelockfp - : base-rewritelockfp; a-rewritemaps = ap_append_arrays(p, overrides-rewritemaps, base-rewritemaps); a-rewriteconds= ap_append_arrays(p, overrides-rewriteconds, @@ -291,8 +289,6 @@ a-rewriteloglevel = overrides-rewriteloglevel; a-rewritelogfile = overrides-rewritelogfile; a-rewritelogfp= overrides-rewritelogfp; -a-rewritelockfile = overrides-rewritelockfile; -a-rewritelockfp = overrides-rewritelockfp; a-rewritemaps = overrides-rewritemaps; a-rewriteconds= overrides-rewriteconds; a-rewriterules= overrides-rewriterules; @@ -528,15 +524,12 @@ static const char *cmd_rewritelock(cmd_parms *cmd, void *dconf, char *a1) { -rewrite_server_conf *sconf; const char *error; if ((error = ap_check_cmd_context(cmd, GLOBAL_ONLY)) != NULL) return error; -sconf = (rewrite_server_conf *) -ap_get_module_config(cmd-server-module_config, rewrite_module); -sconf-rewritelockfile = a1; +lockname = a1; return NULL; } @@ -2920,6 +2913,9 @@ char buf[LONG_STRING_LEN]; char c; int i; +#ifndef NO_WRITEV +struct iovec iov[2]; +#endif /* when `RewriteEngine off' was used in the per-server * context then the rewritemap-programs were not spawned. @@ -2934,8 +2930,16 @@ rewritelock_alloc(r); /* write out the request key */ +#ifdef NO_WRITEV write(fpin, key, strlen(key)); write(fpin, \n, 1); +#else +iov[0].iov_base = key; +iov[0].iov_len = strlen(key); +iov[1].iov_base = \n; +iov[1].iov_len = 1; +writev(fpin, iov, 2); +#endif /* read in the response value */ i = 0; @@ -3254,28 +3258,26 @@ conf = ap_get_module_config(s-module_config, rewrite_module); /* only operate if a lockfile is used */ -if (conf-rewritelockfile ==
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 99/06/29 01:37:44 Modified:src/modules/standard mod_rewrite.c Log: typos Revision ChangesPath 1.141 +2 -2 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.140 retrieving revision 1.141 diff -u -r1.140 -r1.141 --- mod_rewrite.c 1999/06/22 00:51:37 1.140 +++ mod_rewrite.c 1999/06/29 08:37:43 1.141 @@ -158,9 +158,9 @@ { RewriteBase, cmd_rewritebase, NULL, OR_FILEINFO, TAKE1, the base URL of the per-directory context }, { RewriteCond, cmd_rewritecond, NULL, OR_FILEINFO, RAW_ARGS, - a input string and a to be applied regexp-pattern }, + an input string and a to be applied regexp-pattern }, { RewriteRule, cmd_rewriterule, NULL, OR_FILEINFO, RAW_ARGS, - a URL-applied regexp-pattern and a substitution URL }, + an URL-applied regexp-pattern and a substitution URL }, { RewriteMap, cmd_rewritemap, NULL, RSRC_CONF, TAKE2, a mapname and a filename }, { RewriteLock, cmd_rewritelock, NULL, RSRC_CONF, TAKE1,
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 99/04/22 03:49:00 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Fix special RewriteCond -s pattern matching. Submitted by: Bob Finch [EMAIL PROTECTED] Reviewed by: Ralf S. Engelschall Revision ChangesPath 1.1325+3 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1324 retrieving revision 1.1325 diff -u -r1.1324 -r1.1325 --- CHANGES 1999/04/22 10:19:19 1.1324 +++ CHANGES 1999/04/22 10:48:57 1.1325 @@ -1,5 +1,8 @@ Changes with Apache 1.3.7 + *) Fix special RewriteCond -s pattern matching. + [Bob Finch [EMAIL PROTECTED]] + *) Fix value quoting in src/Configure script for ap_config_auto.h [Paul Sutton [EMAIL PROTECTED]] 1.138 +1 -1 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.137 retrieving revision 1.138 diff -u -r1.137 -r1.138 --- mod_rewrite.c 1999/04/22 09:54:37 1.137 +++ mod_rewrite.c 1999/04/22 10:48:59 1.138 @@ -2175,7 +2175,7 @@ } } } -else if (strcmp(p-pattern, -s ) == 0) { +else if (strcmp(p-pattern, -s) == 0) { if (stat(input, sb) == 0) { if (S_ISREG(sb.st_mode) sb.st_size 0) { rc = 1;
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/12/02 00:24:40 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Fixed possible (but harmless in practice) bug in the DBM lookup procedure of mod_rewrite: very long keys were truncated. Revision ChangesPath 1.1156+4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1155 retrieving revision 1.1156 diff -u -r1.1155 -r1.1156 --- CHANGES 1998/12/02 06:12:09 1.1155 +++ CHANGES 1998/12/02 08:24:35 1.1156 @@ -1,5 +1,9 @@ Changes with Apache 1.3.4 + *) Fixed possible (but harmless in practice) bug in the DBM lookup + procedure of mod_rewrite: very long keys were truncated. + [Ralf S. Engelschall] + *) There is no longer a _default_ path layout for APACI configure. This means the user _HAS_ to specifiy a path layout _explicitly_. 1.132 +4 -3 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.131 retrieving revision 1.132 diff -u -r1.131 -r1.132 --- mod_rewrite.c 1998/10/28 15:01:18 1.131 +++ mod_rewrite.c 1998/12/02 08:24:39 1.132 @@ -2877,12 +2877,13 @@ char buf[MAX_STRING_LEN]; dbmkey.dptr = key; -dbmkey.dsize = (strlen(key) sizeof(buf) - 1 ? -strlen(key) : sizeof(buf)-1); +dbmkey.dsize = strlen(key); if ((dbmfp = dbm_open(file, O_RDONLY, 0666)) != NULL) { dbmval = dbm_fetch(dbmfp, dbmkey); if (dbmval.dptr != NULL) { -memcpy(buf, dbmval.dptr, dbmval.dsize); +memcpy(buf, dbmval.dptr, + dbmval.dsize sizeof(buf)-1 ? + dbmval.dsize : sizeof(buf)-1 ); buf[dbmval.dsize] = '\0'; value = ap_pstrdup(r-pool, buf); }
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/10/28 07:01:19 Modified:src/support apxs.pl src/modules/standard mod_rewrite.c Log: Fix hook order in mod_rewrite's and apxs's module structure _comments_. The poor man who discovered this bug after he was already totally confused was Lincoln Stein [EMAIL PROTECTED]. Thanks for sharing your confusion, Lincoln. Revision ChangesPath 1.11 +2 -2 apache-1.3/src/support/apxs.pl Index: apxs.pl === RCS file: /export/home/cvs/apache-1.3/src/support/apxs.pl,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- apxs.pl 1998/08/03 08:44:08 1.10 +++ apxs.pl 1998/10/28 15:01:17 1.11 @@ -599,11 +599,11 @@ NULL, /* [#1] URI to filename translation*/ NULL, /* [#4] validate user id from request */ NULL, /* [#5] check if the user is ok _here_ */ -NULL, /* [#2] check access by host address */ +NULL, /* [#3] check access by host address */ NULL, /* [#6] determine MIME type*/ NULL, /* [#7] pre-run fixups */ NULL, /* [#9] log a transaction */ -NULL, /* [#3] header parser */ +NULL, /* [#2] header parser */ NULL, /* child_init */ NULL, /* child_exit */ NULL /* [#0] post read-request */ 1.131 +2 -2 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.130 retrieving revision 1.131 diff -u -r1.130 -r1.131 --- mod_rewrite.c 1998/08/25 09:15:39 1.130 +++ mod_rewrite.c 1998/10/28 15:01:18 1.131 @@ -192,11 +192,11 @@ hook_uri2file, /* [#1] URI to filename translation*/ NULL,/* [#4] validate user id from request */ NULL,/* [#5] check if the user is ok _here_ */ - NULL,/* [#2] check access by host address */ + NULL,/* [#3] check access by host address */ hook_mimetype, /* [#6] determine MIME type*/ hook_fixup, /* [#7] pre-run fixups */ NULL,/* [#9] log a transaction */ - NULL,/* [#3] header parser */ + NULL,/* [#2] header parser */ init_child, /* child_init */ NULL,/* child_exit */ NULL /* [#0] post read-request */
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
coar98/07/23 04:34:02 Modified:src/modules/standard mod_rewrite.c mod_rewrite.h Log: Add some capability for setting the Vary response field when mod_rewrite makes changes based upon request fields. This is by no means a complete treatment of the problem (redirects don't inherit the Vary at the moment, for instance), but at least we're not ignoring Vary here completely any more. PR: 1644 Reviewed by: Ralf Engelschall Revision ChangesPath 1.126 +20 -0 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.125 retrieving revision 1.126 diff -u -r1.125 -r1.126 --- mod_rewrite.c 1998/07/18 15:30:46 1.125 +++ mod_rewrite.c 1998/07/23 11:34:00 1.126 @@ -1728,6 +1728,7 @@ { char *uri; char *output; +const char *vary; char newuri[MAX_STRING_LEN]; char env[MAX_STRING_LEN]; regex_t *regexp; @@ -1841,6 +1842,7 @@ /* One condition is false, but another can be * still true, so we have to continue... */ + ap_table_unset(r-notes, VARY_KEY_THIS); continue; } else { @@ -1866,13 +1868,30 @@ break; } } + vary = ap_table_get(r-notes, VARY_KEY_THIS); + if (vary != NULL) { + ap_table_merge(r-notes, VARY_KEY, vary); + ap_table_unset(r-notes, VARY_KEY_THIS); + } } /* if any condition fails the complete rule fails */ if (failed) { +ap_table_unset(r-notes, VARY_KEY); +ap_table_unset(r-notes, VARY_KEY_THIS); return 0; } /* + * Regardless of what we do next, we've found a match. Check to see + * if any of the request header fields were involved, and add them + * to the Vary field of the response. + */ +if ((vary = ap_table_get(r-notes, VARY_KEY)) != NULL) { +ap_table_merge(r-headers_out, Vary, vary); + ap_table_unset(r-notes, VARY_KEY); +} + +/* * If this is a pure matching rule (`RewriteRule pat -') * we stop processing and return immediately. The only thing * we have not to forget are the environment variables @@ -3718,6 +3737,7 @@ continue; } if (strcasecmp(hdrs[i].key, name) == 0) { + ap_table_merge(r-notes, VARY_KEY_THIS, name); return hdrs[i].val; } } 1.56 +7 -0 apache-1.3/src/modules/standard/mod_rewrite.h Index: mod_rewrite.h === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- mod_rewrite.h 1998/07/13 11:32:46 1.55 +++ mod_rewrite.h 1998/07/23 11:34:01 1.56 @@ -113,6 +113,13 @@ #include http_log.h #include http_vhost.h +/* + * The key in the r-notes table wherein we store our accumulated + * Vary values, and the one used for per-condition checks in a chain. + */ +#define VARY_KEY rewrite-Vary +#define VARY_KEY_THIS rewrite-Vary-this + /* The NDBM support: * We support only NDBM files. * But we have to stat the file for the mtime,
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
jim 98/07/18 08:30:47 Modified:src/helpers TestCompile src/include ap_config.h src/modules/standard mod_rewrite.c Log: Submitted by: Brian Havard [EMAIL PROTECTED] Reviewed by: Jim Jagielski EMX OS/2 Port Revision ChangesPath 1.13 +1 -1 apache-1.3/src/helpers/TestCompile Index: TestCompile === RCS file: /export/home/cvs/apache-1.3/src/helpers/TestCompile,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- TestCompile 1998/07/11 10:24:07 1.12 +++ TestCompile 1998/07/18 15:30:41 1.13 @@ -1,6 +1,6 @@ #!/bin/sh exstat=1 -trap 'rm -f Makefile dummy testfunc.c testfunc; exit $exstat' 0 1 2 3 15 +trap 'rm -f Makefile dummy dummy.exe testfunc.c testfunc testfunc.exe; exit $exstat' 0 1 2 3 15 # # Yet another Apache Configure helper script. # This script tests certain aspects of the compilation 1.227 +2 -0 apache-1.3/src/include/ap_config.h Index: ap_config.h === RCS file: /export/home/cvs/apache-1.3/src/include/ap_config.h,v retrieving revision 1.226 retrieving revision 1.227 diff -u -r1.226 -r1.227 --- ap_config.h 1998/07/13 12:35:53 1.226 +++ ap_config.h 1998/07/18 15:30:43 1.227 @@ -662,6 +662,8 @@ #define NEED_STRNCASECMP #define NO_SETSID #define NO_TIMES +/* ap_config_auto.h gets this wrong, force sys/select.h to be included */ +#define HAVE_SYS_SELECT_H #define CASE_BLIND_FILESYSTEM /* Add some drive name support */ #define chdir _chdir2 1.125 +1 -1 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.124 retrieving revision 1.125 diff -u -r1.124 -r1.125 --- mod_rewrite.c 1998/07/12 15:47:39 1.124 +++ mod_rewrite.c 1998/07/18 15:30:46 1.125 @@ -3213,7 +3213,7 @@ file %s, conf-rewritelockfile); exit(1); } -#ifndef WIN32 +#if !defined(__EMX__) !defined(WIN32) /* make sure the childs have access to this file */ if (geteuid() == 0 /* is superuser */) chown(conf-rewritelockfile, ap_user_id, -1 /* no gid change */);
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
pcs 98/07/12 08:47:40 Modified:src/modules/standard mod_rewrite.c Log: Quick fix to make this compile on Windows: ifdef out reference to geteuid() and chown(). Revision ChangesPath 1.124 +2 -0 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.123 retrieving revision 1.124 diff -u -r1.123 -r1.124 --- mod_rewrite.c 1998/07/11 10:56:07 1.123 +++ mod_rewrite.c 1998/07/12 15:47:39 1.124 @@ -3213,9 +3213,11 @@ file %s, conf-rewritelockfile); exit(1); } +#ifndef WIN32 /* make sure the childs have access to this file */ if (geteuid() == 0 /* is superuser */) chown(conf-rewritelockfile, ap_user_id, -1 /* no gid change */); +#endif return; }
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
rse 98/07/11 03:56:09 Modified:src CHANGES src/modules/standard mod_rewrite.c mod_rewrite.h Log: mod_rewrite created RewriteLock files under the uid of the parent process, thus the child processes had no write access to the files. Now a chown() is done to the uid of the childs if applicable. Submitted by: Lars Eilebrecht Reviewed and fixed by: Ralf S. Engelschall PR: 2341 PS: Lars, I've changed s-server_uid to ap_user_id because s-server_uid can be different inside virtual hosts for the suEXEC mechanism. But we need the uid of the process, so ap_user_id is correct IMHO. And I've searched for the PR in the bugdb for you and noted it above. Revision ChangesPath 1.960 +5 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.959 retrieving revision 1.960 diff -u -r1.959 -r1.960 --- CHANGES 1998/07/11 10:24:05 1.959 +++ CHANGES 1998/07/11 10:56:03 1.960 @@ -1,5 +1,10 @@ Changes with Apache 1.3.1 + *) mod_rewrite created RewriteLock files under the uid of the parent + process, thus the child processes had no write access to the files. + Now a chown() is done to the uid of the childs if applicable. + [Lars Eilebrecht, Ralf S. Engelschall] PR#2341 + *) Autogenerate some HAVE_X_H defines in conf_auto.h (determined via TestCompile) instead of defining them manually in conf.h based on less accurate platform definitions. This way we no longer have to fiddle with 1.123 +4 -0 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.122 retrieving revision 1.123 diff -u -r1.122 -r1.123 --- mod_rewrite.c 1998/07/09 17:13:56 1.122 +++ mod_rewrite.c 1998/07/11 10:56:07 1.123 @@ -3213,6 +3213,10 @@ file %s, conf-rewritelockfile); exit(1); } +/* make sure the childs have access to this file */ +if (geteuid() == 0 /* is superuser */) +chown(conf-rewritelockfile, ap_user_id, -1 /* no gid change */); + return; } 1.54 +1 -0 apache-1.3/src/modules/standard/mod_rewrite.h Index: mod_rewrite.h === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- mod_rewrite.h 1998/05/29 08:32:40 1.53 +++ mod_rewrite.h 1998/07/11 10:56:08 1.54 @@ -107,6 +107,7 @@ /* Include from the Apache server ... */ #include httpd.h #include http_config.h +#include http_conf_globals.h #include http_request.h #include http_core.h #include http_log.h
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/07/09 10:13:58 Modified:src/modules/standard mod_rewrite.c Log: Replace a very old in-place hack for APACHE_SSL with a more clean ap_http_method() based variant (which is still ok for Apache-SSL because it patches ap_http_method() itself). This way there is now really _no_ sort of crypto hook in the official Apache distribution ;-) Revision ChangesPath 1.122 +9 -9 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.121 retrieving revision 1.122 diff -u -r1.121 -r1.122 --- mod_rewrite.c 1998/07/08 17:47:18 1.121 +++ mod_rewrite.c 1998/07/09 17:13:56 1.122 @@ -2330,21 +2330,21 @@ char host[LONG_STRING_LEN]; char buf[MAX_STRING_LEN]; char *olduri; +int l; -#ifdef APACHE_SSL -if ( (!r-connection-client-ssl -strncasecmp(r-filename, http://;, 7) == 0) -|| (r-connection-client-ssl -strncasecmp(r-filename, https://;, 8) == 0)) { -#else -if (strncasecmp(r-filename, http://;, 7) == 0) { -#endif +cp = ap_http_method(r); +l = strlen(cp); +if ( strlen(r-filename) l+3 + strncasecmp(r-filename, cp, l) == 0 + r-filename[l] == ':' + r-filename[l+1] == '/' + r-filename[l+2] == '/' ) { /* there was really a rewrite to a remote path */ olduri = ap_pstrdup(r-pool, r-filename); /* save for logging */ /* cut the hostname and port out of the URI */ -ap_cpystrn(buf, r-filename+strlen(ap_http_method(r))+3, sizeof(buf)); +ap_cpystrn(buf, r-filename+(l+3), sizeof(buf)); hostp = buf; for (cp = hostp; *cp != '\0' *cp != '/' *cp != ':'; cp++) ;
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
coar98/06/16 05:19:45 Modified:src/modules/standard mod_rewrite.c Log: More style-guide cleanup (preparatory to some Vary work). Revision ChangesPath 1.117 +405 -213 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.116 retrieving revision 1.117 diff -u -r1.116 -r1.117 --- mod_rewrite.c 1998/06/13 15:23:11 1.116 +++ mod_rewrite.c 1998/06/16 12:19:43 1.117 @@ -265,16 +265,21 @@ * local directives override * and anything else is inherited */ -a-rewriteloglevel = overrides-rewriteloglevel != 0 ? - overrides-rewriteloglevel : base-rewriteloglevel; -a-rewritelogfile = overrides-rewritelogfile != NULL ? - overrides-rewritelogfile : base-rewritelogfile; -a-rewritelogfp= overrides-rewritelogfp != -1 ? - overrides-rewritelogfp : base-rewritelogfp; -a-rewritelockfile = overrides-rewritelockfile != NULL ? - overrides-rewritelockfile : base-rewritelockfile; -a-rewritelockfp = overrides-rewritelockfp != -1 ? - overrides-rewritelockfp : base-rewritelockfp; +a-rewriteloglevel = overrides-rewriteloglevel != 0 + ? overrides-rewriteloglevel + : base-rewriteloglevel; +a-rewritelogfile = overrides-rewritelogfile != NULL + ? overrides-rewritelogfile + : base-rewritelogfile; +a-rewritelogfp= overrides-rewritelogfp != -1 + ? overrides-rewritelogfp + : base-rewritelogfp; +a-rewritelockfile = overrides-rewritelockfile != NULL + ? overrides-rewritelockfile + : base-rewritelockfile; +a-rewritelockfp = overrides-rewritelockfp != -1 + ? overrides-rewritelockfp + : base-rewritelockfp; a-rewritemaps = ap_append_arrays(p, overrides-rewritemaps, base-rewritemaps); a-rewriteconds= ap_append_arrays(p, overrides-rewriteconds, @@ -319,14 +324,17 @@ a-rewriteconds= ap_make_array(p, 2, sizeof(rewritecond_entry)); a-rewriterules= ap_make_array(p, 2, sizeof(rewriterule_entry)); -if (path == NULL) +if (path == NULL) { a-directory = NULL; +} else { /* make sure it has a trailing slash */ -if (path[strlen(path)-1] == '/') +if (path[strlen(path)-1] == '/') { a-directory = ap_pstrdup(p, path); -else + } + else { a-directory = ap_pstrcat(p, path, /, NULL); + } } return (void *)a; @@ -336,7 +344,8 @@ { rewrite_perdir_conf *a, *base, *overrides; -a = (rewrite_perdir_conf *)ap_pcalloc(p, sizeof(rewrite_perdir_conf)); +a = (rewrite_perdir_conf *)ap_pcalloc(p, + sizeof(rewrite_perdir_conf)); base = (rewrite_perdir_conf *)basev; overrides = (rewrite_perdir_conf *)overridesv; @@ -371,13 +380,16 @@ { rewrite_server_conf *sconf; -sconf = (rewrite_server_conf *) -ap_get_module_config(cmd-server-module_config, rewrite_module); +sconf = +(rewrite_server_conf *)ap_get_module_config(cmd-server-module_config, + rewrite_module); -if (cmd-path == NULL) /* is server command */ +if (cmd-path == NULL) { /* is server command */ sconf-state = (flag ? ENGINE_ENABLED : ENGINE_DISABLED); -else /* is per-directory command */ +} +else /* is per-directory command */ { dconf-state = (flag ? ENGINE_ENABLED : ENGINE_DISABLED); +} return NULL; } @@ -391,12 +403,14 @@ sconf = (rewrite_server_conf *) ap_get_module_config(cmd-server-module_config, rewrite_module); -if (cmd-path == NULL) /* is server command */ +if (cmd-path == NULL) { /* is server command */ err = cmd_rewriteoptions_setoption(cmd-pool, (sconf-options), option); -else /* is per-directory command */ +} +else { /* is per-directory command */ err = cmd_rewriteoptions_setoption(cmd-pool, (dconf-options), option); +}
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/06/16 07:03:39 Modified:src/modules/standard mod_rewrite.c Log: Great thanks to Ken for the source style adjustments. I've now only converted the introduced tabs to spaces as in the remaining part of the mod_rewrite.c source code for consistency. Revision ChangesPath 1.118 +149 -149 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.117 retrieving revision 1.118 diff -u -r1.117 -r1.118 --- mod_rewrite.c 1998/06/16 12:19:43 1.117 +++ mod_rewrite.c 1998/06/16 14:03:38 1.118 @@ -266,20 +266,20 @@ * and anything else is inherited */ a-rewriteloglevel = overrides-rewriteloglevel != 0 - ? overrides-rewriteloglevel - : base-rewriteloglevel; + ? overrides-rewriteloglevel + : base-rewriteloglevel; a-rewritelogfile = overrides-rewritelogfile != NULL - ? overrides-rewritelogfile - : base-rewritelogfile; + ? overrides-rewritelogfile + : base-rewritelogfile; a-rewritelogfp= overrides-rewritelogfp != -1 - ? overrides-rewritelogfp - : base-rewritelogfp; + ? overrides-rewritelogfp + : base-rewritelogfp; a-rewritelockfile = overrides-rewritelockfile != NULL - ? overrides-rewritelockfile - : base-rewritelockfile; + ? overrides-rewritelockfile + : base-rewritelockfile; a-rewritelockfp = overrides-rewritelockfp != -1 - ? overrides-rewritelockfp - : base-rewritelockfp; + ? overrides-rewritelockfp + : base-rewritelockfp; a-rewritemaps = ap_append_arrays(p, overrides-rewritemaps, base-rewritemaps); a-rewriteconds= ap_append_arrays(p, overrides-rewriteconds, @@ -331,10 +331,10 @@ /* make sure it has a trailing slash */ if (path[strlen(path)-1] == '/') { a-directory = ap_pstrdup(p, path); - } - else { +} +else { a-directory = ap_pstrcat(p, path, /, NULL); - } +} } return (void *)a; @@ -345,7 +345,7 @@ rewrite_perdir_conf *a, *base, *overrides; a = (rewrite_perdir_conf *)ap_pcalloc(p, - sizeof(rewrite_perdir_conf)); + sizeof(rewrite_perdir_conf)); base = (rewrite_perdir_conf *)basev; overrides = (rewrite_perdir_conf *)overridesv; @@ -382,7 +382,7 @@ sconf = (rewrite_server_conf *)ap_get_module_config(cmd-server-module_config, - rewrite_module); +rewrite_module); if (cmd-path == NULL) { /* is server command */ sconf-state = (flag ? ENGINE_ENABLED : ENGINE_DISABLED); @@ -423,7 +423,7 @@ } else { return ap_pstrcat(p, RewriteOptions: unknown option ', - name, '\n, NULL); + name, '\n, NULL); } return NULL; } @@ -497,14 +497,14 @@ new-checkfile = NULL; if (strcmp(a2+4, tolower) == 0) { new-func = rewrite_mapfunc_tolower; - } +} else if (strcmp(a2+4, toupper) == 0) { new-func = rewrite_mapfunc_toupper; - } +} else if (sconf-state == ENGINE_ENABLED) { return ap_pstrcat(cmd-pool, RewriteMap: internal map not found:, a2+4, NULL); - } +} } else { new-type = MAPTYPE_TXT; @@ -515,9 +515,9 @@ new-fpout = -1; if (new-checkfile (sconf-state == ENGINE_ENABLED) - (stat(new-checkfile, st) == -1)) { + (stat(new-checkfile, st) == -1)) { return ap_pstrcat(cmd-pool, - RewriteMap: map file or program not found:, + RewriteMap: map file or program not found:, new-checkfile, NULL); } @@ -593,9 +593,9 @@ new-flags = CONDFLAG_NONE; if (a3 != NULL) { if ((err = cmd_rewritecond_parseflagfield(cmd-pool,
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/06/09 02:35:08 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Replace two bad sprintf() calls with ap_snprintf() variants in mod_rewrite. The sprintf()'s were incorrectly introduced recently because Ralf didn't recognize that although the ap_psprintf() needs a pool (which is not available at the particular place in mod_rewrite) we also have the non-pool based more secure ap_snprintf() (which is now used). Thanks to Marc for complaining and giving the hint to ap_snprintf(). Revision ChangesPath 1.901 +7 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.900 retrieving revision 1.901 diff -u -r1.900 -r1.901 --- CHANGES 1998/06/09 05:22:10 1.900 +++ CHANGES 1998/06/09 09:35:05 1.901 @@ -1,5 +1,12 @@ Changes with Apache 1.3.1 + *) Replace two bad sprintf() calls with ap_snprintf() variants in + mod_rewrite. The sprintf()'s were incorrectly introduced recently because + Ralf didn't recognize that although the ap_psprintf() needs a pool (which + is not available at the particular place in mod_rewrite) we also have the + non-pool based more secure ap_snprintf() (which is now used). + [Ralf S. Engelschall] + *) Fix missing usage description for MetaFiles directive. [David MacKenzie [EMAIL PROTECTED]] PR#2384 1.115 +3 -2 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.114 retrieving revision 1.115 diff -u -r1.114 -r1.115 --- mod_rewrite.c 1998/06/03 12:12:11 1.114 +++ mod_rewrite.c 1998/06/09 09:35:07 1.115 @@ -2820,7 +2820,8 @@ char buf[50]; rewrite_rand_init(); -sprintf(buf, %.0f, (((double)(rand()%RAND_MAX)/RAND_MAX)*(h-l))); +ap_snprintf(buf, sizeof(buf), %.0f, +(((double)(rand()%RAND_MAX)/RAND_MAX)*(h-l))); i = atoi(buf)+1; if (i l) i = l; if (i h) i = h; @@ -3194,7 +3195,7 @@ STARTUPINFO si; PROCESS_INFORMATION pi; -sprintf(pCommand, %s /C %s, SHELL_PATH, cmd); +ap_snprintf(pCommand, sizeof(pCommand), %s /C %s, SHELL_PATH, cmd); memset(si, 0, sizeof(si)); memset(pi, 0, sizeof(pi));
Re: cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
On 3 Jun 1998 [EMAIL PROTECTED] wrote: rse 98/06/03 05:12:12 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Fix recently introduced Win32 child spawning code in mod_rewrite.c which was broken because of invalid ap_pstrcat() - strcat() transformation. I'm a little bit confused: Seems like no one has actually compiled Apache with all modules under Win32 just before Jim rolled the 1.3.0 tarball. Because else someone had received a compile error. Hmmm... I knew why I hates to put code into mod_rewrite I couldn't test myself... :-( Why is it using sprintf? No. Code. Should. Use. sprintf. Almost. We have an ap_snprintf. Use it. I don't care if it isn't necessary or you think it isn't necessary or it may not be necessary or you hope it isn't necessary. Always unless you shouldn't. And I see no reason why you shouldn't here. +++ mod_rewrite.c 1998/06/03 12:12:11 1.114 @@ -3190,11 +3190,11 @@ #if defined(WIN32) /* MS Windows */ { -char *pCommand; +char pCommand[MAX_STRING_LEN]; STARTUPINFO si; PROCESS_INFORMATION pi; -pCommand = strcat(SHELL_PATH, /C , cmd, NULL); +sprintf(pCommand, %s /C %s, SHELL_PATH, cmd); memset(si, 0, sizeof(si)); memset(pi, 0, sizeof(pi));
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/06/03 05:12:12 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: Fix recently introduced Win32 child spawning code in mod_rewrite.c which was broken because of invalid ap_pstrcat() - strcat() transformation. I'm a little bit confused: Seems like no one has actually compiled Apache with all modules under Win32 just before Jim rolled the 1.3.0 tarball. Because else someone had received a compile error. Hmmm... I knew why I hates to put code into mod_rewrite I couldn't test myself... :-( Revision ChangesPath 1.882 +4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.881 retrieving revision 1.882 diff -u -r1.881 -r1.882 --- CHANGES 1998/06/02 12:50:44 1.881 +++ CHANGES 1998/06/03 12:12:10 1.882 @@ -1,5 +1,9 @@ Changes with Apache 1.3.1 + *) Fix recently introduced Win32 child spawning code in mod_rewrite.c which + was broken because of invalid ap_pstrcat() - strcat() transformation. + [Ralf S. Engelschall] + *) Proxy Cache Fixes: account for directory sizes, fork off garbage collection to continue in background, use predefined types (off_t, size_t, time_t), log the current cache usage percentage at LogLevel debug 1.114 +2 -2 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.113 retrieving revision 1.114 diff -u -r1.113 -r1.114 --- mod_rewrite.c 1998/05/29 09:19:41 1.113 +++ mod_rewrite.c 1998/06/03 12:12:11 1.114 @@ -3190,11 +3190,11 @@ #if defined(WIN32) /* MS Windows */ { -char *pCommand; +char pCommand[MAX_STRING_LEN]; STARTUPINFO si; PROCESS_INFORMATION pi; -pCommand = strcat(SHELL_PATH, /C , cmd, NULL); +sprintf(pCommand, %s /C %s, SHELL_PATH, cmd); memset(si, 0, sizeof(si)); memset(pi, 0, sizeof(pi));
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/05/28 23:59:36 Modified:src/modules/standard mod_rewrite.c Log: Separate cosmetics from coming ap_log_error-patch. Revision ChangesPath 1.111 +3 -3 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.110 retrieving revision 1.111 diff -u -r1.110 -r1.111 --- mod_rewrite.c 1998/05/28 22:09:58 1.110 +++ mod_rewrite.c 1998/05/29 06:59:35 1.111 @@ -2896,7 +2896,7 @@ fprintf(stderr, mod_rewrite: could not open reliable piped log for RewriteLog\n); -exit (1); +exit(1); } conf-rewritelogfp = ap_piped_log_write_fd(pl); } @@ -3156,8 +3156,8 @@ fpin = NULL; fpout = NULL; rc = ap_spawn_child(p, rewritemap_program_child, - (void *)map-datafile, kill_after_timeout, - fpin, fpout, fperr); +(void *)map-datafile, kill_after_timeout, +fpin, fpout, fperr); if (rc == 0 || fpin == NULL || fpout == NULL) { perror(ap_spawn_child); fprintf(stderr, mod_rewrite:
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
rse 98/05/29 01:32:41 Modified:src CHANGES src/modules/standard mod_rewrite.c mod_rewrite.h Log: Change usage of perror()+fprintf(stderr,...) in mod_rewrite to more proper ap_log_error() variants. Same Brian has done for the other modules, BTW. Revision ChangesPath 1.876 +4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.875 retrieving revision 1.876 diff -u -r1.875 -r1.876 --- CHANGES 1998/05/29 07:59:55 1.875 +++ CHANGES 1998/05/29 08:32:36 1.876 @@ -1,5 +1,9 @@ Changes with Apache 1.3b8 + *) Change usage of perror()+fprintf(stderr,...) in mod_rewrite to + more proper ap_log_error() variants. + [Ralf S. Engelschall] + *) Make sure the argument for the --add-module option to APACI's configure script is of type [path/to/]mod_xxx.c because all calculations inside configure and src/Configure depend on this. 1.112 +25 -43apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.111 retrieving revision 1.112 diff -u -r1.111 -r1.112 --- mod_rewrite.c 1998/05/29 06:59:35 1.111 +++ mod_rewrite.c 1998/05/29 08:32:39 1.112 @@ -2892,10 +2892,9 @@ if (*conf-rewritelogfile == '|') { if ((pl = ap_open_piped_log(p, conf-rewritelogfile+1)) == NULL) { -perror(ap_open_piped_log); -fprintf(stderr, -mod_rewrite: could not open reliable piped log for -RewriteLog\n); +ap_log_error(APLOG_MARK, APLOG_ERR, s, + mod_rewrite: could not open reliable pipe + to RewriteLog filter %s, conf-rewritelogfile+1); exit(1); } conf-rewritelogfp = ap_piped_log_write_fd(pl); @@ -2903,10 +2902,9 @@ else if (*conf-rewritelogfile != '\0') { if ((conf-rewritelogfp = ap_popenf(p, fname, rewritelog_flags, rewritelog_mode)) 0) { -perror(open); -fprintf(stderr, -mod_rewrite: could not open RewriteLog file %s.\n, -fname); +ap_log_error(APLOG_MARK, APLOG_ERR, s, + mod_rewrite: could not open RewriteLog + file %s, fname); exit(1); } } @@ -2980,9 +2978,9 @@ (unsigned long)(r-server), (unsigned long)r, type, redir, level, str2); -fd_lock(conf-rewritelogfp); +fd_lock(r, conf-rewritelogfp); write(conf-rewritelogfp, str3, strlen(str3)); -fd_unlock(conf-rewritelogfp); +fd_unlock(r, conf-rewritelogfp); va_end(ap); return; @@ -3042,9 +3040,9 @@ if ((conf-rewritelockfp = ap_popenf(p, conf-rewritelockfile, O_WRONLY|O_CREAT, REWRITELOCK_MODE)) 0) { -perror(open); -fprintf(stderr, mod_rewrite: Parent could not create RewriteLock - file %s.\n, conf-rewritelockfile); +ap_log_error(APLOG_MARK, APLOG_ERR, s, + mod_rewrite: Parent could not create RewriteLock + file %s, conf-rewritelockfile); exit(1); } return; @@ -3065,9 +3063,9 @@ if ((conf-rewritelockfp = ap_popenf(p, conf-rewritelockfile, O_WRONLY, REWRITELOCK_MODE)) 0) { -perror(open); -fprintf(stderr, mod_rewrite: Child could not open RewriteLock - file %s.\n, conf-rewritelockfile); +ap_log_error(APLOG_MARK, APLOG_ERR, s, + mod_rewrite: Child could not open RewriteLock + file %s, conf-rewritelockfile); exit(1); } return; @@ -3098,7 +3096,7 @@ conf = ap_get_module_config(r-server-module_config, rewrite_module); if (conf-rewritelockfp != -1) -fd_lock(conf-rewritelockfp); +fd_lock(r, conf-rewritelockfp); return; } @@ -3109,7 +3107,7 @@ conf = ap_get_module_config(r-server-module_config, rewrite_module); if (conf-rewritelockfp != -1) -fd_unlock(conf-rewritelockfp); +fd_unlock(r, conf-rewritelockfp); return; } @@ -3159,9 +3157,9 @@ (void *)map-datafile, kill_after_timeout, fpin, fpout, fperr); if (rc == 0 || fpin
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/05/29 02:19:42 Modified:src/modules/standard mod_rewrite.c Log: Some indentation cosmetics because with the ap_ prefix some long lines moved. Revision ChangesPath 1.113 +77 -76apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.112 retrieving revision 1.113 diff -u -r1.112 -r1.113 --- mod_rewrite.c 1998/05/29 08:32:39 1.112 +++ mod_rewrite.c 1998/05/29 09:19:41 1.113 @@ -276,11 +276,11 @@ a-rewritelockfp = overrides-rewritelockfp != -1 ? overrides-rewritelockfp : base-rewritelockfp; a-rewritemaps = ap_append_arrays(p, overrides-rewritemaps, - base-rewritemaps); + base-rewritemaps); a-rewriteconds= ap_append_arrays(p, overrides-rewriteconds, - base-rewriteconds); + base-rewriteconds); a-rewriterules= ap_append_arrays(p, overrides-rewriterules, - base-rewriterules); + base-rewriterules); } else { /* @@ -347,9 +347,9 @@ if (a-options OPTION_INHERIT) { a-rewriteconds = ap_append_arrays(p, overrides-rewriteconds, -base-rewriteconds); + base-rewriteconds); a-rewriterules = ap_append_arrays(p, overrides-rewriterules, -base-rewriterules); + base-rewriterules); } else { a-rewriteconds = overrides-rewriteconds; @@ -467,7 +467,7 @@ new-checkfile = ap_pstrcat(cmd-pool, a2+4, NDBM_FILE_SUFFIX, NULL); #else return ap_pstrdup(cmd-pool, RewriteMap: cannot use NDBM mapfile, - because no NDBM support is compiled in); + because no NDBM support is compiled in); #endif } else if (strncmp(a2, prg:, 4) == 0) { @@ -485,7 +485,7 @@ new-func = rewrite_mapfunc_toupper; else if (sconf-state == ENGINE_ENABLED) return ap_pstrcat(cmd-pool, RewriteMap: internal map not found:, - a2+4, NULL); + a2+4, NULL); } else { new-type = MAPTYPE_TXT; @@ -498,7 +498,7 @@ if (new-checkfile (sconf-state == ENGINE_ENABLED) (stat(new-checkfile, st) == -1)) return ap_pstrcat(cmd-pool, RewriteMap: map file or program not found:, - new-checkfile, NULL); + new-checkfile, NULL); return NULL; } @@ -555,7 +555,7 @@ /* parse the argument line ourself */ if (parseargline(str, a1, a2, a3)) return ap_pstrcat(cmd-pool, RewriteCond: bad argument line ', str, - '\n, NULL); + '\n, NULL); /* arg1: the input string */ new-input = ap_pstrdup(cmd-pool, a1); @@ -587,8 +587,8 @@ rc = ((regexp = ap_pregcomp(cmd-pool, cp, REG_EXTENDED)) == NULL); if (rc) return ap_pstrcat(cmd-pool, - RewriteCond: cannot compile regular expression ', a2, - '\n, NULL); + RewriteCond: cannot compile regular expression ', + a2, '\n, NULL); new-pattern = ap_pstrdup(cmd-pool, cp); new-regexp = regexp; @@ -685,7 +685,7 @@ /* parse the argument line ourself */ if (parseargline(str, a1, a2, a3)) return ap_pstrcat(cmd-pool, RewriteRule: bad argument line ', str, - '\n, NULL); + '\n, NULL); /* arg1: the pattern * try to compile the regexp to test if is ok @@ -698,8 +698,8 @@ } if ((regexp = ap_pregcomp(cmd-pool, cp, REG_EXTENDED)) == NULL) return ap_pstrcat(cmd-pool, - RewriteRule: cannot compile regular expression ', a1, - '\n, NULL); + RewriteRule: cannot compile regular expression ', + a1, '\n, NULL); new-pattern = ap_pstrdup(cmd-pool, cp); new-regexp = regexp; @@ -726,12 +726,12 @@ if (cmd-path == NULL) { /* is server command */ new-rewriteconds = sconf-rewriteconds; sconf-rewriteconds = ap_make_array(cmd-pool, 2, - sizeof(rewritecond_entry));
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
rse 98/05/28 04:09:47 Modified:src CHANGES src/modules/standard mod_rewrite.c mod_rewrite.h Log: Upgrade the child spawning code in mod_rewrite for the RewriteMap programs: ap_spawn_child_err() is used and the Win32 case now uses CreateProcess() instead of a low-level execl() (which caused problems in the past under Win32). Reviewed by: Ben Laurie Revision ChangesPath 1.869 +6 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.868 retrieving revision 1.869 diff -u -r1.868 -r1.869 --- CHANGES 1998/05/28 10:57:56 1.868 +++ CHANGES 1998/05/28 11:09:44 1.869 @@ -1,4 +1,10 @@ Changes with Apache 1.3b8 + + *) Upgrade the child spawning code in mod_rewrite for the RewriteMap + programs: ap_spawn_child_err() is used and the Win32 case now uses + CreateProcess() instead of a low-level execl() (which caused problems in + the past under Win32). + [Ralf S. Engelschall] *) A few cosmetics and trivial enhancements to APXS to make the generated Makefile more user friendly. [Ralf S. Engelschall] 1.108 +40 -6 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.107 retrieving revision 1.108 diff -u -r1.107 -r1.108 --- mod_rewrite.c 1998/05/27 14:01:38 1.107 +++ mod_rewrite.c 1998/05/28 11:09:45 1.108 @@ -3127,6 +3127,7 @@ rewrite_server_conf *conf; FILE *fpin; FILE *fpout; +FILE *fperr; array_header *rewritemaps; rewritemap_entry *entries; rewritemap_entry *map; @@ -3154,16 +3155,18 @@ continue; fpin = NULL; fpout = NULL; -rc = spawn_child(p, rewritemap_program_child, (void *)map-datafile, - kill_after_timeout, fpin, fpout); +rc = ap_spawn_child_err(p, rewritemap_program_child, +(void *)map-datafile, kill_after_timeout, +fpin, fpout, fperr); if (rc == 0 || fpin == NULL || fpout == NULL) { -perror(spawn_child); +perror(ap_spawn_child); fprintf(stderr, mod_rewrite: could not fork child for RewriteMap process\n); exit(1); } map-fpin = fileno(fpin); map-fpout = fileno(fpout); +map-fperr = fileno(fperr); } return; } @@ -3173,17 +3176,48 @@ { int child_pid = 1; +/* + * Prepare for exec + */ ap_cleanup_for_exec(); #ifdef SIGHUP signal(SIGHUP, SIG_IGN); #endif + +/* + * Exec() the child program + */ #if defined(WIN32) -child_pid = spawnl(_P_NOWAIT, SHELL_PATH, SHELL_PATH, - /c, (char *)cmd, NULL); +/* MS Windows */ +{ +char *pCommand; +STARTUPINFO si; +PROCESS_INFORMATION pi; + +pCommand = strcat(SHELL_PATH, /C , cmd, NULL); + +memset(si, 0, sizeof(si)); +memset(pi, 0, sizeof(pi)); + +si.cb = sizeof(si); +si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; +si.wShowWindow = SW_HIDE; +si.hStdInput = pinfo-hPipeInputRead; +si.hStdOutput = pinfo-hPipeOutputWrite; +si.hStdError = pinfo-hPipeErrorWrite; + +if (CreateProcess(NULL, pCommand, NULL, NULL, TRUE, 0, + environ, NULL, si, pi)) { +CloseHandle(pi.hProcess); +CloseHandle(pi.hThread); +child_pid = pi.dwProcessId; +} +} #elif defined(__EMX__) -/* OS/2 needs a '/' */ +/* IBM OS/2 */ execl(SHELL_PATH, SHELL_PATH, /c, (char *)cmd, NULL); #else +/* Standard Unix */ execl(SHELL_PATH, SHELL_PATH, -c, (char *)cmd, NULL); #endif return(child_pid); 1.52 +1 -0 apache-1.3/src/modules/standard/mod_rewrite.h Index: mod_rewrite.h === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- mod_rewrite.h 1998/05/20 15:34:27 1.51 +++ mod_rewrite.h 1998/05/28 11:09:46 1.52 @@ -252,6 +252,7 @@ int type;/* the type of the map */ int fpin;/* in file pointer for program maps */ int fpout; /* out file pointer for program maps */ +
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/05/27 07:01:39 Modified:src CHANGES src/include compat.h http_config.h httpd.h src/main http_core.c http_protocol.c util.c src/modules/proxy mod_proxy.c src/modules/standard mod_rewrite.c Log: Renamed three more functions to common ap_ prefix which we missed at the Big Symbol Renaming because they're #defines and not real C functions: is_default_port() ap_is_default_port() default_port()== ap_default_port() http_method() ap_http_method(). Submitted by: Ralf S. Engelschall (Hint by Dean Gaudet) Reviewed by: Brian Behlendorf Revision ChangesPath 1.863 +5 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.862 retrieving revision 1.863 diff -u -r1.862 -r1.863 --- CHANGES 1998/05/26 00:54:06 1.862 +++ CHANGES 1998/05/27 14:01:29 1.863 @@ -1,4 +1,9 @@ Changes with Apache 1.3b8 + + *) Renamed three more functions to common ap_ prefix which we missed at the + Big Symbol Renaming because they're #defines and not real C functions: + is_default_port(), default_port(), http_method(). + [Ralf S. Engelschall] *) A zero-length name after a $ in an SSI document should cause just the $ to be in the expansion. This was broken during the 1.8 +3 -0 apache-1.3/src/include/compat.h Index: compat.h === RCS file: /export/home/cvs/apache-1.3/src/include/compat.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- compat.h 1998/05/06 12:23:40 1.7 +++ compat.h 1998/05/27 14:01:30 1.8 @@ -101,6 +101,7 @@ #define daemons_min_free ap_daemons_min_free #define daemons_to_start ap_daemons_to_start #define day_snames ap_day_snames +#define default_port ap_default_port #define default_port_for_request ap_default_port_for_request #define default_port_for_schemeap_default_port_for_scheme #define default_type ap_default_type @@ -160,6 +161,7 @@ #define hard_timeout ap_hard_timeout #define header_parse ap_header_parse #define ht_timeap_ht_time +#define http_methodap_http_method #define indap_ind #define index_of_response ap_index_of_response #define init_alloc ap_init_alloc @@ -169,6 +171,7 @@ #define internal_redirect ap_internal_redirect #define internal_redirect_handler ap_internal_redirect_handler #define invoke_handler ap_invoke_handler +#define is_default_portap_is_default_port #define is_directory ap_is_directory #define is_fnmatch ap_is_fnmatch #define is_initial_req ap_is_initial_req 1.87 +1 -1 apache-1.3/src/include/http_config.h Index: http_config.h === RCS file: /export/home/cvs/apache-1.3/src/include/http_config.h,v retrieving revision 1.86 retrieving revision 1.87 diff -u -r1.86 -r1.87 --- http_config.h 1998/05/19 18:00:59 1.86 +++ http_config.h 1998/05/27 14:01:31 1.87 @@ -275,7 +275,7 @@ * handle it back-compatibly, or at least signal an error). */ -#define MODULE_MAGIC_NUMBER 19980519 +#define MODULE_MAGIC_NUMBER 19980527 #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, -1, __FILE__, NULL, NULL /* Generic accessors for other modules to get at their own module-specific 1.215 +3 -3 apache-1.3/src/include/httpd.h Index: httpd.h === RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v retrieving revision 1.214 retrieving revision 1.215 diff -u -r1.214 -r1.215 --- httpd.h 1998/05/22 00:37:29 1.214 +++ httpd.h 1998/05/27 14:01:31 1.215 @@ -128,9 +128,9 @@ #define DEFAULT_HTTP_PORT80 #define DEFAULT_HTTPS_PORT 443 -#define is_default_port(port,r) ((port) == default_port(r)) -#define http_method(r) http -#define default_port(r) DEFAULT_HTTP_PORT +#define ap_is_default_port(port,r) ((port) == ap_default_port(r)) +#define ap_http_method(r)http +#define ap_default_port(r) DEFAULT_HTTP_PORT /* - Default user name and group name running standalone -- */ /* --- These may be specified as numbers by placing a # before a number --- */ 1.202 +6 -6
Re: cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
In article [EMAIL PROTECTED] you wrote: Beachtet dieser Patch die ExecCGI option? Oder kann man die damit unterlaufen? No, ExecCGI is still needed. And BTW, this is not a new feature, the [T=xxx] option exists for years. And it always was used this way. All I changed this time was to remove the inconsistency with the - pseudo-substitution URL (which means no subst). Nothing else. In the past one has to rewrite the URL to whatever and the whatever back to the URL to achieve this effect because - didn't honor the MIME-type stuff. So, no new features or new bugs, just one inconsistency less. Ralf S. Engelschall [EMAIL PROTECTED] www.engelschall.com
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/05/05 07:04:22 Modified:src/modules/standard mod_rewrite.c Log: Repair mod_rewrite - Lars' patch Brain comitted was totally broken. Thanks to Ben Hyde for immediately discovering this. Revision ChangesPath 1.103 +22 -15apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.102 retrieving revision 1.103 diff -u -r1.102 -r1.103 --- mod_rewrite.c 1998/05/05 04:47:59 1.102 +++ mod_rewrite.c 1998/05/05 14:04:20 1.103 @@ -943,11 +943,13 @@ void *sconf; rewrite_server_conf *conf; char *var; -char *thisserver, *thisport, *thisurl; +const char *thisserver; +char *thisport, *thisurl; char buf[512]; char docroot[512]; char *cp, *cp2; struct stat finfo; +unsigned int port; int n; int l; @@ -998,12 +1000,12 @@ */ /* add the canonical URI of this URL */ -thisserver = (char *) ap_get_server_name(r); -thisport = (char *) ap_get_server_port(r); -if (is_default_port((int) thisport, r)) +thisserver = ap_get_server_name(r); +port = ap_get_server_port(r); +if (is_default_port(port, r)) thisport = ; else { -ap_snprintf(buf, sizeof(buf), :%u, thisport); +ap_snprintf(buf, sizeof(buf), :%u, port); thisport = buf; } thisurl = ap_table_get(r-subprocess_env, ENVVAR_SCRIPT_URL); @@ -2249,8 +2251,10 @@ static void fully_qualify_uri(request_rec *r) { int i; -char port[32]; +char buf[32]; +const char *thisserver; char *thisport; +int port; i = strlen(r-filename); if (!( (i 7 strncasecmp(r-filename, http://;, 7) == 0) @@ -2258,20 +2262,23 @@ || (i 9 strncasecmp(r-filename, gopher://;, 9) == 0) || (i 6 strncasecmp(r-filename, ftp://;, 6)== 0))) { -thisport = (char *) ap_get_server_port(r); -if (is_default_port((int) thisport,r)) -port[0] = '\0'; -else -ap_snprintf(port, sizeof(port), :%u, thisport); +thisserver = ap_get_server_name(r); +port = ap_get_server_port(r); +if (is_default_port(port,r)) +thisport = ; +else { +ap_snprintf(buf, sizeof(buf), :%u, port); +thisport = buf; +} if (r-filename[0] == '/') r-filename = ap_psprintf(r-pool, %s://%s%s%s, -http_method(r), ap_get_server_name(r), -port, r-filename); +http_method(r), thisserver, +thisport, r-filename); else r-filename = ap_psprintf(r-pool, %s://%s%s/%s, -http_method(r), ap_get_server_name(r), -port, r-filename); +http_method(r), thisserver, +thisport, r-filename); } return; }
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/04/07 23:40:25 Modified:.STATUS src CHANGES src/modules/standard mod_rewrite.c Log: A little fix for the error messages from RewriteBase directive. Submitted by: Todd Eigenschink [EMAIL PROTECTED] Reviewed by: Ralf S. Engelschall Revision ChangesPath 1.276 +1 -0 apache-1.3/STATUS Index: STATUS === RCS file: /export/home/cvs/apache-1.3/STATUS,v retrieving revision 1.275 retrieving revision 1.276 diff -u -r1.275 -r1.276 --- STATUS1998/04/07 15:15:17 1.275 +++ STATUS1998/04/08 06:40:21 1.276 @@ -155,6 +155,7 @@ * Ralf's add of the query (-q) option to apxs * Ralf's initial doc and Configuration.tmpl entry for mod_mmap_static * OS/2 tweak to deal with multiple .exe targets. [Brian Havard] +* Fixed ordering of argument checks for RewriteBase directive, PR#2045 Available Patches: 1.759 +3 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.758 retrieving revision 1.759 diff -u -r1.758 -r1.759 --- CHANGES 1998/04/06 05:21:40 1.758 +++ CHANGES 1998/04/08 06:40:22 1.759 @@ -1,5 +1,8 @@ Changes with Apache 1.3b6 + *) Fixed ordering of argument checks for RewriteBase directive. + [Todd Eigenschink [EMAIL PROTECTED], PR#2045] + *) Change Win32 IS_MODULE to SHARED_MODULE to match Unix' method of indicating that a module is being compiled for dynamic loading. Also remove #define IS_MODULE from modules and add SHARED_MODULE define 1.100 +2 -2 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.99 retrieving revision 1.100 diff -u -r1.99 -r1.100 --- mod_rewrite.c 1998/04/01 14:24:35 1.99 +++ mod_rewrite.c 1998/04/08 06:40:24 1.100 @@ -520,10 +520,10 @@ { if (cmd-path == NULL || dconf == NULL) return RewriteBase: only valid in per-directory config files; -if (a1[0] != '/') -return RewriteBase: argument is not a valid URL; if (a1[0] == '\0') return RewriteBase: empty URL not allowed; +if (a1[0] != '/') +return RewriteBase: argument is not a valid URL; dconf-baseurl = a1;
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/03/27 07:43:55 Modified:.STATUS src CHANGES src/modules/standard mod_rewrite.c Log: Adjust the proxy pass-through feature in mod_rewrite to fit the requirements of mod_proxy again. Revision ChangesPath 1.225 +1 -0 apache-1.3/STATUS Index: STATUS === RCS file: /export/home/cvs/apache-1.3/STATUS,v retrieving revision 1.224 retrieving revision 1.225 diff -u -r1.224 -r1.225 --- STATUS1998/03/27 14:22:36 1.224 +++ STATUS1998/03/27 15:43:48 1.225 @@ -115,6 +115,7 @@ * Dean's fix for making work the `HostnameLookups Off' * Dean's mark of a few bitfields as signed to ensure correct code. * Dean's changes to scoreboard defs which helps gcc generate better code. +* Ralf's fix for QUERY_STRING and the proxy pass-through of mod_rewrite Available Patches: 1.738 +4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.737 retrieving revision 1.738 diff -u -r1.737 -r1.738 --- CHANGES 1998/03/26 21:20:46 1.737 +++ CHANGES 1998/03/27 15:43:49 1.738 @@ -1,5 +1,9 @@ Changes with Apache 1.3b6 + *) Fix the proxy pass-through feature of mod_rewrite for the case of + existing QUERY_STRING now that mod_proxy was recently changed because of + the new URL parsing stuff. [Ralf S. Engelschall] + *) A few changes to scoreboard definitions which helps gcc generate better code. [Dean Gaudet] 1.94 +10 -9 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.93 retrieving revision 1.94 diff -u -r1.93 -r1.94 --- mod_rewrite.c 1998/03/13 19:20:42 1.93 +++ mod_rewrite.c 1998/03/27 15:43:53 1.94 @@ -1039,10 +1039,11 @@ /* make sure the QUERY_STRING and * PATH_INFO parts get incorporated */ -r-filename = pstrcat(r-pool, r-filename, - r-path_info ? r-path_info : , - r-args ? ? : NULL, r-args, - NULL); +if (r-path_info != NULL) +r-filename = pstrcat(r-pool, r-filename, r-path_info, NULL); +if (r-args != NULL +r-uri == r-unparsed_uri /* see proxy_http:proxy_http_canon() */) +r-filename = pstrcat(r-pool, r-filename, ?, r-args, NULL); /* now make sure the request gets handled by the proxy handler */ r-proxyreq = 1; @@ -1281,12 +1282,12 @@ /* make sure the QUERY_STRING and * PATH_INFO parts get incorporated + * (r-path_info was already appended by the + * rewriting engine because of the per-dir context!) */ -r-filename = pstrcat(r-pool, r-filename, - /* r-path_info was already - * appended by the rewriting engine - * because of the per-dir context! */ - r-args ? ? : NULL, r-args, NULL); +if (r-args != NULL +r-uri == r-unparsed_uri /* see proxy_http:proxy_http_canon() */) +r-filename = pstrcat(r-pool, r-filename, ?, r-args, NULL); /* now make sure the request gets handled by the proxy handler */ r-proxyreq = 1;
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/03/27 07:50:25 Modified:src/modules/standard mod_rewrite.c Log: just a few whitespace cosmetics... Revision ChangesPath 1.95 +4 -4 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.94 retrieving revision 1.95 diff -u -r1.94 -r1.95 --- mod_rewrite.c 1998/03/27 15:43:53 1.94 +++ mod_rewrite.c 1998/03/27 15:50:16 1.95 @@ -801,7 +801,7 @@ status = atoi(val); if (!is_HTTP_REDIRECT(status)) return RewriteRule: invalid HTTP response code - for flag 'R'; + for flag 'R'; cfg-forced_responsecode = status; } } @@ -820,7 +820,7 @@ else if ( strcasecmp(key, type) == 0 || strcasecmp(key, T) == 0 ) { cfg-forced_mimetype = pstrdup(p, val); - str_tolower(cfg-forced_mimetype); +str_tolower(cfg-forced_mimetype); } else if ( strcasecmp(key, env) == 0 || strcasecmp(key, E) == 0 ) { @@ -3439,7 +3439,7 @@ /* file stuff */ else if (strcasecmp(var, SCRIPT_USER) == 0) { - result = unknown; +result = unknown; if (r-finfo.st_mode != 0) { if ((pw = getpwuid(r-finfo.st_uid)) != NULL) { result = pw-pw_name; @@ -3454,7 +3454,7 @@ } } else if (strcasecmp(var, SCRIPT_GROUP) == 0) { - result = unknown; +result = unknown; if (r-finfo.st_mode != 0) { if ((gr = getgrgid(r-finfo.st_gid)) != NULL) { result = gr-gr_name;
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
dgaudet 98/03/07 18:50:15 Modified:src/modules/standard mod_rewrite.c Log: defend against possible sh lameness Revision ChangesPath 1.89 +1 -1 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- mod_rewrite.c 1998/03/06 13:47:40 1.88 +++ mod_rewrite.c 1998/03/08 02:50:13 1.89 @@ -134,7 +134,7 @@ * Name: rewrite_module * ConfigStart . ./helpers/find-dbm-lib -if [ $found_dbm = 1 ]; then +if [ x$found_dbm = x1 ]; then echo enabling DBM support for mod_rewrite else echo disabling DBM support for mod_rewrite
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
rse 98/03/06 04:52:59 Modified:src CHANGES src/modules/standard mod_rewrite.c mod_rewrite.h Log: Avoid the flock()-fork() problematic by giving each child an own file descriptor instead of a shared one. Revision ChangesPath 1.692 +11 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.691 retrieving revision 1.692 diff -u -r1.691 -r1.692 --- CHANGES 1998/03/06 09:37:04 1.691 +++ CHANGES 1998/03/06 12:52:55 1.692 @@ -1,5 +1,16 @@ Changes with Apache 1.3b6 + *) Fix one more special locking problem for RewriteMap programs in + mod_rewrite: According to the documentation of flock(), Locks are on + files, not file descriptors. That is, file descriptors duplicated + through dup(2) or fork(2) do not result in multiple instances of a lock, + but rather multiple references to a single lock. If a process holding a + lock on a file forks and the child explicitly unlocks the file, the + parent will lose its lock.. To overcome this we have to make sure the + RewriteLock file is opened _AFTER_ the childs were spawned which is now + the case by opening it in the child_init instead of the module_init API + hook. [Ralf S. Engelschall, PR#1029] + *) Change to Location and LocationMatch semantics. LocationMatch no longer lets a single slash match multiple adjacent slashes in the URL. This change is for consistency with RewriteRule and 1.87 +86 -29apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.86 retrieving revision 1.87 diff -u -r1.86 -r1.87 --- mod_rewrite.c 1998/03/05 12:42:37 1.86 +++ mod_rewrite.c 1998/03/06 12:52:57 1.87 @@ -193,7 +193,7 @@ hook_fixup, /* [#7] pre-run fixups */ NULL,/* [#9] log a transaction */ NULL,/* [#3] header parser */ - NULL,/* child_init */ + init_child, /* child_init */ NULL,/* child_exit */ NULL /* [#0] post read-request */ }; @@ -869,7 +869,7 @@ /* ** -** module initialisation +** Global Module Initialization ** [called from read_config() after all ** config commands were already called] ** @@ -877,26 +877,42 @@ static void init_module(server_rec *s, pool *p) { +/* check if proxy module is available */ +proxy_available = is_proxy_available(s); + +/* precompile a static pattern + for the txt mapfile parsing */ +lookup_map_txtfile_regexp = pregcomp(p, MAPFILE_PATTERN, REG_EXTENDED); + +/* create the rewriting lockfile in the parent */ +rewritelock_create(s, p); +register_cleanup(p, (void *)s, rewritelock_remove, null_cleanup); + /* step through the servers and * - open each rewriting logfile - * - open each rewriting lockfile * - open the RewriteMap prg:xxx programs */ for (; s; s = s-next) { open_rewritelog(s, p); -open_rewritelock(s, p); run_rewritemap_programs(s, p); } +} -/* create the lookup cache */ -cachep = init_cache(p); -/* check if proxy module is available */ -proxy_available = is_proxy_available(s); +/* +** +** Per-Child Module Initialization +** [called after a child process is spawned] +** +*/ -/* precompile a static pattern - for the txt mapfile parsing */ -lookup_map_txtfile_regexp = pregcomp(p, MAPFILE_PATTERN, REG_EXTENDED); +static void init_child(server_rec *s, pool *p) +{ + /* open the rewriting lockfile */ + rewritelock_open(s, p); + + /* create the lookup cache */ + cachep = init_cache(p); } @@ -2984,37 +3000,78 @@ ** +---+ */ -static void open_rewritelock(server_rec *s, pool *p) -{ -rewrite_server_conf *conf; -char *fname; -intrewritelock_flags = ( O_WRONLY|O_APPEND|O_CREAT ); #ifdef WIN32 -mode_t rewritelock_mode = ( _S_IREAD|_S_IWRITE ); +#define REWRITELOCK_MODE ( _S_IREAD|_S_IWRITE ) #else -mode_t rewritelock_mode = ( S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH ); +#define REWRITELOCK_MODE ( S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH ) #endif +static void rewritelock_create(server_rec *s, pool *p) +{ +
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
rse 98/03/06 05:47:42 Modified:src/modules/standard mod_rewrite.c mod_rewrite.h Log: Inline the proxy availability check because the existence of the function is_proxy_available() is historical and from days where no find_linked_module() function existed and where this was a bigger function. Revision ChangesPath 1.88 +1 -13 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -r1.87 -r1.88 --- mod_rewrite.c 1998/03/06 12:52:57 1.87 +++ mod_rewrite.c 1998/03/06 13:47:40 1.88 @@ -878,7 +878,7 @@ static void init_module(server_rec *s, pool *p) { /* check if proxy module is available */ -proxy_available = is_proxy_available(s); +proxy_available = (find_linked_module(mod_proxy.c) != NULL); /* precompile a static pattern for the txt mapfile parsing */ @@ -3783,18 +3783,6 @@ return 1; else return 0; -} - -/* -** -** check if proxy module is available -** i.e. if it is compiled in and turned on -** -*/ - -static int is_proxy_available(server_rec *s) -{ -return (find_linked_module(mod_proxy.c) != NULL); } 1.48 +0 -3 apache-1.3/src/modules/standard/mod_rewrite.h Index: mod_rewrite.h === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- mod_rewrite.h 1998/03/06 12:52:58 1.47 +++ mod_rewrite.h 1998/03/06 13:47:41 1.48 @@ -458,9 +458,6 @@ static intprefix_stat(const char *path, struct stat *sb); static void add_env_variable(request_rec *r, char *s); -/* Proxy Module check */ -static int is_proxy_available(server_rec *s); - /* File locking */ static void fd_lock(int fd); static void fd_unlock(int fd);
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/03/04 23:50:33 Modified:src/modules/standard mod_rewrite.c Log: Make sure the returned value of rand() is not greater then RAND_MAX on systems like SunOS where we guessed the RAND_MAX value. This the way Ben requested but without the +1 because this actually leaded to an overflow warning under compiletime and is not really needed because this is random number generating functions where it doesn't count because of the additional bounding checks. I've tested it now under FreeBSD 2.1.5 _and_ SunOS 4.1.3 and it both correctly gives numbers between 1 and N when run with l=1 and h=N. Nothing more is needed Revision ChangesPath 1.82 +1 -1 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -r1.81 -r1.82 --- mod_rewrite.c 1998/03/04 13:55:08 1.81 +++ mod_rewrite.c 1998/03/05 07:50:31 1.82 @@ -2796,7 +2796,7 @@ char buf[50]; rewrite_rand_init(); -sprintf(buf, %.0f, (((double)rand()/RAND_MAX)*(h-l))); +sprintf(buf, %.0f, (((double)(rand()%RAND_MAX)/RAND_MAX)*(h-l))); i = atoi(buf)+1; if (i l) i = l; if (i h) i = h;
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/03/04 23:54:01 Modified:src/modules/standard mod_rewrite.c Log: Just cosmetic issues I stumpled over... Revision ChangesPath 1.83 +4 -4 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.82 retrieving revision 1.83 diff -u -r1.82 -r1.83 --- mod_rewrite.c 1998/03/05 07:50:31 1.82 +++ mod_rewrite.c 1998/03/05 07:53:59 1.83 @@ -130,7 +130,7 @@ ** ** o Runtime logic of a request is as following: ** while(request or subrequest) -** foreach(stage #1...#9) +** foreach(stage #0...#9) ** foreach(module) (**) ** try to run hook ** @@ -141,7 +141,7 @@ ** ** o there are two different types of result checking and ** continue processing: -** for hook #1,#4,#5,#6,#8: +** for hook #0,#1,#4,#5,#6,#8: ** hook run loop stops on first modules which gives ** back a result != DECLINED, i.e. it usually returns OK ** which says OK, module has handled this _stage_ and for #1 @@ -222,7 +222,7 @@ NULL,/* [#3] header parser */ NULL,/* child_init */ NULL,/* child_exit */ - NULL /* post read-request */ + NULL /* [#0] post read-request */ }; /* the cache */ @@ -2240,7 +2240,7 @@ } /* now check whether we could reduce it to a local path... */ - if (matches_request_vhost(r, host, port)) { +if (matches_request_vhost(r, host, port)) { /* this is our host, so only the URL remains */ r-filename = pstrdup(r-pool, url); rewritelog(r, 3, reduce %s - %s, olduri, r-filename);
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/03/05 02:48:07 Modified:src/modules/standard mod_rewrite.c Log: Add missing MODULE_VAR_EXPORT for mod_rewrite's module structure as requested by Marc. Thanks to him for discovering this. Revision ChangesPath 1.85 +1 -1 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.84 retrieving revision 1.85 diff -u -r1.84 -r1.85 --- mod_rewrite.c 1998/03/05 10:21:24 1.84 +++ mod_rewrite.c 1998/03/05 10:48:05 1.85 @@ -175,7 +175,7 @@ }; /* the main config structure */ -module rewrite_module = { +module MODULE_VAR_EXPORT rewrite_module = { STANDARD_MODULE_STUFF, init_module, /* module initializer */ config_perdir_create,/* create per-dirconfig structures */
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
rse 98/03/04 05:17:01 Modified:src CHANGES src/modules/standard mod_rewrite.c mod_rewrite.h Log: Reanimate the DBM support for RewriteMap in mod_rewrite by fixing two source code errors and making sure it is disabled when DBM support is not available on the used platform. Revision ChangesPath 1.684 +6 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.683 retrieving revision 1.684 diff -u -r1.683 -r1.684 --- CHANGES 1998/03/04 12:08:45 1.683 +++ CHANGES 1998/03/04 13:16:56 1.684 @@ -1,5 +1,11 @@ Changes with Apache 1.3b6 + *) Fixed the DBM RewriteMap support for mod_rewrite: First the support now + is automatically disabled under configure time when the dbm_xxx functions + are not available. Second, two heavy source code errors in the DBM + support code were fixed. This makes DBM RewriteMap's useable again after + a long time of brokeness. [Ralf S. Engelschall] + *) Now all configuration files support Unix-style line-continuation via the trailing backslash (\) character. This enables us to write down complex or just very long directives in a more readable way. The 1.80 +22 -7 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.79 retrieving revision 1.80 diff -u -r1.79 -r1.80 --- mod_rewrite.c 1998/03/04 02:28:23 1.79 +++ mod_rewrite.c 1998/03/04 13:16:59 1.80 @@ -157,6 +157,21 @@ ** or not! */ +/* The section for the Configure script: + * MODULE-DEFINITION-START + * Name: rewrite_module + * ConfigStart +if ./helpers/TestCompile func dbm_open; then +echo enabling DBM support for mod_rewrite +else +echo disabling DBM support for mod_rewrite +echo (perhaps you need to add -ldbm, -lndbm or -lgdbm to EXTRA_LIBS) +CFLAGS=$CFLAGS -DNO_DBM_REWRITEMAP +fi + * ConfigEnd + * MODULE-DEFINITION-END + */ + /* the table of commands we provide */ static command_rec command_table[] = { { RewriteEngine, cmd_rewriteengine, NULL, OR_FILEINFO, FLAG, @@ -472,7 +487,7 @@ new-checkfile = a2+4; } else if (strncmp(a2, dbm:, 4) == 0) { -#ifdef HAS_NDBM_LIB +#ifndef NO_DBM_REWRITEMAP new-type = MAPTYPE_DBM; new-datafile = a2+4; new-checkfile = pstrcat(cmd-pool, a2+4, NDBM_FILE_SUFFIX, NULL); @@ -2519,13 +2534,13 @@ } } else if (s-type == MAPTYPE_DBM) { -#if HAS_NDBM_LIB +#ifndef NO_DBM_REWRITEMAP if (stat(s-checkfile, st) == -1) { -aplog_error(APLOG_MARK, APLOG_ERROR, r-server, -mod_rewrite: can't access dbm RewriteMap -file %s: %s, s-checkfile); +aplog_error(APLOG_MARK, APLOG_ERR, r-server, +mod_rewrite: can't access DBM RewriteMap +file %s, s-checkfile); rewritelog(r, 1, - can't open RewriteMap file, see error log); + can't open DBM RewriteMap file, see error log); return NULL; } value = get_cache_string(cachep, s-name, CACHEMODE_TS, @@ -2660,7 +2675,7 @@ return value; } -#if HAS_NDBM_LIB +#ifndef NO_DBM_REWRITEMAP static char *lookup_map_dbmfile(request_rec *r, char *file, char *key) { DBM *dbmfp = NULL; 1.43 +2 -2 apache-1.3/src/modules/standard/mod_rewrite.h Index: mod_rewrite.h === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- mod_rewrite.h 1998/03/03 15:58:11 1.42 +++ mod_rewrite.h 1998/03/04 13:17:00 1.43 @@ -95,7 +95,7 @@ * But we have to stat the file for the mtime, * so we also need to know the file extension */ -#if HAS_NDBM_LIB +#ifndef NO_DBM_REWRITEMAP #include ndbm.h #if (__FreeBSD__) #define NDBM_FILE_SUFFIX .db @@ -379,7 +379,7 @@ /* rewrite map support functions */ static char *lookup_map(request_rec *r, char *name, char *key); static char *lookup_map_txtfile(request_rec *r, char *file, char *key); -#if HAS_NDBM_LIB +#ifndef NO_DBM_REWRITEMAP static char
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
rse 98/03/04 05:55:11 Modified:src CHANGES src/modules/standard mod_rewrite.c mod_rewrite.h Log: Ok, here it comes: the last bugfix for mod_rewrite on my TODO list. It fixes the PR's problem the way Dean initially wanted: On-the-fly without changing any configuration structures. Revision ChangesPath 1.685 +9 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.684 retrieving revision 1.685 diff -u -r1.684 -r1.685 --- CHANGES 1998/03/04 13:16:56 1.684 +++ CHANGES 1998/03/04 13:55:06 1.685 @@ -1,5 +1,14 @@ Changes with Apache 1.3b6 + *) Fix mod_rewrite for the ugly API case where VirtualHost sections exist + but without any RewriteX directives. Here mod_rewrite is given no + chance by the API to initialise its per-server configuration and thus + receives the wrong one from the main server. This is now avoided by + remembering the server together with the config structure while + configuring and later assuming there is no config when we see a + difference between the remembered server and the one calling us. + [Ralf S. Engelschall, PR#1790] + *) Fixed the DBM RewriteMap support for mod_rewrite: First the support now is automatically disabled under configure time when the dbm_xxx functions are not available. Second, two heavy source code errors in the DBM 1.81 +13 -0 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.80 retrieving revision 1.81 diff -u -r1.80 -r1.81 --- mod_rewrite.c 1998/03/04 13:16:59 1.80 +++ mod_rewrite.c 1998/03/04 13:55:08 1.81 @@ -271,6 +271,7 @@ a-rewritemaps = make_array(p, 2, sizeof(rewritemap_entry)); a-rewriteconds= make_array(p, 2, sizeof(rewritecond_entry)); a-rewriterules= make_array(p, 2, sizeof(rewriterule_entry)); +a-server = s; return (void *)a; } @@ -285,6 +286,7 @@ a-state = overrides-state; a-options = overrides-options; +a-server = overrides-server; if (a-options OPTION_INHERIT) { /* @@ -971,6 +973,17 @@ * else return immediately! */ if (conf-state == ENGINE_DISABLED) +return DECLINED; + +/* + * check for the ugly API case of a virtual host section where no + * mod_rewrite directives exists. In this situation we became no chance + * by the API to setup our default per-server config so we have to + * on-the-fly assume we have the default config. But because the default + * config has a disabled rewriting engine we are lucky because can + * just stop operating now. + */ +if (conf-server != r-server) return DECLINED; /* 1.44 +1 -0 apache-1.3/src/modules/standard/mod_rewrite.h Index: mod_rewrite.h === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- mod_rewrite.h 1998/03/04 13:17:00 1.43 +++ mod_rewrite.h 1998/03/04 13:55:09 1.44 @@ -263,6 +263,7 @@ array_header *rewritemaps; /* the RewriteMap entries */ array_header *rewriteconds;/* the RewriteCond entries (temporary) */ array_header *rewriterules;/* the RewriteRule entries */ +server_rec *server; /* the corresponding server indicator */ } rewrite_server_conf;
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/02/27 06:31:13 Modified:src/modules/standard mod_rewrite.c Log: fixed a comment and added even more comments for better understanding. Revision ChangesPath 1.76 +9 -4 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- mod_rewrite.c 1998/02/26 11:13:40 1.75 +++ mod_rewrite.c 1998/02/27 14:31:11 1.76 @@ -1760,9 +1760,13 @@ */ if (strcmp(output, -) == 0) { for (i = 0; p-env[i] != NULL; i++) { +/* 1. take the string */ ap_cpystrn(env, p-env[i], sizeof(env)); +/* 2. expand $N (i.e. backrefs to RewriteRule pattern) */ expand_backref_inbuffer(r-pool, env, sizeof(env), briRR, '$'); +/* 3. expand %N (i.e. backrefs to latest RewriteCond pattern) */ expand_backref_inbuffer(r-pool, env, sizeof(env), briRC, '%'); +/* and add the variable to Apache's structures */ add_env_variable(r, env); } return 2; @@ -1791,7 +1795,7 @@ /* * Additionally do expansion for the environment variable - * strings (`RewriteCond .. .. [E=string]'). + * strings (`RewriteRule .. .. [E=string]'). */ for (i = 0; p-env[i] != NULL; i++) { /* 1. take the string */ @@ -1953,12 +1957,13 @@ * Construct the string we match against */ -/* expand the regex backreferences from the RewriteRule ($0-$9), - then from the last RewriteCond (%0-%9) and then expand the - variables (%{}) */ +/* 1. take the string */ ap_cpystrn(input, p-input, sizeof(input)); +/* 2. expand $N (i.e. backrefs to RewriteRule pattern) */ expand_backref_inbuffer(r-pool, input, sizeof(input), briRR, '$'); +/* 3. expand %N (i.e. backrefs to latest RewriteCond pattern) */ expand_backref_inbuffer(r-pool, input, sizeof(input), briRC, '%'); +/* 4. expand %{...} (i.e. variables) */ expand_variables_inbuffer(r, input, sizeof(input)); /*
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/02/27 06:47:48 Modified:src/modules/standard mod_rewrite.c Log: It's unbelievable, it's unbelievable... We have three locations where one can construct a string in rewriting rules by expanding $N, %N, %{NAME} and ${map:key}: - RewriteCond Location-1 ... - RewriteRule ... Location-2 ... - RewriteRule ... ... [..,E=NAME:Location-3,...] And just after I've added exact comments of what we expand in each location, I discovered that they are expanded totally inconsequent. For Location-3 the %{NAME} and ${map:key} constructs were not expanded (ok, perhaps not really a %major drawback) and for Location-1 the ${map:key} construct was not %expanded while for Location-2 all are expanded. At least the missing ${map:key} expansion for Location-1 is horrible because this way we unnesessarily restricted the usefulness of RewriteCond dramatically. Perhaps I should add more source comments to mod_rewrite.c to discover that it then can even can cook a cake now ;-) Revision ChangesPath 1.77 +10 -0 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.76 retrieving revision 1.77 diff -u -r1.76 -r1.77 --- mod_rewrite.c 1998/02/27 14:31:11 1.76 +++ mod_rewrite.c 1998/02/27 14:47:46 1.77 @@ -1766,6 +1766,10 @@ expand_backref_inbuffer(r-pool, env, sizeof(env), briRR, '$'); /* 3. expand %N (i.e. backrefs to latest RewriteCond pattern) */ expand_backref_inbuffer(r-pool, env, sizeof(env), briRC, '%'); +/* 4. expand %{...} (i.e. variables) */ +expand_variables_inbuffer(r, env, sizeof(env)); +/* 5. expand ${...} (RewriteMap lookups) */ +expand_map_lookups(r, env, sizeof(env)); /* and add the variable to Apache's structures */ add_env_variable(r, env); } @@ -1804,6 +1808,10 @@ expand_backref_inbuffer(r-pool, env, sizeof(env), briRR, '$'); /* 3. expand %N (i.e. backrefs to latest RewriteCond pattern) */ expand_backref_inbuffer(r-pool, env, sizeof(env), briRC, '%'); +/* 4. expand %{...} (i.e. variables) */ +expand_variables_inbuffer(r, env, sizeof(env)); +/* 5. expand ${...} (RewriteMap lookups) */ +expand_map_lookups(r, env, sizeof(env)); /* and add the variable to Apache's structures */ add_env_variable(r, env); } @@ -1965,6 +1973,8 @@ expand_backref_inbuffer(r-pool, input, sizeof(input), briRC, '%'); /* 4. expand %{...} (i.e. variables) */ expand_variables_inbuffer(r, input, sizeof(input)); +/* 5. expand ${...} (RewriteMap lookups) */ +expand_map_lookups(r, input, sizeof(input)); /* * Apply the patterns
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/02/26 01:32:29 Modified:src/modules/standard mod_rewrite.c Log: just tab-space cosmetics Revision ChangesPath 1.72 +10 -10apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- mod_rewrite.c 1998/02/24 16:40:51 1.71 +++ mod_rewrite.c 1998/02/26 09:32:27 1.72 @@ -363,7 +363,7 @@ */ static const char *cmd_rewriteengine(cmd_parms *cmd, - rewrite_perdir_conf *dconf, int flag) + rewrite_perdir_conf *dconf, int flag) { rewrite_server_conf *sconf; @@ -404,7 +404,7 @@ *options |= OPTION_INHERIT; else return pstrcat(p, RewriteOptions: unknown option ', -name, '\n, NULL); + name, '\n, NULL); return NULL; } @@ -722,12 +722,12 @@ if (cmd-path == NULL) { /* is server command */ new-rewriteconds = sconf-rewriteconds; sconf-rewriteconds = make_array(cmd-pool, 2, - sizeof(rewritecond_entry)); + sizeof(rewritecond_entry)); } else {/* is per-directory command */ new-rewriteconds = dconf-rewriteconds; dconf-rewriteconds = make_array(cmd-pool, 2, - sizeof(rewritecond_entry)); + sizeof(rewritecond_entry)); } return NULL; @@ -1223,7 +1223,7 @@ aplog_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r-server, Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: - %s, r-filename); +%s, r-filename); return FORBIDDEN; } else { @@ -1264,7 +1264,7 @@ r-handler = proxy-server; rewritelog(r, 1, [per-dir %s] go-ahead with proxy request -%s [OK], dconf-directory, r-filename); + %s [OK], dconf-directory, r-filename); return OK; } else if ( (strlen(r-filename) 7 @@ -1528,7 +1528,7 @@ if (p-flags RULEFLAG_FORBIDDEN) { rewritelog(r, 2, forcing '%s' to be forbidden, r-filename); r-filename = pstrcat(r-pool, forbidden:, - r-filename, NULL); + r-filename, NULL); changed = 1; break; } @@ -1993,7 +1993,7 @@ /* log it */ rewritelog(r, 5, RewriteCond URI (-U) check: -path=%s - status=%d, input, rsub-status); + path=%s - status=%d, input, rsub-status); /* cleanup by destroying the subrequest */ destroy_sub_req(rsub); @@ -2043,7 +2043,7 @@ else { /* it is really a regexp pattern, so apply it */ rc = (regexec(p-regexp, input, - p-regexp-re_nsub+1, regmatch,0) == 0); + p-regexp-re_nsub+1, regmatch,0) == 0); /* if it isn't a negated pattern and really matched we update the passed-through regex subst info structure */ @@ -3054,7 +3054,7 @@ if (rc == 0 || fpin == NULL || fpout == NULL) { perror(spawn_child); fprintf(stderr, mod_rewrite: - could not fork child for RewriteMap process\n); +could not fork child for RewriteMap process\n); exit(1); } map-fpin = fileno(fpin);
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/02/26 02:18:36 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: One more fix for RewriteMap programs. 0 when treated as NULL is ok as an error condition for filehandles (FILE *) but not for filenumbers. Here we have to use -1 as the error indicator like open() does. Revision ChangesPath 1.668 +4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.667 retrieving revision 1.668 diff -u -r1.667 -r1.668 --- CHANGES 1998/02/25 09:36:09 1.667 +++ CHANGES 1998/02/26 10:18:31 1.668 @@ -1,5 +1,9 @@ Changes with Apache 1.3b6 + *) Fix `RewriteMap' program lookup in situations where such maps are + defined but disabled (`RewriteEngine off') in per-server context. + [Ralf S. Engelschall, PR#1431] + *) Fix bug introduced in 1.3b4-dev, config with no Port setting would cause server to bind to port 0 rather than 80. [Dean Gaudet] 1.73 +19 -12apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- mod_rewrite.c 1998/02/26 09:32:27 1.72 +++ mod_rewrite.c 1998/02/26 10:18:34 1.73 @@ -488,8 +488,8 @@ new-datafile = a2; new-checkfile = a2; } -new-fpin = 0; -new-fpout = 0; +new-fpin = -1; +new-fpout = -1; if (new-checkfile (sconf-state == ENGINE_ENABLED) (stat(new-checkfile, st) == -1)) @@ -2661,6 +2661,14 @@ char c; int i; +/* when `RewriteEngine off' was used in the per-server + * context then the rewritemap-programs were not spawned. + * In this case using such a map (usually in per-dir context) + * is useless because it is not available. + */ +if (fpin == -1 || fpout == -1) +return NULL; + /* take the lock */ rewritelock_alloc(r); @@ -3027,13 +3035,12 @@ int rc; conf = get_module_config(s-module_config, rewrite_module); -/* - * If the engine isn't turned on, don't even try to do anything. + +/* If the engine isn't turned on, + * don't even try to do anything. */ -if (conf-state == ENGINE_DISABLED) { +if (conf-state == ENGINE_DISABLED) return; -} - rewritemaps = conf-rewritemaps; entries = (rewritemap_entry *)rewritemaps-elts; @@ -3041,13 +3048,13 @@ map = entries[i]; if (map-type != MAPTYPE_PRG) continue; -if (map-datafile == NULL|| -*(map-datafile) == '\0' || -map-fpin 0|| -map-fpout 0 ) +if (map-datafile == NULL +|| *(map-datafile) == '\0' +|| map-fpin != -1 +|| map-fpout != -1) continue; fname = server_root_relative(p, map-datafile); -fpin = NULL; +fpin = NULL; fpout = NULL; rc = spawn_child(p, rewritemap_program_child, (void *)map-datafile, kill_after_timeout, fpin, fpout);
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/02/26 03:04:05 Modified:src CHANGES src/modules/standard mod_rewrite.c Log: The RewriteLoglevel was different and incorrect against the docs and the per-server config merging was also inconsistent and bogus. Revision ChangesPath 1.669 +6 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.668 retrieving revision 1.669 diff -u -r1.668 -r1.669 --- CHANGES 1998/02/26 10:18:31 1.668 +++ CHANGES 1998/02/26 11:04:01 1.669 @@ -1,5 +1,11 @@ Changes with Apache 1.3b6 + *) Fix initialization of RewriteLogLevel (default now is 0 as documented + and not 1) and the per-virtual-server merging of directives. Now all + directives except `RewriteEngine' and `RewriteOption' are either + completely overridden (default) or completely inherited (when + `RewriteOptions inherit') is used. [Ralf S. Engelschall, PR#1325] + *) Fix `RewriteMap' program lookup in situations where such maps are defined but disabled (`RewriteEngine off') in per-server context. [Ralf S. Engelschall, PR#1431] 1.74 +35 -21apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- mod_rewrite.c 1998/02/26 10:18:34 1.73 +++ mod_rewrite.c 1998/02/26 11:04:03 1.74 @@ -249,7 +249,7 @@ a-options = OPTION_NONE; a-rewritelogfile = NULL; a-rewritelogfp= -1; -a-rewriteloglevel = 1; +a-rewriteloglevel = 0; a-rewritelockfile = NULL; a-rewritelockfp = -1; a-rewritemaps = make_array(p, 2, sizeof(rewritemap_entry)); @@ -267,30 +267,44 @@ base = (rewrite_server_conf *)basev; overrides = (rewrite_server_conf *)overridesv; -a-state = overrides-state; -a-options = overrides-options; -a-rewritelogfile = base-rewritelogfile != NULL ? - base-rewritelogfile : overrides-rewritelogfile; -a-rewritelogfp= base-rewritelogfp != -1 ? - base-rewritelogfp : overrides-rewritelogfp; -a-rewriteloglevel = overrides-rewriteloglevel; -a-rewritelockfile = base-rewritelockfile != NULL ? - base-rewritelockfile : overrides-rewritelockfile; -a-rewritelockfp = base-rewritelockfp != -1 ? - base-rewritelockfp : overrides-rewritelockfp; +a-state = overrides-state; +a-options = overrides-options; if (a-options OPTION_INHERIT) { -a-rewritemaps = append_arrays(p, overrides-rewritemaps, -base-rewritemaps); -a-rewriteconds = append_arrays(p, overrides-rewriteconds, -base-rewriteconds); -a-rewriterules = append_arrays(p, overrides-rewriterules, -base-rewriterules); +/* + * local directives override + * and anything else is inherited + */ +a-rewriteloglevel = overrides-rewriteloglevel != 0 ? + overrides-rewriteloglevel : base-rewriteloglevel; +a-rewritelogfile = overrides-rewritelogfile != NULL ? + overrides-rewritelogfile : base-rewritelogfile; +a-rewritelogfp= overrides-rewritelogfp != -1 ? + overrides-rewritelogfp : base-rewritelogfp; +a-rewritelockfile = overrides-rewritelockfile != NULL ? + overrides-rewritelockfile : base-rewritelockfile; +a-rewritelockfp = overrides-rewritelockfp != -1 ? + overrides-rewritelockfp : base-rewritelockfp; +a-rewritemaps = append_arrays(p, overrides-rewritemaps, + base-rewritemaps); +a-rewriteconds= append_arrays(p, overrides-rewriteconds, + base-rewriteconds); +a-rewriterules= append_arrays(p, overrides-rewriterules, + base-rewriterules); } else { -a-rewritemaps = overrides-rewritemaps; -a-rewriteconds = overrides-rewriteconds; -a-rewriterules = overrides-rewriterules; +/* + * local directives override + * and anything else gets defaults + */ +a-rewriteloglevel = overrides-rewriteloglevel; +a-rewritelogfile =
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/02/26 03:13:41 Modified:src/modules/standard mod_rewrite.c Log: Seems today I'm very pedantic about cosmetic issues... ;-) Revision ChangesPath 1.75 +1 -1 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.74 retrieving revision 1.75 diff -u -r1.74 -r1.75 --- mod_rewrite.c 1998/02/26 11:04:03 1.74 +++ mod_rewrite.c 1998/02/26 11:13:40 1.75 @@ -2887,7 +2887,7 @@ conf = get_module_config(r-server-module_config, rewrite_module); conn = r-connection; -if (conf-rewritelogfp 0) +if (conf-rewritelogfp 0) return; if (conf-rewritelogfile == NULL) return;
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
rse 98/02/24 05:39:12 Modified:src CHANGES htdocs/manual/mod mod_rewrite.html src/modules/standard mod_rewrite.c mod_rewrite.h Log: First part to fix the synchronization-locking for RewriteMap programs under Unix derivates who doesn't accept the locking of pipes directly. But we perhaps have another problem: According to FreeBSD's manpage and a hint by the submitter of PR#1029 flock() has to be used on opened filedescriptors which are _not_ duplicated via fork(). This currently is not the case... Submitted by: Ralf S. Engelschall Reviewed by: Ralf S. Engelschall, Jim Jagielski Revision ChangesPath 1.666 +6 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.665 retrieving revision 1.666 diff -u -r1.665 -r1.666 --- CHANGES 1998/02/24 12:40:55 1.665 +++ CHANGES 1998/02/24 13:39:05 1.666 @@ -1,5 +1,11 @@ Changes with Apache 1.3b6 + *) Fix long-standing problem with RewriteMap _programs_ under Unix derivates + (like SunOS and FreeBSD) which don't accept the locking of pipes + directly. A new directive RewriteLock is introduced which can be used to + setup a separate locking file which then is used for synchronization. + [Ralf S. Engelschall, PR#1029] + *) WIN32: The server root is obtained from the registry key HKLM\SOFTWARE\Apache Group\Apache\version (version is currently 1.3 beta), unless overridden by the -d command line flag. The 1.24 +32 -2 apache-1.3/htdocs/manual/mod/mod_rewrite.html Index: mod_rewrite.html === RCS file: /export/home/cvs/apache-1.3/htdocs/manual/mod/mod_rewrite.html,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- mod_rewrite.html 1998/02/23 08:27:36 1.23 +++ mod_rewrite.html 1998/02/24 13:39:08 1.24 @@ -68,6 +68,7 @@ LIA HREF=#RewriteOptionsRewriteOptions/A LIA HREF=#RewriteLogRewriteLog/A LIA HREF=#RewriteLogLevelRewriteLogLevel/A +LIA HREF=#RewriteLockRewriteLock/A LIA HREF=#RewriteMapRewriteMap/A LIA HREF=#RewriteBaseRewriteBase/A LIA HREF=#RewriteCondRewriteCond/A @@ -252,6 +253,32 @@ hr noshade size=1 P +H3A NAME=RewriteLockRewriteLock/A/H3 +A + HREF=directive-dict.html#Syntax + REL=Help +STRONGSyntax:/STRONG/A CODERewriteLock/CODE EMFilename/EMBR +A + HREF=directive-dict.html#Default + REL=Help +STRONGDefault:/STRONG/A -EMNone/EM-BR +A + HREF=directive-dict.html#Context + REL=Help +STRONGContext:/STRONG/A server config, virtual hostBR +P + +This directive sets the filename for a synchronization lockfile which +mod_rewrite needs to communicate with SAMPRewriteMap/SAMP +EMprograms/EM. Set this lockfile to a local path (not on a NFS-mounted +device) when you want to use a rewriting map-program. It is not required for +SAMP +using all other types of rewriting maps. + +P +hr noshade size=1 +P + H3A NAME=RewriteMapRewriteMap/A/H3 A HREF=directive-dict.html#Syntax @@ -437,8 +464,11 @@ if this program hangs it will lead to a hang of the Apache server when the rule occurs. LIAvoid one common mistake: never do buffered I/O on TTstdout/TT! -This will cause a deadloop! Hence the ``TT$|=1/TT'' in the above -example... +This will cause a deadloop! Hence the ``TT$|=1/TT'' in the above +example... +LIUse the SAMPRewriteLock/SAMP directive to define a lockfile +mod_rewrite can use to synchronize the communication to the program. +Per default no such synchronization takes place. /OL /UL 1.69 +109 -22 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- mod_rewrite.c 1998/02/23 15:18:50 1.68 +++ mod_rewrite.c 1998/02/24 13:39:10 1.69 @@ -112,9 +112,6 @@ /* now our own stuff ... */ #include mod_rewrite.h -#ifdef USE_LOCKING -#include sys/locking.h -#endif /* @@ -172,6 +169,8 @@ a URL-applied regexp-pattern and a substitution URL }, { RewriteMap, cmd_rewritemap, NULL, RSRC_CONF, TAKE2, a mapname and a filename }, +{ RewriteLock, cmd_rewritelock, NULL, RSRC_CONF, TAKE1, + the filename of a lockfile used for inter-process synchronization}, { RewriteLog, cmd_rewritelog, NULL, RSRC_CONF, TAKE1, the filename of the rewriting
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/02/24 07:44:33 Modified:src/modules/standard mod_rewrite.c Log: Add missing static and include stdlib.h for RAND_MAX. Thanks to Ben Hyde [EMAIL PROTECTED]. Revision ChangesPath 1.70 +3 -2 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- mod_rewrite.c 1998/02/24 13:39:10 1.69 +++ mod_rewrite.c 1998/02/24 15:44:31 1.70 @@ -90,6 +90,7 @@ /* from the underlaying Unix system ... */ #include string.h #include stdarg.h +#include stdlib.h #include time.h #include signal.h #include errno.h @@ -2708,7 +2709,7 @@ static int rewrite_rand_init_done = 0; -void rewrite_rand_init(void) +static void rewrite_rand_init(void) { if (!rewrite_rand_init_done) { srand((unsigned)(getpid())); @@ -2717,7 +2718,7 @@ return; } -int rewrite_rand(int l, int h) +static int rewrite_rand(int l, int h) { int i; char buf[50];
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
rse 98/02/24 08:40:54 Modified:src/modules/standard mod_rewrite.c mod_rewrite.h Log: just cosmetics: - remove trailing spaces on lines ([ \t]+$) - break lines which still were over 79 chars - typos Revision ChangesPath 1.71 +234 -228 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- mod_rewrite.c 1998/02/24 15:44:31 1.70 +++ mod_rewrite.c 1998/02/24 16:40:51 1.71 @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - *notice, this list of conditions and the following disclaimer. + *notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in @@ -52,8 +52,8 @@ */ -/* __ _ -** _ __ ___ ___ __| |_ __ _ ___ __(_) |_ ___ +/* __ _ +** _ __ ___ ___ __| |_ __ _ ___ __(_) |_ ___ ** | '_ ` _ \ / _ \ / _` | | '__/ _ \ \ /\ / / '__| | __/ _ \ ** | | | | | | (_) | (_| | | | | __/\ V V /| | | | || __/ ** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___| @@ -62,21 +62,21 @@ ** URL Rewriting Module ** ** This module uses a rule-based rewriting engine (based on a -** regular-expression parser) to rewrite requested URLs on the fly. -** +** regular-expression parser) to rewrite requested URLs on the fly. +** ** It supports an unlimited number of additional rule conditions (which can ** operate on a lot of variables, even on HTTP headers) for granular ** matching and even external database lookups (either via plain text ** tables, DBM hash files or even external processes) for advanced URL ** substitution. -** +** ** It operates on the full URLs (including the PATH_INFO part) both in ** per-server context (httpd.conf) and per-dir context (.htaccess) and even ** can generate QUERY_STRING parts on result. The rewriting result finally ** can lead to internal subprocessing, external request redirection or even ** to internal proxy throughput. ** -** This module was originally written in April 1996 and +** This module was originally written in April 1996 and ** gifted exclusively to the The Apache Group in July 1997 by ** ** Ralf S. Engelschall @@ -128,8 +128,8 @@ ** Our interface to the Apache server kernel: ** ** o Runtime logic of a request is as following: -** while(request or subrequest) -** foreach(stage #1...#9) +** while(request or subrequest) +** foreach(stage #1...#9) ** foreach(module) (**) ** try to run hook ** @@ -138,7 +138,7 @@ ** specified is the first one called for each hook! ** The core module is always the last! ** -** o there are two different types of result checking and +** o there are two different types of result checking and ** continue processing: ** for hook #1,#4,#5,#6,#8: ** hook run loop stops on first modules which gives @@ -148,7 +148,7 @@ ** for hook #2,#3,#7,#9: ** all hooks are run, independend of result ** -** o at the last stage, the core module always +** o at the last stage, the core module always ** - says BAD_REQUEST if r-filename does not begin with / ** - prefix URL with document_root or replaced server_root ** with document_root and sets r-filename @@ -158,23 +158,23 @@ /* the table of commands we provide */ static command_rec command_table[] = { -{ RewriteEngine, cmd_rewriteengine, NULL, OR_FILEINFO, FLAG, +{ RewriteEngine, cmd_rewriteengine, NULL, OR_FILEINFO, FLAG, On or Off to enable or disable (default) the whole rewriting engine }, -{ RewriteOptions, cmd_rewriteoptions, NULL, OR_FILEINFO, ITERATE, +{ RewriteOptions, cmd_rewriteoptions, NULL, OR_FILEINFO, ITERATE, List of option strings to set }, -{ RewriteBase, cmd_rewritebase, NULL, OR_FILEINFO, TAKE1, +{ RewriteBase, cmd_rewritebase, NULL, OR_FILEINFO, TAKE1, the base URL of the per-directory context }, -{ RewriteCond, cmd_rewritecond, NULL, OR_FILEINFO, RAW_ARGS, +{ RewriteCond, cmd_rewritecond, NULL, OR_FILEINFO, RAW_ARGS, a input string and a to be applied regexp-pattern }, -{ RewriteRule, cmd_rewriterule, NULL, OR_FILEINFO, RAW_ARGS, +
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
rse 98/02/23 07:18:52 Modified:src/modules/standard mod_rewrite.c Log: mod_rewrite shouldn't make any assumptions on which characters a username can contain because a lot of Unix derivates allow more then [a-zA-Z0-9]. We now treat anything between ^/~ and the next slash or end of URL as the username because this does not hurt us. We always expand only after we have successfully resolved the cut out name via /etc/passwd. Revision ChangesPath 1.68 +4 -10 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- mod_rewrite.c 1998/02/23 08:27:38 1.67 +++ mod_rewrite.c 1998/02/23 15:18:50 1.68 @@ -2244,7 +2244,7 @@ /* ** -** Expand tilde-paths (~user) through +** Expand tilde-paths (/~user) through ** Unix /etc/passwd database information ** */ @@ -2259,15 +2259,9 @@ newuri = uri; if (uri != NULL strlen(uri) 2 uri[0] == '/' uri[1] == '~') { /* cut out the username */ -for (j = 0, i = 2; j sizeof(user)-1 uri[i] != '\0' -#ifndef CHARSET_EBCDIC - ( (uri[i] = '0' uri[i] = '9') -|| (uri[i] = 'a' uri[i] = 'z') -|| (uri[i] = 'A' uri[i] = 'Z')) -#else - isalnum(uri[i]) -#endif -; ) +for (j = 0, i = 2; j sizeof(user)-1 +uri[i] != '\0' +uri[i] != '/' ; ) user[j++] = uri[i++]; user[j] = '\0';
cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
randy 98/02/02 14:33:41 Modified:src/include httpd.h src/main http_config.c http_core.c http_protocol.c util.c src/modules/proxy mod_proxy.c proxy_http.c src/modules/standard mod_rewrite.c Log: Generalize default_port manipulations. The proxy may still need some work, but will defer until I can review these changes with others. Obtained from: Ben Laurie, Randy Terbush Reviewed by: Ben Laurie, Randy Terbush Revision ChangesPath 1.180 +6 -2 apache-1.3/src/include/httpd.h Index: httpd.h === RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v retrieving revision 1.179 retrieving revision 1.180 diff -u -r1.179 -r1.180 --- httpd.h 1998/02/01 22:05:34 1.179 +++ httpd.h 1998/02/02 22:33:29 1.180 @@ -116,7 +116,11 @@ /* -- Port number for server running standalone --- */ -#define DEFAULT_PORT 80 +#define DEFAULT_HTTP_PORT80 +#define DEFAULT_HTTPS_PORT 443 +#define is_default_port(port,r) ((port) == default_port(r)) +#define http_method(r) http +#define default_port(r) DEFAULT_HTTP_PORT /* - Default user name and group name running standalone -- */ /* --- These may be specified as numbers by placing a # before a number --- */ @@ -802,7 +806,7 @@ #define escape_uri(ppool,path) os_escape_path(ppool,path,1) API_EXPORT(char *) escape_html(pool *p, const char *s); API_EXPORT(char *) construct_server(pool *p, const char *hostname, - unsigned port); + unsigned port, const request_rec *r); API_EXPORT(char *) escape_shell_cmd(pool *p, const char *s); API_EXPORT(int) count_dirs(const char *path); 1.95 +1 -1 apache-1.3/src/main/http_config.c Index: http_config.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_config.c,v retrieving revision 1.94 retrieving revision 1.95 diff -u -r1.94 -r1.95 --- http_config.c 1998/01/21 22:11:01 1.94 +++ http_config.c 1998/02/02 22:33:31 1.95 @@ -1225,7 +1225,7 @@ { server_rec *s = (server_rec *) pcalloc(p, sizeof(server_rec)); -s-port = DEFAULT_PORT; +s-port = 0; s-server_admin = DEFAULT_ADMIN; s-server_hostname = NULL; s-error_fname = DEFAULT_ERRORLOG; 1.156 +3 -3 apache-1.3/src/main/http_core.c Index: http_core.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v retrieving revision 1.155 retrieving revision 1.156 diff -u -r1.155 -r1.156 --- http_core.c 1998/02/02 19:46:53 1.155 +++ http_core.c 1998/02/02 22:33:32 1.156 @@ -622,11 +622,11 @@ : r-server-port; host = r-hostname ? r-hostname : r-server-server_hostname; } -if (port == DEFAULT_PORT) { - return pstrcat(p, http://;, host, uri, NULL); +if (is_default_port(port, r)) { + return pstrcat(p, http_method(r), ://, host, uri, NULL); } ap_snprintf(portnum, sizeof(portnum), %u, port); -return pstrcat(p, http://;, host, :, portnum, uri, NULL); +return pstrcat(p, http_method(r), ://, host, :, portnum, uri, NULL); } /* 1.184 +9 -6 apache-1.3/src/main/http_protocol.c Index: http_protocol.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_protocol.c,v retrieving revision 1.183 retrieving revision 1.184 diff -u -r1.183 -r1.184 --- http_protocol.c 1998/01/31 00:15:43 1.183 +++ http_protocol.c 1998/02/02 22:33:33 1.184 @@ -625,14 +625,17 @@ const char *check_fulluri(request_rec *r, const char *uri) { -char *name, *host; -int i; +char *name, *host, *proto; +int i, plen; unsigned port; /* This routine parses full URLs, if they match the server */ -if (strncasecmp(uri, http://;, 7)) +proto = http_method(r); +plen = strlen(proto); + +if (strncasecmp(uri, proto, plen) || strncasecmp(uri + plen, ://, 3)) return uri; -name = pstrdup(r-pool, uri + 7); +name = pstrdup(r-pool, uri + plen); /* Find the hostname, assuming a valid request */ i = ind(name, '/'); @@ -643,7 +646,7 @@ if (*name) port = atoi(name); else -port = 80; +port = default_port(r); /* Make sure ports patch */ if (port != r-server-port) @@ -651,7 +654,7 @@ /* Save it for later use */ r-hostname = pstrdup(r-pool, host);