cvs commit: apache-2.0/src/modules/standard mod_rewrite.c
rbb 00/01/07 07:50:42 Modified:src/modules/standard mod_rewrite.c Log: Fix mod_rewrite to work with the new APR stat structure. Submitted by: Paul Reder Reviewed by: Ryan Bloom Revision ChangesPath 1.9 +4 -4 apache-2.0/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_rewrite.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- mod_rewrite.c 2000/01/04 19:01:04 1.8 +++ mod_rewrite.c 2000/01/07 15:50:40 1.9 @@ -3762,8 +3762,8 @@ /* file stuff */ else if (strcasecmp(var, "SCRIPT_USER") == 0) { result = ""; -if (r->finfo.st_mode != 0) { -if ((pw = getpwuid(r->finfo.st_uid)) != NULL) { +if (r->finfo.protection != 0) { +if ((pw = getpwuid(r->finfo.user)) != NULL) { result = pw->pw_name; } } @@ -3777,8 +3777,8 @@ } else if (strcasecmp(var, "SCRIPT_GROUP") == 0) { result = ""; -if (r->finfo.st_mode != 0) { -if ((gr = getgrgid(r->finfo.st_gid)) != NULL) { +if (r->finfo.protection != 0) { +if ((gr = getgrgid(r->finfo.group)) != NULL) { result = gr->gr_name; } }
cvs commit: apache-2.0/src/modules/standard mod_rewrite.c
stoddard00/02/17 18:53:12 Modified:src/lib/apr/file_io/win32 fileio.h readwrite.c src/lib/apr/include apr_file_io.h src/main iol_file.c src/modules/standard mod_rewrite.c Log: Have seperate variable on ap_writev to set the number of iovecs passed in and pass back the number of bytes written. Use ap_iovec_t on the call rather than struct iovec (I may reverse this tomorrow :-). Whatever we do, the network_io and file_io calls need to use iovecs consistently, which isn't the case now. Revision ChangesPath 1.6 +1 -1 apache-2.0/src/lib/apr/file_io/win32/fileio.h Index: fileio.h === RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/fileio.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- fileio.h 2000/01/11 23:21:29 1.5 +++ fileio.h 2000/02/18 02:53:11 1.6 @@ -122,7 +122,7 @@ struct iovec_t { ap_context_t *cntxt; -struct iovec *iov; +struct iovec *theiov; }; ap_status_t file_cleanup(void *); 1.11 +7 -6 apache-2.0/src/lib/apr/file_io/win32/readwrite.c Index: readwrite.c === RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/readwrite.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- readwrite.c 2000/02/01 00:40:40 1.10 +++ readwrite.c 2000/02/18 02:53:11 1.11 @@ -117,19 +117,20 @@ /* * Too bad WriteFileGather() is not supported on 95&98 (or NT prior to SP2) */ -ap_status_t ap_writev(struct file_t *thefile, const struct iovec_t *vec, ap_ssize_t *iocnt) +ap_status_t ap_writev(struct file_t *thefile, const ap_iovec_t *vec, ap_size_t nvec, + ap_ssize_t *nbytes) { int i; DWORD bwrote = 0; -int numvec = *iocnt; -*iocnt = 0; +struct iovec *iov = vec->theiov; -for (i = 0; i < numvec; i++) { +*nbytes = 0; +for (i = 0; i < nvec; i++) { if (!WriteFile(thefile->filehand, - vec->iov[i].iov_base, vec->iov[i].iov_len, &bwrote, NULL)) { + iov[i].iov_base, iov[i].iov_len, &bwrote, NULL)) { return GetLastError(); } -*iocnt += bwrote; +*nbytes += bwrote; } return APR_SUCCESS; } 1.29 +1 -1 apache-2.0/src/lib/apr/include/apr_file_io.h Index: apr_file_io.h === RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- apr_file_io.h 2000/01/10 15:35:48 1.28 +++ apr_file_io.h 2000/02/18 02:53:11 1.29 @@ -136,7 +136,7 @@ ap_status_t ap_read(ap_file_t *, void *, ap_ssize_t *); ap_status_t ap_write(ap_file_t *, void *, ap_ssize_t *); -ap_status_t ap_writev(ap_file_t *, const ap_iovec_t *, ap_ssize_t *); +ap_status_t ap_writev(ap_file_t *, const ap_iovec_t *vec, ap_size_t nvec, ap_ssize_t *nbytes); ap_status_t ap_putc(char, ap_file_t *); ap_status_t ap_getc(char *, ap_file_t *); ap_status_t ap_ungetc(char, ap_file_t *); 1.8 +15 -85apache-2.0/src/main/iol_file.c Index: iol_file.c === RCS file: /home/cvs/apache-2.0/src/main/iol_file.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- iol_file.c2000/01/28 18:01:26 1.7 +++ iol_file.c2000/02/18 02:53:12 1.8 @@ -60,92 +60,9 @@ #include "ap_iol.h" #include -#if 0 -/* This is the non-APRed iol_file */ -#include typedef struct { ap_iol iol; -int fd; -} iol_file; - -#define method(syscall, args)\ -static ap_status_t file_##syscall args \ -{ \ - iol_file *iol = (iol_file *)viol; \ - int rv; \ - /* try writing, ignoring EINTR, the upper layer has to handle \ - partial read/writes anyhow, so we can return early */ \ - do { \ - rv = syscall(iol->fd, arg1, arg2); \ - } while (rv == -1 && errno == EINTR); \ -if (rv >= 0) { \ -*nbytes = rv; -return APR_SUCCESS; \ -} \ -*nbytes = 0; - return errno; \ -} - -method(write, (ap_iol *viol, const char *arg1, ap_size_t arg2, - ap_ssize_t *nbytes)) -method(writev, (ap_iol *viol, const struct iovec *arg1, int arg2, ap_ssize_t *nbytes)) -method(read, (ap_iol *viol, char *arg1, ap_size_t arg2, ap_ssize_t *nbytes)) - - -static ap_status_t file_close(ap_iol *viol) -{ -iol_file *iol = (iol_file *)viol; -int rv; -int saved_errno; - -
cvs commit: apache-2.0/src/modules/standard mod_rewrite.c
stoddard00/02/21 08:41:42 Modified:src/include ap_iol.h src/lib/apr aprlib.def src/lib/apr/file_io/beos readwrite.c src/lib/apr/file_io/os2 fileio.h readwrite.c src/lib/apr/file_io/unix fileio.h readwrite.c src/lib/apr/file_io/win32 fileio.h readwrite.c src/lib/apr/include apr_file_io.h src/main buff.c iol_file.c src/modules/standard mod_rewrite.c Log: Make file I/O and network I/O writev/sendv APIs consistent. Eliminate use of ap_iovec_t and use Posix struct iovec. I never did hear a case (much less a strong case) supporting the need for ap_iovec_t, so out it goes. Revision ChangesPath 1.11 +1 -1 apache-2.0/src/include/ap_iol.h Index: ap_iol.h === RCS file: /home/cvs/apache-2.0/src/include/ap_iol.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ap_iol.h 2000/02/18 18:05:15 1.10 +++ ap_iol.h 2000/02/21 16:41:38 1.11 @@ -106,7 +106,7 @@ ap_status_t (*close)(ap_iol *fd); ap_status_t (*write)(ap_iol *fd, const char *buf, ap_size_t len, ap_ssize_t *nbytes); -ap_status_t (*writev)(ap_iol *fd, const ap_iovec_t *vec, int nvec, +ap_status_t (*writev)(ap_iol *fd, const struct iovec *vec, int nvec, ap_ssize_t *nbytes); ap_status_t (*read)(ap_iol *fd, char *buf, ap_size_t len, ap_ssize_t *nbytes); 1.11 +1 -1 apache-2.0/src/lib/apr/aprlib.def Index: aprlib.def === RCS file: /home/cvs/apache-2.0/src/lib/apr/aprlib.def,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- aprlib.def2000/02/18 18:05:16 1.10 +++ aprlib.def2000/02/21 16:41:39 1.11 @@ -20,7 +20,7 @@ ;ap_get_filesize @12 ;ap_get_fileatime @13 ;ap_get_filectime @14 - ap_make_iov @15 +;ap_make_iov @15 ap_dupfile @16 ap_getfileinfo @17 ap_open @18 1.7 +3 -15 apache-2.0/src/lib/apr/file_io/beos/readwrite.c Index: readwrite.c === RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/beos/readwrite.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- readwrite.c 2000/02/05 12:05:06 1.6 +++ readwrite.c 2000/02/21 16:41:39 1.7 @@ -127,7 +127,7 @@ } /* ***APRDOC - * ap_status_t ap_writev(ap_file_t *, ap_iovec_t *, ap_ssize_t *) + * ap_status_t ap_writev(ap_file_t *, iovec *, ap_ssize_t *) *Write data from ap_iovec array to the specified file. * arg 1) The file descriptor to write to. * arg 2) The array from which to get the data to write to the file. @@ -138,22 +138,10 @@ *written on function exit. */ #ifdef HAVE_WRITEV - -ap_status_t ap_make_iov(struct iovec_t **new, struct iovec *iova, ap_context_t *cntxt) +ap_status_t ap_writev(struct file_t *thefile, const struct iovec *vec, ap_ssize_t *iocnt) { -(*new) = ap_palloc(cntxt, sizeof(struct iovec_t)); -if ((*new) == NULL) { -return APR_ENOMEM; -} -(*new)->cntxt = cntxt; -(*new)->theiov = iova; -return APR_SUCCESS; -} - -ap_status_t ap_writev(struct file_t *thefile, const struct iovec_t *vec, ap_ssize_t *iocnt) -{ int bytes; -if ((bytes = writev(thefile->filedes, vec->theiov, *iocnt)) < 0) { +if ((bytes = writev(thefile->filedes, vec, *iocnt)) < 0) { *iocnt = bytes; return errno; } 1.8 +0 -5 apache-2.0/src/lib/apr/file_io/os2/fileio.h Index: fileio.h === RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/os2/fileio.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- fileio.h 2000/01/10 15:35:45 1.7 +++ fileio.h 2000/02/21 16:41:39 1.8 @@ -91,11 +91,6 @@ int validentry; }; -struct iovec_t { -ap_context_t *cntxt; -struct iovec *theiov; -}; - ap_status_t file_cleanup(void *); ap_status_t ap_os2_time_to_ap_time(ap_time_t *result, FDATE os2date, FTIME os2time); int os2errno( ULONG oserror ); 1.12 +2 -15 apache-2.0/src/lib/apr/file_io/os2/readwrite.c Index: readwrite.c === RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/os2/readwrite.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- readwrite.c 2000/01/10 15:35:45 1.11 +
cvs commit: apache-2.0/src/modules/standard mod_rewrite.c mod_rewrite.h
dgaudet 99/12/30 21:03:34 Modified:src CHANGES src/modules/standard mod_rewrite.c mod_rewrite.h Log: port mod_rewrite to 2.0 Submitted by: Paul J. Reder <[EMAIL PROTECTED]> Revision ChangesPath 1.20 +2 -0 apache-2.0/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-2.0/src/CHANGES,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- CHANGES 1999/12/21 11:33:21 1.19 +++ CHANGES 1999/12/31 05:03:32 1.20 @@ -1,5 +1,7 @@ Changes with Apache 2.0-dev + *) port mod_rewrite to 2.0. [Paul J. Reder <[EMAIL PROTECTED]>] + *) More rigorous checking of Host: headers to fix security problems with mass name-based virtual hosting (whether using mod_rewrite or mod_vhost_alias). 1.6 +234 -202 apache-2.0/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_rewrite.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- mod_rewrite.c 1999/10/22 16:01:27 1.5 +++ mod_rewrite.c 1999/12/31 05:03:33 1.6 @@ -89,8 +89,18 @@ */ +#include "httpd.h" +#include "http_config.h" +#include "http_request.h" +#include "http_core.h" +#include "http_log.h" +#include "http_protocol.h" #include "mod_rewrite.h" +#if !defined(OS2) && !defined(WIN32) +#include "unixd.h" +#endif + #ifndef NO_WRITEV #include #include @@ -183,27 +193,26 @@ { NULL } }; +static void register_hooks(void) +{ +ap_hook_post_config(init_module,NULL,NULL,HOOK_MIDDLE); +ap_hook_child_init(init_child,NULL,NULL,HOOK_MIDDLE); + +ap_hook_fixups(hook_fixup,NULL,NULL,HOOK_FIRST); +ap_hook_translate_name(hook_uri2file,NULL,NULL,HOOK_FIRST); +ap_hook_type_checker(hook_mimetype,NULL,NULL,HOOK_MIDDLE); +} + /* the main config structure */ module MODULE_VAR_EXPORT rewrite_module = { - STANDARD_MODULE_STUFF, - init_module, /* module initializer */ + STANDARD20_MODULE_STUFF, config_perdir_create,/* create per-dirconfig structures */ config_perdir_merge, /* merge per-dirconfig structures */ config_server_create,/* create per-server config structures */ config_server_merge, /* merge per-server config structures */ - command_table, /* ap_table_t of config file commands */ + command_table, /* ap_table_t of config file commands */ handler_table, /* [#8] MIME-typed-dispatched handlers */ - hook_uri2file, /* [#1] URI to filename translation*/ - NULL,/* [#4] validate user id from request */ - NULL,/* [#5] check if the user is ok _here_ */ - 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,/* [#2] header parser */ - init_child, /* child_init */ - NULL,/* child_exit */ - NULL /* [#0] post read-request */ + register_hooks /* register hooks */ }; /* the cache */ @@ -211,9 +220,10 @@ /* whether proxy module is available or not */ static int proxy_available; +static int once_through = 0; -static char *lockname; -static int lockfd = -1; +static const char *lockname; +static ap_file_t *lockfd = NULL; /* ** +---+ @@ -238,7 +248,7 @@ a->state = ENGINE_DISABLED; a->options = OPTION_NONE; a->rewritelogfile = NULL; -a->rewritelogfp= -1; +a->rewritelogfp= NULL; a->rewriteloglevel = 0; a->rewritemaps = ap_make_array(p, 2, sizeof(rewritemap_entry)); a->rewriteconds= ap_make_array(p, 2, sizeof(rewritecond_entry)); @@ -271,7 +281,7 @@ a->rewritelogfile = overrides->rewritelogfile != NULL ? overrides->rewritelogfile : base->rewritelogfile; -a->rewritelogfp= overrides->rewritelogfp != -1 +a->rewritelogfp= overrides->rewritelogfp != NULL ? overrides->rewritelogfp : base->rewritelogfp;
cvs commit: apache-2.0/src/modules/standard mod_rewrite.c mod_rewrite.h
dgaudet 99/12/30 21:05:29 Modified:src/modules/standard mod_rewrite.c mod_rewrite.h Log: merge 1.3 changes to rewrite forward onto 2.0 Submitted by: Paul J. Reder <[EMAIL PROTECTED]> Revision ChangesPath 1.7 +89 -61apache-2.0/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c === RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_rewrite.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- mod_rewrite.c 1999/12/31 05:03:33 1.6 +++ mod_rewrite.c 1999/12/31 05:05:27 1.7 @@ -102,7 +102,9 @@ #endif #ifndef NO_WRITEV +#ifndef NETWARE #include +#endif #include #endif @@ -1145,13 +1147,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:' */ @@ -1171,8 +1179,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 */ @@ -1216,7 +1224,7 @@ /* it was finally rewritten to a local path */ /* expand "/~user" prefix */ -#ifndef WIN32 +#if !defined(WIN32) && !defined(NETWARE) r->filename = expand_tildepaths(r, r->filename); #endif rewritelog(r, 2, "local path result: %s", r->filename); @@ -1389,9 +1397,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); } @@ -1405,13 +1411,19 @@ return OK; } else if ( (strlen(r->filename) > 7 && -strncmp(r->filename, "http://";, 7) == 0) -|| (strlen(r->filename) > 8 && -strncmp(r->filename, "https://";, 8) == 0) +strncasecmp(r->filename, "http://";, 7) == 0) +|| (strlen(r->filename) > 8 && +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 @@ -1460,8 +1472,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->filena