dgaudet 98/09/22 11:05:55
Modified: apache-nspr Configuration.tmpl Makefile.tmpl apache-nspr/ap Makefile.tmpl ap.dsp ap_snprintf.c apache-nspr/include alloc.h ap.h ap_config.h buff.h hsregex.h http_conf_globals.h http_log.h http_protocol.h http_request.h httpd.h scoreboard.h util_md5.h apache-nspr/main Makefile.tmpl alloc.c buff.c http_config.c http_core.c http_log.c http_main.c http_protocol.c http_request.c rfc1413.c util.c util_date.c util_md5.c util_script.c apache-nspr/modules/example mod_example.c apache-nspr/modules/experimental mod_mmap_static.c apache-nspr/modules/proxy Makefile.tmpl proxy_cache.c proxy_connect.c proxy_ftp.c proxy_http.c apache-nspr/modules/standard Makefile.tmpl mod_access.c mod_actions.c mod_asis.c mod_auth.c mod_autoindex.c mod_cern_meta.c mod_cgi.c mod_digest.c mod_dir.c mod_expires.c mod_imap.c mod_include.c mod_info.c mod_log_config.c mod_mime.c mod_mime_magic.c mod_negotiation.c mod_rewrite.c mod_rewrite.h mod_so.c mod_speling.c mod_status.c mod_userdir.c apache-nspr/os/unix os.c apache-nspr/os/win32 modules.c util_win32.c Removed: apache-nspr/include conf.h Log: painful conflict resolution... I have not tried to compile this Revision Changes Path 1.3 +27 -20 apache-2.0/apache-nspr/Configuration.tmpl Index: Configuration.tmpl =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/Configuration.tmpl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Configuration.tmpl 1998/06/30 08:57:04 1.2 +++ Configuration.tmpl 1998/09/22 18:05:05 1.3 @@ -58,6 +58,7 @@ EXTRA_DEPS= #CC= +#CPP= #OPTIM= #RANLIB= @@ -72,8 +73,7 @@ # knowledge on how to compile these DSO files because this is # heavily platform-dependent. The current state of supported and # explicitly unsupported platforms can be found in the file -# "htdocs/manual/sharedobjects.html", under -# "Supported Platforms". +# "htdocs/manual/dso.html", under "Supported Platforms". # # For other platforms where you want to use the DSO mechanism you # first have to make sure it supports the pragmatic dlopen() @@ -90,6 +90,19 @@ # Then enable the DSO feature for particular modules individually # by replacing their `AddModule' command with `SharedModule' and # change the filename extension from `.o' to `.so'. +# +# Sometimes the DSO files need to be linked against other shared +# libraries to explicitly resolve symbols from them when the +# httpd program not already contains references to them. For +# instance when buidling mod_auth_db as a DSO you need to link +# the DSO against the libdb explicity because the Apache kernel +# has no references for this library. But the problem is that +# this "chaining" is not supported on all platforms. Although one +# usually can link a DSO against another DSO without linker +# complains the linkage is not really done on these platforms. +# So, when you receive "unresolved symbol" errors under runtime +# when using the LoadModule directive for a particular module try +# to enable the SHARED_CHAIN rule below. #CFLAGS_SHLIB= #LD_SHLIB= @@ -97,6 +110,7 @@ #LDFLAGS_SHLIB_EXPORT= Rule SHARED_CORE=default +Rule SHARED_CHAIN=default ################################################################ # Rules configuration @@ -105,7 +119,7 @@ # functions. The format is: Rule RULE=value # # At present, only the following RULES are known: WANTHSREGEX, SOCKS4, -# SOCKS5, STATUS, IRIXNIS, IRIXN32 and PARANOID. +# SOCKS5, IRIXNIS, IRIXN32 and PARANOID. # # For all Rules, if set to "yes", then Configure knows we want that # capability and does what is required to add it in. If set to "default" @@ -122,12 +136,6 @@ # location to EXTRA_LIBS, otherwise Configure will assume # "-L/usr/local/lib -lsocks5" # -# STATUS: -# If Configure determines that you are using the status_module, -# it will automatically enable full status information if set -# to 'yes'. If the status module is not included, having STATUS -# set to 'yes' has no impact. -# # IRIXNIS: # Only takes effect if Configure determines that you are running # SGI IRIX. If you are using a (ancient) 4.x version of IRIX, you @@ -148,7 +156,6 @@ # actually print-out the code that the modules execute # -Rule STATUS=yes Rule SOCKS4=no Rule SOCKS5=no Rule IRIXNIS=no @@ -188,6 +195,13 @@ # is and the more memory it will take, so if you are unlikely to use the # functionality of a particular module you might wish to leave it out. +## mod_mmap_static is an experimental module, you almost certainly +## don't need it. It can make some webservers faster. No further +## documentation is provided here because you'd be foolish +## to use mod_mmap_static without reading the full documentation. + +# AddModule modules/experimental/mod_mmap_static.o + ## ## Config manipulation modules ## @@ -223,10 +237,10 @@ ## ## The status module allows the server to display current details about ## how well it is performing and what it is doing. Consider also enabling -## STATUS=yes (see the Rules section near the start of this file) to allow -## full status information. Check conf/access.conf on how to enable this. +## the 'ExtendedStatus On' directive to allow full status information. +## Please note that doing so can result in a palpable performance hit. -# AddModule modules/standard/mod_status.o +AddModule modules/standard/mod_status.o ## The Info module displays configuration information for the server and ## all included modules. It's very useful for debugging. @@ -358,13 +372,6 @@ ## Don't change this entry to a 'SharedModule' variant (Bootstrapping!) # AddModule modules/standard/mod_so.o - -## mod_mmap_static is an experimental module, you almost certainly -## don't need it. It can make some webservers faster. No further -## documentation is provided here because you'd be foolish -## to use mod_mmap_static without reading the full documentation. - -# AddModule modules/experimental/mod_mmap_static.o ## mod_setenvif lets you set environment variables based on the HTTP header ## fields in the request; this is useful for conditional HTML, for example. 1.3 +10 -16 apache-2.0/apache-nspr/Makefile.tmpl Index: Makefile.tmpl =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/Makefile.tmpl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile.tmpl 1998/06/30 08:57:04 1.2 +++ Makefile.tmpl 1998/09/22 18:05:06 1.3 @@ -34,20 +34,20 @@ $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) \ -o $(TARGET) -DSHARED_CORE_BOOTSTRAP main/http_main.c -libhttpd.ep: libhttpd.so +libhttpd.ep: libhttpd.$(SHLIB_SUFFIX_NAME) $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) \ -o libhttpd.ep -DSHARED_CORE_TIESTATIC main/http_main.c \ -L. -lhttpd $(LIBS) -libhttpd.so: subdirs modules.o +libhttpd.$(SHLIB_SUFFIX_NAME): subdirs modules.o $(CC) -c $(INCLUDES) $(CFLAGS) buildmark.c - $(LD_SHLIB) $(LDFLAGS_SHLIB) -o libhttpd.so buildmark.o $(OBJS) $(REGLIB) + $(LD_SHLIB) $(LDFLAGS_SHLIB) -o libhttpd.$(SHLIB_SUFFIX_NAME) buildmark.o $(OBJS) $(REGLIB) @if [ ".$(SHLIB_SUFFIX_LIST)" != . ]; then \ - rm -f libhttpd.so.*; \ + rm -f libhttpd.$(SHLIB_SUFFIX_NAME).*; \ for suffix in $(SHLIB_SUFFIX_LIST) ""; do \ [ ".$$suffix" = . ] && continue; \ - echo "ln libhttpd.so libhttpd.so.$$suffix"; \ - ln libhttpd.so libhttpd.so.$$suffix; \ + echo "ln libhttpd.$(SHLIB_SUFFIX_NAME) libhttpd.$(SHLIB_SUFFIX_NAME).$$suffix"; \ + ln libhttpd.$(SHLIB_SUFFIX_NAME) libhttpd.$(SHLIB_SUFFIX_NAME).$$suffix; \ done; \ fi @@ -66,7 +66,7 @@ echo "<=== $(SDP)support" clean: - rm -f $(TARGET) libhttpd.* *.o + -rm -f $(TARGET) libhttpd.* *.o @for i in $(SUBDIRS); do \ echo "===> $(SDP)$$i"; \ ( cd $$i && $(MAKE) $(MFLAGS_STATIC) SDP='$(SDP)' $@ ) || exit 1; \ @@ -74,13 +74,13 @@ done distclean: - -rm -f $(TARGET) *.o + -rm -f $(TARGET) libhttpd.* *.o @for i in $(SUBDIRS); do \ echo "===> $(SDP)$$i"; \ ( cd $$i && $(MAKE) $(MFLAGS_STATIC) SDP='$(SDP)' $@ ) || exit 1; \ echo "<=== $(SDP)$$i"; \ done - -rm -f include/ap_config.h + -rm -f include/ap_config_auto.h -rm -f modules.c -rm -f modules/Makefile -rm -f regex/Makefile @@ -108,12 +108,6 @@ #Dependencies -$(OBJS): Makefile +$(OBJS): Makefile subdirs # DO NOT REMOVE -buildmark.o: buildmark.c include/conf.h os/unix/os.h include/httpd.h \ - include/alloc.h include/buff.h include/ap.h include/util_uri.h -iterate_components.o: iterate_components.c -modules.o: modules.c include/httpd.h include/conf.h os/unix/os.h \ - include/alloc.h include/buff.h include/ap.h include/util_uri.h \ - include/http_config.h 1.3 +25 -16 apache-2.0/apache-nspr/ap/Makefile.tmpl Index: Makefile.tmpl =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/ap/Makefile.tmpl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile.tmpl 1998/06/30 08:57:05 1.2 +++ Makefile.tmpl 1998/09/22 18:05:07 1.3 @@ -6,7 +6,7 @@ LIB=libap.a OBJS=ap_execve.o ap_cpystrn.o \ - ap_slack.o ap_snprintf.o + ap_slack.o ap_snprintf.o ap_fnmatch.o .c.o: $(CC) -c $(INCLUDES) $(CFLAGS) $< @@ -39,18 +39,27 @@ && rm Makefile.new # DO NOT REMOVE -ap_cpystrn.o: ap_cpystrn.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h -ap_execve.o: ap_execve.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h -ap_signal.o: ap_signal.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h -ap_slack.o: ap_slack.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_log.h -ap_snprintf.o: ap_snprintf.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h +ap_cpystrn.o: ap_cpystrn.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \ + $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \ + $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/alloc.h \ + $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h +ap_execve.o: ap_execve.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \ + $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \ + $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/alloc.h \ + $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h +ap_fnmatch.o: ap_fnmatch.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \ + $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(INCDIR)/ap_ctype.h \ + $(INCDIR)/hsregex.h $(INCDIR)/fnmatch.h +ap_signal.o: ap_signal.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \ + $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \ + $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/alloc.h \ + $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h +ap_slack.o: ap_slack.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \ + $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \ + $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/alloc.h \ + $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ + $(INCDIR)/http_log.h +ap_snprintf.o: ap_snprintf.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \ + $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \ + $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/alloc.h \ + $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h 1.3 +4 -0 apache-2.0/apache-nspr/ap/ap.dsp Index: ap.dsp =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/ap/ap.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ap.dsp 1998/06/30 08:57:05 1.2 +++ ap.dsp 1998/09/22 18:05:07 1.3 @@ -83,6 +83,10 @@ # End Source File # Begin Source File +SOURCE=.\ap_fnmatch.c +# End Source File +# Begin Source File + SOURCE=.\ap_signal.c # End Source File # Begin Source File 1.3 +5 -5 apache-2.0/apache-nspr/ap/ap_snprintf.c Index: ap_snprintf.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/ap/ap_snprintf.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ap_snprintf.c 1998/06/30 08:57:05 1.2 +++ ap_snprintf.c 1998/09/22 18:05:08 1.3 @@ -290,7 +290,7 @@ #define STR_TO_DEC( str, num ) \ num = NUM( *str++ ) ; \ - while ( isdigit( *str ) ) \ + while ( ap_isdigit( *str ) ) \ { \ num *= 10 ; \ num += NUM( *str++ ) ; \ @@ -450,7 +450,7 @@ /* * Check for Infinity and NaN */ - if (isalpha(*p)) { + if (ap_isalpha(*p)) { *len = strlen(strcpy(buf, p)); *is_negative = FALSE; return (buf); @@ -610,7 +610,7 @@ /* * Try to avoid checking for flags, width or precision */ - if (isascii(*fmt) && !islower(*fmt)) { + if (!ap_islower(*fmt)) { /* * Recognize flags: -, #, BLANK, + */ @@ -632,7 +632,7 @@ /* * Check if a width was specified */ - if (isdigit(*fmt)) { + if (ap_isdigit(*fmt)) { STR_TO_DEC(fmt, min_width); adjust_width = YES; } @@ -658,7 +658,7 @@ if (*fmt == '.') { adjust_precision = YES; fmt++; - if (isdigit(*fmt)) { + if (ap_isdigit(*fmt)) { STR_TO_DEC(fmt, precision); } else if (*fmt == '*') { 1.5 +26 -0 apache-2.0/apache-nspr/include/alloc.h Index: alloc.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/alloc.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- alloc.h 1998/09/17 16:12:32 1.4 +++ alloc.h 1998/09/22 18:05:09 1.5 @@ -216,6 +216,32 @@ API_EXPORT(table *) ap_overlay_tables(pool *p, const table *overlay, const table *base); +/* Conceptually, ap_overlap_tables does this: + + array_header *barr = ap_table_elts(b); + table_entry *belt = (table_entry *)barr->elts; + int i; + + for (i = 0; i < barr->nelts; ++i) { + if (flags & AP_OVERLAP_TABLES_MERGE) { + ap_table_mergen(a, belt[i].key, belt[i].val); + } + else { + ap_table_setn(a, belt[i].key, belt[i].val); + } + } + + Except that it is more efficient (less space and cpu-time) especially + when b has many elements. + + Notice the assumptions on the keys and values in b -- they must be + in an ancestor of a's pool. In practice b and a are usually from + the same pool. +*/ +#define AP_OVERLAP_TABLES_SET (0) +#define AP_OVERLAP_TABLES_MERGE (1) +API_EXPORT(void) ap_overlap_tables(table *a, const table *b, unsigned flags); + /* XXX: these know about the definition of struct table in alloc.c. That * definition is not here because it is supposed to be private, and by not * placing it here we are able to get compile-time diagnostics from modules 1.4 +3 -3 apache-2.0/apache-nspr/include/ap.h Index: ap.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/ap.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ap.h 1998/09/05 16:54:09 1.3 +++ ap.h 1998/09/22 18:05:09 1.4 @@ -53,9 +53,9 @@ * For more information on the Apache Group and the Apache HTTP server * project, please see <http://www.apache.org/>. * - * This code is based on, and used with the permission of, the - * SIO stdio-replacement strx_* functions by Panos Tsirigotis - * <[EMAIL PROTECTED]> for xinetd. + * The ap_vsnprintf/ap_snprintf functions are based on, and used with the + * permission of, the SIO stdio-replacement strx_* functions by Panos + * Tsirigotis <[EMAIL PROTECTED]> for xinetd. */ #ifndef APACHE_AP_H 1.2 +19 -999 apache-2.0/apache-nspr/include/ap_config.h Index: ap_config.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/ap_config.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ap_config.h 1998/09/22 16:46:32 1.1 +++ ap_config.h 1998/09/22 18:05:09 1.2 @@ -63,348 +63,22 @@ #endif /* - * ap_config.h: system-dependant #defines and includes... + * conf.h: system-dependant #defines and includes... * See PORTING for a listing of what they mean */ -#include "ap_mmn.h" /* MODULE_MAGIC_NUMBER_ */ - -/* - * Support for platform dependent autogenerated defines - */ -#ifndef WIN32 -#include "ap_config_auto.h" -#else -/* not available under WIN32, so provide important entries manually */ -#undef HAVE_UNISTD_H -#endif - -/* Have to include sys/stat.h before ../os/win32/os.h so we can override -stat() properly */ -#include <sys/types.h> -#include <sys/stat.h> +#include <stdlib.h> +#include <string.h> -#ifdef WIN32 -/* include process.h first so we can override spawn[lv]e* properly */ -#include <process.h> -#include "../os/win32/os.h" -#else #include "os.h" -#endif - -#if !defined(QNX) && !defined(MPE) && !defined(WIN32) -#include <sys/param.h> -#endif /* Define one of these according to your system. */ -#if defined(MINT) -typedef int rlim_t; -#define JMP_BUF sigjmp_buf -#define NO_LONG_DOUBLE -#define USE_FLOCK_SERIALIZED_ACCEPT -#define _BSD_SOURCE -#define EAGAIN EWOULDBLOCK -int initgroups (char *, int); -char *crypt (const char *pw, const char *salt); -int gethostname (char *name, int namelen); - -#elif defined(MPE) -#include <sys/times.h> -#define NO_SETSID -#define NO_KILLPG -#define NO_WRITEV -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -#define SHM_R 0400 /* Read permission */ -#define SHM_W 0200 /* Write permission */ -#define NEED_INITGROUPS -#define NEED_STRCASECMP -#define NEED_STRDUP -#define NEED_STRNCASECMP -extern void GETPRIVMODE(); -extern void GETUSERMODE(); -extern char *inet_ntoa(); -#define NO_SLACK -#define NO_GETTIMEOFDAY -#define S_IEXEC S_IXUSR -#define S_IREAD S_IRUSR -#define S_IWRITE S_IWUSR -#define PF_INET AF_INET - -#elif defined(SUNOS4) -#define HAVE_GMTOFF 1 -#undef NO_KILLPG -#undef NO_SETSID -char *crypt(const char *pw, const char *salt); -char *mktemp(char *template); -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#include <sys/time.h> -#define NEED_STRERROR -typedef int rlim_t; -#define memmove(a,b,c) bcopy(b,a,c) -#define NO_LINGCLOSE -#define USE_FLOCK_SERIALIZED_ACCEPT -#define NEED_DIFFTIME -#define HAVE_SYSLOG 1 - -#elif defined(SOLARIS2) -#undef HAVE_GMTOFF -#define NO_KILLPG -#undef NO_SETSID -#define bzero(a,b) memset(a,0,b) -#if !defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && \ - !defined(USE_PTHREAD_SERIALIZED_ACCEPT) -#define USE_FCNTL_SERIALIZED_ACCEPT -#endif -#define NEED_UNION_SEMUN -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -int gethostname(char *name, int namelen); -#define HAVE_SYSLOG 1 -#define SYS_SIGLIST _sys_siglist - -#elif defined(IRIX) -#undef HAVE_GMTOFF -/* IRIX has killpg, but it's only in _BSD_COMPAT, so don't use it in case - * there's some weird conflict with non-BSD signals */ -#define NO_KILLPG -#undef NO_SETSID -#if !defined(USE_FLOCK_SERIALIZED_ACCEPT) && \ - !defined(USE_USLOCK_SERIALIZED_ACCEPT) && \ - !defined(USE_SYSVSEM_SERIALIZED_ACCEPT) -#define USE_FCNTL_SERIALIZED_ACCEPT -#endif -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -#define HAVE_MMAP 1 -#define USE_MMAP_FILES -#define NO_LONG_DOUBLE -#define NO_LINGCLOSE -#define HAVE_SYSLOG 1 - -#elif defined(HIUX) -#undef HAVE_GMTOFF -#define NO_KILLPG -#undef NO_SETSID -#ifndef _HIUX_SOURCE -#define _HIUX_SOURCE -#endif -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -#define SELECT_NEEDS_CAST -#define HAVE_SYSLOG 1 - -#elif defined(HPUX) || defined(HPUX10) -#undef HAVE_GMTOFF -#define NO_KILLPG -#undef NO_SETSID -#define USE_FCNTL_SERIALIZED_ACCEPT -#ifndef _HPUX_SOURCE -#define _HPUX_SOURCE -#endif -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -#define HAVE_SYSLOG 1 -#ifndef HPUX10 -#define SELECT_NEEDS_CAST -typedef int rlim_t; -#endif - -#elif defined(HPUX11) -#ifndef _HPUX_SOURCE -#define _HPUX_SOURCE -#endif -#define HAVE_SHMGET -#define USE_SHMGET_SCOREBOARD -#undef HAVE_GMTOFF -#define USE_FCNTL_SERIALIZED_ACCEPT -/* feeling brave? want to try using POSIX mutexes? */ -/* #define HAVE_MMAP */ -/* #define USE_MMAP_SCOREBOARD */ -/* #define USE_MMAP_FILES */ -/* #define USE_PTHREAD_SERIALIZED_ACCEPT */ -#define NO_KILLPG -#undef NO_SETSID -#define HAVE_SYSLOG - -#elif defined(AIX) -#undef HAVE_GMTOFF -#undef NO_KILLPG -#undef NO_SETSID -#ifndef __ps2__ -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#define HAVE_SYSLOG 1 -#ifndef DEFAULT_GROUP -#define DEFAULT_GROUP "nobody" -#endif -#endif -#ifndef DEFAULT_USER -#define DEFAULT_USER "nobody" -#endif -#ifdef NEED_RLIM_T -typedef int rlim_t; -#endif -#define USE_FCNTL_SERIALIZED_ACCEPT -#ifdef USEBCOPY -#define memmove(a,b,c) bcopy(b,a,c) -#endif -#if AIX >= 42 -#define NET_SIZE_T size_t -#endif - -#elif defined(ULTRIX) -/* we don't want to use sys/resource.h under - Ultrix although this header exists. */ -#undef HAVE_SYS_RESOURCE_H -#define HAVE_GMTOFF 1 -#undef NO_KILLPG -#undef NO_SETSID -#define ULTRIX_BRAIN_DEATH -#define NEED_STRDUP -/* If you have Ultrix 4.3, and are using cc, const is broken */ -#ifndef __ultrix__ /* Hack to check for pre-Ultrix 4.4 cc */ -#define const /* Not implemented */ -#endif - -#elif defined(OSF1) -#define HAVE_GMTOFF 1 -#undef NO_KILLPG -#undef NO_SETSID -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#define NO_LONG_DOUBLE -#define HAVE_SYSLOG 1 -#define USE_FLOCK_SERIALIZED_ACCEPT -#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT - -#elif defined(PARAGON) -#define HAVE_GMTOFF 1 -#undef NO_KILLPG -#undef NO_SETSID -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#define NO_LONG_DOUBLE -#define HAVE_SYSLOG 1 -typedef int rlim_t; - -#elif defined(SEQUENT) -#define HAVE_GMTOFF 1 -#undef NO_KILLPG -#define NO_SETSID -#define NEED_STRDUP -#define HAVE_SYSLOG 1 - -#elif defined(NEXT) -typedef unsigned short mode_t; -#define HAVE_GMTOFF 1 -#undef NO_KILLPG -#define NO_SETSID -#define NEED_STRDUP -#define NO_LINGCLOSE -#undef _POSIX_SOURCE -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif -#ifndef S_ISDIR -#define S_ISDIR(m) (((m)&(S_IFMT)) == (S_IFDIR)) -#endif -#ifndef S_ISREG -#define S_ISREG(m) (((m)&(S_IFMT)) == (S_IFREG)) -#endif -#ifndef S_IXUSR -#define S_IXUSR 00100 -#endif -#ifndef S_IRGRP -#define S_IRGRP 00040 -#endif -#ifndef S_IXGRP -#define S_IXGRP 00010 -#endif -#ifndef S_IROTH -#define S_IROTH 00004 -#endif -#ifndef S_IXOTH -#define S_IXOTH 00001 -#endif -#ifndef S_IRUSR -#define S_IRUSR S_IREAD -#endif -#ifndef S_IWUSR -#define S_IWUSR S_IWRITE -#endif -#ifndef S_IWGRP -#define S_IWGRP 000020 -#endif -#ifndef S_IWOTH -#define S_IWOTH 000002 -#ifndef rlim_t -typedef int rlim_t; -#endif -typedef u_long n_long; -#endif - -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 - -/* PR#2293 fix */ -#define ap_wait_t union wait -#define waitpid(a,b,c) wait4((a) == -1 ? 0 : (a),(union wait *)(b),c,NULL) -#define WEXITSTATUS(status) (int)( WIFEXITED(status) ? ( (status).w_retcode ) : -1) -#define WTERMSIG(status) (int)( (status).w_termsig ) - -typedef int pid_t; -#define USE_LONGJMP -#define NO_USE_SIGACTION -#define HAVE_SYSLOG 1 - -#elif defined(RHAPSODY) /* Mac OS X Server */ -#define HAVE_GMTOFF -#define HAVE_MMAP -#define USE_MMAP_FILES -#define USE_MMAP_SCOREBOARD -#define MAP_TMPFILE -#define HAVE_RESOURCE -#define HAVE_SYS_RESOURCE_H /* apaci should catch this but doesn't */ -#define HAVE_SNPRINTF -#define JMP_BUF jmp_buf -#define USE_LONGJMP -#define USE_FLOCK_SERIALIZED_ACCEPT -#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT -/* - * If you are using APACI, (you should be on Rhapsody) these - * values are set at configure time. These are here as reference; - * the apache that is built into Rhapsody is configured with - * these values. - */ -#if 0 -#define HTTPD_ROOT "/Local/Library/WebServer" -#define DOCUMENT_LOCATION HTTPD_ROOT "/Documents" -#define DEFAULT_XFERLOG "Logs/Access" -#define DEFAULT_ERRORLOG "Logs/Errors" -#define DEFAULT_PIDLOG "Logs/Process" -#define DEFAULT_SCOREBOARD "Logs/Status" -#define DEFAULT_LOCKFILE "Logs/Lock" -#define SERVER_CONFIG_FILE "Configuration/Server" -#define RESOURCE_CONFIG_FILE "Configuration/Resources" -#define TYPES_CONFIG_FILE "Configuration/MIME" -#define ACCESS_CONFIG_FILE "Configuration/Access" -#define DEFAULT_USER_DIR "Library/Web Documents" -#define DEFAULT_USER "nobody" -#define DEFAULT_GROUP "nogroup" -#define DEFAULT_PATH "/bin:/usr/bin:/usr/local/bin" -#endif - -#elif defined(LINUX) -#if LINUX > 1 +/* XXX: all the old defines removed... since most of it is not needed with + * an NSPR based system. The few things we do need we should find via + * autoconf. So take care to use autoconf-style defines here. + */ +#if defined(LINUX) #include <features.h> /* libc4 systems probably still work, it probably doesn't define @@ -417,401 +91,13 @@ * all glibc based systems need crypt.h */ #if defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 -#include <crypt.h> -#endif - -/* glibc 2.0.0 through 2.0.4 need size_t * here, where 2.0.5 needs socklen_t * - * there's no way to discern between these two libraries. But using int should - * be portable because otherwise these libs would be hopelessly broken with - * reams of existing networking code. We'll use socklen_t * for 2.1.x and - * later. - * - * int works for all the earlier libs, and is picked up by default later. - */ -#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 0)) -#define NET_SIZE_T socklen_t -#endif - -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -#define HAVE_MMAP 1 -#define USE_MMAP_FILES - -/* glibc 2.1 and later finally define rlim_t */ -#if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) -typedef int rlim_t; +#define HAVE_CRYPT_H 1 #endif -/* flock is faster ... but hasn't been tested on 1.x systems */ -#define USE_FLOCK_SERIALIZED_ACCEPT - -#define SYS_SIGLIST _sys_siglist - #else -#define USE_FCNTL_SERIALIZED_ACCEPT -#endif -#undef HAVE_GMTOFF -#undef NO_KILLPG -#undef NO_SETSID -#undef NEED_STRDUP -#include <sys/time.h> -#define HAVE_SYSLOG 1 - -#elif defined(SCO) -#undef HAVE_GMTOFF -#undef NO_KILLPG -#undef NO_SETSID -#define NEED_INITGROUPS -#define NO_WRITEV -#include <sys/time.h> -#define HAVE_SYSLOG 1 - -#elif defined(SCO5) - -#define USE_FCNTL_SERIALIZED_ACCEPT -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#define SecureWare -#define HAVE_SYSLOG 1 - -/* Although SCO 5 defines these in <strings.h> (note the "s") they don't have - consts. Sigh. */ -extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, unsigned); - -#elif defined(AUX3) -/* These are to let -Wall compile more cleanly */ -extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, unsigned); -extern int set42sig(), getopt(), getpeername(), bzero(); -extern int listen(), bind(), socket(), getsockname(); -extern int accept(), gethostname(), connect(), lstat(); -extern int select(), killpg(), shutdown(); -extern int initgroups(), setsockopt(); -extern char *shmat(); -extern int shmctl(); -extern int shmget(); -extern char *sbrk(); -extern char *crypt(); -#include <sys/time.h> -#undef HAVE_GMTOFF -#undef NO_KILLPG -#undef NO_SETSID -#define NEED_STRDUP -/* fcntl() locking is expensive with NFS */ -#define USE_FLOCK_SERIALIZED_ACCEPT -#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -/* - * NOTE: If when you run Apache under A/UX and you get a warning - * that httpd couldn't move break, then the below value for - * MOVEBREAK (64megs) is too large for your setup. Try reducing - * to 0x2000000 which is still PLENTY of space. I doubt if - * even on heavy systems sbrk() would be called at all... - */ -#define MOVEBREAK 0x4000000 -#define NO_LINGCLOSE -#define NO_SLACK -#define HAVE_SYSLOG 1 -#undef HAVE_SYS_RESOURCE_H /* exists but does not provide *rlimit funcs */ - -#elif defined(SVR4) -#define NO_KILLPG -#undef NO_SETSID -#undef NEED_STRDUP -#ifndef MPRAS -#define NEED_STRCASECMP -#ifndef ENCORE -#define NEED_STRNCASECMP -#endif /* ENCORE */ -#endif /* MPRAS */ -#define bzero(a,b) memset(a,0,b) -/* A lot of SVR4 systems need this */ -#ifndef USE_SYSVSEM_SERIALIZED_ACCEPT -#define USE_FCNTL_SERIALIZED_ACCEPT -#endif -#define HAVE_SYSLOG 1 -#define NET_SIZE_T size_t -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -#ifdef _OSD_POSIX /* BS2000-POSIX mainframe needs initgroups */ -#define NEED_INITGROUPS -#define NEED_HASHBANG_EMUL /* execve() doesn't start shell scripts by default */ -#undef HAVE_SHMGET -#undef USE_SHMGET_SCOREBOARD -#undef bzero -#endif /*_OSD_POSIX*/ - -#elif defined(UW) -#define NO_LINGCLOSE -#define NO_KILLPG -#undef NO_SETSID -#undef NEED_STRDUP -#define NEED_STRCASECMP -#define NEED_STRNCASECMP -#define bzero(a,b) memset(a,0,b) -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#define HAVE_SHMGET 1 -#undef USE_SHMGET_SCOREBOARD /* force use of mmap() scoreboard */ -#include <sys/time.h> -#if UW >= 200 -#define _POSIX_SOURCE -#endif -#define NET_SIZE_T size_t -#define HAVE_SYSLOG 1 -#define USE_FCNTL_SERIALIZED_ACCEPT - -#elif defined(DGUX) -#define NO_KILLPG -#undef NO_SETSID -#undef NEED_STRDUP -#define NEED_STRCASECMP -#define NEED_STRNCASECMP -#define bzero(a,b) memset(a,0,b) -/* A lot of SVR4 systems need this */ -#define USE_FCNTL_SERIALIZED_ACCEPT -#define ap_inet_addr inet_network -#define HAVE_SYSLOG 1 - -#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(NETBSD) -#define HAVE_GMTOFF 1 -#undef NO_KILLPG -#undef NO_SETSID -#define HAVE_SYSLOG 1 -#ifndef DEFAULT_USER -#define DEFAULT_USER "nobody" -#endif -#ifndef DEFAULT_GROUP -#define DEFAULT_GROUP "nogroup" -#define HAVE_SHMGET 1 -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#endif - -#elif defined(UTS21) -#undef HAVE_GMTOFF -#undef NO_KILLPG -#define NO_SETSID -#define NEED_WAITPID -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#define HAVE_SYSLOG 1 -#define USE_LONGJMP -#define JMP_BUF jmp_buf -#define NO_USE_SIGACTION -#define NEED_STRERROR -#define NEED_STRSTR -#define NEED_HASHBANG_EMUL -#define NDELAY_PIPE_RETURNS_ZERO -#define NO_DATA NO_ADDRESS -#define ap_wait_t union wait -#define WEXITSTATUS(status) (int)((status).w_retcode) -#define WTERMSIG(status) (int)((status).w_termsig) -#define strftime(buf,bufsize,fmt,tm) ascftime(buf,fmt,tm) -#include <sys/types.h> -#include <sys/time.h> +/* nada */ -#elif defined(APOLLO) -#undef HAVE_GMTOFF -#undef NO_KILLPG -#undef NO_SETSID -#define HAVE_SYSLOG 1 - -#elif defined(__FreeBSD__) || defined(__bsdi__) -#if defined(__FreeBSD__) -#include <osreldate.h> -#endif -#define HAVE_GMTOFF 1 -#undef NO_KILLPG -#undef NO_SETSID -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#ifndef DEFAULT_USER -#define DEFAULT_USER "nobody" -#endif -#ifndef DEFAULT_GROUP -#define DEFAULT_GROUP "nogroup" -#endif -#if defined(__bsdi__) || \ -(defined(__FreeBSD_version) && (__FreeBSD_version < 220000)) -typedef quad_t rlim_t; -#endif -#define USE_FLOCK_SERIALIZED_ACCEPT -#define HAVE_SYSLOG 1 -#define SYS_SIGLIST sys_siglist - -#elif defined(QNX) -#ifndef crypt -char *crypt(const char *pw, const char *salt); -#endif -#ifndef initgroups -int initgroups(char *, int); -#endif -#ifndef strncasecmp -#define strncasecmp strnicmp -#endif -#undef NO_KILLPG -#undef NO_SETSID -#define NEED_INITGROUPS -#define NEED_SELECT_H -#define NEED_PROCESS_H -#include <unix.h> -#define HAVE_MMAP 1 -#define USE_POSIX_SCOREBOARD -#define USE_FLOCK_SERIALIZED_ACCEPT -#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT -#define HAVE_SYSLOG 1 - -#elif defined(LYNXOS) -#undef HAVE_GMTOFF -#undef USE_MMAP_SCOREBOARD -#undef USE_SHMGET_SCOREBOARD -#undef USE_FCNTL_SERIALIZED_ACCEPT -#undef USE_FLOCK_SERIALIZED_ACCEPT -#define USE_LONGJMP -#undef NO_KILLPG -#undef NO_SETSID -#undef NO_USE_SIGACTION -#undef NO_LINGCLOSE -extern char *crypt(char *pw, char *salt); -typedef int rlim_t; -#define HAVE_SYSLOG 1 - -#elif defined(UXPDS) -#undef NEED_STRCASECMP -#undef NEED_STRNCASECMP -#undef NEED_STRDUP -#undef HAVE_GMTOFF -#define NO_KILLPG -#undef NO_SETSID -#define bzero(a,b) memset(a,0,b) -#define USE_FCNTL_SERIALIZED_ACCEPT -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#define HAVE_SYSLOG 1 - -#elif defined(OS2) -/* Defines required for EMX OS/2 port. */ -#define NO_KILLPG -#define NEED_STRCASECMP -#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 -#include <sys/time.h> -#define MAXSOCKETS 4096 -#define USE_OS2_SCOREBOARD -#define NO_RELIABLE_PIPED_LOGS -#define USE_OS2SEM_SERIALIZED_ACCEPT -#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT - -#elif defined(__MACHTEN__) -typedef int rlim_t; -#undef NO_KILLPG -#define NO_SETSID -#define HAVE_GMTOFF 1 -#ifndef __MACHTEN_PPC__ -#ifndef __MACHTEN_68K__ -#define __MACHTEN_68K__ -#endif -#define USE_FLOCK_SERIALIZED_ACCEPT -#define NO_USE_SIGACTION -#define JMP_BUF sigjmp_buf -#define USE_LONGJMP -#undef NEED_STRDUP -#else -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -#define USE_FCNTL_SERIALIZED_ACCEPT -#endif - -/* Convex OS v11 */ -#elif defined(CONVEXOS11) -#undef HAVE_GMTOFF -#undef NO_KILLPG -#undef NO_SETSID -#undef NEED_STRDUP -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD -#define USE_MMAP_FILES -#define HAVE_SYSLOG 1 - -#define NO_TIMEZONE -#include <stdio.h> -#include <sys/types.h> -typedef int rlim_t; - -#elif defined(ISC) -#include <net/errno.h> -#define NO_KILLPG -#undef NO_SETSID -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -#define USE_FCNTL_SERIALIZED_ACCEPT -#define HAVE_SYSLOG 1 - -#elif defined(NEWSOS) -#define HAVE_SHMGET 1 -#define USE_SHMGET_SCOREBOARD -#define USE_LONGJMP -#define NO_SETSID -#define NO_USE_SIGACTION -#define NEED_WAITPID -#define NO_OTHER_CHILD -#define HAVE_SYSLOG 1 -#include <sys/time.h> -#include <stdlib.h> -#include <sys/types.h> -typedef int pid_t; -typedef int rlim_t; -typedef int mode_t; - -#elif defined(RISCIX) -#include <sys/time.h> -typedef int rlim_t; -#define NO_USE_SIGACTION -#define USE_LONGJMP -#define NEED_STRCASECMP -#define NEED_STRNCASECMP -#define NEED_STRDUP - -#elif defined(BEOS) -#include <stddef.h> - -#define NO_WRITEV -#define NO_KILLPG -#define NEED_INITGROUPS - -#elif defined(WIN32) - -/* All windows stuff is now in os/win32/os.h */ - -#else -/* Unknown system - Edit these to match */ -#ifdef BSD -#define HAVE_GMTOFF 1 -#else -#undef HAVE_GMTOFF -#endif -/* NO_KILLPG is set on systems that don't have killpg */ -#undef NO_KILLPG -/* NO_SETSID is set on systems that don't have setsid */ -#undef NO_SETSID -/* NEED_STRDUP is set on stupid systems that don't have strdup. */ -#undef NEED_STRDUP #endif /* stuff marked API_EXPORT is part of the API, and intended for use @@ -847,17 +133,6 @@ #define CORE_EXPORT_NONSTD API_EXPORT_NONSTD #endif -/* On OpenStep and Rhapsody, symbols that conflict with loaded dylibs - * (eg. System framework) need to be declared as private symbols with - * __private_extern__. - * For other systems, make that a no-op. - */ -#if defined(RHAPSODY) || defined(NEXT) -#define ap_private_extern __private_extern__ -#else -#define ap_private_extern -#endif - /* So that we can use inline on some critical functions, and use * GNUC attributes (such as to get -Wall warnings for printf-like * functions). Only do this in gcc 2.7 or later ... it may work @@ -878,187 +153,23 @@ #define USE_GNU_INLINE #define ENUM_BITFIELD(e,n,w) e n : w #endif - -/* - * The particular directory style your system supports. If you have dirent.h - * in /usr/include (POSIX) or /usr/include/sys (SYSV), #include - * that file and define DIR_TYPE to be dirent. Otherwise, if you have - * /usr/include/sys/dir.h, define DIR_TYPE to be direct and include that - * file. If you have neither, I'm confused. - */ - -#include <sys/types.h> -#include <stdarg.h> -#if !defined(NEXT) && !defined(WIN32) -#include <dirent.h> -#define DIR_TYPE dirent -#elif !defined(WIN32) -#include <sys/dir.h> -#define DIR_TYPE direct -#else -#define DIR_TYPE dirent +/* Do we have sys/resource.h; assume that BSD does. */ +#ifndef HAVE_SYS_RESOURCE_H +#ifdef BSD +#define HAVE_SYS_RESOURCE_H 1 #endif +#endif /* HAVE_SYS_RESOURCE_H */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "ap_ctype.h" -#if !defined(MPE) && !defined(WIN32) -#include <sys/file.h> -#endif -#ifndef WIN32 -#include <sys/socket.h> -#ifdef HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif /* HAVE_SYS_SELECT_H */ -#include <netinet/in.h> -#include <netdb.h> -#include <sys/ioctl.h> -#if !defined(MPE) && !defined(BEOS) -#include <arpa/inet.h> /* for inet_ntoa */ -#endif -#include <sys/wait.h> -#include <pwd.h> -#include <grp.h> -#include <fcntl.h> -#include <limits.h> -#define closesocket(s) close(s) -#ifndef O_BINARY -#define O_BINARY (0) -#endif - -#else /* WIN32 */ -#include <winsock.h> -#include <malloc.h> -#include <io.h> -#include <fcntl.h> -#endif /* ndef WIN32 */ - -#include <time.h> /* for ctime */ -#include <signal.h> -#include <errno.h> -#if !defined(QNX) && !defined(CONVEXOS11) && !defined(NEXT) -#include <memory.h> -#endif - -#ifdef NEED_PROCESS_H -#include <process.h> -#endif - -#ifdef WIN32 -#include "../include/hsregex.h" -#elif defined(USE_HSREGEX) +#if defined(USE_HSREGEX) #include "hsregex.h" #else +#include <sys/types.h> #include <regex.h> #endif - -#ifdef HAVE_SYS_RESOURCE_H -#include <sys/resource.h> -#ifdef SUNOS4 -int getrlimit(int, struct rlimit *); -int setrlimit(int, struct rlimit *); -#endif -#endif -#ifdef USE_MMAP_SCOREBOARD -#if !defined(OS2) && !defined(WIN32) -/* This file is not needed for OS/2 */ -#include <sys/mman.h> -#endif -#endif -#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) -#define MAP_ANON MAP_ANONYMOUS -#endif - -#if defined(USE_MMAP_FILES) && (defined(NO_MMAP) || !defined(HAVE_MMAP)) -#undef USE_MMAP_FILES -#endif - -#if defined(USE_MMAP_SCOREBOARD) && (defined(NO_MMAP) || !defined(HAVE_MMAP)) -#undef USE_MMAP_SCOREBOARD -#endif - -#if defined(USE_SHMGET_SCOREBOARD) && (defined(NO_SHMGET) || !defined(HAVE_SHMGET)) -#undef USE_SHMGET_SCOREBOARD -#endif - -#ifndef LOGNAME_MAX -#define LOGNAME_MAX 25 -#endif - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#ifdef ultrix -#define ULTRIX_BRAIN_DEATH -#endif - -#ifndef S_ISLNK -#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -#endif - -#ifndef INADDR_NONE -#define INADDR_NONE ((unsigned long) -1) -#endif - -/* - * Replace signal function with sigaction equivalent - */ -#ifndef NO_USE_SIGACTION -typedef void Sigfunc(int); - -#if defined(SIG_IGN) && !defined(SIG_ERR) -#define SIG_ERR ((Sigfunc *)-1) -#endif - -/* - * For some strange reason, QNX defines signal to signal. Eliminate it. - */ -#ifdef signal -#undef signal -#endif -#define signal(s,f) ap_signal(s,f) -Sigfunc *signal(int signo, Sigfunc * func); -#endif -#include <setjmp.h> - -#if defined(USE_LONGJMP) -#define ap_longjmp(x, y) longjmp((x), (y)) -#define ap_setjmp(x) setjmp(x) -#ifndef JMP_BUF -#define JMP_BUF jmp_buf -#endif -#else -#define ap_longjmp(x, y) siglongjmp((x), (y)) -#define ap_setjmp(x) sigsetjmp((x), 1) -#ifndef JMP_BUF -#define JMP_BUF sigjmp_buf -#endif -#endif - -#ifdef SELECT_NEEDS_CAST -#define ap_select(_a, _b, _c, _d, _e) \ - select((_a), (int *)(_b), (int *)(_c), (int *)(_d), (_e)) -#else -#define ap_select select -#endif - -#ifdef ULTRIX_BRAIN_DEATH -#define ap_fdopen(d,m) fdopen((d), (char *)(m)) -#else -#define ap_fdopen(d,m) fdopen((d), (m)) -#endif - -#ifndef ap_inet_addr -#define ap_inet_addr inet_addr -#endif - -#ifdef NO_OTHER_CHILD +/* XXX: some day we'll get this working with NSPR */ #define NO_RELIABLE_PIPED_LOGS -#endif /* When the underlying OS doesn't support exec() of scripts which start * with a HASHBANG (#!) followed by interpreter name and args, define this. @@ -1104,97 +215,6 @@ #define XtOffsetOf(s_type,field) XtOffset(s_type*,field) #endif -/* - * NET_SIZE_T exists because of shortsightedness on the POSIX committee. BSD - * systems used "int *" as the parameter to accept(), getsockname(), - * getpeername() et al. Consequently many unixes took an int * for that - * parameter. The POSIX committee decided that "int" was just too generic and - * had to be replaced with size_t almost everywhere. There's no problem with - * that when you're passing by value. But when you're passing by reference - * this creates a gross source incompatibility with existing programs. On - * 32-bit architectures it creates only a warning. On 64-bit architectures it - * creates broken code -- because "int *" is a pointer to a 64-bit quantity and - * "size_t *" is frequently a pointer to a 32-bit quantity. - * - * Some Unixes adopted "size_t *" for the sake of POSIX compliance. Others - * ignored it because it was such a broken interface. Chaos ensued. POSIX - * finally woke up and decided that it was wrong and created a new type - * socklen_t. The only useful value for socklen_t is int, and that's how - * everyone who has a clue implements it. It is almost always the case that - * NET_SIZE_T should be defined to be an int, unless the system being compiled - * for was created in the window of POSIX madness. - */ -#ifndef NET_SIZE_T -#define NET_SIZE_T int -#endif - -/* Linux defines __WCOREDUMP, but doesn't define WCOREDUMP unless __USE_BSD - * is in use... we'd prefer to just use WCOREDUMP everywhere. - */ -#if defined(__WCOREDUMP) && !defined(WCOREDUMP) -#define WCOREDUMP __WCOREDUMP -#endif - -#ifdef SUNOS_LIB_PROTOTYPES -/* Prototypes needed to get a clean compile with gcc -Wall. - * Believe it or not, these do have to be declared, at least on SunOS, - * because they aren't mentioned in the relevant system headers. - * Sun Quality Software. Gotta love it. This section is not - * currently (13Nov97) used. - */ - -int getopt(int, char **, char *); - -int strcasecmp(const char *, const char *); -int strncasecmp(const char *, const char *, int); -int toupper(int); -int tolower(int); - -int printf(char *,...); -int fprintf(FILE *, char *,...); -int fputs(char *, FILE *); -int fread(char *, int, int, FILE *); -int fwrite(char *, int, int, FILE *); -int fgetc(FILE *); -char *fgets(char *s, int, FILE*); -int fflush(FILE *); -int fclose(FILE *); -int ungetc(int, FILE *); -int _filbuf(FILE *); /* !!! */ -int _flsbuf(unsigned char, FILE *); /* !!! */ -int sscanf(char *, char *,...); -void setbuf(FILE *, char *); -void perror(char *); - -time_t time(time_t *); -int strftime(char *, int, const char *, struct tm *); - -int initgroups(char *, int); -int wait3(int *, int, void *); /* Close enough for us... */ -int lstat(const char *, struct stat *); -int stat(const char *, struct stat *); -int flock(int, int); -#ifndef NO_KILLPG -int killpg(int, int); -#endif -int socket(int, int, int); -int setsockopt(int, int, int, const char *, int); -int listen(int, int); -int bind(int, struct sockaddr *, int); -int connect(int, struct sockaddr *, int); -int accept(int, struct sockaddr *, int *); -int shutdown(int, int); - -int getsockname(int s, struct sockaddr *name, int *namelen); -int getpeername(int s, struct sockaddr *name, int *namelen); -int gethostname(char *name, int namelen); -void syslog(int, char *,...); -char *mktemp(char *); - -long vfprintf(FILE *, const char *, va_list); - -#endif /* SUNOS_LIB_PROTOTYPES */ - /* The assumption is that when the functions are missing, * then there's no matching prototype available either. * Declare what is needed exactly as the replacement routines implement it. @@ -1229,4 +249,4 @@ } #endif -#endif /* !AP_CONFIG_H */ +#endif /* !APACHE_CONF_H */ 1.3 +1 -1 apache-2.0/apache-nspr/include/buff.h Index: buff.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/buff.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- buff.h 1998/06/30 08:57:05 1.2 +++ buff.h 1998/09/22 18:05:09 1.3 @@ -127,7 +127,7 @@ API_EXPORT(int) ap_bsetflag(BUFF *fb, int flag, int value); API_EXPORT(PRStatus) ap_bclose(BUFF *fb); -#define bgetflag(fb, flag) ((fb)->flags & (flag)) +#define ap_bgetflag(fb, flag) ((fb)->flags & (flag)) /* Error handling */ API_EXPORT(void) ap_bonerror(BUFF *fb, void (*error) (BUFF *, int, void *), 1.3 +9 -1 apache-2.0/apache-nspr/include/hsregex.h Index: hsregex.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/hsregex.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- hsregex.h 1998/06/30 08:57:05 1.2 +++ hsregex.h 1998/09/22 18:05:10 1.3 @@ -1,3 +1,5 @@ +/* DON'T EVEN THINK ABOUT EDITING THIS, go see regex/Makefile, + * search for mkh */ #ifndef _REGEX_H_ #define _REGEX_H_ /* never again */ /* ========= begin header generated by ./mkh ========= */ @@ -14,7 +16,13 @@ #endif #endif -typedef long regoff_t; +#if defined(RHAPSODY) || defined(NEXT) +#define ap_private_extern __private_extern__ +#else +#define ap_private_extern +#endif + +typedef off_t regoff_t; typedef struct { int re_magic; size_t re_nsub; /* number of parenthesized subexpressions */ 1.3 +1 -0 apache-2.0/apache-nspr/include/http_conf_globals.h Index: http_conf_globals.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/http_conf_globals.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- http_conf_globals.h 1998/06/30 08:57:05 1.2 +++ http_conf_globals.h 1998/09/22 18:05:10 1.3 @@ -86,6 +86,7 @@ extern MODULE_VAR_EXPORT int ap_suexec_enabled; extern int ap_listenbacklog; extern int ap_dump_settings; +extern API_VAR_EXPORT int ap_extended_status; extern char *ap_pid_fname; extern char *ap_scoreboard_fname; 1.3 +3 -0 apache-2.0/apache-nspr/include/http_log.h Index: http_log.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/http_log.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- http_log.h 1998/06/30 08:57:06 1.2 +++ http_log.h 1998/09/22 18:05:10 1.3 @@ -108,6 +108,9 @@ API_EXPORT(void) ap_log_error(const char *file, int line, int level, const server_rec *s, const char *fmt, ...) __attribute__((format(printf,5,6))); +API_EXPORT(void) ap_log_rerror(const char *file, int line, int level, + const request_rec *s, const char *fmt, ...) + __attribute__((format(printf,5,6))); API_EXPORT(void) ap_error_log2stderr (server_rec *); void ap_log_pid (pool *p, char *fname); 1.3 +3 -3 apache-2.0/apache-nspr/include/http_protocol.h Index: http_protocol.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/http_protocol.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- http_protocol.h 1998/06/30 08:57:06 1.2 +++ http_protocol.h 1998/09/22 18:05:10 1.3 @@ -91,12 +91,12 @@ /* Send the response to special method requests */ -int ap_send_http_trace(request_rec *r); +API_EXPORT(int) ap_send_http_trace(request_rec *r); int ap_send_http_options(request_rec *r); /* Finish up stuff after a request */ -void ap_finalize_request_protocol(request_rec *r); +API_EXPORT(void) ap_finalize_request_protocol(request_rec *r); /* Send error back to client... last arg indicates error status in case * we get an error in the process of trying to deal with an ErrorDocument @@ -197,7 +197,7 @@ API_EXPORT(void) ap_note_auth_failure(request_rec *r); API_EXPORT(void) ap_note_basic_auth_failure(request_rec *r); API_EXPORT(void) ap_note_digest_auth_failure(request_rec *r); -API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, char **pw); +API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw); /* * Setting up the protocol fields for subsidiary requests... 1.3 +1 -1 apache-2.0/apache-nspr/include/http_request.h Index: http_request.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/http_request.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- http_request.h 1998/06/30 08:57:06 1.2 +++ http_request.h 1998/09/22 18:05:11 1.3 @@ -106,7 +106,7 @@ #ifdef CORE_PRIVATE /* Function called by main.c to handle first-level request */ void ap_process_request(request_rec *); -void ap_die(int type, request_rec *r); +API_EXPORT(void) ap_die(int type, request_rec *r); #endif #ifdef __cplusplus 1.3 +53 -20 apache-2.0/apache-nspr/include/httpd.h Index: httpd.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/httpd.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- httpd.h 1998/06/30 08:57:06 1.2 +++ httpd.h 1998/09/22 18:05:11 1.3 @@ -73,7 +73,7 @@ /* Headers in which EVERYONE has an interest... */ -#include "conf.h" +#include "ap_config.h" #include "alloc.h" #include "buff.h" #include "ap.h" @@ -93,7 +93,7 @@ * file with a relative pathname will have this added. */ #ifndef HTTPD_ROOT -#ifdef __EMX__ +#ifdef OS2 /* Set default for OS/2 file system */ #define HTTPD_ROOT "/os2httpd" #elif defined(WIN32) @@ -108,7 +108,7 @@ * directive. */ #ifndef DOCUMENT_LOCATION -#ifdef __EMX__ +#ifdef OS2 /* Set default for OS/2 file system */ #define DOCUMENT_LOCATION HTTPD_ROOT "/docs" #else @@ -136,6 +136,8 @@ /* -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- */ #define HTTP_VERSION(major,minor) (1000*(major)+(minor)) +#define HTTP_VERSION_MAJOR(number) ((number)/1000) +#define HTTP_VERSION_MINOR(number) ((number)%1000) /* -------------- Port number for server running standalone --------------- */ @@ -158,7 +160,7 @@ /* The name of the log files */ #ifndef DEFAULT_XFERLOG -#ifdef __EMX__ +#ifdef OS2 /* Set default for OS/2 file system */ #define DEFAULT_XFERLOG "logs/access.log" #else @@ -167,7 +169,7 @@ #endif /* DEFAULT_XFERLOG */ #ifndef DEFAULT_ERRORLOG -#ifdef __EMX__ +#ifdef OS2 /* Set default for OS/2 file system */ #define DEFAULT_ERRORLOG "logs/error.log" #else @@ -203,7 +205,7 @@ /* Define this to be what your per-directory security files are called */ #ifndef DEFAULT_ACCESS_FNAME -#ifdef __EMX__ +#ifdef OS2 /* Set default for OS/2 file system */ #define DEFAULT_ACCESS_FNAME "htaccess" #else @@ -247,7 +249,7 @@ /* The path to the shell interpreter, for parsed docs */ #ifndef SHELL_PATH -#if defined(__EMX__) || defined(WIN32) +#if defined(OS2) || defined(WIN32) /* Set default for OS/2 and Windows file system */ #define SHELL_PATH "CMD.EXE" #else @@ -383,6 +385,32 @@ #define DEFAULT_LISTENBACKLOG 511 #endif +/* Limits on the size of various request items. These limits primarily + * exist to prevent simple denial-of-service attacks on a server based + * on misuse of the protocol. The recommended values will depend on the + * nature of the server resources -- CGI scripts and database backends + * might require large values, but most servers could get by with much + * smaller limits than we use below. The request message body size can + * be limited by the per-dir config directive LimitRequestBody. + * + * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE + * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190. + * These two limits can be lowered (but not raised) by the server config + * directives LimitRequestLine and LimitRequestFieldsize, respectively. + * + * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by + * the server config directive LimitRequestFields. + */ +#ifndef DEFAULT_LIMIT_REQUEST_LINE +#define DEFAULT_LIMIT_REQUEST_LINE 8190 +#endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */ +#ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE +#define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190 +#endif /* default limit on bytes in any one header field */ +#ifndef DEFAULT_LIMIT_REQUEST_FIELDS +#define DEFAULT_LIMIT_REQUEST_FIELDS 100 +#endif /* default limit on number of request header fields */ + /* * The below defines the base string of the Server: header. Additional * tokens can be added via the ap_add_version_component() API call. @@ -396,7 +424,7 @@ * Example: "Apache/1.1.0 MrWidget/0.1-alpha" */ -#define SERVER_BASEVERSION "Apache/1.3.1-dev" /* SEE COMMENTS ABOVE */ +#define SERVER_BASEVERSION "Apache/1.3.3-dev" /* SEE COMMENTS ABOVE */ #define SERVER_VERSION SERVER_BASEVERSION enum server_token_type { SrvTk_MIN, /* eg: Apache/1.3.0 */ @@ -413,7 +441,7 @@ * For a final release, 'betaseq' should be set to '99'. * For example, Apache 1.4.2 should be '1040299' */ -#define APACHE_RELEASE 1030101 +#define APACHE_RELEASE 1030301 #define SERVER_PROTOCOL "HTTP/1.1" #ifndef SERVER_SUPPORT @@ -489,12 +517,12 @@ #define BAD_GATEWAY HTTP_BAD_GATEWAY #define VARIANT_ALSO_VARIES HTTP_VARIANT_ALSO_VARIES -#define is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200)) -#define is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300)) -#define is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400)) -#define is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600)) -#define is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500)) -#define is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600)) +#define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200)) +#define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300)) +#define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400)) +#define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600)) +#define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500)) +#define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600)) #define status_drops_connection(x) (((x) == HTTP_BAD_REQUEST) || \ ((x) == HTTP_REQUEST_TIME_OUT) || \ @@ -848,9 +876,13 @@ array_header *names; /* Normal names for ServerAlias servers */ array_header *wild_names; /* Wildcarded names for ServerAlias servers */ + + uid_t server_uid; /* effective user id when calling exec wrapper */ + gid_t server_gid; /* effective group id when calling exec wrapper */ - uid_t server_uid; /* effective user id when calling exec wrapper */ - gid_t server_gid; /* effective group id when calling exec wrapper */ + int limit_req_line; /* limit on size of the HTTP request line */ + int limit_req_fieldsize; /* limit on size of any request header field */ + int limit_req_fields; /* limit on number of request header fields */ }; /* These are more like real hosts than virtual hosts */ @@ -915,7 +947,8 @@ API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp); API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp); API_EXPORT(char *) ap_uudecode(pool *, const char *); -#ifdef __EMX__ +API_EXPORT(char *) ap_uuencode(pool *p, char *string); +#ifdef OS2 void os2pathname(char *path); #endif @@ -981,12 +1014,12 @@ #endif #ifdef _OSD_POSIX -extern const char *os_set_authfile(pool *p, const char *filename); +extern const char *os_set_account(pool *p, const char *account); extern int os_init_job_environment(server_rec *s, const char *user_name); #endif /* _OSD_POSIX */ char *ap_get_local_host(pool *); -PRUint32 ap_get_virthost_addr(const char *hostname, PRUint16 *port); +PRUint32 ap_get_virthost_addr(char *hostname, PRUint16 *port); extern API_VAR_EXPORT PRTime ap_restart_time; 1.4 +0 -2 apache-2.0/apache-nspr/include/scoreboard.h Index: scoreboard.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/scoreboard.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- scoreboard.h 1998/09/22 16:12:06 1.3 +++ scoreboard.h 1998/09/22 18:05:11 1.4 @@ -88,7 +88,6 @@ /* stuff which the children generally write, and the parent mainly reads */ typedef struct { unsigned char status; -#if defined(STATUS) unsigned long access_count; unsigned long bytes_served; unsigned long my_access_count; @@ -104,7 +103,6 @@ char client[32]; /* Keep 'em small... */ char request[64]; /* We just want an idea... */ char vhost[32]; /* What virtual host is being accessed? */ -#endif } short_score; typedef struct { 1.3 +2 -1 apache-2.0/apache-nspr/include/util_md5.h Index: util_md5.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/util_md5.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- util_md5.h 1998/06/30 08:57:06 1.2 +++ util_md5.h 1998/09/22 18:05:11 1.3 @@ -66,7 +66,8 @@ #include "ap_md5.h" -API_EXPORT(char *) ap_md5(pool *a, unsigned char *string); +API_EXPORT(char *) ap_md5(pool *a, const unsigned char *string); +API_EXPORT(char *) ap_md5_binary(pool *a, const unsigned char *buf, int len); API_EXPORT(char *) ap_md5contextTo64(pool *p, AP_MD5_CTX * context); API_EXPORT(char *) ap_md5digest(pool *p, PRFileDesc *infile); 1.3 +1 -81 apache-2.0/apache-nspr/main/Makefile.tmpl Index: Makefile.tmpl =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/Makefile.tmpl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile.tmpl 1998/06/30 08:57:06 1.2 +++ Makefile.tmpl 1998/09/22 18:05:15 1.3 @@ -11,7 +11,7 @@ http_config.o http_core.o http_log.o http_main.o \ http_protocol.o http_request.o http_vhost.o \ util.o util_date.o util_script.o util_uri.o util_md5.o \ - md5c.o rfc1413.o fnmatch.o + md5c.o rfc1413.o .c.o: $(CC) -c $(INCLUDES) $(CFLAGS) $< @@ -58,83 +58,3 @@ $(OBJS): Makefile # DO NOT REMOVE -alloc.o: alloc.c $(INCDIR)/httpd.h $(INCDIR)/conf.h $(OSDIR)/os.h \ - $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_log.h -buff.o: buff.c $(INCDIR)/httpd.h $(INCDIR)/conf.h $(OSDIR)/os.h \ - $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_main.h $(INCDIR)/http_log.h -fnmatch.o: fnmatch.c $(INCDIR)/conf.h $(OSDIR)/os.h \ - $(INCDIR)/fnmatch.h -gen_test_char.o: gen_test_char.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h -gen_uri_delims.o: gen_uri_delims.c -http_config.o: http_config.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_conf_globals.h $(INCDIR)/http_vhost.h \ - $(INCDIR)/explain.h -http_core.o: http_core.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_conf_globals.h $(INCDIR)/http_vhost.h \ - $(INCDIR)/http_main.h $(INCDIR)/http_log.h $(INCDIR)/rfc1413.h \ - $(INCDIR)/util_md5.h $(INCDIR)/ap_md5.h $(INCDIR)/scoreboard.h \ - $(INCDIR)/fnmatch.h -http_log.o: http_log.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_main.h -http_main.o: http_main.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_main.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_request.h $(INCDIR)/http_conf_globals.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_vhost.h \ - $(INCDIR)/util_script.h $(INCDIR)/scoreboard.h $(INCDIR)/explain.h -http_protocol.o: http_protocol.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_protocol.h $(INCDIR)/http_main.h \ - $(INCDIR)/http_request.h $(INCDIR)/http_vhost.h \ - $(INCDIR)/http_log.h $(INCDIR)/util_date.h \ - $(INCDIR)/http_conf_globals.h -http_request.o: http_request.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \ - $(INCDIR)/http_request.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_protocol.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_main.h $(INCDIR)/scoreboard.h $(INCDIR)/fnmatch.h -http_vhost.o: http_vhost.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \ - $(INCDIR)/http_conf_globals.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_vhost.h $(INCDIR)/http_protocol.h -md5c.o: md5c.c $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/ap_md5.h -rfc1413.o: rfc1413.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_log.h $(INCDIR)/rfc1413.h \ - $(INCDIR)/http_main.h -util.o: util.c $(INCDIR)/httpd.h $(INCDIR)/conf.h $(OSDIR)/os.h \ - $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_conf_globals.h \ - $(INCDIR)/http_log.h test_char.h -util_date.o: util_date.c $(INCDIR)/conf.h $(OSDIR)/os.h \ - $(INCDIR)/util_date.h -util_md5.o: util_md5.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/util_md5.h $(INCDIR)/ap_md5.h -util_script.o: util_script.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \ - $(INCDIR)/http_conf_globals.h $(INCDIR)/http_main.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_request.h \ - $(INCDIR)/util_script.h $(INCDIR)/util_date.h -util_uri.o: util_uri.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \ - $(INCDIR)/util_uri.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_conf_globals.h uri_delims.h 1.3 +157 -0 apache-2.0/apache-nspr/main/alloc.c Index: alloc.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/alloc.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- alloc.c 1998/06/30 08:57:06 1.2 +++ alloc.c 1998/09/22 18:05:15 1.3 @@ -1378,6 +1378,163 @@ va_end(vp); } +/* Curse libc and the fact that it doesn't guarantee a stable sort. We + * have to enforce stability ourselves by using the order field. If it + * provided a stable sort then we wouldn't even need temporary storage to + * do the work below. -djg + * + * ("stable sort" means that equal keys retain their original relative + * ordering in the output.) + */ +typedef struct { + char *key; + char *val; + int order; +} overlap_key; + +static int sort_overlap(const void *va, const void *vb) +{ + const overlap_key *a = va; + const overlap_key *b = vb; + int r; + + r = strcasecmp(a->key, b->key); + if (r) { + return r; + } + return a->order - b->order; +} + +/* prefer to use the stack for temp storage for overlaps smaller than this */ +#ifndef AP_OVERLAP_TABLES_ON_STACK +#define AP_OVERLAP_TABLES_ON_STACK (512) +#endif + +API_EXPORT(void) ap_overlap_tables(table *a, const table *b, unsigned flags) +{ + overlap_key cat_keys_buf[AP_OVERLAP_TABLES_ON_STACK]; + overlap_key *cat_keys; + int nkeys; + table_entry *e; + table_entry *last_e; + overlap_key *left; + overlap_key *right; + overlap_key *last; + + nkeys = a->a.nelts + b->a.nelts; + if (nkeys < AP_OVERLAP_TABLES_ON_STACK) { + cat_keys = cat_keys_buf; + } + else { + /* XXX: could use scratch free space in a or b's pool instead... + * which could save an allocation in b's pool. + */ + cat_keys = ap_palloc(b->a.pool, sizeof(overlap_key) * nkeys); + } + + nkeys = 0; + + /* Create a list of the entries from a concatenated with the entries + * from b. + */ + e = (table_entry *)a->a.elts; + last_e = e + a->a.nelts; + while (e < last_e) { + cat_keys[nkeys].key = e->key; + cat_keys[nkeys].val = e->val; + cat_keys[nkeys].order = nkeys; + ++nkeys; + ++e; + } + + e = (table_entry *)b->a.elts; + last_e = e + b->a.nelts; + while (e < last_e) { + cat_keys[nkeys].key = e->key; + cat_keys[nkeys].val = e->val; + cat_keys[nkeys].order = nkeys; + ++nkeys; + ++e; + } + + qsort(cat_keys, nkeys, sizeof(overlap_key), sort_overlap); + + /* Now iterate over the sorted list and rebuild a. + * Start by making sure it has enough space. + */ + a->a.nelts = 0; + if (a->a.nalloc < nkeys) { + a->a.elts = ap_palloc(a->a.pool, a->a.elt_size * nkeys * 2); + a->a.nalloc = nkeys * 2; + } + + /* + * In both the merge and set cases we retain the invariant: + * + * left->key, (left+1)->key, (left+2)->key, ..., (right-1)->key + * are all equal keys. (i.e. strcasecmp returns 0) + * + * We essentially need to find the maximal + * right for each key, then we can do a quick merge or set as + * appropriate. + */ + + if (flags & AP_OVERLAP_TABLES_MERGE) { + left = cat_keys; + last = left + nkeys; + while (left < last) { + right = left + 1; + if (right == last + || strcasecmp(left->key, right->key)) { + ap_table_addn(a, left->key, left->val); + left = right; + } + else { + char *strp; + char *value; + size_t len; + + /* Have to merge some headers. Let's re-use the order field, + * since it's handy... we'll store the length of val there. + */ + left->order = strlen(left->val); + len = left->order; + do { + right->order = strlen(right->val); + len += 2 + right->order; + ++right; + } while (right < last + && !strcasecmp(left->key, right->key)); + /* right points one past the last header to merge */ + value = ap_palloc(a->a.pool, len + 1); + strp = value; + for (;;) { + memcpy(strp, left->val, left->order); + strp += left->order; + ++left; + if (left == right) break; + *strp++ = ','; + *strp++ = ' '; + } + *strp = 0; + ap_table_addn(a, (left-1)->key, value); + } + } + } + else { + left = cat_keys; + last = left + nkeys; + while (left < last) { + right = left + 1; + while (right < last && !strcasecmp(left->key, right->key)) { + ++right; + } + ap_table_addn(a, (right-1)->key, (right-1)->val); + left = right; + } + } +} + /***************************************************************** * * Managing generic cleanups. 1.3 +20 -14 apache-2.0/apache-nspr/main/buff.c Index: buff.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/buff.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- buff.c 1998/06/30 08:57:06 1.2 +++ buff.c 1998/09/22 18:05:17 1.3 @@ -221,7 +221,7 @@ /* already chunking */ return; } - if (!(fb->flags & B_WR) || (fb->flags & (B_WRERR | B_EOUT))) { + if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR) { /* unbuffered writes */ return; } @@ -399,7 +399,7 @@ } i = read_with_errors(fb, buf, nbyte); #ifdef CHARSET_EBCDIC - if (i > 0 && bgetflag(fb, B_ASCII2EBCDIC)) + if (i > 0 && ap_bgetflag(fb, B_ASCII2EBCDIC)) ascii2ebcdic(buf, buf, i); #endif /*CHARSET_EBCDIC*/ return i; @@ -438,7 +438,7 @@ /* read directly into caller's buffer */ i = read_with_errors(fb, buf, nbyte); #ifdef CHARSET_EBCDIC - if (i > 0 && bgetflag(fb, B_ASCII2EBCDIC)) + if (i > 0 && ap_bgetflag(fb, B_ASCII2EBCDIC)) ascii2ebcdic(buf, buf, i); #endif /*CHARSET_EBCDIC*/ if (i == -1) { @@ -643,7 +643,8 @@ } /* - * Empty the buffer after putting a single character in it + * output a single character. Used by ap_bputs when the buffer + * is full... and so it'll cause the buffer to be flushed first. */ API_EXPORT(PRInt32) ap_bflsbuf(PRInt32 c, BUFF *fb) { @@ -794,8 +795,15 @@ #ifdef CHARSET_EBCDIC static char *cbuf = NULL; static int csize = 0; +#endif /*CHARSET_EBCDIC*/ + + if (fb->flags & (B_WRERR | B_EOUT)) + return -1; + if (nbyte == 0) + return 0; - if (bgetflag(fb, B_EBCDIC2ASCII)) { +#ifdef CHARSET_EBCDIC + if (ap_bgetflag(fb, B_EBCDIC2ASCII)) { if (nbyte > csize) { if (cbuf != NULL) free(cbuf); @@ -808,11 +816,6 @@ } #endif /*CHARSET_EBCDIC*/ - if (fb->flags & (B_WRERR | B_EOUT)) - return -1; - if (nbyte == 0) - return 0; - if (!(fb->flags & B_WR)) { /* unbuffered write -- have to use bcwrite since we aren't taking care * of chunking any other way */ @@ -961,10 +964,7 @@ { PRInt32 ret; - if (!(fb->flags & B_WR) || (fb->flags & B_EOUT)) - return 0; - - if (fb->flags & B_WRERR) + if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR) return -1; if (fb->flags & B_CHUNK) @@ -1095,6 +1095,9 @@ PRInt32 res; struct bprintf_data b; + /* XXX: only works with buffered writes */ + if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR) + return -1; b.vbuff.curpos = (char *)&fb->outbase[fb->outcnt]; b.vbuff.endpos = (char *)&fb->outbase[fb->bufsiz]; b.fb = fb; @@ -1119,6 +1122,9 @@ struct bprintf_data b; PRInt32 res; + /* XXX: only works with buffered writes */ + if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR) + return -1; b.vbuff.curpos = (char *)&fb->outbase[fb->outcnt]; b.vbuff.endpos = (char *)&fb->outbase[fb->bufsiz]; b.fb = fb; 1.3 +27 -8 apache-2.0/apache-nspr/main/http_config.c Index: http_config.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/http_config.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- http_config.c 1998/06/30 08:57:07 1.2 +++ http_config.c 1998/09/22 18:05:17 1.3 @@ -483,6 +483,7 @@ const char *handler; char *p; size_t handler_len; + int result = NOT_IMPLEMENTED; if (r->handler) { handler = r->handler; @@ -505,19 +506,24 @@ for (handp = handlers; handp->hr.content_type; ++handp) { if (handler_len == handp->len && !strncmp(handler, handp->hr.content_type, handler_len)) { - int result = (*handp->hr.handler) (r); + result = (*handp->hr.handler) (r); if (result != DECLINED) return result; } } + if (result == NOT_IMPLEMENTED && r->handler) { + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, r, + "handler \"%s\" not found for: %s", r->handler, r->filename); + } + /* Pass two --- wildcard matches */ for (handp = wildhandlers; handp->hr.content_type; ++handp) { if (handler_len >= handp->len && !strncmp(handler, handp->hr.content_type, handp->len)) { - int result = (*handp->hr.handler) (r); + result = (*handp->hr.handler) (r); if (result != DECLINED) return result; @@ -541,7 +547,7 @@ * though, we don't. */ - if (m->version != MODULE_MAGIC_NUMBER) { + if (m->version != MODULE_MAGIC_NUMBER_MAJOR) { PR_fprintf(PR_STDERR, "httpd: module \"%s\" is not compatible with this " "version of Apache.\n", m->name); PR_fprintf(PR_STDERR, "Please contact the author for the correct version.\n"); @@ -601,6 +607,7 @@ if (modp == m) { /* We are the top module, special case */ top_module = modp->next; + m->next = NULL; } else { /* Not the top module, find use. When found modp will @@ -1239,8 +1246,8 @@ ap_cfg_closefile(f); if (errmsg) { - ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, r->server, "%s: %s", - filename, errmsg); + ap_log_rerror(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, r, "%s: %s", + filename, errmsg); return HTTP_INTERNAL_SERVER_ERROR; } @@ -1254,9 +1261,13 @@ dc = NULL; break; default: - ap_log_error(APLOG_MARK, APLOG_CRIT, r->server, - "%s pcfg_openfile: unable to check htaccess file, ensure it is readable", - filename); + ap_log_rerror(APLOG_MARK, APLOG_CRIT, r, + "%s pcfg_openfile: unable to check htaccess file, " + "ensure it is readable", + filename); + ap_table_setn(r->notes, "error-notes", + "Server unable to read htaccess file, denying " + "access to be safe"); return HTTP_FORBIDDEN; } } @@ -1317,6 +1328,10 @@ s->server_uid = ap_user_id; s->server_gid = ap_group_id; + s->limit_req_line = main_server->limit_req_line; + s->limit_req_fieldsize = main_server->limit_req_fieldsize; + s->limit_req_fields = main_server->limit_req_fields; + *ps = s; return ap_parse_vhost_addrs(p, hostname, s); @@ -1389,6 +1404,7 @@ PR_InitializeNetAddr(PR_IpAddrAny, 0, &ap_bind_address); ap_listeners = NULL; ap_listenbacklog = DEFAULT_LISTENBACKLOG; + ap_extended_status = 0; /* Global virtual host hash bucket pointers. Init to null. */ ap_init_vhost_config(p); @@ -1408,6 +1424,9 @@ s->loglevel = DEFAULT_LOGLEVEL; s->srm_confname = RESOURCE_CONFIG_FILE; s->access_confname = ACCESS_CONFIG_FILE; + s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE; + s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE; + s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS; s->timeout_interval = PR_SecondsToInterval(DEFAULT_TIMEOUT); s->keep_alive_timeout_interval = PR_SecondsToInterval(DEFAULT_KEEPALIVE_TIMEOUT); s->keep_alive_max = DEFAULT_KEEPALIVE; 1.3 +1169 -612 apache-2.0/apache-nspr/main/http_core.c Index: http_core.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/http_core.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- http_core.c 1998/06/30 08:57:07 1.2 +++ http_core.c 1998/09/22 18:05:17 1.3 @@ -86,16 +86,22 @@ * the http_conf_globals. */ -static void *create_core_dir_config (pool *a, char *dir) +static void *create_core_dir_config(pool *a, char *dir) { - core_dir_config *conf = - (core_dir_config *)ap_pcalloc(a, sizeof(core_dir_config)); - - if (!dir || dir[strlen(dir) - 1] == '/') conf->d = dir; - else if (strncmp(dir,"proxy:",6)==0) conf->d = ap_pstrdup (a, dir); - else conf->d = ap_pstrcat (a, dir, "/", NULL); - conf->d_is_fnmatch = conf->d ? (ap_is_fnmatch (conf->d) != 0) : 0; - conf->d_components = conf->d ? ap_count_dirs (conf->d) : 0; + core_dir_config *conf; + + conf = (core_dir_config *)ap_pcalloc(a, sizeof(core_dir_config)); + if (!dir || dir[strlen(dir) - 1] == '/') { + conf->d = dir; + } + else if (strncmp(dir, "proxy:", 6) == 0) { + conf->d = ap_pstrdup(a, dir); + } + else { + conf->d = ap_pstrcat(a, dir, "/", NULL); + } + conf->d_is_fnmatch = conf->d ? (ap_is_fnmatch(conf->d) != 0) : 0; + conf->d_components = conf->d ? ap_count_dirs(conf->d) : 0; conf->opts = dir ? OPT_UNSET : OPT_UNSET|OPT_ALL; conf->opts_add = conf->opts_remove = OPT_NONE; @@ -106,7 +112,7 @@ conf->use_canonical_name = 1 | 2; /* 2 = unset, default on */ conf->hostname_lookups = HOSTNAME_LOOKUP_UNSET; - conf->do_rfc1413 = DEFAULT_RFC1413 | 2; /* set bit 1 to indicate default */ + conf->do_rfc1413 = DEFAULT_RFC1413 | 2; /* set bit 1 to indicate default */ conf->satisfy = SATISFY_NOSPEC; #ifdef RLIMIT_CPU @@ -119,25 +125,27 @@ conf->limit_nproc = NULL; #endif - conf->sec = ap_make_array (a, 2, sizeof(void *)); + conf->limit_req_body = 0; + conf->sec = ap_make_array(a, 2, sizeof(void *)); return (void *)conf; } -static void *merge_core_dir_configs (pool *a, void *basev, void *newv) +static void *merge_core_dir_configs(pool *a, void *basev, void *newv) { core_dir_config *base = (core_dir_config *)basev; core_dir_config *new = (core_dir_config *)newv; - core_dir_config *conf = - (core_dir_config *)ap_palloc (a, sizeof(core_dir_config)); + core_dir_config *conf; int i; - memcpy ((char *)conf, (const char *)base, sizeof(core_dir_config)); - if( base->response_code_strings ) { - conf->response_code_strings = ap_palloc(a, - sizeof(*conf->response_code_strings) * RESPONSE_CODES ); - memcpy( conf->response_code_strings, base->response_code_strings, - sizeof(*conf->response_code_strings) * RESPONSE_CODES ); + conf = (core_dir_config *)ap_palloc(a, sizeof(core_dir_config)); + memcpy((char *)conf, (const char *)base, sizeof(core_dir_config)); + if (base->response_code_strings) { + conf->response_code_strings = + ap_palloc(a, sizeof(*conf->response_code_strings) + * RESPONSE_CODES); + memcpy(conf->response_code_strings, base->response_code_strings, + sizeof(*conf->response_code_strings) * RESPONSE_CODES); } conf->d = new->d; @@ -150,10 +158,12 @@ * preserve the invariant (opts_add & opts_remove) == 0 */ conf->opts_add = (conf->opts_add & ~new->opts_remove) | new->opts_add; - conf->opts_remove = (conf->opts_remove & ~new->opts_add) | new->opts_remove; + conf->opts_remove = (conf->opts_remove & ~new->opts_add) + | new->opts_remove; conf->opts = (conf->opts & ~conf->opts_remove) | conf->opts_add; - if ((base->opts & OPT_INCNOEXEC) && (new->opts & OPT_INCLUDES)) - conf->opts = (conf->opts & ~OPT_INCNOEXEC) | OPT_INCLUDES; + if ((base->opts & OPT_INCNOEXEC) && (new->opts & OPT_INCLUDES)) { + conf->opts = (conf->opts & ~OPT_INCNOEXEC) | OPT_INCLUDES; + } } else { /* otherwise we just copy, because an explicit opts setting @@ -164,75 +174,112 @@ conf->opts_remove = new->opts_remove; } - if (!(new->override & OR_UNSET)) conf->override = new->override; - if (new->ap_default_type) conf->ap_default_type = new->ap_default_type; + if (!(new->override & OR_UNSET)) { + conf->override = new->override; + } + if (new->ap_default_type) { + conf->ap_default_type = new->ap_default_type; + } - if (new->ap_auth_type) conf->ap_auth_type = new->ap_auth_type; - if (new->ap_auth_name) conf->ap_auth_name = new->ap_auth_name; - if (new->ap_requires) conf->ap_requires = new->ap_requires; + if (new->ap_auth_type) { + conf->ap_auth_type = new->ap_auth_type; + } + if (new->ap_auth_name) { + conf->ap_auth_name = new->ap_auth_name; + } + if (new->ap_requires) { + conf->ap_requires = new->ap_requires; + } - if( new->response_code_strings ) { - if( conf->response_code_strings == NULL ) { + if (new->response_code_strings) { + if (conf->response_code_strings == NULL) { conf->response_code_strings = ap_palloc(a, - sizeof(*conf->response_code_strings) * RESPONSE_CODES ); - memcpy( conf->response_code_strings, new->response_code_strings, - sizeof(*conf->response_code_strings) * RESPONSE_CODES ); - } else { - for (i = 0; i < RESPONSE_CODES; ++i) - if (new->response_code_strings[i] != NULL) - conf->response_code_strings[i] = new->response_code_strings[i]; + sizeof(*conf->response_code_strings) * RESPONSE_CODES); + memcpy(conf->response_code_strings, new->response_code_strings, + sizeof(*conf->response_code_strings) * RESPONSE_CODES); } + else { + for (i = 0; i < RESPONSE_CODES; ++i) { + if (new->response_code_strings[i] != NULL) { + conf->response_code_strings[i] + = new->response_code_strings[i]; + } + } + } } - if (new->hostname_lookups != HOSTNAME_LOOKUP_UNSET) + if (new->hostname_lookups != HOSTNAME_LOOKUP_UNSET) { conf->hostname_lookups = new->hostname_lookups; - if ((new->do_rfc1413 & 2) == 0) conf->do_rfc1413 = new->do_rfc1413; - if ((new->content_md5 & 2) == 0) conf->content_md5 = new->content_md5; + } + if ((new->do_rfc1413 & 2) == 0) { + conf->do_rfc1413 = new->do_rfc1413; + } + if ((new->content_md5 & 2) == 0) { + conf->content_md5 = new->content_md5; + } if ((new->use_canonical_name & 2) == 0) { conf->use_canonical_name = new->use_canonical_name; } #ifdef RLIMIT_CPU - if (new->limit_cpu) conf->limit_cpu = new->limit_cpu; + if (new->limit_cpu) { + conf->limit_cpu = new->limit_cpu; + } #endif #if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) - if (new->limit_mem) conf->limit_mem = new->limit_mem; + if (new->limit_mem) { + conf->limit_mem = new->limit_mem; + } #endif #ifdef RLIMIT_NPROC - if (new->limit_nproc) conf->limit_nproc = new->limit_nproc; + if (new->limit_nproc) { + conf->limit_nproc = new->limit_nproc; + } #endif - conf->sec = ap_append_arrays (a, base->sec, new->sec); + if (new->limit_req_body) { + conf->limit_req_body = new->limit_req_body; + } + conf->sec = ap_append_arrays(a, base->sec, new->sec); - if (new->satisfy != SATISFY_NOSPEC) conf->satisfy = new->satisfy; + if (new->satisfy != SATISFY_NOSPEC) { + conf->satisfy = new->satisfy; + } return (void*)conf; } -static void *create_core_server_config (pool *a, server_rec *s) +static void *create_core_server_config(pool *a, server_rec *s) { - core_server_config *conf = - (core_server_config *)ap_pcalloc(a, sizeof(core_server_config)); + core_server_config *conf; int is_virtual = s->is_virtual; + conf = (core_server_config *)ap_pcalloc(a, sizeof(core_server_config)); +#ifdef GPROF + conf->gprof_dir = NULL; +#endif conf->access_name = is_virtual ? NULL : DEFAULT_ACCESS_FNAME; conf->ap_document_root = is_virtual ? NULL : DOCUMENT_LOCATION; - conf->sec = ap_make_array (a, 40, sizeof(void *)); - conf->sec_url = ap_make_array (a, 40, sizeof(void *)); + conf->sec = ap_make_array(a, 40, sizeof(void *)); + conf->sec_url = ap_make_array(a, 40, sizeof(void *)); return (void *)conf; } -static void *merge_core_server_configs (pool *p, void *basev, void *virtv) +static void *merge_core_server_configs(pool *p, void *basev, void *virtv) { core_server_config *base = (core_server_config *)basev; core_server_config *virt = (core_server_config *)virtv; - core_server_config *conf = - (core_server_config *)ap_pcalloc(p, sizeof(core_server_config)); + core_server_config *conf; + conf = (core_server_config *)ap_pcalloc(p, sizeof(core_server_config)); *conf = *virt; - if (!conf->access_name) conf->access_name = base->access_name; - if (!conf->ap_document_root) conf->ap_document_root = base->ap_document_root; - conf->sec = ap_append_arrays (p, base->sec, virt->sec); - conf->sec_url = ap_append_arrays (p, base->sec_url, virt->sec_url); + if (!conf->access_name) { + conf->access_name = base->access_name; + } + if (!conf->ap_document_root) { + conf->ap_document_root = base->ap_document_root; + } + conf->sec = ap_append_arrays(p, base->sec, virt->sec); + conf->sec_url = ap_append_arrays(p, base->sec_url, virt->sec_url); return conf; } @@ -241,27 +288,27 @@ * these are part of the core server config. */ -CORE_EXPORT(void) ap_add_per_dir_conf (server_rec *s, void *dir_config) +CORE_EXPORT(void) ap_add_per_dir_conf(server_rec *s, void *dir_config) { - core_server_config *sconf = ap_get_module_config (s->module_config, - &core_module); - void **new_space = (void **) ap_push_array (sconf->sec); + core_server_config *sconf = ap_get_module_config(s->module_config, + &core_module); + void **new_space = (void **)ap_push_array(sconf->sec); *new_space = dir_config; } -CORE_EXPORT(void) ap_add_per_url_conf (server_rec *s, void *url_config) +CORE_EXPORT(void) ap_add_per_url_conf(server_rec *s, void *url_config) { - core_server_config *sconf = ap_get_module_config (s->module_config, - &core_module); - void **new_space = (void **) ap_push_array (sconf->sec_url); + core_server_config *sconf = ap_get_module_config(s->module_config, + &core_module); + void **new_space = (void **)ap_push_array(sconf->sec_url); *new_space = url_config; } -static void add_file_conf (core_dir_config *conf, void *url_config) +static void add_file_conf(core_dir_config *conf, void *url_config) { - void **new_space = (void **) ap_push_array (conf->sec); + void **new_space = (void **)ap_push_array(conf->sec); *new_space = url_config; } @@ -274,7 +321,7 @@ * See directory_walk(). */ -#if defined(__EMX__) || defined(WIN32) +#if defined(OS2) || defined(WIN32) #define IS_SPECIAL(entry_core) \ ((entry_core)->r != NULL \ || ((entry_core)->d[0] != '/' && (entry_core)->d[1] != ':')) @@ -293,26 +340,29 @@ int orig_index; }; -static int reorder_sorter (const void *va, const void *vb) +static int reorder_sorter(const void *va, const void *vb) { const struct reorder_sort_rec *a = va; const struct reorder_sort_rec *b = vb; core_dir_config *core_a; core_dir_config *core_b; - core_a = (core_dir_config *)ap_get_module_config (a->elt, &core_module); - core_b = (core_dir_config *)ap_get_module_config (b->elt, &core_module); + core_a = (core_dir_config *)ap_get_module_config(a->elt, &core_module); + core_b = (core_dir_config *)ap_get_module_config(b->elt, &core_module); if (IS_SPECIAL(core_a)) { if (!IS_SPECIAL(core_b)) { return 1; } - } else if (IS_SPECIAL(core_b)) { + } + else if (IS_SPECIAL(core_b)) { return -1; - } else { + } + else { /* we know they're both not special */ if (core_a->d_components < core_b->d_components) { return -1; - } else if (core_a->d_components > core_b->d_components) { + } + else if (core_a->d_components > core_b->d_components) { return 1; } } @@ -322,7 +372,7 @@ return a->orig_index - b->orig_index; } -void ap_core_reorder_directories (pool *p, server_rec *s) +void ap_core_reorder_directories(pool *p, server_rec *s) { core_server_config *sconf; array_header *sec; @@ -335,24 +385,24 @@ * and we need some scratch space to do it. The old array and the * scratch space are never freed. */ - sconf = ap_get_module_config (s->module_config, &core_module); + sconf = ap_get_module_config(s->module_config, &core_module); sec = sconf->sec; nelts = sec->nelts; elts = (void **)sec->elts; /* build our sorting space */ - sortbin = ap_palloc (p, sec->nelts * sizeof (*sortbin)); + sortbin = ap_palloc(p, sec->nelts * sizeof(*sortbin)); for (i = 0; i < nelts; ++i) { sortbin[i].orig_index = i; sortbin[i].elt = elts[i]; } - qsort (sortbin, nelts, sizeof (*sortbin), reorder_sorter); + qsort(sortbin, nelts, sizeof(*sortbin), reorder_sorter); /* and now build a new array */ - sec = ap_make_array (p, nelts, sizeof (void *)); + sec = ap_make_array(p, nelts, sizeof(void *)); for (i = 0; i < nelts; ++i) { - *(void **)ap_push_array (sec) = sortbin[i].elt; + *(void **)ap_push_array(sec) = sortbin[i].elt; } sconf->sec = sec; @@ -366,7 +416,7 @@ * here... */ -API_EXPORT(int) ap_allow_options (request_rec *r) +API_EXPORT(int) ap_allow_options(request_rec *r) { core_dir_config *conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); @@ -374,60 +424,69 @@ return conf->opts; } -API_EXPORT(int) ap_allow_overrides (request_rec *r) +API_EXPORT(int) ap_allow_overrides(request_rec *r) { - core_dir_config *conf = - (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); + core_dir_config *conf; + conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); return conf->override; } -API_EXPORT(char *) ap_auth_type (request_rec *r) +API_EXPORT(const char *) ap_auth_type(request_rec *r) { - core_dir_config *conf = - (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); + core_dir_config *conf; + conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); return conf->ap_auth_type; } -API_EXPORT(char *) ap_auth_name (request_rec *r) +API_EXPORT(const char *) ap_auth_name(request_rec *r) { - core_dir_config *conf = - (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); + core_dir_config *conf; + conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); return conf->ap_auth_name; } -API_EXPORT(char *) ap_default_type (request_rec *r) +API_EXPORT(const char *) ap_default_type(request_rec *r) { - core_dir_config *conf = - (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); + core_dir_config *conf; - return conf->ap_default_type ? conf->ap_default_type : DEFAULT_CONTENT_TYPE; + conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); + return conf->ap_default_type + ? conf->ap_default_type + : DEFAULT_CONTENT_TYPE; } -API_EXPORT(char *) ap_document_root (request_rec *r) /* Don't use this!!! */ +API_EXPORT(const char *) ap_document_root(request_rec *r) /* Don't use this! */ { - core_server_config *conf = - (core_server_config *)ap_get_module_config(r->server->module_config, - &core_module); + core_server_config *conf; + conf = (core_server_config *)ap_get_module_config(r->server->module_config, + &core_module); return conf->ap_document_root; } -API_EXPORT(array_header *) ap_requires (request_rec *r) +API_EXPORT(const array_header *) ap_requires(request_rec *r) { - core_dir_config *conf = - (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); + core_dir_config *conf; + conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); return conf->ap_requires; } -API_EXPORT(int) ap_satisfies (request_rec *r) +API_EXPORT(int) ap_satisfies(request_rec *r) { - core_dir_config *conf = - (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); + core_dir_config *conf; + conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); + return conf->satisfy; } @@ -436,12 +495,14 @@ * modules). */ -char *ap_response_code_string (request_rec *r, int error_index) +char *ap_response_code_string(request_rec *r, int error_index) { - core_dir_config *conf = - (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); + core_dir_config *conf; + + conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); - if( conf->response_code_strings == NULL ) { + if (conf->response_code_strings == NULL) { return NULL; } return conf->response_code_strings[error_index]; @@ -483,14 +544,13 @@ conn->double_reverse = -1; } -API_EXPORT(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type) +API_EXPORT(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, + int type) { char hentbuf[PR_NETDB_BUF_SIZE]; PRHostEnt hent; int hostname_lookups; -#ifdef STATUS int old_stat = SERVER_DEAD; /* we shouldn't ever be in this state */ -#endif /* If we haven't checked the host name, and we want to */ if (dir_config) { @@ -500,7 +560,8 @@ if (hostname_lookups == HOSTNAME_LOOKUP_UNSET) { hostname_lookups = HOSTNAME_LOOKUP_OFF; } - } else { + } + else { /* the default */ hostname_lookups = HOSTNAME_LOOKUP_OFF; } @@ -509,7 +570,6 @@ && conn->remote_host == NULL && (type == REMOTE_DOUBLE_REV || hostname_lookups != HOSTNAME_LOOKUP_OFF)) { -#ifdef STATUS old_stat = ap_update_child_status(conn->child_num, SERVER_BUSY_DNS, (request_rec*)NULL); #endif /* STATUS */ @@ -526,7 +586,9 @@ } } /* if failed, set it to the NULL string to indicate error */ - if (conn->remote_host == NULL) conn->remote_host = ""; + if (conn->remote_host == NULL) { + conn->remote_host = ""; + } } if (type == REMOTE_DOUBLE_REV) { do_double_reverse (conn, hentbuf, &hent); @@ -534,41 +596,47 @@ return NULL; } } -#ifdef STATUS if (old_stat != SERVER_DEAD) { - (void)ap_update_child_status(conn->child_num,old_stat,(request_rec*)NULL); + (void)ap_update_child_status(conn->child_num, old_stat, + (request_rec*)NULL); } -#endif /* STATUS */ /* * Return the desired information; either the remote DNS name, if found, * or either NULL (if the hostname was requested) or the IP address * (if any identifier was requested). */ - if (conn->remote_host != NULL && conn->remote_host[0] != '\0') + if (conn->remote_host != NULL && conn->remote_host[0] != '\0') { return conn->remote_host; - else - { - if (type == REMOTE_HOST || type == REMOTE_DOUBLE_REV) return NULL; - else return conn->remote_ip; } + else { + if (type == REMOTE_HOST || type == REMOTE_DOUBLE_REV) { + return NULL; + } + else { + return conn->remote_ip; + } + } } API_EXPORT(const char *) ap_get_remote_logname(request_rec *r) { core_dir_config *dir_conf; - if (r->connection->remote_logname != NULL) + if (r->connection->remote_logname != NULL) { return r->connection->remote_logname; + } /* If we haven't checked the identity, and we want to */ - dir_conf = (core_dir_config *) - ap_get_module_config(r->per_dir_config, &core_module); + dir_conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); - if (dir_conf->do_rfc1413 & 1) + if (dir_conf->do_rfc1413 & 1) { return ap_rfc1413(r->connection, r->server); - else + } + else { return NULL; + } } /* There are two options regarding what the "name" of a server is. The @@ -579,9 +647,10 @@ */ API_EXPORT(const char *) ap_get_server_name(const request_rec *r) { - core_dir_config *d = - (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); - + core_dir_config *d; + + d = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); if (d->use_canonical_name & 1) { return r->server->server_hostname; } @@ -604,7 +673,8 @@ : port; } -API_EXPORT(char *) ap_construct_url(pool *p, const char *uri, const request_rec *r) +API_EXPORT(char *) ap_construct_url(pool *p, const char *uri, + const request_rec *r) { unsigned port; const char *host; @@ -619,10 +689,12 @@ if (r->hostname) /* XXX: ipv6 */ port = PR_ntohs(r->connection->local_addr.inet.port); - else if (r->server->port) + else if (r->server->port) { port = r->server->port; - else + } + else { port = ap_default_port(r); + } host = r->hostname ? r->hostname : r->server->server_hostname; } @@ -632,6 +704,14 @@ return ap_psprintf(p, "%s://%s:%u%s", ap_http_method(r), host, port, uri); } +API_EXPORT(unsigned long) ap_get_limit_req_body(const request_rec *r) +{ + core_dir_config *d = + (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); + + return d->limit_req_body; +} + /***************************************************************** * * Commands... this module handles almost all of the NCSA httpd.conf @@ -649,61 +729,95 @@ static const char end_ifdefine_section[] = "</IfDefine>"; -API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden) +API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, + unsigned forbidden) { const char *gt = (cmd->cmd->name[0] == '<' - && cmd->cmd->name[strlen(cmd->cmd->name)-1] != '>') ? ">" : ""; + && cmd->cmd->name[strlen(cmd->cmd->name)-1] != '>') + ? ">" : ""; - if ((forbidden & NOT_IN_VIRTUALHOST) && cmd->server->is_virtual) + if ((forbidden & NOT_IN_VIRTUALHOST) && cmd->server->is_virtual) { return ap_pstrcat(cmd->pool, cmd->cmd->name, gt, - " cannot occur within <VirtualHost> section", NULL); + " cannot occur within <VirtualHost> section", NULL); + } - if ((forbidden & NOT_IN_LIMIT) && cmd->limited != -1) + if ((forbidden & NOT_IN_LIMIT) && cmd->limited != -1) { return ap_pstrcat(cmd->pool, cmd->cmd->name, gt, - " cannot occur within <Limit> section", NULL); + " cannot occur within <Limit> section", NULL); + } - if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE && cmd->path != NULL) + if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE + && cmd->path != NULL) { return ap_pstrcat(cmd->pool, cmd->cmd->name, gt, - " cannot occur within <Directory/Location/Files> section", NULL); + " cannot occur within <Directory/Location/Files> " + "section", NULL); + } - if (((forbidden & NOT_IN_DIRECTORY) && (cmd->end_token == end_directory_section - || cmd->end_token == end_directorymatch_section)) || - ((forbidden & NOT_IN_LOCATION) && (cmd->end_token == end_location_section - || cmd->end_token == end_locationmatch_section)) || - ((forbidden & NOT_IN_FILES) && (cmd->end_token == end_files_section - || cmd->end_token == end_filesmatch_section))) - + if (((forbidden & NOT_IN_DIRECTORY) + && (cmd->end_token == end_directory_section + || cmd->end_token == end_directorymatch_section)) + || ((forbidden & NOT_IN_LOCATION) + && (cmd->end_token == end_location_section + || cmd->end_token == end_locationmatch_section)) + || ((forbidden & NOT_IN_FILES) + && (cmd->end_token == end_files_section + || cmd->end_token == end_filesmatch_section))) { return ap_pstrcat(cmd->pool, cmd->cmd->name, gt, - " cannot occur within <", cmd->end_token+2, - " section", NULL); + " cannot occur within <", cmd->end_token+2, + " section", NULL); + } return NULL; } -static const char *set_access_name (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_access_name(cmd_parms *cmd, void *dummy, char *arg) { void *sconf = cmd->server->module_config; - core_server_config *conf = ap_get_module_config (sconf, &core_module); + core_server_config *conf = ap_get_module_config(sconf, &core_module); - const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + if (err != NULL) { + return err; + } conf->access_name = ap_pstrdup(cmd->pool, arg); return NULL; } -static const char *set_document_root (cmd_parms *cmd, void *dummy, char *arg) +#ifdef GPROF +static const char *set_gprof_dir(cmd_parms *cmd, void *dummy, char *arg) { void *sconf = cmd->server->module_config; - core_server_config *conf = ap_get_module_config (sconf, &core_module); + core_server_config *conf = ap_get_module_config(sconf, &core_module); + + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + if (err != NULL) { + return err; + } + + conf->gprof_dir = ap_pstrdup(cmd->pool, arg); + return NULL; +} +#endif /*GPROF*/ + +static const char *set_document_root(cmd_parms *cmd, void *dummy, char *arg) +{ + void *sconf = cmd->server->module_config; + core_server_config *conf = ap_get_module_config(sconf, &core_module); - const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + if (err != NULL) { + return err; + } arg = ap_os_canonical_filename(cmd->pool, arg); - if (!ap_is_directory (arg)) { + if (!ap_is_directory(arg)) { if (cmd->server->is_virtual) { - PR_fprintf (PR_STDERR, "Warning: DocumentRoot [%s] does not exist\n", arg); + PR_fprintf (PR_STDERR, "Warning: DocumentRoot [%s] does not exist\n", + arg); } else { return "DocumentRoot must be a directory"; @@ -714,36 +828,62 @@ return NULL; } -static const char *set_error_document (cmd_parms *cmd, core_dir_config *conf, - char *line) +API_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string) { + core_dir_config *conf = + ap_get_module_config(r->per_dir_config, &core_module); + int idx; + + if(conf->response_code_strings == NULL) { + conf->response_code_strings = + ap_pcalloc(r->pool, + sizeof(*conf->response_code_strings) * + RESPONSE_CODES); + } + + idx = ap_index_of_response(status); + + conf->response_code_strings[idx] = + ((ap_is_url(string) || (*string == '/')) && (*string != '"')) ? + ap_pstrdup(r->pool, string) : ap_pstrcat(r->pool, "\"", string, NULL); +} + +static const char *set_error_document(cmd_parms *cmd, core_dir_config *conf, + char *line) +{ int error_number, index_number, idx500; char *w; const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } /* 1st parameter should be a 3 digit number, which we recognize; * convert it into an array index */ - w = ap_getword_conf_nc (cmd->pool, &line); + w = ap_getword_conf_nc(cmd->pool, &line); error_number = atoi(w); idx500 = ap_index_of_response(HTTP_INTERNAL_SERVER_ERROR); - if (error_number == HTTP_INTERNAL_SERVER_ERROR) + if (error_number == HTTP_INTERNAL_SERVER_ERROR) { index_number = idx500; - else if ((index_number = ap_index_of_response(error_number)) == idx500) - return ap_pstrcat(cmd->pool, "Unsupported HTTP response code ", w, NULL); + } + else if ((index_number = ap_index_of_response(error_number)) == idx500) { + return ap_pstrcat(cmd->pool, "Unsupported HTTP response code ", + w, NULL); + } /* Store it... */ - if( conf->response_code_strings == NULL ) { - conf->response_code_strings = ap_pcalloc(cmd->pool, - sizeof(*conf->response_code_strings) * RESPONSE_CODES ); + if (conf->response_code_strings == NULL) { + conf->response_code_strings = + ap_pcalloc(cmd->pool, + sizeof(*conf->response_code_strings) * RESPONSE_CODES); } - conf->response_code_strings[index_number] = ap_pstrdup (cmd->pool, line); + conf->response_code_strings[index_number] = ap_pstrdup(cmd->pool, line); return NULL; } @@ -757,7 +897,8 @@ * discards as harmless. Cheesy, but it works. */ -static const char *set_override (cmd_parms *cmd, core_dir_config *d, const char *l) +static const char *set_override(cmd_parms *cmd, core_dir_config *d, + const char *l) { char *w; @@ -767,69 +908,90 @@ } d->override = OR_NONE; - while(l[0]) { - w = ap_getword_conf (cmd->pool, &l); - if(!strcasecmp(w,"Limit")) + while (l[0]) { + w = ap_getword_conf(cmd->pool, &l); + if (!strcasecmp(w, "Limit")) { d->override |= OR_LIMIT; - else if(!strcasecmp(w,"Options")) + } + else if (!strcasecmp(w, "Options")) { d->override |= OR_OPTIONS; - else if(!strcasecmp(w,"FileInfo")) + } + else if (!strcasecmp(w, "FileInfo")) { d->override |= OR_FILEINFO; - else if(!strcasecmp(w,"AuthConfig")) + } + else if (!strcasecmp(w, "AuthConfig")) { d->override |= OR_AUTHCFG; - else if(!strcasecmp(w,"Indexes")) + } + else if (!strcasecmp(w, "Indexes")) { d->override |= OR_INDEXES; - else if(!strcasecmp(w,"None")) + } + else if (!strcasecmp(w, "None")) { d->override = OR_NONE; - else if(!strcasecmp(w,"All")) + } + else if (!strcasecmp(w, "All")) { d->override = OR_ALL; - else - return ap_pstrcat (cmd->pool, "Illegal override option ", w, NULL); + } + else { + return ap_pstrcat(cmd->pool, "Illegal override option ", w, NULL); + } d->override &= ~OR_UNSET; } return NULL; } -static const char *set_options (cmd_parms *cmd, core_dir_config *d, const char *l) +static const char *set_options(cmd_parms *cmd, core_dir_config *d, + const char *l) { allow_options_t opt; int first = 1; char action; - while(l[0]) { + while (l[0]) { char *w = ap_getword_conf(cmd->pool, &l); action = '\0'; - if (*w == '+' || *w == '-') + if (*w == '+' || *w == '-') { action = *(w++); + } else if (first) { d->opts = OPT_NONE; first = 0; } - if(!strcasecmp(w,"Indexes")) + if (!strcasecmp(w, "Indexes")) { opt = OPT_INDEXES; - else if(!strcasecmp(w,"Includes")) + } + else if (!strcasecmp(w, "Includes")) { opt = OPT_INCLUDES; - else if(!strcasecmp(w,"IncludesNOEXEC")) + } + else if (!strcasecmp(w, "IncludesNOEXEC")) { opt = (OPT_INCLUDES | OPT_INCNOEXEC); - else if(!strcasecmp(w,"FollowSymLinks")) + } + else if (!strcasecmp(w, "FollowSymLinks")) { opt = OPT_SYM_LINKS; - else if(!strcasecmp(w,"SymLinksIfOwnerMatch")) + } + else if (!strcasecmp(w, "SymLinksIfOwnerMatch")) { opt = OPT_SYM_OWNER; - else if(!strcasecmp(w,"execCGI")) + } + else if (!strcasecmp(w, "execCGI")) { opt = OPT_EXECCGI; - else if (!strcasecmp(w,"MultiViews")) + } + else if (!strcasecmp(w, "MultiViews")) { opt = OPT_MULTI; - else if (!strcasecmp(w,"RunScripts")) /* AI backcompat. Yuck */ + } + else if (!strcasecmp(w, "RunScripts")) { /* AI backcompat. Yuck */ opt = OPT_MULTI|OPT_EXECCGI; - else if(!strcasecmp(w,"None")) + } + else if (!strcasecmp(w, "None")) { opt = OPT_NONE; - else if(!strcasecmp(w,"All")) + } + else if (!strcasecmp(w, "All")) { opt = OPT_ALL; - else - return ap_pstrcat (cmd->pool, "Illegal option ", w, NULL); + } + else { + return ap_pstrcat(cmd->pool, "Illegal option ", w, NULL); + } /* we ensure the invariant (d->opts_add & d->opts_remove) == 0 */ if (action == '-') { @@ -850,61 +1012,84 @@ return NULL; } -static const char *satisfy (cmd_parms *cmd, core_dir_config *c, char *arg) +static const char *satisfy(cmd_parms *cmd, core_dir_config *c, char *arg) { - if(!strcasecmp(arg,"all")) + if (!strcasecmp(arg, "all")) { c->satisfy = SATISFY_ALL; - else if(!strcasecmp(arg,"any")) + } + else if (!strcasecmp(arg, "any")) { c->satisfy = SATISFY_ANY; - else + } + else { return "Satisfy either 'any' or 'all'."; + } return NULL; } -static const char *require (cmd_parms *cmd, core_dir_config *c, char *arg) +static const char *require(cmd_parms *cmd, core_dir_config *c, char *arg) { require_line *r; - if (!c->ap_requires) - c->ap_requires = ap_make_array (cmd->pool, 2, sizeof(require_line)); - - r = (require_line *)ap_push_array (c->ap_requires); - r->requirement = ap_pstrdup (cmd->pool, arg); + if (!c->ap_requires) { + c->ap_requires = ap_make_array(cmd->pool, 2, sizeof(require_line)); + } + r = (require_line *)ap_push_array(c->ap_requires); + r->requirement = ap_pstrdup(cmd->pool, arg); r->method_mask = cmd->limited; return NULL; } -CORE_EXPORT_NONSTD(const char *) ap_limit_section (cmd_parms *cmd, void *dummy, const char *arg) +CORE_EXPORT_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, + const char *arg) { - const char *limited_methods = ap_getword(cmd->pool,&arg,'>'); + const char *limited_methods = ap_getword(cmd->pool, &arg, '>'); int limited = 0; const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } /* XXX: NB: Currently, we have no way of checking * whether <Limit> sections are closed properly. * (If we would add a srm_command_loop() here we might...) */ - while(limited_methods[0]) { - char *method = ap_getword_conf (cmd->pool, &limited_methods); - if(!strcasecmp(method,"GET")) limited |= (1 << M_GET); - else if(!strcasecmp(method,"PUT")) limited |= (1 << M_PUT); - else if(!strcasecmp(method,"POST")) limited |= (1 << M_POST); - else if(!strcasecmp(method,"DELETE")) limited |= (1 << M_DELETE); - else if(!strcasecmp(method,"CONNECT")) limited |= (1 << M_CONNECT); - else if(!strcasecmp(method,"OPTIONS")) limited |= (1 << M_OPTIONS); - else return "unknown method in <Limit>"; + while (limited_methods[0]) { + char *method = ap_getword_conf(cmd->pool, &limited_methods); + if (!strcmp(method, "GET")) { + limited |= (1 << M_GET); + } + else if (!strcmp(method, "PUT")) { + limited |= (1 << M_PUT); + } + else if (!strcmp(method, "POST")) { + limited |= (1 << M_POST); + } + else if (!strcmp(method, "DELETE")) { + limited |= (1 << M_DELETE); + } + else if (!strcmp(method, "CONNECT")) { + limited |= (1 << M_CONNECT); + } + else if (!strcmp(method, "OPTIONS")) { + limited |= (1 << M_OPTIONS); + } + else { + return ap_pstrcat(cmd->pool, "unknown method \"", + method, "\" in <Limit>", NULL); + } } cmd->limited = limited; return NULL; } -static const char *endlimit_section (cmd_parms *cmd, void *dummy, void *dummy2) +static const char *endlimit_section(cmd_parms *cmd, void *dummy, void *dummy2) { - if (cmd->limited == -1) return "</Limit> unexpected"; + if (cmd->limited == -1) { + return "</Limit> unexpected"; + } cmd->limited = -1; return NULL; @@ -914,13 +1099,14 @@ * When a section is not closed properly when end-of-file is reached, * then an error message should be printed: */ -static const char *missing_endsection (cmd_parms *cmd, int nest) +static const char *missing_endsection(cmd_parms *cmd, int nest) { - if (nest < 2) + if (nest < 2) { return ap_psprintf(cmd->pool, "Missing %s directive at end-of-file", - cmd->end_token); + cmd->end_token); + } return ap_psprintf(cmd->pool, "%d missing %s directives at end-of-file", - nest, cmd->end_token); + nest, cmd->end_token); } /* We use this in <DirectoryMatch> and <FilesMatch>, to ensure that @@ -936,35 +1122,46 @@ static const char *end_nested_section(cmd_parms *cmd, void *dummy) { if (cmd->end_token == NULL) { - return ap_pstrcat(cmd->pool, cmd->cmd->name, - " without matching <", cmd->cmd->name + 2, " section", NULL); - } + return ap_pstrcat(cmd->pool, cmd->cmd->name, + " without matching <", cmd->cmd->name + 2, + " section", NULL); + } + /* + * This '!=' may look weird on a string comparison, but it's correct -- + * it's been set up so that checking for two pointers to the same datum + * is valid here. And faster. + */ if (cmd->cmd->name != cmd->end_token) { return ap_pstrcat(cmd->pool, "Expected ", cmd->end_token, " but saw ", - cmd->cmd->name, NULL); + cmd->cmd->name, NULL); } return cmd->end_token; } -static const char *dirsection (cmd_parms *cmd, void *dummy, const char *arg) +static const char *dirsection(cmd_parms *cmd, void *dummy, const char *arg) { const char *errmsg; - char *endp = strrchr (arg, '>'); + char *endp = strrchr(arg, '>'); int old_overrides = cmd->override; char *old_path = cmd->path; core_dir_config *conf; - void *new_dir_conf = ap_create_per_dir_config (cmd->pool); + void *new_dir_conf = ap_create_per_dir_config(cmd->pool); regex_t *r = NULL; const char *old_end_token; const command_rec *thiscmd = cmd->cmd; - const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + if (err != NULL) { + return err; + } - if (endp) *endp = '\0'; + if (endp) { + *endp = '\0'; + } - cmd->path = ap_getword_conf (cmd->pool, &arg); -#ifdef __EMX__ + cmd->path = ap_getword_conf(cmd->pool, &arg); +#ifdef OS2 /* Fix OS/2 HPFS filename case problem. */ cmd->path = strlwr(cmd->path); #endif @@ -974,7 +1171,7 @@ r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); } else if (!strcmp(cmd->path, "~")) { - cmd->path = ap_getword_conf (cmd->pool, &arg); + cmd->path = ap_getword_conf(cmd->pool, &arg); r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); } else { @@ -984,22 +1181,26 @@ old_end_token = cmd->end_token; cmd->end_token = thiscmd->cmd_data ? end_directorymatch_section : end_directory_section; - errmsg = ap_srm_command_loop (cmd, new_dir_conf); + errmsg = ap_srm_command_loop(cmd, new_dir_conf); if (errmsg == NULL) { errmsg = missing_endsection(cmd, 1); } cmd->end_token = old_end_token; - if (errmsg != (thiscmd->cmd_data ? end_directorymatch_section : end_directory_section)) + if (errmsg != (thiscmd->cmd_data + ? end_directorymatch_section + : end_directory_section)) { return errmsg; + } conf = (core_dir_config *)ap_get_module_config(new_dir_conf, &core_module); conf->r = r; - ap_add_per_dir_conf (cmd->server, new_dir_conf); + ap_add_per_dir_conf(cmd->server, new_dir_conf); - if (*arg != '\0') - return ap_pstrcat (cmd->pool, "Multiple ", thiscmd->name, - "> arguments not (yet) supported.", NULL); + if (*arg != '\0') { + return ap_pstrcat(cmd->pool, "Multiple ", thiscmd->name, + "> arguments not (yet) supported.", NULL); + } cmd->path = old_path; cmd->override = old_overrides; @@ -1007,10 +1208,10 @@ return NULL; } -static const char *urlsection (cmd_parms *cmd, void *dummy, const char *arg) +static const char *urlsection(cmd_parms *cmd, void *dummy, const char *arg) { const char *errmsg; - char *endp = strrchr (arg, '>'); + char *endp = strrchr(arg, '>'); int old_overrides = cmd->override; char *old_path = cmd->path; core_dir_config *conf; @@ -1018,44 +1219,54 @@ const char *old_end_token; const command_rec *thiscmd = cmd->cmd; - void *new_url_conf = ap_create_per_dir_config (cmd->pool); + void *new_url_conf = ap_create_per_dir_config(cmd->pool); - const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + if (err != NULL) { + return err; + } - if (endp) *endp = '\0'; + if (endp) { + *endp = '\0'; + } - cmd->path = ap_getword_conf (cmd->pool, &arg); + cmd->path = ap_getword_conf(cmd->pool, &arg); cmd->override = OR_ALL|ACCESS_CONF; if (thiscmd->cmd_data) { /* <LocationMatch> */ r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); } else if (!strcmp(cmd->path, "~")) { - cmd->path = ap_getword_conf (cmd->pool, &arg); + cmd->path = ap_getword_conf(cmd->pool, &arg); r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); } old_end_token = cmd->end_token; - cmd->end_token = thiscmd->cmd_data ? end_locationmatch_section : end_location_section; - errmsg = ap_srm_command_loop (cmd, new_url_conf); + cmd->end_token = thiscmd->cmd_data ? end_locationmatch_section + : end_location_section; + errmsg = ap_srm_command_loop(cmd, new_url_conf); if (errmsg == NULL) { errmsg = missing_endsection(cmd, 1); } cmd->end_token = old_end_token; - if (errmsg != (thiscmd->cmd_data ? end_locationmatch_section : end_location_section)) + if (errmsg != (thiscmd->cmd_data + ? end_locationmatch_section + : end_location_section)) { return errmsg; + } conf = (core_dir_config *)ap_get_module_config(new_url_conf, &core_module); conf->d = ap_pstrdup(cmd->pool, cmd->path); /* No mangling, please */ - conf->d_is_fnmatch = ap_is_fnmatch( conf->d ) != 0; + conf->d_is_fnmatch = ap_is_fnmatch(conf->d) != 0; conf->r = r; - ap_add_per_url_conf (cmd->server, new_url_conf); + ap_add_per_url_conf(cmd->server, new_url_conf); - if (*arg != '\0') - return ap_pstrcat (cmd->pool, "Multiple ", thiscmd->name, - "> arguments not (yet) supported.", NULL); + if (*arg != '\0') { + return ap_pstrcat(cmd->pool, "Multiple ", thiscmd->name, + "> arguments not (yet) supported.", NULL); + } cmd->path = old_path; cmd->override = old_overrides; @@ -1063,10 +1274,11 @@ return NULL; } -static const char *filesection (cmd_parms *cmd, core_dir_config *c, const char *arg) +static const char *filesection(cmd_parms *cmd, core_dir_config *c, + const char *arg) { const char *errmsg; - char *endp = strrchr (arg, '>'); + char *endp = strrchr(arg, '>'); int old_overrides = cmd->override; char *old_path = cmd->path; core_dir_config *conf; @@ -1074,23 +1286,28 @@ const char *old_end_token; const command_rec *thiscmd = cmd->cmd; - void *new_file_conf = ap_create_per_dir_config (cmd->pool); + void *new_file_conf = ap_create_per_dir_config(cmd->pool); - const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT | NOT_IN_LOCATION); - if (err != NULL) return err; + const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_LOCATION); + if (err != NULL) { + return err; + } - if (endp) *endp = '\0'; + if (endp) { + *endp = '\0'; + } - cmd->path = ap_getword_conf (cmd->pool, &arg); + cmd->path = ap_getword_conf(cmd->pool, &arg); /* Only if not an .htaccess file */ - if (!old_path) + if (!old_path) { cmd->override = OR_ALL|ACCESS_CONF; + } if (thiscmd->cmd_data) { /* <FilesMatch> */ r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); } else if (!strcmp(cmd->path, "~")) { - cmd->path = ap_getword_conf (cmd->pool, &arg); + cmd->path = ap_getword_conf(cmd->pool, &arg); r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); } else { @@ -1100,24 +1317,29 @@ old_end_token = cmd->end_token; cmd->end_token = thiscmd->cmd_data ? end_filesmatch_section : end_files_section; - errmsg = ap_srm_command_loop (cmd, new_file_conf); + errmsg = ap_srm_command_loop(cmd, new_file_conf); if (errmsg == NULL) { errmsg = missing_endsection(cmd, 1); } cmd->end_token = old_end_token; - if (errmsg != (thiscmd->cmd_data ? end_filesmatch_section : end_files_section)) + if (errmsg != (thiscmd->cmd_data + ? end_filesmatch_section + : end_files_section)) { return errmsg; + } - conf = (core_dir_config *)ap_get_module_config(new_file_conf, &core_module); + conf = (core_dir_config *)ap_get_module_config(new_file_conf, + &core_module); conf->d = cmd->path; conf->d_is_fnmatch = ap_is_fnmatch(conf->d) != 0; conf->r = r; - add_file_conf (c, new_file_conf); + add_file_conf(c, new_file_conf); - if (*arg != '\0') - return ap_pstrcat (cmd->pool, "Multiple ", thiscmd->name, - "> arguments not (yet) supported.", NULL); + if (*arg != '\0') { + return ap_pstrcat(cmd->pool, "Multiple ", thiscmd->name, + "> arguments not (yet) supported.", NULL); + } cmd->path = old_path; cmd->override = old_overrides; @@ -1130,31 +1352,39 @@ * Extra (redundant, unpaired) </IfModule> directives are * simply silently ignored. */ -static const char *end_ifmod (cmd_parms *cmd, void *dummy) { +static const char *end_ifmod(cmd_parms *cmd, void *dummy) +{ return NULL; } -static const char *start_ifmod (cmd_parms *cmd, void *dummy, char *arg) +static const char *start_ifmod(cmd_parms *cmd, void *dummy, char *arg) { - char *endp = strrchr (arg, '>'); + char *endp = strrchr(arg, '>'); char l[MAX_STRING_LEN]; int not = (arg[0] == '!'); module *found; int nest = 1; - if (endp) *endp = '\0'; - if (not) arg++; + if (endp) { + *endp = '\0'; + } + if (not) { + arg++; + } found = ap_find_linked_module(arg); - if ((!not && found) || (not && !found)) - return NULL; + if ((!not && found) || (not && !found)) { + return NULL; + } while (nest && !(ap_cfg_getline (l, sizeof(l), cmd->config_file))) { - if (!strncasecmp(l, "<IfModule", 9)) - nest++; - if (!strcasecmp(l, "</IfModule>")) + if (!strncasecmp(l, "<IfModule", 9)) { + nest++; + } + if (!strcasecmp(l, "</IfModule>")) { nest--; + } } if (nest) { @@ -1171,8 +1401,9 @@ defines = (char **)ap_server_config_defines->elts; for (i = 0; i < ap_server_config_defines->nelts; i++) { - if (strcmp(defines[i], name) == 0) + if (strcmp(defines[i], name) == 0) { return 1; + } } return 0; } @@ -1191,8 +1422,9 @@ int nest = 1; endp = strrchr(arg, '>'); - if (endp) + if (endp) { *endp = '\0'; + } if (arg[0] == '!') { not = 1; arg++; @@ -1200,14 +1432,17 @@ defined = ap_exists_config_define(arg); - if ((!not && defined) || (not && !defined)) + if ((!not && defined) || (not && !defined)) { return NULL; + } while (nest && !(ap_cfg_getline(l, MAX_STRING_LEN, cmd->config_file))) { - if (!strncasecmp(l, "<IfDefine", 9)) - nest++; - if (!strcasecmp(l, "</IfDefine>")) - nest--; + if (!strncasecmp(l, "<IfDefine", 9)) { + nest++; + } + if (!strcasecmp(l, "</IfDefine>")) { + nest--; + } } if (nest) { cmd->end_token = end_ifdefine_section; @@ -1218,30 +1453,36 @@ /* httpd.conf commands... beginning with the <VirtualHost> business */ -static const char *virtualhost_section (cmd_parms *cmd, void *dummy, char *arg) +static const char *virtualhost_section(cmd_parms *cmd, void *dummy, char *arg) { server_rec *main_server = cmd->server, *s; const char *errmsg; - char *endp = strrchr (arg, '>'); + char *endp = strrchr(arg, '>'); pool *p = cmd->pool, *ptemp = cmd->temp_pool; const char *old_end_token; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - if (endp) *endp = '\0'; + if (endp) { + *endp = '\0'; + } /* FIXME: There's another feature waiting to happen here -- since you can now put multiple addresses/names on a single <VirtualHost> you might want to use it to group common definitions and then define other "subhosts" with their individual differences. But personally I'd rather just do it with a macro preprocessor. -djg */ - if (main_server->is_virtual) + if (main_server->is_virtual) { return "<VirtualHost> doesn't nest!"; + } - errmsg = ap_init_virtual_host (p, arg, main_server, &s); - if (errmsg) + errmsg = ap_init_virtual_host(p, arg, main_server, &s); + if (errmsg) { return errmsg; + } s->next = main_server->next; main_server->next = s; @@ -1252,124 +1493,157 @@ old_end_token = cmd->end_token; cmd->end_token = end_virtualhost_section; cmd->server = s; - errmsg = ap_srm_command_loop (cmd, s->lookup_defaults); + errmsg = ap_srm_command_loop(cmd, s->lookup_defaults); cmd->server = main_server; if (errmsg == NULL) { errmsg = missing_endsection(cmd, 1); } cmd->end_token = old_end_token; - if (s->srm_confname) - ap_process_resource_config (s, s->srm_confname, p, ptemp); + if (s->srm_confname) { + ap_process_resource_config(s, s->srm_confname, p, ptemp); + } - if (s->access_confname) - ap_process_resource_config (s, s->access_confname, p, ptemp); + if (s->access_confname) { + ap_process_resource_config(s, s->access_confname, p, ptemp); + } - if (errmsg == end_virtualhost_section) + if (errmsg == end_virtualhost_section) { return NULL; + } return errmsg; } -static const char *set_server_alias(cmd_parms *cmd, void *dummy, const char *arg) +static const char *set_server_alias(cmd_parms *cmd, void *dummy, + const char *arg) { - if (!cmd->server->names) + if (!cmd->server->names) { return "ServerAlias only used in <VirtualHost>"; + } while (*arg) { char **item, *name = ap_getword_conf(cmd->pool, &arg); - if (ap_is_matchexp(name)) - item = (char **) ap_push_array(cmd->server->wild_names); - else - item = (char **) ap_push_array(cmd->server->names); + if (ap_is_matchexp(name)) { + item = (char **)ap_push_array(cmd->server->wild_names); + } + else { + item = (char **)ap_push_array(cmd->server->names); + } *item = name; } return NULL; } -static const char *add_module_command (cmd_parms *cmd, void *dummy, char *arg) +static const char *add_module_command(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - if (!ap_add_named_module(arg)) + if (!ap_add_named_module(arg)) { return ap_pstrcat(cmd->pool, "Cannot add module via name '", arg, "': not in list of loaded modules", NULL); + } return NULL; } -static const char *clear_module_list_command (cmd_parms *cmd, void *dummy) +static const char *clear_module_list_command(cmd_parms *cmd, void *dummy) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - ap_clear_module_list (); + ap_clear_module_list(); return NULL; } -static const char *set_server_string_slot (cmd_parms *cmd, void *dummy, - char *arg) +static const char *set_server_string_slot(cmd_parms *cmd, void *dummy, + char *arg) { /* This one's pretty generic... */ int offset = (int)(long)cmd->info; char *struct_ptr = (char *)cmd->server; - const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + if (err != NULL) { + return err; + } *(char **)(struct_ptr + offset) = arg; return NULL; } -static const char *server_type (cmd_parms *cmd, void *dummy, char *arg) +static const char *server_type(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - if (!strcasecmp (arg, "inetd")) ap_standalone = 0; - else if (!strcasecmp (arg, "standalone")) ap_standalone = 1; - else return "ServerType must be either 'inetd' or 'standalone'"; + if (!strcasecmp(arg, "inetd")) { + ap_standalone = 0; + } + else if (!strcasecmp(arg, "standalone")) { + ap_standalone = 1; + } + else { + return "ServerType must be either 'inetd' or 'standalone'"; + } return NULL; } -static const char *server_port (cmd_parms *cmd, void *dummy, char *arg) +static const char *server_port(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); int port; - if (err != NULL) + if (err != NULL) { return err; + } port = atoi(arg); - if (port <= 0 || port >= 65536) /* 65536 == 1<<16 */ + if (port <= 0 || port >= 65536) { /* 65536 == 1<<16 */ return ap_pstrcat(cmd->temp_pool, "The port number \"", arg, - "\" is outside the appropriate range (i.e. 1..65535).", - NULL); + "\" is outside the appropriate range " + "(i.e., 1..65535).", NULL); + } cmd->server->port = port; return NULL; } -static const char *set_signature_flag (cmd_parms *cmd, core_dir_config *d, - char *arg) +static const char *set_signature_flag(cmd_parms *cmd, core_dir_config *d, + char *arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - if (strcasecmp(arg, "On") == 0) + if (strcasecmp(arg, "On") == 0) { d->server_signature = srv_sig_on; - else if (strcasecmp(arg, "Off") == 0) - d->server_signature = srv_sig_off; - else if (strcasecmp(arg, "EMail") == 0) + } + else if (strcasecmp(arg, "Off") == 0) { + d->server_signature = srv_sig_off; + } + else if (strcasecmp(arg, "EMail") == 0) { d->server_signature = srv_sig_withmail; - else + } + else { return "ServerSignature: use one of: off | on | email"; + } return NULL; } -static const char *set_send_buffer_size (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_send_buffer_size(cmd_parms *cmd, void *dummy, char *arg) { - int s = atoi (arg); + int s = atoi(arg); const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } if (s < 512 && s != 0) { return "SendBufferSize must be >= 512 bytes, or 0 for system default."; @@ -1378,18 +1652,21 @@ return NULL; } -static const char *set_user (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_user(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } if (!cmd->server->is_virtual) { ap_user_name = arg; cmd->server->server_uid = ap_user_id = ap_uname2id(arg); } else { - if (ap_suexec_enabled) + if (ap_suexec_enabled) { cmd->server->server_uid = ap_uname2id(arg); + } else { cmd->server->server_uid = ap_user_id; PR_fprintf(PR_STDERR, @@ -1397,7 +1674,7 @@ "requires SUEXEC wrapper.\n"); } } -#if !defined (BIG_SECURITY_HOLE) && !defined (__EMX__) +#if !defined (BIG_SECURITY_HOLE) && !defined (OS2) if (cmd->server->server_uid == 0) { PR_fprintf (PR_STDERR, "Error:\tApache has not been designed to serve pages while running\n" @@ -1414,16 +1691,20 @@ return NULL; } -static const char *set_group (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_group(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - if (!cmd->server->is_virtual) + if (!cmd->server->is_virtual) { cmd->server->server_gid = ap_group_id = ap_gname2id(arg); + } else { - if (ap_suexec_enabled) + if (ap_suexec_enabled) { cmd->server->server_gid = ap_gname2id(arg); + } else { cmd->server->server_gid = ap_group_id; PR_fprintf(PR_STDERR, @@ -1434,158 +1715,204 @@ return NULL; } -static const char *set_server_root (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_server_root(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; - if (!ap_is_directory (arg)) return "ServerRoot must be a valid directory"; - ap_cpystrn (ap_server_root, ap_os_canonical_filename(cmd->pool, arg), sizeof(ap_server_root)); + if (err != NULL) { + return err; + } + + arg = ap_os_canonical_filename(cmd->pool, arg); + + if (!ap_is_directory(arg)) { + return "ServerRoot must be a valid directory"; + } + ap_cpystrn(ap_server_root, arg, + sizeof(ap_server_root)); return NULL; } -static const char *set_timeout (cmd_parms *cmd, void *dummy, char *arg) { +static const char *set_timeout(cmd_parms *cmd, void *dummy, char *arg) +{ const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } cmd->server->timeout_interval = PR_SecondsToInterval(atoi(arg)); return NULL; } -static const char *set_keep_alive_timeout (cmd_parms *cmd, void *dummy, - char *arg) +static const char *set_keep_alive_timeout(cmd_parms *cmd, void *dummy, + char *arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } cmd->server->keep_alive_timeout_interval = PR_SecondsToInterval(atoi(arg)); return NULL; } -static const char *set_keep_alive (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_keep_alive(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } /* We've changed it to On/Off, but used to use numbers * so we accept anything but "Off" or "0" as "On" */ - if (!strcasecmp(arg, "off") || !strcmp(arg, "0")) + if (!strcasecmp(arg, "off") || !strcmp(arg, "0")) { cmd->server->keep_alive = 0; - else + } + else { cmd->server->keep_alive = 1; + } return NULL; } -static const char *set_keep_alive_max (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_keep_alive_max(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - cmd->server->keep_alive_max = atoi (arg); + cmd->server->keep_alive_max = atoi(arg); return NULL; } -static const char *set_pidfile (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - if (cmd->server->is_virtual) + if (cmd->server->is_virtual) { return "PidFile directive not allowed in <VirtualHost>"; + } ap_pid_fname = arg; return NULL; } -static const char *set_scoreboard (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_scoreboard(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } ap_scoreboard_fname = arg; return NULL; } -static const char *set_lockfile (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_lockfile(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } ap_lock_fname = arg; return NULL; } -static const char *set_idcheck (cmd_parms *cmd, core_dir_config *d, int arg) +static const char *set_idcheck(cmd_parms *cmd, core_dir_config *d, int arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } d->do_rfc1413 = arg != 0; return NULL; } -static const char *set_hostname_lookups (cmd_parms *cmd, core_dir_config *d, - char *arg) +static const char *set_hostname_lookups(cmd_parms *cmd, core_dir_config *d, + char *arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - if (!strcasecmp (arg, "on")) { + if (!strcasecmp(arg, "on")) { d->hostname_lookups = HOSTNAME_LOOKUP_ON; - } else if (!strcasecmp (arg, "off")) { + } + else if (!strcasecmp(arg, "off")) { d->hostname_lookups = HOSTNAME_LOOKUP_OFF; - } else if (!strcasecmp (arg, "double")) { + } + else if (!strcasecmp(arg, "double")) { d->hostname_lookups = HOSTNAME_LOOKUP_DOUBLE; - } else { + } + else { return "parameter must be 'on', 'off', or 'double'"; } return NULL; } -static const char *set_serverpath (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_serverpath(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } cmd->server->path = arg; - cmd->server->pathlen = strlen (arg); + cmd->server->pathlen = strlen(arg); return NULL; } -static const char *set_content_md5 (cmd_parms *cmd, core_dir_config *d, int arg) +static const char *set_content_md5(cmd_parms *cmd, core_dir_config *d, int arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); - if (err != NULL) return err; + if (err != NULL) { + return err; + } d->content_md5 = arg != 0; return NULL; } -static const char *set_use_canonical_name (cmd_parms *cmd, core_dir_config *d, - int arg) +static const char *set_use_canonical_name(cmd_parms *cmd, core_dir_config *d, + int arg) { const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); - if (err != NULL) + if (err != NULL) { return err; + } d->use_canonical_name = arg != 0; return NULL; } -static const char *set_daemons_to_start (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, char *arg) { +#ifdef WIN32 + fprintf(stderr, "WARNING: StartServers has no effect on Win32\n"); +#else const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - ap_daemons_to_start = atoi (arg); + ap_daemons_to_start = atoi(arg); +#endif return NULL; } -static const char *set_min_free_servers (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_min_free_servers(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } ap_daemons_min_free = atoi (arg); if (ap_daemons_min_free < 0) { @@ -1598,21 +1925,25 @@ return NULL; } -static const char *set_max_free_servers (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_max_free_servers(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - ap_daemons_max_free = atoi (arg); + ap_daemons_max_free = atoi(arg); return NULL; } static const char *set_server_limit (cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - ap_daemons_limit = atoi (arg); + ap_daemons_limit = atoi(arg); if (ap_daemons_limit > HARD_SERVER_LIMIT) { PR_fprintf(PR_STDERR, "WARNING: MaxClients of %d exceeds compile time limit " "of %d servers,\n", ap_daemons_limit, HARD_SERVER_LIMIT); @@ -1620,32 +1951,46 @@ "see the\n", HARD_SERVER_LIMIT); PR_fprintf(PR_STDERR, " HARD_SERVER_LIMIT define in src/httpd.h.\n"); ap_daemons_limit = HARD_SERVER_LIMIT; - } else if (ap_daemons_limit < 1) { + } + else if (ap_daemons_limit < 1) { PR_fprintf (PR_STDERR, "WARNING: Require MaxClients > 0, setting to 1\n"); ap_daemons_limit = 1; } return NULL; } -static const char *set_threads (cmd_parms *cmd, void *dummy, char *arg) { +static const char *set_threads(cmd_parms *cmd, void *dummy, char *arg) +{ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - ap_threads_per_child = atoi (arg); -#ifdef WIN32 - if(ap_threads_per_child > 64) - return "Can't have more than 64 threads in Windows (for now)"; -#endif + ap_threads_per_child = atoi(arg); + if (ap_threads_per_child > HARD_SERVER_LIMIT) { + PR_fprintf(PR_STDERR, "WARNING: ThreadsPerChild of %d exceeds compile time limit " + "of %d threads,\n", ap_threads_per_child, HARD_SERVER_LIMIT); + PR_fprintf(PR_STDERR, " lowering ThreadsPerChild to %d. To increase, please " + "see the\n", HARD_SERVER_LIMIT); + PR_fprintf(PR_STDERR, " HARD_SERVER_LIMIT define in src/include/httpd.h.\n"); + ap_threads_per_child = HARD_SERVER_LIMIT; + } + else if (ap_threads_per_child < 1) { + PR_fprintf(PR_STDERR, "WARNING: Require ThreadsPerChild > 0, setting to 1\n"); + ap_threads_per_child = 1; + } return NULL; } -static const char *set_excess_requests (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_excess_requests(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - ap_excess_requests_per_child = atoi (arg); + ap_excess_requests_per_child = atoi(arg); return NULL; } @@ -1656,16 +2001,16 @@ { char *str; struct rlimit *limit; - /* If your platform doesn't define rlim_t then typedef it in conf.h */ + /* If your platform doesn't define rlim_t then typedef it in ap_config.h */ rlim_t cur = 0; rlim_t max = 0; - *plimit = (struct rlimit *)ap_pcalloc(cmd->pool,sizeof **plimit); + *plimit = (struct rlimit *)ap_pcalloc(cmd->pool, sizeof(**plimit)); limit = *plimit; if ((getrlimit(type, limit)) != 0) { *plimit = NULL; ap_log_error(APLOG_MARK, APLOG_ERR, cmd->server, - "%s: getrlimit failed", cmd->cmd->name); + "%s: getrlimit failed", cmd->cmd->name); return; } @@ -1679,32 +2024,36 @@ } else { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, cmd->server, - "Invalid parameters for %s", cmd->cmd->name); + "Invalid parameters for %s", cmd->cmd->name); return; } - if (arg2 && (str = ap_getword_conf(cmd->pool, &arg2))) + if (arg2 && (str = ap_getword_conf(cmd->pool, &arg2))) { max = atol(str); + } /* if we aren't running as root, cannot increase max */ if (geteuid()) { limit->rlim_cur = cur; - if (max) + if (max) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, cmd->server, - "Must be uid 0 to raise maximum %s", cmd->cmd->name); + "Must be uid 0 to raise maximum %s", cmd->cmd->name); + } } else { - if (cur) + if (cur) { limit->rlim_cur = cur; - if (max) + } + if (max) { limit->rlim_max = max; + } } } #endif #if !defined (RLIMIT_CPU) || !(defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)) || !defined (RLIMIT_NPROC) -static const char *no_set_limit (cmd_parms *cmd, core_dir_config *conf, - char *arg, char *arg2) +static const char *no_set_limit(cmd_parms *cmd, core_dir_config *conf, + char *arg, char *arg2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, cmd->server, "%s not supported on this platform", cmd->cmd->name); @@ -1713,42 +2062,44 @@ #endif #ifdef RLIMIT_CPU -static const char *set_limit_cpu (cmd_parms *cmd, core_dir_config *conf, - char *arg, char *arg2) +static const char *set_limit_cpu(cmd_parms *cmd, core_dir_config *conf, + char *arg, char *arg2) { - set_rlimit(cmd,&conf->limit_cpu,arg,arg2,RLIMIT_CPU); + set_rlimit(cmd, &conf->limit_cpu, arg, arg2, RLIMIT_CPU); return NULL; } #endif #if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) -static const char *set_limit_mem (cmd_parms *cmd, core_dir_config *conf, - char *arg, char * arg2) +static const char *set_limit_mem(cmd_parms *cmd, core_dir_config *conf, + char *arg, char * arg2) { #if defined(RLIMIT_AS) - set_rlimit(cmd,&conf->limit_mem,arg,arg2,RLIMIT_AS); + set_rlimit(cmd, &conf->limit_mem, arg, arg2 ,RLIMIT_AS); #elif defined(RLIMIT_DATA) - set_rlimit(cmd,&conf->limit_mem,arg,arg2,RLIMIT_DATA); + set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_DATA); #elif defined(RLIMIT_VMEM) - set_rlimit(cmd,&conf->limit_mem,arg,arg2,RLIMIT_VMEM); + set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_VMEM); #endif return NULL; } #endif #ifdef RLIMIT_NPROC -static const char *set_limit_nproc (cmd_parms *cmd, core_dir_config *conf, - char *arg, char * arg2) +static const char *set_limit_nproc(cmd_parms *cmd, core_dir_config *conf, + char *arg, char * arg2) { - set_rlimit(cmd,&conf->limit_nproc,arg,arg2,RLIMIT_NPROC); + set_rlimit(cmd, &conf->limit_nproc, arg, arg2, RLIMIT_NPROC); return NULL; } #endif -static const char *set_bind_address (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_bind_address(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } /* XXX: ipv6 */ ap_bind_address.inet.ip = ap_get_virthost_addr (arg, NULL); @@ -1762,17 +2113,23 @@ unsigned short port; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - ports=strchr(ips, ':'); - if (ports != NULL) - { - if (ports == ips) return "Missing IP address"; - else if (ports[1] == '\0') + ports = strchr(ips, ':'); + if (ports != NULL) { + if (ports == ips) { + return "Missing IP address"; + } + else if (ports[1] == '\0') { return "Address must end in :<port-number>"; + } *(ports++) = '\0'; - } else + } + else { ports = ips; + } new=ap_pcalloc(cmd->pool, sizeof(listen_rec)); /* XXX: ipv6 */ @@ -1783,9 +2140,10 @@ else { new->local_addr.inet.ip = ap_get_virthost_addr(ips, NULL); } - port=atoi(ports); - if(!port) + port = atoi(ports); + if (!port) { return "Port must be numeric"; + } new->local_addr.inet.port = PR_htons(port); new->fd = NULL; new->index = 0; @@ -1794,15 +2152,19 @@ return NULL; } -static const char *set_listenbacklog (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_listenbacklog(cmd_parms *cmd, void *dummy, char *arg) { int b; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - b = atoi (arg); - if (b < 1) return "ListenBacklog must be > 0"; + b = atoi(arg); + if (b < 1) { + return "ListenBacklog must be > 0"; + } ap_listenbacklog = b; return NULL; } @@ -1811,13 +2173,15 @@ { PRFileInfo finfo; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } arg = ap_server_root_relative(cmd->pool, arg); if (PR_GetFileInfo(arg, &finfo) != PR_SUCCESS || finfo.type != PR_FILE_DIRECTORY) { return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", arg, - " does not exist or is not a directory", NULL); + " does not exist or is not a directory", NULL); } ap_cpystrn(ap_coredump_dir, arg, sizeof(ap_coredump_dir)); return NULL; @@ -1832,59 +2196,76 @@ return NULL; } -static const char *set_loglevel (cmd_parms *cmd, void *dummy, const char *arg) +static const char *set_loglevel(cmd_parms *cmd, void *dummy, const char *arg) { - char *str; + char *str; - const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); - if (err != NULL) return err; + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + if (err != NULL) { + return err; + } - if ((str = ap_getword_conf(cmd->pool, &arg))) { - if (!strcasecmp(str, "emerg")) - cmd->server->loglevel = APLOG_EMERG; - else if (!strcasecmp(str, "alert")) - cmd->server->loglevel = APLOG_ALERT; - else if (!strcasecmp(str, "crit")) - cmd->server->loglevel = APLOG_CRIT; - else if (!strcasecmp(str, "error")) - cmd->server->loglevel = APLOG_ERR; - else if (!strcasecmp(str, "warn")) - cmd->server->loglevel = APLOG_WARNING; - else if (!strcasecmp(str, "notice")) - cmd->server->loglevel = APLOG_NOTICE; - else if (!strcasecmp(str, "info")) - cmd->server->loglevel = APLOG_INFO; - else if (!strcasecmp(str, "debug")) - cmd->server->loglevel = APLOG_DEBUG; - else - return "LogLevel requires level keyword: one of emerg/alert/crit/error/warn/notice/info/debug"; - } - else - return "LogLevel requires level keyword"; - - return NULL; + if ((str = ap_getword_conf(cmd->pool, &arg))) { + if (!strcasecmp(str, "emerg")) { + cmd->server->loglevel = APLOG_EMERG; + } + else if (!strcasecmp(str, "alert")) { + cmd->server->loglevel = APLOG_ALERT; + } + else if (!strcasecmp(str, "crit")) { + cmd->server->loglevel = APLOG_CRIT; + } + else if (!strcasecmp(str, "error")) { + cmd->server->loglevel = APLOG_ERR; + } + else if (!strcasecmp(str, "warn")) { + cmd->server->loglevel = APLOG_WARNING; + } + else if (!strcasecmp(str, "notice")) { + cmd->server->loglevel = APLOG_NOTICE; + } + else if (!strcasecmp(str, "info")) { + cmd->server->loglevel = APLOG_INFO; + } + else if (!strcasecmp(str, "debug")) { + cmd->server->loglevel = APLOG_DEBUG; + } + else { + return "LogLevel requires level keyword: one of " + "emerg/alert/crit/error/warn/notice/info/debug"; + } + } + else { + return "LogLevel requires level keyword"; + } + + return NULL; } API_EXPORT(const char *) ap_psignature(const char *prefix, request_rec *r) { char sport[20]; - core_dir_config *conf = - (core_dir_config *) ap_get_module_config(r->per_dir_config, &core_module); + core_dir_config *conf; - if (conf->server_signature == srv_sig_off) + conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); + if (conf->server_signature == srv_sig_off) { return ""; + } ap_snprintf(sport, sizeof sport, "%u", (unsigned) ap_get_server_port(r)); if (conf->server_signature == srv_sig_withmail) { return ap_pstrcat(r->pool, prefix, "<ADDRESS>" SERVER_BASEVERSION - " Server at <A HREF=\"mailto:", r->server->server_admin, "\">", - ap_get_server_name(r), "</A> Port ", sport, - "</ADDRESS>\n", NULL); + " Server at <A HREF=\"mailto:", + r->server->server_admin, "\">", + ap_get_server_name(r), "</A> Port ", sport, + "</ADDRESS>\n", NULL); } return ap_pstrcat(r->pool, prefix, "<ADDRESS>" SERVER_BASEVERSION - " Server at ", ap_get_server_name(r), " Port ", sport, - "</ADDRESS>\n", NULL); + " Server at ", ap_get_server_name(r), " Port ", sport, + "</ADDRESS>\n", NULL); } /* @@ -1900,12 +2281,14 @@ } #ifdef _OSD_POSIX /* BS2000 Logon Passwd file */ -static const char *set_bs2000_authfile (cmd_parms *cmd, void *dummy, char *name) +static const char *set_bs2000_account(cmd_parms *cmd, void *dummy, char *name) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - return os_set_authfile(cmd->pool, name); + return os_set_account(cmd->pool, name); } #endif /*_OSD_POSIX*/ @@ -1917,20 +2300,108 @@ * string. */ -static const char *set_serv_tokens (cmd_parms *cmd, void *dummy, char *arg) +static const char *set_serv_tokens(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) return err; + if (err != NULL) { + return err; + } - if (!strcasecmp(arg, "OS")) + if (!strcasecmp(arg, "OS")) { ap_server_tokens = SrvTk_OS; - else if (!strcasecmp(arg, "Min") || !strcasecmp(arg, "Minimal")) + } + else if (!strcasecmp(arg, "Min") || !strcasecmp(arg, "Minimal")) { ap_server_tokens = SrvTk_MIN; - else + } + else { ap_server_tokens = SrvTk_FULL; + } + return NULL; +} + +static const char *set_limit_req_line(cmd_parms *cmd, void *dummy, char *arg) +{ + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + int lim; + + if (err != NULL) { + return err; + } + lim = atoi(arg); + if (lim < 0) { + return ap_pstrcat(cmd->temp_pool, "LimitRequestLine \"", arg, + "\" must be a non-negative integer", NULL); + } + if (lim > DEFAULT_LIMIT_REQUEST_LINE) { + return ap_psprintf(cmd->temp_pool, "LimitRequestLine \"%s\" " + "must not exceed the precompiled maximum of %d", + arg, DEFAULT_LIMIT_REQUEST_LINE); + } + cmd->server->limit_req_line = lim; + return NULL; +} + +static const char *set_limit_req_fieldsize(cmd_parms *cmd, void *dummy, + char *arg) +{ + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + int lim; + + if (err != NULL) { + return err; + } + lim = atoi(arg); + if (lim < 0) { + return ap_pstrcat(cmd->temp_pool, "LimitRequestFieldsize \"", arg, + "\" must be a non-negative integer (0 = no limit)", + NULL); + } + if (lim > DEFAULT_LIMIT_REQUEST_FIELDSIZE) { + return ap_psprintf(cmd->temp_pool, "LimitRequestFieldsize \"%s\" " + "must not exceed the precompiled maximum of %d", + arg, DEFAULT_LIMIT_REQUEST_FIELDSIZE); + } + cmd->server->limit_req_fieldsize = lim; return NULL; } +static const char *set_limit_req_fields(cmd_parms *cmd, void *dummy, char *arg) +{ + const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + int lim; + + if (err != NULL) { + return err; + } + lim = atoi(arg); + if (lim < 0) { + return ap_pstrcat(cmd->temp_pool, "LimitRequestFields \"", arg, + "\" must be a non-negative integer (0 = no limit)", + NULL); + } + cmd->server->limit_req_fields = lim; + return NULL; +} + +static const char *set_limit_req_body(cmd_parms *cmd, core_dir_config *conf, + char *arg) +{ + const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); + if (err != NULL) { + return err; + } + + /* WTF: If strtoul is not portable, then write a replacement. + * Instead we have an idiotic define in httpd.h that prevents + * it from being used even when it is available. Sheesh. + */ + conf->limit_req_body = (unsigned long)strtol(arg, (char **)NULL, 10); + return NULL; +} + /* Note --- ErrorDocument will now work from .htaccess files. * The AllowOverride of Fileinfo allows webmasters to turn it off */ @@ -1942,51 +2413,91 @@ { "<Directory", dirsection, NULL, RSRC_CONF, RAW_ARGS, "Container for directives affecting resources located in the specified " "directories" }, -{ end_directory_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS, "Marks end of <Directory>" }, -{ "<Location", urlsection, NULL, RSRC_CONF, RAW_ARGS, "Container for directives affecting resources accessed through the specified URL paths" }, -{ end_location_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS, "Marks end of <Location>" }, -{ "<VirtualHost", virtualhost_section, NULL, RSRC_CONF, RAW_ARGS, "Container to map directives to a particular virtual host, takes one or more host addresses" }, -{ end_virtualhost_section, end_nested_section, NULL, RSRC_CONF, NO_ARGS, "Marks end of <VirtualHost>" }, -{ "<Files", filesection, NULL, OR_ALL, RAW_ARGS, "Container for directives affecting files matching specified patterns" }, -{ end_files_section, end_nested_section, NULL, OR_ALL, NO_ARGS, "Marks end of <Files>" }, -{ "<Limit", ap_limit_section, NULL, OR_ALL, RAW_ARGS, "Container for authentication directives when accessed using specified HTTP methods" }, -{ "</Limit>", endlimit_section, NULL, OR_ALL, NO_ARGS, "Marks end of <Limit>" }, -{ "<IfModule", start_ifmod, NULL, OR_ALL, RAW_ARGS, "Container for directives based on existance of specified modules" }, -{ end_ifmodule_section, end_ifmod, NULL, OR_ALL, NO_ARGS, "Marks end of <IfModule>" }, -{ "<IfDefine", start_ifdefine, NULL, OR_ALL, RAW_ARGS, "Container for directives based on existance of command line defines" }, -{ end_ifdefine_section, end_ifdefine, NULL, OR_ALL, NO_ARGS, "Marks end of <IfDefine>" }, -{ "<DirectoryMatch", dirsection, (void*)1, RSRC_CONF, RAW_ARGS, "Container for directives affecting resources located in the specified directories" }, -{ end_directorymatch_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS, "Marks end of <DirectoryMatch>" }, -{ "<LocationMatch", urlsection, (void*)1, RSRC_CONF, RAW_ARGS, "Container for directives affecting resources accessed through the specified URL paths" }, -{ end_locationmatch_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS, "Marks end of <LocationMatch>" }, -{ "<FilesMatch", filesection, (void*)1, OR_ALL, RAW_ARGS, "Container for directives affecting files matching specified patterns" }, -{ end_filesmatch_section, end_nested_section, NULL, OR_ALL, NO_ARGS, "Marks end of <FilesMatch>" }, -{ "AuthType", ap_set_string_slot, (void*)XtOffsetOf(core_dir_config, ap_auth_type), - OR_AUTHCFG, TAKE1, "An HTTP authorization type (e.g., \"Basic\")" }, +{ end_directory_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS, + "Marks end of <Directory>" }, +{ "<Location", urlsection, NULL, RSRC_CONF, RAW_ARGS, + "Container for directives affecting resources accessed through the " + "specified URL paths" }, +{ end_location_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS, + "Marks end of <Location>" }, +{ "<VirtualHost", virtualhost_section, NULL, RSRC_CONF, RAW_ARGS, + "Container to map directives to a particular virtual host, takes one or " + "more host addresses" }, +{ end_virtualhost_section, end_nested_section, NULL, RSRC_CONF, NO_ARGS, + "Marks end of <VirtualHost>" }, +{ "<Files", filesection, NULL, OR_ALL, RAW_ARGS, "Container for directives " + "affecting files matching specified patterns" }, +{ end_files_section, end_nested_section, NULL, OR_ALL, NO_ARGS, + "Marks end of <Files>" }, +{ "<Limit", ap_limit_section, NULL, OR_ALL, RAW_ARGS, "Container for " + "authentication directives when accessed using specified HTTP methods" }, +{ "</Limit>", endlimit_section, NULL, OR_ALL, NO_ARGS, + "Marks end of <Limit>" }, +{ "<IfModule", start_ifmod, NULL, OR_ALL, TAKE1, + "Container for directives based on existance of specified modules" }, +{ end_ifmodule_section, end_ifmod, NULL, OR_ALL, NO_ARGS, + "Marks end of <IfModule>" }, +{ "<IfDefine", start_ifdefine, NULL, OR_ALL, TAKE1, + "Container for directives based on existance of command line defines" }, +{ end_ifdefine_section, end_ifdefine, NULL, OR_ALL, NO_ARGS, + "Marks end of <IfDefine>" }, +{ "<DirectoryMatch", dirsection, (void*)1, RSRC_CONF, RAW_ARGS, + "Container for directives affecting resources located in the " + "specified directories" }, +{ end_directorymatch_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS, + "Marks end of <DirectoryMatch>" }, +{ "<LocationMatch", urlsection, (void*)1, RSRC_CONF, RAW_ARGS, + "Container for directives affecting resources accessed through the " + "specified URL paths" }, +{ end_locationmatch_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS, + "Marks end of <LocationMatch>" }, +{ "<FilesMatch", filesection, (void*)1, OR_ALL, RAW_ARGS, + "Container for directives affecting files matching specified patterns" }, +{ end_filesmatch_section, end_nested_section, NULL, OR_ALL, NO_ARGS, + "Marks end of <FilesMatch>" }, +{ "AuthType", ap_set_string_slot, + (void*)XtOffsetOf(core_dir_config, ap_auth_type), OR_AUTHCFG, TAKE1, + "An HTTP authorization type (e.g., \"Basic\")" }, { "AuthName", set_authname, NULL, OR_AUTHCFG, TAKE1, - "The authentication realm (e.g. \"Members Only\")" }, -{ "Require", require, NULL, OR_AUTHCFG, RAW_ARGS, "Selects which authenticated users or groups may access a protected space" }, + "The authentication realm (e.g. \"Members Only\")" }, +{ "Require", require, NULL, OR_AUTHCFG, RAW_ARGS, + "Selects which authenticated users or groups may access a protected space" }, { "Satisfy", satisfy, NULL, OR_AUTHCFG, TAKE1, - "access policy if both allow and require used ('all' or 'any')" }, + "access policy if both allow and require used ('all' or 'any')" }, +#ifdef GPROF +{ "GprofDir", set_gprof_dir, NULL, RSRC_CONF, TAKE1, + "Directory to plop gmon.out files" }, +#endif /* Old resource config file commands */ -{ "AccessFileName", set_access_name, NULL, RSRC_CONF, RAW_ARGS, "Name(s) of per-directory config files (default: .htaccess)" }, -{ "DocumentRoot", set_document_root, NULL, RSRC_CONF, TAKE1, "Root directory of the document tree" }, -{ "ErrorDocument", set_error_document, NULL, OR_FILEINFO, RAW_ARGS, "Change responses for HTTP errors" }, -{ "AllowOverride", set_override, NULL, ACCESS_CONF, RAW_ARGS, "Controls what groups of directives can be configured by per-directory config files" }, -{ "Options", set_options, NULL, OR_OPTIONS, RAW_ARGS, "Set a number of attributes for a given directory" }, +{ "AccessFileName", set_access_name, NULL, RSRC_CONF, RAW_ARGS, + "Name(s) of per-directory config files (default: .htaccess)" }, +{ "DocumentRoot", set_document_root, NULL, RSRC_CONF, TAKE1, + "Root directory of the document tree" }, +{ "ErrorDocument", set_error_document, NULL, OR_FILEINFO, RAW_ARGS, + "Change responses for HTTP errors" }, +{ "AllowOverride", set_override, NULL, ACCESS_CONF, RAW_ARGS, + "Controls what groups of directives can be configured by per-directory " + "config files" }, +{ "Options", set_options, NULL, OR_OPTIONS, RAW_ARGS, + "Set a number of attributes for a given directory" }, { "DefaultType", ap_set_string_slot, - (void*)XtOffsetOf (core_dir_config, ap_default_type), - OR_FILEINFO, TAKE1, "the default MIME type for untypable files" }, + (void*)XtOffsetOf (core_dir_config, ap_default_type), + OR_FILEINFO, TAKE1, "the default MIME type for untypable files" }, /* Old server config file commands */ -{ "ServerType", server_type, NULL, RSRC_CONF, TAKE1,"'inetd' or 'standalone'"}, +{ "ServerType", server_type, NULL, RSRC_CONF, TAKE1, + "'inetd' or 'standalone'"}, { "Port", server_port, NULL, RSRC_CONF, TAKE1, "A TCP port number"}, -{ "HostnameLookups", set_hostname_lookups, NULL, ACCESS_CONF|RSRC_CONF, TAKE1, "\"on\" to enable, \"off\" to disable reverse DNS lookups, or \"double\" to enable double-reverse DNS lookups" }, -{ "User", set_user, NULL, RSRC_CONF, TAKE1, "Effective user id for this server"}, -{ "Group", set_group, NULL, RSRC_CONF, TAKE1, "Effective group id for this server"}, +{ "HostnameLookups", set_hostname_lookups, NULL, ACCESS_CONF|RSRC_CONF, TAKE1, + "\"on\" to enable, \"off\" to disable reverse DNS lookups, or \"double\" to " + "enable double-reverse DNS lookups" }, +{ "User", set_user, NULL, RSRC_CONF, TAKE1, + "Effective user id for this server"}, +{ "Group", set_group, NULL, RSRC_CONF, TAKE1, + "Effective group id for this server"}, { "ServerAdmin", set_server_string_slot, (void *)XtOffsetOf (server_rec, server_admin), RSRC_CONF, TAKE1, "The email address of the server administrator" }, @@ -1995,7 +2506,8 @@ "The hostname of the server" }, { "ServerSignature", set_signature_flag, NULL, ACCESS_CONF|RSRC_CONF, TAKE1, "En-/disable server signature (on|off|email)" }, -{ "ServerRoot", set_server_root, NULL, RSRC_CONF, TAKE1, "Common directory of server-related files (logs, confs, etc)" }, +{ "ServerRoot", set_server_root, NULL, RSRC_CONF, TAKE1, + "Common directory of server-related files (logs, confs, etc.)" }, { "ErrorLog", set_server_string_slot, (void *)XtOffsetOf (server_rec, error_fname), RSRC_CONF, TAKE1, "The filename of the error log" }, @@ -2015,66 +2527,100 @@ "A name or names alternately used to access the server" }, { "ServerPath", set_serverpath, NULL, RSRC_CONF, TAKE1, "The pathname the server can be reached at" }, -{ "Timeout", set_timeout, NULL, RSRC_CONF, TAKE1, "Timeout duration (sec)"}, -{ "KeepAliveTimeout", set_keep_alive_timeout, NULL, RSRC_CONF, TAKE1, "Keep-Alive timeout duration (sec)"}, -{ "MaxKeepAliveRequests", set_keep_alive_max, NULL, RSRC_CONF, TAKE1, "Maximum number of Keep-Alive requests per connection, or 0 for infinite" }, -{ "KeepAlive", set_keep_alive, NULL, RSRC_CONF, TAKE1, "Whether persistent connections should be On or Off" }, -{ "IdentityCheck", set_idcheck, NULL, RSRC_CONF|ACCESS_CONF, FLAG, "Enable identd (RFC 1413) user lookups - SLOW" }, -{ "ContentDigest", set_content_md5, NULL, RSRC_CONF|ACCESS_CONF|OR_AUTHCFG, FLAG, "whether or not to send a Content-MD5 header with each request" }, -{ "UseCanonicalName", set_use_canonical_name, NULL, RSRC_CONF|ACCESS_CONF|OR_AUTHCFG, FLAG, "whether or not to always use the canonical ServerName : Port when constructing URLs" }, -{ "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1, "Number of child processes launched at server startup" }, -{ "MinSpareServers", set_min_free_servers, NULL, RSRC_CONF, TAKE1, "Minimum number of idle children, to handle request spikes" }, -{ "MaxSpareServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1, "Maximum number of idle children" }, -{ "MaxServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1, "Deprecated equivalent to MaxSpareServers" }, -{ "ServersSafetyLimit", set_server_limit, NULL, RSRC_CONF, TAKE1, "Deprecated equivalent to MaxClients" }, -{ "MaxClients", set_server_limit, NULL, RSRC_CONF, TAKE1, "Maximum number of children alive at the same time" }, +{ "Timeout", set_timeout, NULL, RSRC_CONF, TAKE1, "Timeout duration (sec)" }, +{ "KeepAliveTimeout", set_keep_alive_timeout, NULL, RSRC_CONF, TAKE1, + "Keep-Alive timeout duration (sec)"}, +{ "MaxKeepAliveRequests", set_keep_alive_max, NULL, RSRC_CONF, TAKE1, + "Maximum number of Keep-Alive requests per connection, or 0 for infinite" }, +{ "KeepAlive", set_keep_alive, NULL, RSRC_CONF, TAKE1, + "Whether persistent connections should be On or Off" }, +{ "IdentityCheck", set_idcheck, NULL, RSRC_CONF|ACCESS_CONF, FLAG, + "Enable identd (RFC 1413) user lookups - SLOW" }, +{ "ContentDigest", set_content_md5, NULL, RSRC_CONF|ACCESS_CONF|OR_AUTHCFG, + FLAG, "whether or not to send a Content-MD5 header with each request" }, +{ "UseCanonicalName", set_use_canonical_name, NULL, + RSRC_CONF|ACCESS_CONF|OR_AUTHCFG, FLAG, + "Whether or not to always use the canonical ServerName : Port when " + "constructing URLs" }, +{ "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1, + "Number of child processes launched at server startup" }, +{ "MinSpareServers", set_min_free_servers, NULL, RSRC_CONF, TAKE1, + "Minimum number of idle children, to handle request spikes" }, +{ "MaxSpareServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1, + "Maximum number of idle children" }, +{ "MaxServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1, + "Deprecated equivalent to MaxSpareServers" }, +{ "ServersSafetyLimit", set_server_limit, NULL, RSRC_CONF, TAKE1, + "Deprecated equivalent to MaxClients" }, +{ "MaxClients", set_server_limit, NULL, RSRC_CONF, TAKE1, + "Maximum number of children alive at the same time" }, #if 0 /* XXX: document that this doesn't exist any longer */ -{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1, "Maximum number of requests a particular child serves before dying." }, +{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1, + "Maximum number of requests a particular child serves before dying." }, #endif { "RLimitCPU", #ifdef RLIMIT_CPU - set_limit_cpu, (void*)XtOffsetOf(core_dir_config, limit_cpu), + set_limit_cpu, (void*)XtOffsetOf(core_dir_config, limit_cpu), #else - no_set_limit, NULL, + no_set_limit, NULL, #endif - OR_ALL, TAKE12, "soft/hard limits for max CPU usage in seconds" }, + OR_ALL, TAKE12, "Soft/hard limits for max CPU usage in seconds" }, { "RLimitMEM", #if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined (RLIMIT_AS) - set_limit_mem, (void*)XtOffsetOf(core_dir_config, limit_mem), + set_limit_mem, (void*)XtOffsetOf(core_dir_config, limit_mem), #else - no_set_limit, NULL, + no_set_limit, NULL, #endif - OR_ALL, TAKE12, "soft/hard limits for max memory usage per process" }, + OR_ALL, TAKE12, "Soft/hard limits for max memory usage per process" }, { "RLimitNPROC", #ifdef RLIMIT_NPROC - set_limit_nproc, (void*)XtOffsetOf(core_dir_config, limit_nproc), + set_limit_nproc, (void*)XtOffsetOf(core_dir_config, limit_nproc), #else - no_set_limit, NULL, + no_set_limit, NULL, #endif - OR_ALL, TAKE12, "soft/hard limits for max number of processes per uid" }, + OR_ALL, TAKE12, "soft/hard limits for max number of processes per uid" }, { "BindAddress", set_bind_address, NULL, RSRC_CONF, TAKE1, "'*', a numeric IP address, or the name of a host with a unique IP address"}, { "Listen", set_listener, NULL, RSRC_CONF, TAKE1, - "a port number or a numeric IP address and a port number"}, -{ "SendBufferSize", set_send_buffer_size, NULL, RSRC_CONF, TAKE1, "send buffer size in bytes"}, + "A port number or a numeric IP address and a port number"}, +{ "SendBufferSize", set_send_buffer_size, NULL, RSRC_CONF, TAKE1, + "Send buffer size in bytes"}, { "AddModule", add_module_command, NULL, RSRC_CONF, ITERATE, - "the name of a module" }, -{ "ClearModuleList", clear_module_list_command, NULL, RSRC_CONF, NO_ARGS, NULL }, -{ "ThreadsPerChild", set_threads, NULL, RSRC_CONF, TAKE1, "Number of threads a child creates" }, -{ "ExcessRequestsPerChild", set_excess_requests, NULL, RSRC_CONF, TAKE1, "Maximum number of requests a particular child serves after it is ready to die." }, -{ "ListenBacklog", set_listenbacklog, NULL, RSRC_CONF, TAKE1, "maximum length of the queue of pending connections, as used by listen(2)" }, -{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1, "The location of the directory Apache changes to before dumping core" }, -{ "Include", include_config, NULL, RSRC_CONF, TAKE1, "config file to be included" }, -{ "LogLevel", set_loglevel, NULL, RSRC_CONF, TAKE1, "set level of verbosity in error logging" }, + "The name of a module" }, +{ "ClearModuleList", clear_module_list_command, NULL, RSRC_CONF, NO_ARGS, + NULL }, +{ "ThreadsPerChild", set_threads, NULL, RSRC_CONF, TAKE1, + "Number of threads a child creates" }, +{ "ExcessRequestsPerChild", set_excess_requests, NULL, RSRC_CONF, TAKE1, + "Maximum number of requests a particular child serves after it is ready " + "to die." }, +{ "ListenBacklog", set_listenbacklog, NULL, RSRC_CONF, TAKE1, + "Maximum length of the queue of pending connections, as used by listen(2)" }, +{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1, + "The location of the directory Apache changes to before dumping core" }, +{ "Include", include_config, NULL, (RSRC_CONF | ACCESS_CONF), TAKE1, + "Name of the config file to be included" }, +{ "LogLevel", set_loglevel, NULL, RSRC_CONF, TAKE1, + "Level of verbosity in error logging" }, { "NameVirtualHost", ap_set_name_virtual_host, NULL, RSRC_CONF, TAKE1, - "a numeric ip address:port, or the name of a host" }, + "A numeric IP address:port, or the name of a host" }, #ifdef _OSD_POSIX -{ "BS2000AuthFile", set_bs2000_authfile, NULL, RSRC_CONF, TAKE1, - "server User's bs2000 logon password file (read-protected)" }, +{ "BS2000Account", set_bs2000_account, NULL, RSRC_CONF, TAKE1, + "Name of server User's bs2000 logon account name" }, #endif { "ServerTokens", set_serv_tokens, NULL, RSRC_CONF, TAKE1, "Determine tokens displayed in the Server: header - Min(imal), OS or Full" }, +{ "LimitRequestLine", set_limit_req_line, NULL, RSRC_CONF, TAKE1, + "Limit on maximum size of an HTTP request line"}, +{ "LimitRequestFieldsize", set_limit_req_fieldsize, NULL, RSRC_CONF, TAKE1, + "Limit on maximum size of an HTTP request header field"}, +{ "LimitRequestFields", set_limit_req_fields, NULL, RSRC_CONF, TAKE1, + "Limit (0 = unlimited) on max number of header fields in a request message"}, +{ "LimitRequestBody", set_limit_req_body, + (void*)XtOffsetOf(core_dir_config, limit_req_body), + RSRC_CONF|ACCESS_CONF|OR_ALL, TAKE1, + "Limit (in bytes) on maximum size of request message body" }, { NULL }, }; @@ -2083,32 +2629,37 @@ * Core handlers for various phases of server operation... */ -static int core_translate (request_rec *r) +static int core_translate(request_rec *r) { void *sconf = r->server->module_config; - core_server_config *conf = ap_get_module_config (sconf, &core_module); + core_server_config *conf = ap_get_module_config(sconf, &core_module); - if (r->proxyreq) return HTTP_FORBIDDEN; + if (r->proxyreq) { + return HTTP_FORBIDDEN; + } if ((r->uri[0] != '/') && strcmp(r->uri, "*")) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, - "Invalid URI in request %s", r->the_request); + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, + "Invalid URI in request %s", r->the_request); return BAD_REQUEST; } - if (r->server->path && - !strncmp(r->uri, r->server->path, r->server->pathlen) && - (r->server->path[r->server->pathlen - 1] == '/' || - r->uri[r->server->pathlen] == '/' || - r->uri[r->server->pathlen] == '\0')) - r->filename = ap_pstrcat (r->pool, conf->ap_document_root, - (r->uri + r->server->pathlen), NULL); - else - r->filename = ap_pstrcat (r->pool, conf->ap_document_root, r->uri, NULL); + if (r->server->path + && !strncmp(r->uri, r->server->path, r->server->pathlen) + && (r->server->path[r->server->pathlen - 1] == '/' + || r->uri[r->server->pathlen] == '/' + || r->uri[r->server->pathlen] == '\0')) { + r->filename = ap_pstrcat(r->pool, conf->ap_document_root, + (r->uri + r->server->pathlen), NULL); + } + else { + r->filename = ap_pstrcat(r->pool, conf->ap_document_root, r->uri, + NULL); + } return OK; } -static int do_nothing (request_rec *r) { return OK; } +static int do_nothing(request_rec *r) { return OK; } /* * Default handler for MIME types without other handlers. Only GET @@ -2118,7 +2669,7 @@ * the last handler called and return 405 or 501. */ -static int default_handler (request_rec *r) +static int default_handler(request_rec *r) { core_dir_config *d = (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); @@ -2134,32 +2685,38 @@ /* This handler has no use for a request body (yet), but we still * need to read and discard it if the client sent one. */ - if ((errstatus = ap_discard_request_body(r)) != OK) + if ((errstatus = ap_discard_request_body(r)) != OK) { return errstatus; + } r->allowed |= (1 << M_GET) | (1 << M_OPTIONS); if (r->method_number == M_INVALID) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid method in request %s", r->the_request); return NOT_IMPLEMENTED; } - if (r->method_number == M_OPTIONS) return ap_send_http_options(r); - if (r->method_number == M_PUT) return METHOD_NOT_ALLOWED; - + if (r->method_number == M_OPTIONS) { + return ap_send_http_options(r); + } + if (r->method_number == M_PUT) { + return METHOD_NOT_ALLOWED; + } if (r->file_exists == 0 || (r->path_info && *r->path_info)) { ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r->server, "File does not exist: %s", r->path_info ? ap_pstrcat(r->pool, r->filename, r->path_info, NULL) : r->filename); - return NOT_FOUND; + return HTTP_NOT_FOUND; + } + if (r->method_number != M_GET) { + return METHOD_NOT_ALLOWED; } - if (r->method_number != M_GET) return METHOD_NOT_ALLOWED; f = ap_popenfd(r->pool, r->filename, PR_RDONLY, 0); if (f == NULL) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, - "file permissions deny server access: %s", r->filename); + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, + "file permissions deny server access: %s", r->filename); return FORBIDDEN; } @@ -2225,23 +2782,23 @@ }; API_VAR_EXPORT module core_module = { - STANDARD_MODULE_STUFF, - NULL, /* initializer */ - create_core_dir_config, /* create per-directory config structure */ - merge_core_dir_configs, /* merge per-directory config structures */ - create_core_server_config, /* create per-server config structure */ - merge_core_server_configs, /* merge per-server config structures */ - core_cmds, /* command table */ - core_handlers, /* handlers */ - core_translate, /* translate_handler */ - NULL, /* check_user_id */ - NULL, /* check auth */ - do_nothing, /* check access */ - do_nothing, /* type_checker */ - NULL, /* pre-run fixups */ - NULL, /* logger */ - NULL, /* header parser */ - NULL, /* child_init */ - NULL, /* child_exit */ - NULL /* post_read_request */ + STANDARD_MODULE_STUFF, + NULL, /* initializer */ + create_core_dir_config, /* create per-directory config structure */ + merge_core_dir_configs, /* merge per-directory config structures */ + create_core_server_config, /* create per-server config structure */ + merge_core_server_configs, /* merge per-server config structures */ + core_cmds, /* command table */ + core_handlers, /* handlers */ + core_translate, /* translate_handler */ + NULL, /* check_user_id */ + NULL, /* check auth */ + do_nothing, /* check access */ + do_nothing, /* type_checker */ + NULL, /* pre-run fixups */ + NULL, /* logger */ + NULL, /* header parser */ + NULL, /* child_init */ + NULL, /* child_exit */ + NULL /* post_read_request */ }; 1.3 +37 -20 apache-2.0/apache-nspr/main/http_log.c Index: http_log.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/http_log.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- http_log.c 1998/06/30 08:57:07 1.2 +++ http_log.c 1998/09/22 18:05:18 1.3 @@ -173,7 +173,7 @@ #if defined(WIN32) child_pid = spawnl (_P_NOWAIT, SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); return(child_pid); -#elif defined(__EMX__) +#elif defined(OS2) /* For OS/2 we need to use a '/' */ execl (SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); #else @@ -290,10 +290,10 @@ #endif } -API_EXPORT(void) ap_log_error (const char *file, int line, int level, - const server_rec *s, const char *fmt, ...) +static void log_error_core (const char *file, int line, int level, + const server_rec *s, const request_rec *r, + const char *fmt, va_list args) { - va_list args; char errstr[MAX_STRING_LEN]; size_t len; PRErrorCode save_errno = PR_GetError(); @@ -366,6 +366,15 @@ len += ap_snprintf(errstr + len, sizeof(errstr) - len, "%s(%d): ", file, line); } + if (r) { + /* XXX: TODO: add a method of selecting whether logged client + * addresses are in dotted quad or resolved form... dotted + * quad is the most secure, which is why I'm implementing it + * first. -djg + */ + len += ap_snprintf(errstr + len, sizeof(errstr) - len, + "[client %s] ", r->connection->remote_ip); + } if (!(level & APLOG_NOERRNO) && (save_errno != 0) #ifdef WIN32 @@ -427,9 +436,7 @@ } #endif - va_start(args, fmt); len += ap_vsnprintf(errstr + len, sizeof(errstr) - len, fmt, args); - va_end(args); /* NULL if we are logging to syslog */ if (logf) { @@ -448,24 +455,34 @@ #endif } +API_EXPORT(void) ap_log_error (const char *file, int line, int level, + const server_rec *s, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + log_error_core(file, line, level, s, NULL, fmt, args); + va_end(args); +} + +API_EXPORT(void) ap_log_rerror(const char *file, int line, int level, + const request_rec *r, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + log_error_core(file, line, level, r->server, r, fmt, args); + if (ap_table_get(r->notes, "error-notes") == NULL) { + ap_table_setn(r->notes, "error-notes", + ap_pvsprintf(r->pool, fmt, args)); + } + va_end(args); +} void ap_log_pid (pool *p, char *fname) { /* XXX: need to log pids for NSPR */ return; -#if 0 - BUFF *pid_file; - - if (!fname) return; - fname = ap_server_root_relative (p, fname); - if (!(pid_file = ap_bopenf(p, fname, PR_WRONLY, 0666))) { - /* XXX: need to give error code still, and stop using fprintf */ - PR_fprintf(PR_STDERR,"httpd: could not log pid to file %s\n", fname); - exit(1); - } - ap_bprintf(pid_file, "%ld\n", (long)getpid()); - ap_bclose(pid_file); -#endif } API_EXPORT(void) ap_log_assert (const char *szExp, const char *szFile, int nLine) @@ -627,7 +644,7 @@ #if defined(WIN32) child_pid = spawnl (_P_NOWAIT, SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); return(child_pid); -#elif defined(__EMX__) +#elif defined(OS2) /* For OS/2 we need to use a '/' */ execl (SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); #else 1.4 +81 -45 apache-2.0/apache-nspr/main/http_main.c Index: http_main.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/http_main.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- http_main.c 1998/09/22 16:12:06 1.3 +++ http_main.c 1998/09/22 18:05:18 1.4 @@ -160,6 +160,7 @@ int ap_suexec_enabled = 0; int ap_listenbacklog; int ap_dump_settings; +API_VAR_EXPORT int ap_extended_status = 0; /* * The max child slot ever assigned, preserved across restarts. Necessary @@ -282,7 +283,7 @@ server_version = NULL; } -API_EXPORT(const char *) ap_get_server_version() +API_EXPORT(const char *) ap_get_server_version(void) { return (server_version ? server_version : SERVER_BASEVERSION); } @@ -315,7 +316,7 @@ * This routine adds the real server base identity to the version string, * and then locks out changes until the next reconfig. */ -static void ap_set_version() +static void ap_set_version(void) { if (ap_server_tokens == SrvTk_MIN) { ap_add_version_component(SERVER_BASEVERSION); @@ -332,9 +333,9 @@ } } - /* a clean exit from a child with proper cleanup */ -static void __attribute__((noreturn)) clean_child_exit(int code) +static void clean_child_exit(int code) __attribute__ ((noreturn)); +static void clean_child_exit(int code) { if (tls()->pchild) { ap_child_exit_modules(tls()->pchild, server_conf); @@ -362,6 +363,7 @@ #ifdef SHARED_CORE PR_fprintf(PR_STDERR, " -L directory : specify an alternate location for shared object files\n"); #endif + PR_fprintf(PR_STDERR, " -D name : define a name for use in <IfDefine name> directives\n"); PR_fprintf(PR_STDERR, " -d directory : specify an alternate initial ServerRoot\n"); PR_fprintf(PR_STDERR, " -f file : specify an alternate ServerConfigFile\n"); PR_fprintf(PR_STDERR, " -C \"directive\" : process directive before reading config files\n"); @@ -393,7 +395,7 @@ * * Many operating systems tend to block, puke, or otherwise mishandle * calls to shutdown only half of the connection. You should define - * NO_LINGCLOSE in conf.h if such is the case for your system. + * NO_LINGCLOSE in ap_config.h if such is the case for your system. */ #ifndef MAX_SECS_TO_LINGER #define MAX_SECS_TO_LINGER 30 @@ -626,7 +628,8 @@ } /* a clean exit from the parent with proper cleanup */ -static void __attribute__((noreturn)) clean_parent_exit(int code) +static void clean_parent_exit(int code) __attribute__((noreturn)); +static void clean_parent_exit(int code) { /* Clear the pool - including any registered cleanups */ ap_destroy_pool(pconf); @@ -645,41 +648,40 @@ old_status = ss->status; ss->status = status; -#if defined(STATUS) - if (status == SERVER_READY || status == SERVER_DEAD) { - /* - * Reset individual counters - */ - if (status == SERVER_DEAD) { - ss->my_access_count = 0L; - ss->my_bytes_served = 0L; + if (ap_extended_server_status) { + if (status == SERVER_READY || status == SERVER_DEAD) { + /* + * Reset individual counters + */ + if (status == SERVER_DEAD) { + ss->my_access_count = 0L; + ss->my_bytes_served = 0L; + } + ss->conn_count = (unsigned short) 0; + ss->conn_bytes = (unsigned long) 0; } - ss->conn_count = (unsigned short) 0; - ss->conn_bytes = (unsigned long) 0; - } - if (r) { - conn_rec *c = r->connection; - ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, - REMOTE_NOLOOKUP), sizeof(ss->client)); - if (r->the_request == NULL) { - ap_cpystrn(ss->request, "NULL", sizeof(ss->request)); - } else if (r->parsed_uri.password == NULL) { - ap_cpystrn(ss->request, r->the_request, sizeof(ss->request)); - } else { - /* Don't reveal the password in the server-status view */ - ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ", - ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD), - r->assbackwards ? NULL : " ", r->protocol, NULL), - sizeof(ss->request)); + if (r) { + conn_rec *c = r->connection; + ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, + REMOTE_NOLOOKUP), sizeof(ss->client)); + if (r->the_request == NULL) { + ap_cpystrn(ss->request, "NULL", sizeof(ss->request)); + } else if (r->parsed_uri.password == NULL) { + ap_cpystrn(ss->request, r->the_request, sizeof(ss->request)); + } else { + /* Don't reveal the password in the server-status view */ + ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ", + ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD), + r->assbackwards ? NULL : " ", r->protocol, NULL), + sizeof(ss->request)); + } + ap_cpystrn(ss->vhost, r->server->server_hostname, sizeof(ss->vhost)); } - ap_cpystrn(ss->vhost, r->server->server_hostname, sizeof(ss->vhost)); } -#endif return old_status; } -#if defined(STATUS) void ap_time_process_request(int child_num, int status) { short_score *ss; @@ -715,8 +717,6 @@ ss->conn_bytes += (unsigned long) bs; } -#endif - static int find_child_by_tid(PRThread *tid) { @@ -1073,7 +1073,8 @@ { printf("Server version: %s\n", ap_get_server_version()); printf("Server built: %s\n", ap_get_server_built()); - printf("Server's Module Magic Number: %u\n", MODULE_MAGIC_NUMBER); + printf("Server's Module Magic Number: %u:%u\n", + MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); printf("Server compiled with....\n"); #ifdef BIG_SECURITY_HOLE printf(" -D BIG_SECURITY_HOLE\n"); @@ -1081,9 +1082,6 @@ #ifdef SECURITY_HOLE_PASS_AUTHORIZATION printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n"); #endif -#ifdef HTTPD_ROOT - printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n"); -#endif #ifdef HAVE_MMAP printf(" -D HAVE_MMAP\n"); #endif @@ -1138,6 +1136,44 @@ #ifdef SHARED_CORE printf(" -D SHARED_CORE\n"); #endif + +/* This list displays the compiled-in default paths: */ +#ifdef HTTPD_ROOT + printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n"); +#endif +#ifdef SUEXEC_BIN + printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n"); +#endif +#ifdef SHARED_CORE_DIR + printf(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n"); +#endif +#ifdef DEFAULT_PIDLOG + printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n"); +#endif +#ifdef DEFAULT_SCOREBOARD + printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n"); +#endif +#ifdef DEFAULT_LOCKFILE + printf(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n"); +#endif +#ifdef DEFAULT_XFERLOG + printf(" -D DEFAULT_XFERLOG=\"" DEFAULT_XFERLOG "\"\n"); +#endif +#ifdef DEFAULT_ERRORLOG + printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n"); +#endif +#ifdef TYPES_CONFIG_FILE + printf(" -D TYPES_CONFIG_FILE=\"" TYPES_CONFIG_FILE "\"\n"); +#endif +#ifdef SERVER_CONFIG_FILE + printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n"); +#endif +#ifdef ACCESS_CONFIG_FILE + printf(" -D ACCESS_CONFIG_FILE=\"" ACCESS_CONFIG_FILE "\"\n"); +#endif +#ifdef RESOURCE_CONFIG_FILE + printf(" -D RESOURCE_CONFIG_FILE=\"" RESOURCE_CONFIG_FILE "\"\n"); +#endif } @@ -1270,11 +1306,11 @@ while ((r = ap_read_request(current_conn)) != NULL) { (void) ap_update_child_status(my_child_num, SERVER_BUSY_WRITE, r); DPRINTF((PR_STDERR,"%d child_main: about to process request\n",my_child_num)); - ap_process_request(r); + if (r->status == HTTP_OK) + ap_process_request(r); DPRINTF((PR_STDERR,"%d child_main: request done\n",my_child_num)); -#if defined(STATUS) - increment_counts(my_child_num, r); -#endif + if (ap_extended_status) + increment_counts(my_child_num, r); if (!current_conn->keepalive || ap_is_aborted(current_conn)) break; ap_destroy_pool(r->pool); @@ -1892,7 +1928,7 @@ } } -#ifdef __EMX__ +#ifdef OS2 printf("%s \n", ap_get_server_version()); #endif 1.3 +147 -114 apache-2.0/apache-nspr/main/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/http_protocol.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- http_protocol.c 1998/06/30 08:57:07 1.2 +++ http_protocol.c 1998/09/22 18:05:18 1.3 @@ -304,7 +304,8 @@ ap_find_last_token(r->pool, ap_table_get(r->headers_out, "Transfer-Encoding"), "chunked") || - ((r->proto_num >= HTTP_VERSION(1,1)) && (r->chunked = 1))) && + ((r->proto_num >= HTTP_VERSION(1,1)) && + (r->chunked = 1))) && /* THIS CODE IS CORRECT, see comment above. */ r->server->keep_alive && (r->server->keep_alive_timeout_interval != PR_INTERVAL_NO_WAIT) && ((r->server->keep_alive_max == 0) || @@ -397,7 +398,7 @@ * complicated. */ - if (!is_HTTP_SUCCESS(r->status) || r->no_local_copy) { + if (!ap_is_HTTP_SUCCESS(r->status) || r->no_local_copy) { return OK; } @@ -601,7 +602,7 @@ status = ap_parse_uri_components(r->pool, uri, &r->parsed_uri); } - if (is_HTTP_SUCCESS(status)) { + if (ap_is_HTTP_SUCCESS(status)) { /* if it has a scheme we may need to do absoluteURI vhost stuff */ if (r->parsed_uri.scheme && !strcasecmp(r->parsed_uri.scheme, ap_http_method(r))) { @@ -612,7 +613,7 @@ r->args = r->parsed_uri.query; r->uri = r->parsed_uri.path ? r->parsed_uri.path : ap_pstrdup(r->pool, "/"); -#if defined(__EMX__) || defined(WIN32) +#if defined(OS2) || defined(WIN32) /* Handle path translations for OS/2 and plug security hole. * This will prevent "http://www.wherever.com/..\..\/" from * returning a directory for the root drive. @@ -627,7 +628,7 @@ ap_str_tolower(r->uri); #endif } -#endif /* __EMX__ || WIN32 */ +#endif /* OS2 || WIN32 */ } else { r->args = NULL; @@ -639,8 +640,9 @@ static int read_request_line(request_rec *r) { - char l[HUGE_STRING_LEN]; - const char *ll = l, *uri; + char l[DEFAULT_LIMIT_REQUEST_LINE + 2]; /* getline's two extra for \n\0 */ + const char *ll = l; + const char *uri; conn_rec *conn = r->connection; int major = 1, minor = 0; /* Assume HTTP/1.0 if non-"HTTP" protocol */ int len; @@ -660,25 +662,13 @@ * have to block during a read. */ ap_bsetflag(conn->client, B_SAFEREAD, 1); - while ((len = getline(l, sizeof(l), conn->client, 0)) == 0) { - /* ignore empty line */ + while ((len = getline(l, sizeof(l), conn->client, 0)) <= 0) { + if ((len < 0) || ap_bgetflag(conn->client, B_EOF)) { + ap_bsetflag(conn->client, B_SAFEREAD, 0); + return 0; + } } ap_bsetflag(conn->client, B_SAFEREAD, 0); - if (len < 0) { - return 0; - } - r->request_time = PR_Now(); - if (len == (sizeof(l) - 1)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, - "request failed for %s, reason: URI too long", - ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME)); - /* hack to deal with the HTTP_REQUEST_TIME_OUT setting up above: */ - if (r->status == HTTP_REQUEST_TIME_OUT) { - r->status = HTTP_OK; - } - ap_die (HTTP_REQUEST_URI_TOO_LARGE, r); - return 0; - } r->the_request = ap_pstrdup(r->pool, l); r->method = ap_getword_white(r->pool, &ll); @@ -708,8 +698,20 @@ ap_parse_uri(r, uri); + /* getline returns (size of max buffer - 1) if it fills up the + * buffer before finding the end-of-line. This is only going to + * happen if it exceeds the configured limit for a request-line. + */ + if (len > r->server->limit_req_line) { + r->status = HTTP_REQUEST_URI_TOO_LARGE; + r->proto_num = HTTP_VERSION(1,0); + r->protocol = ap_pstrdup(r->pool, "HTTP/1.0"); + return 0; + } + r->assbackwards = (ll[0] == '\0'); r->protocol = ap_pstrdup(r->pool, ll[0] ? ll : "HTTP/0.9"); + if (2 == sscanf(r->protocol, "HTTP/%u.%u", &major, &minor) && minor < HTTP_VERSION(1,0)) /* don't allow HTTP/0.1000 */ r->proto_num = HTTP_VERSION(major, minor); @@ -719,56 +721,66 @@ return 1; } -/* -1 on error, 0 on success */ -static int get_mime_headers(request_rec *r) +static void get_mime_headers(request_rec *r) { + char field[DEFAULT_LIMIT_REQUEST_FIELDSIZE + 2]; /* getline's two extra */ conn_rec *c = r->connection; - int len; char *value; - char field[MAX_STRING_LEN]; + char *copy; + int len; + unsigned int fields_read = 0; + table *tmp_headers; + /* We'll use ap_overlap_tables later to merge these into r->headers_in. */ + tmp_headers = ap_make_table(r->pool, 50); + /* * Read header lines until we get the empty separator line, a read error, - * the connection closes (EOF), or we timeout. + * the connection closes (EOF), reach the server limit, or we timeout. */ while ((len = getline(field, sizeof(field), c->client, 1)) > 0) { - char *copy = ap_palloc(r->pool, len + 1); + + if (r->server->limit_req_fields && + (++fields_read > r->server->limit_req_fields)) { + r->status = HTTP_BAD_REQUEST; + ap_table_setn(r->notes, "error-notes", + "The number of request header fields exceeds " + "this server's limit.<P>\n"); + return; + } + /* getline returns (size of max buffer - 1) if it fills up the + * buffer before finding the end-of-line. This is only going to + * happen if it exceeds the configured limit for a field size. + */ + if (len > r->server->limit_req_fieldsize) { + r->status = HTTP_BAD_REQUEST; + ap_table_setn(r->notes, "error-notes", ap_pstrcat(r->pool, + "Size of a request header field exceeds server limit.<P>\n" + "<PRE>\n", field, "</PRE>\n", NULL)); + return; + } + copy = ap_palloc(r->pool, len + 1); memcpy(copy, field, len + 1); - - if (!(value = strchr(copy, ':'))) { /* Find the colon separator */ - /* if there's none, this request is screwed up. - * a hack to deal with how we set HTTP_REQUEST_TIME_OUT earlier.*/ - if (r->status == HTTP_REQUEST_TIME_OUT) - r->status = HTTP_OK; - - ap_die (HTTP_BAD_REQUEST, r); - /* XXX: should this be -1? need to look at better way to return error */ - return 0; - } + + if (!(value = strchr(copy, ':'))) { /* Find the colon separator */ + r->status = HTTP_BAD_REQUEST; /* or abort the bad request */ + ap_table_setn(r->notes, "error-notes", ap_pstrcat(r->pool, + "Request header field is missing colon separator.<P>\n" + "<PRE>\n", copy, "</PRE>\n", NULL)); + return; + } *value = '\0'; ++value; - /* XXX: RFC2068 defines only SP and HT as whitespace, this test is - * wrong... and so are many others probably. - */ - while (isspace(*value)) + while (*value == ' ' || *value == '\t') ++value; /* Skip to start of value */ - /* XXX: should strip trailing whitespace as well */ + /* XXX: should strip trailing whitespace as well */ - ap_table_mergen(r->headers_in, copy, value); - - /* the header was too long; at the least we should skip extra data */ - if (len >= sizeof(field) - 1) { - while ((len = getline(field, sizeof(field), c->client, 1)) - >= sizeof(field) - 1) { - /* soak up the extra data */ - } - if (len == 0) /* time to exit the larger loop as well */ - break; - } + ap_table_addn(tmp_headers, copy, value); } - return ap_is_aborted(c) ? -1 : 0; + + ap_overlap_tables(r->headers_in, tmp_headers, AP_OVERLAP_TABLES_MERGE); } @@ -839,22 +851,28 @@ r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */ r->the_request = NULL; +#ifdef CHARSET_EBCDIC + ap_bsetflag(r->connection->client, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 1); +#endif + /* Get the request... */ ap_bonerror(conn->client, client_bonerror_handler, conn); -#ifdef CHARSET_EBCDIC - ap_bsetflag(conn->client, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 1); -#endif /* CHARSET_EBCDIC */ conn->timeout_name = "read request line"; ap_bsetopt(conn->client, BO_TIMEOUT, conn->keptalive ? &r->server->keep_alive_timeout_interval : &r->server->timeout_interval); if (!read_request_line(r)) { - if (r->status != HTTP_REQUEST_TIME_OUT) { - /* we must have had an error.*/ - ap_log_transaction(r); - } + if (r->status == HTTP_REQUEST_URI_TOO_LARGE) { + + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, + "request failed: URI too long"); + ap_send_error_response(r, 0); + ap_bflush(r->connection->client); + ap_log_transaction(r); + return r; + } return NULL; } if (r->connection->keptalive) { @@ -863,17 +881,17 @@ } conn->timeout_name = "read request headers"; if (!r->assbackwards) { - if (get_mime_headers(r)) { - return NULL; - } - if (r->status != HTTP_REQUEST_TIME_OUT) {/* we must have had an error.*/ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, - "request failed for %s: error reading the headers", - ap_get_remote_host(r->connection, r->per_dir_config, - REMOTE_NAME)); - ap_log_transaction(r); - return NULL; - } + ap_hard_timeout("read request headers", r); + get_mime_headers(r); + ap_kill_timeout(r); + if (r->status != HTTP_REQUEST_TIME_OUT) { + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, + "request failed: error reading the headers"); + ap_send_error_response(r, 0); + ap_bflush(r->connection->client); + ap_log_transaction(r); + return r; + } } r->status = HTTP_OK; /* Until further notice. */ @@ -891,7 +909,7 @@ conn->timeout_name = "request processing"; if ((access_status = ap_run_post_read_request(r))) { ap_die(access_status, r); - ap_log_transaction(r); + ap_log_transaction(r); return NULL; } @@ -970,19 +988,19 @@ ap_pstrdup(r->pool, nonce)); } -API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, char **pw) +API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw) { const char *auth_line = ap_table_get(r->headers_in, r->proxyreq ? "Proxy-Authorization" : "Authorization"); - char *t; + const char *t; if (!(t = ap_auth_type(r)) || strcasecmp(t, "Basic")) return DECLINED; if (!ap_auth_name(r)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, - r->server, "need AuthName: %s", r->uri); + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, + r, "need AuthName: %s", r->uri); return SERVER_ERROR; } @@ -993,7 +1011,7 @@ if (strcasecmp(ap_getword(r->pool, &auth_line, ' '), "Basic")) { /* Client tried to authenticate using wrong auth scheme */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "client used wrong authentication scheme: %s", r->uri); ap_note_basic_auth_failure(r); return AUTH_REQUIRED; @@ -1004,7 +1022,7 @@ * because it has the lifetime of the connection. The other allocations * are temporary and can be tossed away any time. */ - r->connection->user = ap_getword_nulls_nc (r->connection->pool, &t, ':'); + r->connection->user = ap_getword_nulls (r->connection->pool, &t, ':'); r->connection->ap_auth_type = "Basic"; *pw = t; @@ -1107,7 +1125,7 @@ { char *protocol; #ifdef CHARSET_EBCDIC - int convert = bgetflag(r->connection->client, B_EBCDIC2ASCII); + int convert = ap_bgetflag(r->connection->client, B_EBCDIC2ASCII); #endif /*CHARSET_EBCDIC*/ if (r->assbackwards) @@ -1192,7 +1210,7 @@ NULL); } -int ap_send_http_trace(request_rec *r) +API_EXPORT(int) ap_send_http_trace(request_rec *r) { int rv; @@ -1260,7 +1278,7 @@ int i; const PRUint32 zero = 0L; #ifdef CHARSET_EBCDIC - int convert = bgetflag(r->connection->client, B_EBCDIC2ASCII); + int convert = ap_bgetflag(r->connection->client, B_EBCDIC2ASCII); #endif /*CHARSET_EBCDIC*/ if (r->assbackwards) { @@ -1345,7 +1363,7 @@ * information for any wrappers around the response message body * (i.e., transfer encodings). It should have been named finalize_response. */ -void ap_finalize_request_protocol(request_rec *r) +API_EXPORT(void) ap_finalize_request_protocol(request_rec *r) { if (r->chunked && !ap_is_aborted(r->connection)) { /* @@ -1403,6 +1421,7 @@ { const char *tenc = ap_table_get(r->headers_in, "Transfer-Encoding"); const char *lenp = ap_table_get(r->headers_in, "Content-Length"); + unsigned long max_body; r->read_body = read_policy; r->read_chunked = 0; @@ -1410,12 +1429,12 @@ if (tenc) { if (strcasecmp(tenc, "chunked")) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Unknown Transfer-Encoding %s", tenc); return HTTP_NOT_IMPLEMENTED; } if (r->read_body == REQUEST_CHUNKED_ERROR) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "chunked Transfer-Encoding forbidden: %s", r->uri); return (lenp) ? HTTP_BAD_REQUEST : HTTP_LENGTH_REQUIRED; } @@ -1425,10 +1444,10 @@ else if (lenp) { const char *pos = lenp; - while (isdigit(*pos) || isspace(*pos)) + while (ap_isdigit(*pos) || ap_isspace(*pos)) ++pos; if (*pos != '\0') { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid Content-Length %s", lenp); return HTTP_BAD_REQUEST; } @@ -1438,11 +1457,19 @@ if ((r->read_body == REQUEST_NO_BODY) && (r->read_chunked || (r->remaining > 0))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "%s with body is not allowed for %s", r->method, r->uri); return HTTP_REQUEST_ENTITY_TOO_LARGE; } + max_body = ap_get_limit_req_body(r); + if (max_body && (r->remaining > max_body)) { + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, + "Request content-length of %s is larger than the configured " + "limit of %lu", lenp, max_body); + return HTTP_REQUEST_ENTITY_TOO_LARGE; + } + return OK; } @@ -1503,6 +1530,7 @@ int c; long len_read, len_to_read; long chunk_start = 0; + unsigned long max_body; if (!r->read_chunked) { /* Content-length read */ len_to_read = (r->remaining > bufsiz) ? bufsiz : r->remaining; @@ -1527,6 +1555,20 @@ if (bufsiz <= 0) return -1; /* Cannot read chunked with a small buffer */ + /* Check to see if we have already read too much request data. + * For efficiency reasons, we only check this at the top of each + * caller read pass, since the limit exists just to stop infinite + * length requests and nobody cares if it goes over by one buffer. + */ + max_body = ap_get_limit_req_body(r); + if (max_body && (r->read_length > max_body)) { + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, + "Chunked request body is larger than the configured limit of %lu", + max_body); + r->connection->keepalive = -1; + return -1; + } + if (r->remaining == 0) { /* Start of new chunk */ chunk_start = getline(buffer, bufsiz, r->connection->client, 0); @@ -1642,7 +1684,7 @@ * Since we return an error status if the request is malformed, this * routine should be called at the beginning of a no-body handler, e.g., * - * if ((retval = discard_request_body(r)) != OK) + * if ((retval = ap_discard_request_body(r)) != OK) * return retval; */ API_EXPORT(int) ap_discard_request_body(request_rec *r) @@ -1711,11 +1753,8 @@ continue; #endif else { - ap_log_error(APLOG_MARK, APLOG_INFO, r->server, - "%s client stopped connection before send body completed", - ap_get_remote_host(r->connection, - r->per_dir_config, - REMOTE_NAME)); + ap_log_rerror(APLOG_MARK, APLOG_INFO, r, + "client stopped connection before send body completed"); ap_bsetflag(r->connection->client, B_EOUT, 1); break; } @@ -1799,11 +1838,8 @@ continue; #endif else { - ap_log_error(APLOG_MARK, APLOG_INFO, r->server, - "%s client stopped connection before send body completed", - ap_get_remote_host(r->connection, - r->per_dir_config, - REMOTE_NAME)); + ap_log_rerror(APLOG_MARK, APLOG_INFO, r, + "client stopped connection before send body completed"); ap_bsetflag(r->connection->client, B_EOUT, 1); break; } @@ -1865,11 +1901,8 @@ continue; #endif else { - ap_log_error(APLOG_MARK, APLOG_INFO, r->server, - "%s client stopped connection before send mmap completed", - ap_get_remote_host(r->connection, - r->per_dir_config, - REMOTE_NAME)); + ap_log_rerror(APLOG_MARK, APLOG_INFO, r, + "client stopped connection before send mmap completed"); ap_bsetflag(r->connection->client, B_EOUT, 1); break; } @@ -2021,7 +2054,7 @@ ap_clear_table(r->err_headers_out); if (location && *location - && (is_HTTP_REDIRECT(status) || status == HTTP_CREATED)) + && (ap_is_HTTP_REDIRECT(status) || status == HTTP_CREATED)) ap_table_setn(r->headers_out, "Location", location); r->content_language = NULL; @@ -2075,11 +2108,11 @@ */ if (r->status_line != NULL && strlen(r->status_line) > 4 /* long enough */ - && isdigit(r->status_line[0]) - && isdigit(r->status_line[1]) - && isdigit(r->status_line[2]) - && isspace(r->status_line[3]) - && isalnum(r->status_line[4])) { + && ap_isdigit(r->status_line[0]) + && ap_isdigit(r->status_line[1]) + && ap_isdigit(r->status_line[2]) + && ap_isspace(r->status_line[3]) + && ap_isalnum(r->status_line[4])) { title = r->status_line; } 1.3 +20 -25 apache-2.0/apache-nspr/main/http_request.c Index: http_request.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/http_request.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- http_request.c 1998/06/30 08:57:08 1.2 +++ http_request.c 1998/09/22 18:05:18 1.3 @@ -71,6 +71,7 @@ #include "http_request.h" #include "http_core.h" #include "http_protocol.h" +#include "http_conf_globals.h" /* for ap_extended_status */ #include "http_log.h" #include "http_main.h" #include "scoreboard.h" @@ -104,7 +105,7 @@ || r->finfo.type == PR_FILE_DIRECTORY) { return OK; } - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "object is not a file, directory or symlink: %s", r->filename); return HTTP_FORBIDDEN; @@ -114,7 +115,7 @@ static int check_symlinks(char *d, int opts) { /* XXX: figure out how to do symlink stuff on NSPR */ -#if 1 /* defined(__EMX__) || defined(WIN32) */ +#if 1 /* defined(OS2) || defined(WIN32) */ /* OS/2 doesn't have symlinks */ return OK; #else @@ -248,12 +249,10 @@ --cp; } else { - /* XXX: this is bogus, the error code is trashed by the ap_get_remote_host call */ - if (ec != PR_NO_ACCESS_RIGHTS_ERROR) - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, - "access to %s failed for %s", r->uri, - ap_get_remote_host(r->connection, r->per_dir_config, - REMOTE_NOLOOKUP)); + if (ec != PR_NO_ACCESS_RIGHTS_ERROR) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, + "access to %s failed", r->uri); + } return HTTP_FORBIDDEN; } } @@ -386,7 +385,7 @@ */ if ((res = check_symlinks(test_dirname, core_dir->opts))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Symbolic link not allowed: %s", test_dirname); return res; } @@ -481,7 +480,7 @@ */ if ((!r->file_exists || r->finfo.type != PR_FILE_DIRECTORY) && (res = check_symlinks(r->filename, ap_allow_options(r)))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Symbolic link not allowed: %s", r->filename); return res; } @@ -774,7 +773,7 @@ } else { if ((res = check_symlinks(rnew->filename, ap_allow_options(rnew)))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, rnew->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, rnew, "Symbolic link not allowed: %s", rnew->filename); rnew->status = res; return rnew; @@ -852,7 +851,7 @@ * Mainline request processing... */ -void ap_die(int type, request_rec *r) +API_EXPORT(void) ap_die(int type, request_rec *r) { int error_index = ap_index_of_response(type); char *custom_response = ap_response_code_string(r, error_index); @@ -948,7 +947,7 @@ * dying with a recursive server error... */ recursive_error = SERVER_ERROR; - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid error redirection directive: %s", custom_response); } @@ -959,7 +958,7 @@ static void decl_die(int status, char *phase, request_rec *r) { if (status == DECLINED) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_CRIT, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_CRIT, r, "configuration error: couldn't %s: %s", phase, r->uri); ap_die(SERVER_ERROR, r); } @@ -971,7 +970,7 @@ { /* Is there a require line configured for the type of *this* req? */ - array_header *reqs_arr = ap_requires(r); + const array_header *reqs_arr = ap_requires(r); require_line *reqs; int i; @@ -1002,7 +1001,7 @@ * headers! Have to dink things even to make sure the error message * comes through... */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "client sent illegal HTTP/0.9 request: %s", r->uri); r->header_only = 0; ap_die(BAD_REQUEST, r); @@ -1018,7 +1017,7 @@ * HTTP/1.1 mentions twice (S9, S14.23) that a request MUST contain * a Host: header, and the server MUST respond with 400 if it doesn't. */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "client sent HTTP/1.1 request without hostname (see RFC2068 section 9, and 14.23): %s", r->uri); ap_die(BAD_REQUEST, r); return; @@ -1159,18 +1158,15 @@ void ap_process_request(request_rec *r) { -#ifdef STATUS int old_stat; - ap_time_process_request(r->connection->child_num, START_PREQUEST); -#endif + if (ap_extended_status) + ap_time_process_request(r->connection->child_num, START_PREQUEST); process_request_internal(r); -#ifdef STATUS old_stat = ap_update_child_status(r->connection->child_num, SERVER_BUSY_LOG, r); -#endif /* * We want to flush the last packet if this isn't a pipelining connection @@ -1182,10 +1178,9 @@ ap_bhalfduplex(r->connection->client); ap_log_transaction(r); -#ifdef STATUS (void) ap_update_child_status(r->connection->child_num, old_stat, r); - ap_time_process_request(r->connection->child_num, STOP_PREQUEST); -#endif + if (ap_extended_status) + ap_time_process_request(r->connection->child_num, STOP_PREQUEST); } static table *rename_original_env(pool *p, table *t) 1.3 +2 -3 apache-2.0/apache-nspr/main/rfc1413.c Index: rfc1413.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/rfc1413.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- rfc1413.c 1998/06/30 08:57:08 1.2 +++ rfc1413.c 1998/09/22 18:05:19 1.3 @@ -68,7 +68,7 @@ */ /* Some small additions for Apache --- ditch the "sccsid" var if - * compiling with gcc (it *has* changed), include conf.h for the + * compiling with gcc (it *has* changed), include ap_config.h for the * prototypes it defines on at least one system (SunlOSs) which has * them missing from the standard header files, and one minor change * below (extra parens around assign "if (foo = bar) ..." to shut up @@ -236,9 +236,8 @@ if (get_rfc1413(sock, &conn->local_addr, &conn->remote_addr, user, srv) >= 0) result = user; - - ap_set_callback_and_alarm(NULL, 0); } + ap_set_callback_and_alarm(NULL, 0); ap_pclosesocket(conn->pool, sock); conn->remote_logname = result; 1.4 +52 -38 apache-2.0/apache-nspr/main/util.c Index: util.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/util.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- util.c 1998/09/19 19:15:44 1.3 +++ util.c 1998/09/22 18:05:19 1.4 @@ -191,7 +191,7 @@ } return -1; } - else if ((exp[y] != '?') && (tolower(str[x]) != tolower(exp[y]))) + else if ((exp[y] != '?') && (ap_tolower(str[x]) != ap_tolower(exp[y]))) return 1; } return (str[x] != '\0'); @@ -242,7 +242,7 @@ while ((c = *src++) != '\0') { if (c == '&') no = 0; - else if (c == '$' && isdigit(*src)) + else if (c == '$' && ap_isdigit(*src)) no = *src++ - '0'; else no = 10; @@ -267,7 +267,7 @@ while ((c = *src++) != '\0') { if (c == '&') no = 0; - else if (c == '$' && isdigit(*src)) + else if (c == '$' && ap_isdigit(*src)) no = *src++ - '0'; else no = 10; @@ -516,7 +516,7 @@ char *res; for (x = 0; (*line)[x]; x++) { - if (isspace((*line)[x])) { + if (ap_isspace((*line)[x])) { pos = x; break; } @@ -531,7 +531,7 @@ res = ap_palloc(atrans, pos + 1); ap_cpystrn(res, *line, pos + 1); - while (isspace((*line)[pos])) + while (ap_isspace((*line)[pos])) ++pos; *line += pos; @@ -597,7 +597,7 @@ char *res; char quote; - while (*str && isspace(*str)) + while (*str && ap_isspace(*str)) ++str; if (!*str) { @@ -620,13 +620,13 @@ } else { strend = str; - while (*strend && !isspace(*strend)) + while (*strend && !ap_isspace(*strend)) ++strend; res = substring_conf(p, str, strend - str, 0); } - while (*strend && isspace(*strend)) + while (*strend && ap_isspace(*strend)) ++strend; *line = strend; return res; @@ -763,28 +763,20 @@ break; } - /* Compress the line, reducing all blanks and tabs to one space. + /* * Leading and trailing white space is eliminated completely */ - src = dst = buf; - while (isspace(*src)) + src = buf; + while (ap_isspace(*src)) ++src; - while (*src != '\0') - { - /* Copy words */ - while (!isspace(*dst = *src) && *src != '\0') { - ++src; - ++dst; - } - if (*src == '\0') break; - *dst++ = ' '; - while (isspace(*src)) - ++src; - } - *dst = '\0'; /* blast trailing whitespace */ - while (--dst >= buf && isspace(*dst)) + dst = &src[strlen(src)]; + while (--dst >= src && ap_isspace(*dst)) *dst = '\0'; + /* Zap leading whitespace by shifting */ + if (src != buf) + for (dst = buf; (*dst++ = *src++) != '\0'; ) + ; #ifdef DEBUG_CFG_LINES ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, "Read config: %s", buf); @@ -840,7 +832,7 @@ */ } /* blast trailing whitespace */ - while (i > 0 && isspace(buf[i - 1])) + while (i > 0 && ap_isspace(buf[i - 1])) --i; buf[i] = '\0'; #ifdef DEBUG_CFG_LINES @@ -879,7 +871,7 @@ /* Find first non-white byte */ - while (*ptr && isspace(*ptr)) + while (*ptr && ap_isspace(*ptr)) ++ptr; tok_start = ptr; @@ -888,7 +880,7 @@ * (comments are already gone). */ - while (*ptr && (accept_white || !isspace(*ptr)) + while (*ptr && (accept_white || !ap_isspace(*ptr)) && *ptr != ';' && *ptr != ',') { if (*ptr++ == '"') while (*ptr) @@ -901,7 +893,7 @@ /* Advance accept_line pointer to the next non-white byte */ - while (*ptr && isspace(*ptr)) + while (*ptr && ap_isspace(*ptr)) ++ptr; *accept_line = ptr; @@ -956,7 +948,7 @@ lidx = llen - tlen; if ((lidx < 0) || - ((lidx > 0) && !(isspace(line[lidx - 1]) || line[lidx - 1] == ','))) + ((lidx > 0) && !(ap_isspace(line[lidx - 1]) || line[lidx - 1] == ','))) return 0; return (strncasecmp(&line[lidx], tok, tlen) == 0); @@ -973,7 +965,7 @@ s = (const unsigned char *)str; for (; *s; ++s) { -#if defined(__EMX__) || defined(WIN32) +#if defined(OS2) || defined(WIN32) /* Don't allow '&' in parameters under OS/2. */ /* This can be used to send commands to the shell. */ if (*s == '&') { @@ -1216,7 +1208,7 @@ for (x = 0; u[x] != ':'; x++) { if ((!u[x]) || - ((!isalpha(u[x])) && (!isdigit(u[x])) && + ((!ap_isalpha(u[x])) && (!ap_isdigit(u[x])) && (u[x] != '+') && (u[x] != '-') && (u[x] != '.'))) { return 0; } @@ -1245,7 +1237,7 @@ const char *p = a; const char *q = b; for (p = a, q = b; *p && *q; p++, q++) { - int diff = tolower(*p) - tolower(*q); + int diff = ap_tolower(*p) - ap_tolower(*q); if (diff) return diff; } @@ -1270,7 +1262,7 @@ return 0; /* Match up to n characters */ if (!(*p && *q)) return *p - *q; - diff = tolower(*p) - tolower(*q); + diff = ap_tolower(*p) - ap_tolower(*q); if (diff) return diff; } @@ -1384,7 +1376,7 @@ API_EXPORT(void) ap_str_tolower(char *str) { while (*str) { - *str = tolower(*str); + *str = ap_tolower(*str); ++str; } } @@ -1433,7 +1425,7 @@ */ /* XXX: ipv6 */ /* XXX: this is a silly name for this, it's not used for vhosts any longer */ -PRUint32 ap_get_virthost_addr(const char *w, PRUint16 *ports) +PRUint32 ap_get_virthost_addr(char *w, PRUint16 *ports) { char hentbuf[PR_NETDB_BUF_SIZE]; PRHostEnt hent; @@ -1599,8 +1591,30 @@ #endif /*CHARSET_EBCDIC*/ return bufplain; } + +static const char basis_64[] = +"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +API_EXPORT(char *) ap_uuencode(pool *a, char *string) +{ + int i, len = strlen(string); + char *p; + char *encoded = (char *) ap_pcalloc(a, (len+2) / 3 * 4); + + p = encoded; + for (i = 0; i < len; i += 3) { + *p++ = basis_64[string[i] >> 2]; + *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0) >> 4)]; + *p++ = basis_64[((string[i + 1] & 0xF) << 2) | ((int) (string[i + 2] & 0xC0) >> 6)]; + *p++ = basis_64[string[i + 2] & 0x3F]; + } + *p-- = '\0'; + *p-- = '='; + *p-- = '='; + return encoded; +} -#ifdef __EMX__ +#ifdef OS2 void os2pathname(char *path) { char newpath[MAX_STRING_LEN]; @@ -1665,7 +1679,7 @@ *semi = '\0'; } while (*str) { - *str = tolower(*str); + *str = ap_tolower(*str); ++str; } if (semi) { 1.3 +6 -6 apache-2.0/apache-nspr/main/util_date.c Index: util_date.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/util_date.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- util_date.c 1998/06/30 08:57:08 1.2 +++ util_date.c 1998/09/22 18:05:19 1.3 @@ -66,7 +66,7 @@ * */ -#include "conf.h" +#include "ap_config.h" #include "util_date.h" #include <ctype.h> #include <string.h> @@ -97,15 +97,15 @@ return 1; case '@': - if (!isupper(d)) + if (!ap_isupper(d)) return 0; break; case '$': - if (!islower(d)) + if (!ap_islower(d)) return 0; break; case '#': - if (!isdigit(d)) + if (!ap_isdigit(d)) return 0; break; case '&': @@ -113,7 +113,7 @@ return 0; break; case '~': - if ((d != ' ') && !isdigit(d)) + if ((d != ' ') && !ap_isdigit(d)) return 0; break; default: @@ -189,7 +189,7 @@ if (!date) return PR_FAILURE; - while (*date && isspace(*date)) /* Find first non-whitespace char */ + while (*date && ap_isspace(*date)) /* Find first non-whitespace char */ ++date; if (*date == '\0') 1.3 +7 -2 apache-2.0/apache-nspr/main/util_md5.c Index: util_md5.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/util_md5.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- util_md5.c 1998/06/30 08:57:08 1.2 +++ util_md5.c 1998/09/22 18:05:20 1.3 @@ -87,7 +87,7 @@ #include "httpd.h" #include "util_md5.h" -API_EXPORT(char *) ap_md5(pool *p, unsigned char *string) +API_EXPORT(char *) ap_md5_binary(pool *p, const unsigned char *buf, int length) { AP_MD5_CTX my_md5; unsigned char hash[16]; @@ -99,7 +99,7 @@ */ ap_MD5Init(&my_md5); - ap_MD5Update(&my_md5, string, strlen((const char *) string)); + ap_MD5Update(&my_md5, buf, length); ap_MD5Final(hash, &my_md5); for (i = 0, r = result; i < 16; i++, r += 2) @@ -107,6 +107,11 @@ *r = '\0'; return ap_pstrdup(p, result); +} + +API_EXPORT(char *) ap_md5(pool *p, const unsigned char *string) +{ + return ap_md5_binary(p, string, strlen(string)); } /* these portions extracted from mpack, John G. Myers - [EMAIL PROTECTED] */ 1.4 +89 -41 apache-2.0/apache-nspr/main/util_script.c Index: util_script.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/util_script.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- util_script.c 1998/09/19 19:15:44 1.3 +++ util_script.c 1998/09/22 18:05:20 1.4 @@ -139,11 +139,11 @@ char *cp = res; while (*++cp) { - if (!isalnum(*cp) && *cp != '_') { + if (!ap_isalnum(*cp) && *cp != '_') { *cp = '_'; } else { - *cp = toupper(*cp); + *cp = ap_toupper(*cp); } } @@ -166,11 +166,11 @@ } env[j] = ap_pstrcat(p, elts[i].key, "=", elts[i].val, NULL); whack = env[j]; - if (isdigit(*whack)) { + if (ap_isdigit(*whack)) { *whack++ = '_'; } while (*whack != '=') { - if (!isalnum(*whack) && *whack != '_') { + if (!ap_isalnum(*whack) && *whack != '_') { *whack = '_'; } ++whack; @@ -184,7 +184,7 @@ API_EXPORT(void) ap_add_common_vars(request_rec *r) { - table *e = r->subprocess_env; + table *e; server_rec *s = r->server; conn_rec *c = r->connection; const char *rem_logname; @@ -197,6 +197,11 @@ table_entry *hdrs = (table_entry *) hdrs_arr->elts; int i; + /* use a temporary table which we'll overlap onto + * r->subprocess_env later + */ + e = ap_make_table(r->pool, 25 + hdrs_arr->nelts); + /* First, add environment vars from headers... this is as per * CGI specs, though other sorts of scripting interfaces see * the same vars... @@ -213,10 +218,10 @@ */ if (!strcasecmp(hdrs[i].key, "Content-type")) { - ap_table_setn(e, "CONTENT_TYPE", hdrs[i].val); + ap_table_addn(e, "CONTENT_TYPE", hdrs[i].val); } else if (!strcasecmp(hdrs[i].key, "Content-length")) { - ap_table_setn(e, "CONTENT_LENGTH", hdrs[i].val); + ap_table_addn(e, "CONTENT_LENGTH", hdrs[i].val); } /* * You really don't want to disable this check, since it leaves you @@ -230,7 +235,7 @@ } #endif else { - ap_table_setn(e, http2env(r->pool, hdrs[i].key), hdrs[i].val); + ap_table_addn(e, http2env(r->pool, hdrs[i].key), hdrs[i].val); } } @@ -240,24 +245,24 @@ #ifdef WIN32 if (env_temp = getenv("SystemRoot")) { - ap_table_setn(e, "SystemRoot", env_temp); + ap_table_addn(e, "SystemRoot", env_temp); } if (env_temp = getenv("COMSPEC")) { - ap_table_setn(e, "COMSPEC", env_temp); + ap_table_addn(e, "COMSPEC", env_temp); } if (env_temp = getenv("WINDIR")) { - ap_table_setn(e, "WINDIR", env_temp); + ap_table_addn(e, "WINDIR", env_temp); } #endif - ap_table_setn(e, "PATH", env_path); - ap_table_setn(e, "SERVER_SOFTWARE", ap_get_server_version()); - ap_table_setn(e, "SERVER_NAME", ap_get_server_name(r)); - ap_table_setn(e, "SERVER_PORT", + ap_table_addn(e, "PATH", env_path); + ap_table_addn(e, "SERVER_SOFTWARE", ap_get_server_version()); + ap_table_addn(e, "SERVER_NAME", ap_get_server_name(r)); + ap_table_addn(e, "SERVER_PORT", ap_psprintf(r->pool, "%u", ap_get_server_port(r))); host = ap_get_remote_host(c, r->per_dir_config, REMOTE_HOST); if (host) { - ap_table_setn(e, "REMOTE_HOST", host); + ap_table_addn(e, "REMOTE_HOST", host); } ap_table_setn(e, "REMOTE_ADDR", c->remote_ip); ap_table_setn(e, "DOCUMENT_ROOT", ap_document_root(r)); /* Apache */ @@ -269,26 +274,28 @@ PR_ntohs(c->remote_addr.inet.port))); if (c->user) { - ap_table_setn(e, "REMOTE_USER", c->user); + ap_table_addn(e, "REMOTE_USER", c->user); } if (c->ap_auth_type) { - ap_table_setn(e, "AUTH_TYPE", c->ap_auth_type); + ap_table_addn(e, "AUTH_TYPE", c->ap_auth_type); } rem_logname = ap_get_remote_logname(r); if (rem_logname) { - ap_table_setn(e, "REMOTE_IDENT", ap_pstrdup(r->pool, rem_logname)); + ap_table_addn(e, "REMOTE_IDENT", ap_pstrdup(r->pool, rem_logname)); } /* Apache custom error responses. If we have redirected set two new vars */ if (r->prev) { if (r->prev->args) { - ap_table_setn(e, "REDIRECT_QUERY_STRING", r->prev->args); + ap_table_addn(e, "REDIRECT_QUERY_STRING", r->prev->args); } if (r->prev->uri) { - ap_table_setn(e, "REDIRECT_URL", r->prev->uri); + ap_table_addn(e, "REDIRECT_URL", r->prev->uri); } } + + ap_overlap_tables(r->subprocess_env, e, AP_OVERLAP_TABLES_SET); } /* This "cute" little function comes about because the path info on @@ -326,15 +333,15 @@ first = r->the_request; /* use the request-line */ - while (*first && !isspace(*first)) { + while (*first && !ap_isspace(*first)) { ++first; /* skip over the method */ } - while (isspace(*first)) { + while (ap_isspace(*first)) { ++first; /* and the space(s) */ } last = first; - while (*last && !isspace(*last)) { + while (*last && !ap_isspace(*last)) { ++last; /* end at next whitespace */ } @@ -403,17 +410,38 @@ } } + +static int set_cookie_doo_doo(void *v, const char *key, const char *val) +{ + ap_table_addn(v, key, val); + return 1; +} + API_EXPORT(int) ap_scan_script_header_err(request_rec *r, BUFF *fb) { char buf[MAX_STRING_LEN]; char *l; char *strp; int cgi_status = HTTP_OK; + table *merge; + table *cookie_table; + + /* temporary place to hold headers to merge in later */ + merge = ap_make_table(r->pool, 10); + + /* The HTTP specification says that it is legal to merge duplicate + * headers into one. Some browsers that support Cookies don't like + * merged headers and prefer that each Set-Cookie header is sent + * separately. Lets humour those browsers by not merging. + * Oh what a pain it is. + */ + cookie_table = ap_make_table(r->pool, 2); + ap_table_do(set_cookie_doo_doo, cookie_table, r->err_headers_out, "Set-Cookie", NULL); while (1) { if (ap_bgets(buf, sizeof(buf), fb) <= 0) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, - "Premature end of script headers: %s", r->filename); + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, + "Premature end of script headers: %s", r->filename); return HTTP_INTERNAL_SERVER_ERROR; } @@ -444,11 +472,38 @@ if ((cgi_status == HTTP_OK) && (r->method_number == M_GET)) { cond_status = ap_meets_conditions(r); } + ap_overlap_tables(r->err_headers_out, merge, + AP_OVERLAP_TABLES_MERGE); + if (!ap_is_empty_table(cookie_table)) { + r->err_headers_out = ap_overlay_tables(r->pool, + r->err_headers_out, cookie_table); + } return cond_status; } /* if we see a bogus header don't ignore it. Shout and scream */ +#ifdef CHARSET_EBCDIC + /* Chances are that we received an ASCII header text instead of + * the expected EBCDIC header lines. Try to auto-detect: + */ + if (!(l = strchr(buf, ':'))) { + int maybeASCII = 0, maybeEBCDIC = 0; + char *cp; + + for (cp = buf; *cp != '\0'; ++cp) { + if (isprint(*cp) && !isprint(os_toebcdic[*cp])) + ++maybeEBCDIC; + if (!isprint(*cp) && isprint(os_toebcdic[*cp])) + ++maybeASCII; + } + if (maybeASCII > maybeEBCDIC) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + "CGI Interface Error: Script headers apparently ASCII: (CGI = %s)", r->filename); + ascii2ebcdic(buf, buf, cp - buf); + } + } +#endif if (!(l = strchr(buf, ':'))) { char malformed[(sizeof MALFORMED_MESSAGE) + 1 + MALFORMED_HEADER_LENGTH_TO_SHOW]; @@ -460,13 +515,13 @@ while (ap_bgets(buf, sizeof(buf), fb) > 0) continue; - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, - "%s: %s", malformed, r->filename); - return SERVER_ERROR; + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, + "%s: %s", malformed, r->filename); + return HTTP_INTERNAL_SERVER_ERROR; } *l++ = '\0'; - while (*l && isspace(*l)) { + while (*l && ap_isspace(*l)) { ++l; } @@ -476,7 +531,7 @@ /* Nuke trailing whitespace */ char *endp = l + strlen(l) - 1; - while (endp > l && isspace(*endp)) { + while (endp > l && ap_isspace(*endp)) { *endp-- = '\0'; } @@ -527,22 +582,15 @@ ap_table_set(r->headers_out, buf, l); cgi_status = atoi(l); } - - /* The HTTP specification says that it is legal to merge duplicate - * headers into one. Some browsers that support Cookies don't like - * merged headers and prefer that each Set-Cookie header is sent - * separately. Lets humour those browsers. - */ else if (!strcasecmp(buf, "Set-Cookie")) { - ap_table_add(r->err_headers_out, buf, l); + ap_table_add(cookie_table, buf, l); } else { - ap_table_merge(r->err_headers_out, buf, l); + ap_table_add(merge, buf, l); } } } - /* XXX: what the heck is this doing in util_script.c? */ API_EXPORT(void) ap_send_size(size_t size, request_rec *r) { @@ -568,7 +616,7 @@ } -#if defined(__EMX__) || defined(WIN32) +#if defined(OS2) || defined(WIN32) static char **create_argv_cmd(pool *p, char *av0, const char *args, char *path) { register int x, n; 1.3 +8 -0 apache-2.0/apache-nspr/modules/example/mod_example.c Index: mod_example.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/example/mod_example.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_example.c 1998/06/30 08:57:08 1.2 +++ mod_example.c 1998/09/22 18:05:24 1.3 @@ -1126,8 +1126,16 @@ example_type_checker, /* [7] MIME type checker/setter */ example_fixer_upper, /* [8] fixups */ example_logger, /* [10] logger */ +#if MODULE_MAGIC_NUMBER >= 19970103 example_header_parser, /* [3] header parser */ +#endif +#if MODULE_MAGIC_NUMBER >= 19970719 example_child_init, /* process initializer */ +#endif +#if MODULE_MAGIC_NUMBER >= 19970728 example_child_exit, /* process exit/cleanup */ +#endif +#if MODULE_MAGIC_NUMBER >= 19970902 example_post_read_request /* [1] post read_request handling */ +#endif }; 1.3 +6 -1 apache-2.0/apache-nspr/modules/experimental/mod_mmap_static.c Index: mod_mmap_static.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/experimental/mod_mmap_static.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_mmap_static.c 1998/06/30 08:57:08 1.2 +++ mod_mmap_static.c 1998/09/22 18:05:25 1.3 @@ -279,12 +279,17 @@ a_file *match; int res; + sconf = ap_get_module_config(r->server->module_config, &mmap_static_module); + + /* we only operate when at least one mmapfile directive was used */ + if (ap_is_empty_table(sconf->files)) + return DECLINED; + /* we require other modules to first set up a filename */ res = core_module.translate_handler(r); if (res == DECLINED || !r->filename) { return res; } - sconf = ap_get_module_config(r->server->module_config, &mmap_static_module); tmp.filename = r->filename; match = (a_file *)bsearch(&tmp, sconf->files->elts, sconf->files->nelts, sizeof(a_file), file_compare); 1.3 +1 -38 apache-2.0/apache-nspr/modules/proxy/Makefile.tmpl Index: Makefile.tmpl =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/proxy/Makefile.tmpl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile.tmpl 1998/06/30 08:57:08 1.2 +++ Makefile.tmpl 1998/09/22 18:05:26 1.3 @@ -19,7 +19,7 @@ libproxy.so: $(OBJS_PIC) rm -f $@ - $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(OBJS_PIC) + $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(OBJS_PIC) $(LIBS_SHLIB) .SUFFIXES: .o .lo @@ -52,40 +52,3 @@ $(OBJS) $(OBJS_PIC): Makefile # DO NOT REMOVE -mod_proxy.o: mod_proxy.c mod_proxy.h $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/explain.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_vhost.h -proxy_cache.o: proxy_cache.c mod_proxy.h $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/explain.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_main.h $(INCDIR)/util_date.h \ - $(INCDIR)/md5.h -proxy_connect.o: proxy_connect.c mod_proxy.h $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/explain.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_main.h -proxy_ftp.o: proxy_ftp.c mod_proxy.h $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/explain.h $(INCDIR)/http_main.h -proxy_http.o: proxy_http.c mod_proxy.h $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/explain.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_main.h $(INCDIR)/http_core.h \ - $(INCDIR)/util_date.h -proxy_util.o: proxy_util.c mod_proxy.h $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/explain.h $(INCDIR)/http_main.h $(INCDIR)/md5.h \ - $(INCDIR)/http_log.h 1.3 +80 -77 apache-2.0/apache-nspr/modules/proxy/proxy_cache.c Index: proxy_cache.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/proxy/proxy_cache.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- proxy_cache.c 1998/06/30 08:57:08 1.2 +++ proxy_cache.c 1998/09/22 18:05:27 1.3 @@ -118,7 +118,7 @@ static int sub_garbage_coll(request_rec *r, array_header *files, const char *cachedir, const char *cachesubdir); static void help_proxy_garbage_coll(request_rec *r); -#if !defined(WIN32) && !defined(MPE) && !defined(__EMX__) +#if !defined(WIN32) && !defined(MPE) && !defined(OS2) static void detached_proxy_garbage_coll(request_rec *r); #endif @@ -137,7 +137,7 @@ (void) ap_release_mutex(garbage_mutex); ap_block_alarms(); /* avoid SIGALRM on big cache cleanup */ -#if !defined(WIN32) && !defined(MPE) && !defined(__EMX__) +#if !defined(WIN32) && !defined(MPE) && !defined(OS2) detached_proxy_garbage_coll(r); #else help_proxy_garbage_coll(r); @@ -197,7 +197,7 @@ return 0; } -#if !defined(WIN32) && !defined(MPE) && !defined(__EMX__) +#if !defined(WIN32) && !defined(MPE) && !defined(OS2) static void detached_proxy_garbage_coll(request_rec *r) { pid_t pid; @@ -331,7 +331,7 @@ if (cmp_long61(&curbytes, &cachesize) < 0L) { ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r->server, "proxy GC: Cache is %ld%% full (nothing deleted)", - (long)((curbytes.upper<<20)|(curbytes.lower>>10))*100/conf->space); + (long)(((curbytes.upper<<20)|(curbytes.lower>>10))*100/conf->space)); ap_unblock_alarms(); return; } @@ -362,7 +362,7 @@ ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r->server, "proxy GC: Cache is %ld%% full (%d deleted)", - (long)((curbytes.upper<<20)|(curbytes.lower>>10))*100/conf->space, i); + (long)(((curbytes.upper<<20)|(curbytes.lower>>10))*100/conf->space), i); ap_unblock_alarms(); } @@ -423,7 +423,7 @@ /* if (strlen(ent->d_name) != HASH_LEN) continue; */ /* under OS/2 use dirent's d_attr to identify a diretory */ -#ifdef __EMX__ +#ifdef OS2 /* is it a directory? */ if (ent->d_attr & A_DIR) { char newcachedir[HUGE_STRING_LEN]; @@ -459,7 +459,7 @@ } /* In OS/2 this has already been done above */ -#ifndef __EMX__ +#ifndef OS2 if (S_ISDIR(buf.st_mode)) { char newcachedir[HUGE_STRING_LEN]; close(fd); @@ -535,7 +535,7 @@ * 0 on failure (bad file or wrong URL) * -1 on UNIX error */ -static int rdcache(pool *p, BUFF *cachefp, struct cache_req *c) +static int rdcache(request_rec *r, BUFF *cachefp, cache_req *c) { char urlbuff[1034], *strp; int len; @@ -544,7 +544,7 @@ * date SP lastmod SP expire SP count SP content-length CRLF * dates are stored as hex seconds since 1970 */ - len = ap_bgets(urlbuff, 1034, cachefp); + len = ap_bgets(urlbuff, sizeof urlbuff, cachefp); if (len == -1) return -1; if (len == 0 || urlbuff[len - 1] != '\n') @@ -562,7 +562,7 @@ c->len = ap_proxy_hex2sec(urlbuff + 36); /* check that we have the same URL */ - len = ap_bgets(urlbuff, 1034, cachefp); + len = ap_bgets(urlbuff, sizeof urlbuff, cachefp); if (len == -1) return -1; if (len == 0 || strncmp(urlbuff, "X-URL: ", 7) != 0 || @@ -573,29 +573,26 @@ return 0; /* What follows is the message */ - len = ap_bgets(urlbuff, 1034, cachefp); + len = ap_bgets(urlbuff, sizeof urlbuff, cachefp); if (len == -1) return -1; if (len == 0 || urlbuff[len - 1] != '\n') return 0; urlbuff[--len] = '\0'; - c->resp_line = ap_pstrdup(p, urlbuff); + c->resp_line = ap_pstrdup(r->pool, urlbuff); strp = strchr(urlbuff, ' '); if (strp == NULL) return 0; c->status = atoi(strp); - c->hdrs = ap_proxy_read_headers(p, urlbuff, 1034, cachefp); + c->hdrs = ap_proxy_read_headers(r, urlbuff, sizeof urlbuff, cachefp); if (c->hdrs == NULL) return -1; if (c->len != -1) { /* add a content-length header */ - struct hdr_entry *q; - q = ap_proxy_get_header(c->hdrs, "Content-Length"); - if (q == NULL) { - strp = ap_palloc(p, 15); - ap_snprintf(strp, 15, "%lu", (unsigned long)c->len); - ap_proxy_add_header(c->hdrs, "Content-Length", strp, HDR_REP); + if (ap_table_get(c->hdrs, "Content-Length") == NULL) { + ap_table_set(c->hdrs, "Content-Length", + ap_psprintf(r->pool, "%lu", (unsigned long)c->len)); } } return 1; @@ -617,11 +614,11 @@ * last modified date to request */ int ap_proxy_cache_check(request_rec *r, char *url, struct cache_conf *conf, - struct cache_req **cr) + cache_req **cr) { char hashfile[66]; const char *imstr, *pragma, *auth; - struct cache_req *c; + cache_req *c; time_t now; BUFF *cachefp; int cfd, i; @@ -630,7 +627,7 @@ proxy_server_conf *pconf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module); - c = ap_pcalloc(r->pool, sizeof(struct cache_req)); + c = ap_pcalloc(r->pool, sizeof(cache_req)); *cr = c; c->req = r; c->url = ap_pstrdup(r->pool, url); @@ -670,7 +667,7 @@ ap_bpushfd(cachefp, cfd); } else if (errno != ENOENT) - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error opening cache file %s", c->filename); #ifdef EXPLAIN @@ -680,21 +677,24 @@ } if (cachefp != NULL) { - i = rdcache(r->pool, cachefp, c); + i = rdcache(r, cachefp, c); if (i == -1) - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error reading cache file %s", c->filename); else if (i == 0) - ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r, "proxy: bad (short?) cache file: %s", c->filename); if (i != 1) { ap_pclosef(r->pool, cachefp->fd); cachefp = NULL; } } +/* fixed? in this case, we want to get the headers from the remote server + it will be handled later if we don't do this (I hope ;-) if (cachefp == NULL) - c->hdrs = ap_make_array(r->pool, 2, sizeof(struct hdr_entry)); + c->hdrs = ap_make_table(r->pool, 20); +*/ /* FIXME: Shouldn't we check the URL somewhere? */ now = time(NULL); /* Ok, have we got some un-expired data? */ @@ -705,16 +705,12 @@ /* has the cached file changed since this request? */ if (c->date == BAD_DATE || c->date > c->ims) { /* No, but these header values may have changed, so we send them with the - * 304 response + * 304 HTTP_NOT_MODIFIED response */ - /* CHECKME: surely this was wrong? (Ben) - p = table_get(r->headers_in, "Expires"); - */ - struct hdr_entry *q; - - q = ap_proxy_get_header(c->hdrs, "Expires"); - if (q != NULL && q->value != NULL) - ap_table_set(r->headers_out, "Expires", q->value); + const char *q; + + if ((q = ap_table_get(c->hdrs, "Expires")) != NULL) + ap_table_set(r->headers_out, "Expires", q); } ap_pclosef(r->pool, cachefp->fd); Explain0("Use local copy, cached file hasn't changed"); @@ -733,7 +729,7 @@ ap_bsetopt(r->connection->client, BO_BYTECT, &zero); r->sent_bodyct = 1; if (!r->header_only) - ap_proxy_send_fb(cachefp, r, NULL, NULL); + ap_proxy_send_fb(cachefp, r, NULL); ap_pclosef(r->pool, cachefp->fd); return OK; } @@ -748,13 +744,11 @@ * from the cache */ if (c->ims == BAD_DATE || c->ims < c->lmod) { - struct hdr_entry *q; + const char *q; - q = ap_proxy_get_header(c->hdrs, "Last-Modified"); - - if (q != NULL && q->value != NULL) + if ((q = ap_table_get(c->hdrs, "Last-Modified")) != NULL) ap_table_set(r->headers_in, "If-Modified-Since", - (char *) q->value); + (char *) q); } } c->fp = cachefp; @@ -776,7 +770,7 @@ * from the cache, maybe updating the header line * otherwise, delete the old cached file and open a new temporary file */ -int ap_proxy_cache_update(struct cache_req *c, array_header *resp_hdrs, +int ap_proxy_cache_update(cache_req *c, table *resp_hdrs, const int is_HTTP1, int nocache) { #ifdef ULTRIX_BRAIN_DEATH @@ -785,7 +779,7 @@ request_rec *r = c->req; char *p; int i; - struct hdr_entry *expire, *dates, *lmods, *clen; + const char *expire, *lmods, *dates, *clen; time_t expc, date, lmod, now; char buff[46]; void *sconf = r->server->module_config; @@ -799,21 +793,20 @@ /* read expiry date; if a bad date, then leave it so the client can * read it */ - expire = ap_proxy_get_header(resp_hdrs, "Expires"); + expire = ap_table_get(resp_hdrs, "Expires"); if (expire != NULL) - expc = ap_parseHTTPdate(expire->value); + expc = ap_parseHTTPdate(expire); else expc = BAD_DATE; /* * read the last-modified date; if the date is bad, then delete it */ - lmods = ap_proxy_get_header(resp_hdrs, "Last-Modified"); + lmods = ap_table_get(resp_hdrs, "Last-Modified"); if (lmods != NULL) { - lmod = ap_parseHTTPdate(lmods->value); + lmod = ap_parseHTTPdate(lmods); if (lmod == BAD_DATE) { /* kill last modified date */ - lmods->value = NULL; lmods = NULL; } } @@ -823,16 +816,18 @@ /* * what responses should we not cache? * Unknown status responses and those known to be uncacheable - * 304 response when we have no valid cache file, or - * 200 response from HTTP/1.0 and up without a Last-Modified header, or + * 304 HTTP_NOT_MODIFIED response when we have no valid cache file, or + * 200 HTTP_OK response from HTTP/1.0 and up without a Last-Modified header, or * HEAD requests, or * requests with an Authorization header, or * protocol requests nocache (e.g. ftp with user/password) */ - if ((r->status != 200 && r->status != 301 && r->status != 304) || +/* @@@ XXX FIXME: is the test "r->status != HTTP_MOVED_PERMANENTLY" corerct? + * or shouldn't it be "ap_is_HTTP_REDIRECT(r->status)" ? -MnKr */ + if ((r->status != HTTP_OK && r->status != HTTP_MOVED_PERMANENTLY && r->status != HTTP_NOT_MODIFIED) || (expire != NULL && expc == BAD_DATE) || - (r->status == 304 && c->fp == NULL) || - (r->status == 200 && lmods == NULL && is_HTTP1) || + (r->status == HTTP_NOT_MODIFIED && (c == NULL || c->fp == NULL)) || + (r->status == HTTP_OK && lmods == NULL && is_HTTP1) || r->header_only || ap_table_get(r->headers_in, "Authorization") != NULL || nocache) { @@ -843,7 +838,8 @@ c->fp = NULL; } /* delete the previously cached file */ - unlink(c->filename); + if (c->filename) + unlink(c->filename); return DECLINED; /* send data to client but not cache */ } @@ -851,9 +847,9 @@ /* * Read the date. Generate one if one is not supplied */ - dates = ap_proxy_get_header(resp_hdrs, "Date"); + dates = ap_table_get(resp_hdrs, "Date"); if (dates != NULL) - date = ap_parseHTTPdate(dates->value); + date = ap_parseHTTPdate(dates); else date = BAD_DATE; @@ -864,8 +860,8 @@ /* add one; N.B. use the time _now_ rather than when we were checking the cache */ date = now; - p = ap_gm_timestr_822(r->pool, now); - dates = ap_proxy_add_header(resp_hdrs, "Date", p, HDR_REP); + dates = ap_gm_timestr_822(r->pool, now); + ap_table_set(resp_hdrs, "Date", dates); Explain0("Added date header"); } @@ -874,7 +870,7 @@ /* if its in the future, then replace by date */ { lmod = date; - lmods->value = dates->value; + lmods = dates; Explain0("Last modified is in the future, replacing with now"); } /* if the response did not contain the header, then use the cached version */ @@ -885,9 +881,9 @@ /* we now need to calculate the expire data for the object. */ if (expire == NULL && c->fp != NULL) { /* no expiry data sent in response */ - expire = ap_proxy_get_header(c->hdrs, "Expires"); + expire = ap_table_get(c->hdrs, "Expires"); if (expire != NULL) - expc = ap_parseHTTPdate(expire->value); + expc = ap_parseHTTPdate(expire); } /* so we now have the expiry date */ /* if no expiry date then @@ -911,11 +907,11 @@ } /* get the content-length header */ - clen = ap_proxy_get_header(resp_hdrs, "Content-Length"); + clen = ap_table_get(resp_hdrs, "Content-Length"); if (clen == NULL) c->len = -1; else - c->len = atoi(clen->value); + c->len = atoi(clen); ap_proxy_sec2hex(date, buff); buff[8] = ' '; @@ -930,18 +926,18 @@ buff[45] = '\0'; /* if file not modified */ - if (r->status == 304) { + if (r->status == HTTP_NOT_MODIFIED) { if (c->ims != BAD_DATE && lmod != BAD_DATE && lmod <= c->ims) { /* set any changed headers somehow */ /* update dates and version, but not content-length */ if (lmod != c->lmod || expc != c->expire || date != c->date) { off_t curpos = lseek(c->fp->fd, 0, SEEK_SET); if (curpos == -1) - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error seeking on cache file %s", c->filename); else if (write(c->fp->fd, buff, 35) == -1) - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error updating cache file %s", c->filename); } @@ -963,18 +959,18 @@ ap_bsetopt(r->connection->client, BO_BYTECT, &zero); r->sent_bodyct = 1; if (!r->header_only) - ap_proxy_send_fb(c->fp, r, NULL, NULL); + ap_proxy_send_fb(c->fp, r, NULL); /* set any changed headers somehow */ /* update dates and version, but not content-length */ if (lmod != c->lmod || expc != c->expire || date != c->date) { off_t curpos = lseek(c->fp->fd, 0, SEEK_SET); if (curpos == -1) - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error seeking on cache file %s", c->filename); else if (write(c->fp->fd, buff, 35) == -1) - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error updating cache file %s", c->filename); } @@ -1007,7 +1003,7 @@ i = open(c->tempfile, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0622); if (i == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error creating cache file %s", c->tempfile); return DECLINED; @@ -1017,7 +1013,7 @@ ap_bpushfd(c->fp, i); if (ap_bvputs(c->fp, buff, "X-URL: ", c->url, "\n", NULL) == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error writing cache file(%s)", c->tempfile); ap_pclosef(r->pool, c->fp->fd); unlink(c->tempfile); @@ -1026,15 +1022,20 @@ return DECLINED; } -void ap_proxy_cache_tidy(struct cache_req *c) +void ap_proxy_cache_tidy(cache_req *c) { - server_rec *s = c->req->server; + server_rec *s; PRUint32 bc; - if (c->fp == NULL) + if (c == NULL || c->fp == NULL) return; + s = c->req->server; + +/* don't care how much was sent, but rather how much was written to cache ap_bgetopt(c->req->connection->client, BO_BYTECT, &bc); + */ + bc = c->written; if (c->len != -1) { /* file lengths don't match; don't cache it */ @@ -1044,11 +1045,13 @@ return; } } +/* don't care if aborted, cache it if fully retrieved from host! else if (c->req->connection->aborted) { - ap_pclosef(c->req->pool, c->fp->fd); /* no need to flush */ + ap_pclosef(c->req->pool, c->fp->fd); / no need to flush / unlink(c->tempfile); return; } +*/ else { /* update content-length of file */ char buff[9]; @@ -1108,7 +1111,7 @@ *p = '/'; ++p; } -#if defined(__EMX__) || defined(WIN32) +#if defined(OS2) || defined(WIN32) /* Under OS/2 use rename. */ if (rename(c->tempfile, c->filename) == -1) ap_log_error(APLOG_MARK, APLOG_ERR, s, 1.3 +27 -8 apache-2.0/apache-nspr/modules/proxy/proxy_connect.c Index: proxy_connect.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/proxy/proxy_connect.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- proxy_connect.c 1998/06/30 08:57:09 1.2 +++ proxy_connect.c 1998/09/22 18:05:27 1.3 @@ -97,7 +97,21 @@ * FIXME: no check for r->assbackwards, whatever that is. */ -int ap_proxy_connect_handler(request_rec *r, struct cache_req *c, char *url, +static int +allowed_port(proxy_server_conf *conf, int port) +{ + int i; + int *list = (int *) conf->allowed_connect_ports->elts; + + for(i = 0; i < conf->allowed_connect_ports->nelts; i++) { + if(port == list[i]) + return 1; + } + return 0; +} + + +int ap_proxy_connect_handler(request_rec *r, cache_req *c, char *url, const char *proxyhost, int proxyport) { struct sockaddr_in server; @@ -138,13 +152,18 @@ return ap_proxyerror(r, "Connect to remote machine blocked"); } - switch (port) { - case DEFAULT_HTTPS_PORT: + /* Check if it is an allowed port */ + if (conf->allowed_connect_ports->nelts == 0) { + /* Default setting if not overridden by AllowCONNECT */ + switch (port) { + case DEFAULT_HTTPS_PORT: case DEFAULT_SNEWS_PORT: - break; - default: - return HTTP_SERVICE_UNAVAILABLE; - } + break; + default: + return HTTP_FORBIDDEN; + } + } else if(!allowed_port(conf, port)) + return HTTP_FORBIDDEN; if (proxyhost) { Explain2("CONNECT to remote proxy %s on port %d", proxyhost, proxyport); @@ -161,7 +180,7 @@ sock = ap_ptcpsocket(r->pool); if (!sock) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error creating socket"); return HTTP_INTERNAL_SERVER_ERROR; } 1.3 +341 -231 apache-2.0/apache-nspr/modules/proxy/proxy_ftp.c Index: proxy_ftp.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/proxy/proxy_ftp.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- proxy_ftp.c 1998/06/30 08:57:09 1.2 +++ proxy_ftp.c 1998/09/22 18:05:27 1.3 @@ -61,6 +61,8 @@ #include "http_main.h" #include "http_log.h" +#define AUTODETECT_PWD + DEF_Explain /* @@ -195,8 +197,8 @@ if (len == -1) return -1; /* check format */ - if (len < 5 || !isdigit(linebuff[0]) || !isdigit(linebuff[1]) || - !isdigit(linebuff[2]) || (linebuff[3] != ' ' && linebuff[3] != '-')) + if (len < 5 || !ap_isdigit(linebuff[0]) || !ap_isdigit(linebuff[1]) || + !ap_isdigit(linebuff[2]) || (linebuff[3] != ' ' && linebuff[3] != '-')) status = 0; else status = 100 * linebuff[0] + 10 * linebuff[1] + linebuff[2] - 111 * '0'; @@ -236,8 +238,8 @@ len = ap_bgets(linebuff, sizeof linebuff, f); if (len == -1) return -1; - if (len < 5 || !isdigit(linebuff[0]) || !isdigit(linebuff[1]) || - !isdigit(linebuff[2]) || (linebuff[3] != ' ' && linebuff[3] != '-')) + if (len < 5 || !ap_isdigit(linebuff[0]) || !ap_isdigit(linebuff[1]) || + !ap_isdigit(linebuff[2]) || (linebuff[3] != ' ' && linebuff[3] != '-')) status = 0; else status = 100 * linebuff[0] + 10 * linebuff[1] + linebuff[2] - 111 * '0'; @@ -263,65 +265,38 @@ return status; } -static long int send_dir(BUFF *f, request_rec *r, BUFF *f2, struct cache_req *c, char *url) +static long int send_dir(BUFF *f, request_rec *r, cache_req *c, char *cwd) { char buf[IOBUFSIZE]; char buf2[IOBUFSIZE]; char *filename; - char *tempurl; int searchidx = 0; char *searchptr = NULL; int firstfile = 1; - char urlptr[HUGE_STRING_LEN]; unsigned long total_bytes_sent = 0; register int n, o, w; - int hostlen; conn_rec *con = r->connection; - char *dir, *path, *reldir, *site, *psite; - const char *sig; - - tempurl = ap_pstrdup(r->pool, url); - - (void)decodeenc(tempurl); - - /* Determine length of "scheme://site" prefix */ - for (hostlen=0; tempurl[hostlen]!='/'; ++hostlen) - continue; - if (tempurl[hostlen] == '/' && tempurl[hostlen+1] == '/') { - for (hostlen+=2; tempurl[hostlen]!='/' && tempurl[hostlen]!='?'; ++hostlen) - continue; - } else { - hostlen = 0; - } - - /* Save "scheme://site" prefix */ - site = psite = ap_pstrndup(r->pool, tempurl, hostlen); - - if ((n = strcspn(tempurl, "@")) != strlen(tempurl) && n < hostlen) { /* hide user/passwd */ - memmove(tempurl + (n - 5), tempurl, 6); - tempurl += n - 5; /* leave room for ftp:// */ - hostlen -= (n-5); + char *dir, *path, *reldir, *site; - /* Save "scheme://site" prefix without user/password */ - site = ap_pstrndup(r->pool, tempurl, hostlen); - } + /* Save "scheme://site" prefix without password */ + site = ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD|UNP_OMITPATHINFO); + /* ... and path without query args */ + path = ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITSITEPART|UNP_OMITQUERY); + (void)decodeenc(path); /* Copy path, strip (all except the last) trailing slashes */ - path = dir = ap_pstrcat(r->pool, tempurl+hostlen, "/", NULL); + path = dir = ap_pstrcat(r->pool, path, "/", NULL); while ((n = strlen(path)) > 1 && path[n-1] == '/' && path[n-2] == '/') path[n-1] = '\0'; /* print "ftp://host/" */ - ap_snprintf(buf, sizeof(buf), "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n" - "<HTML><HEAD><TITLE>%s</TITLE>\n" + n = ap_snprintf(buf, sizeof(buf), "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n" + "<HTML><HEAD><TITLE>%s%s</TITLE>\n" "<BASE HREF=\"%s%s\"></HEAD>\n" "<BODY><H2>Directory of " "<A HREF=\"/\">%s</A>/", - tempurl, psite, path, site); - ap_bputs(buf, con->client); - if (f2 != NULL) - ap_bputs(buf, f2); - total_bytes_sent += strlen(buf); + site, path, site, path, site); + total_bytes_sent += ap_proxy_bputs2(buf, con->client, c); while ((dir = strchr(dir+1, '/')) != NULL) { @@ -332,31 +307,23 @@ ++reldir; /* print "path/" component */ ap_snprintf(buf, sizeof(buf), "<A HREF=\"/%s/\">%s</A>/", path+1, reldir); - ap_bputs(buf, con->client); - if (f2 != NULL) - ap_bputs(buf, f2); - total_bytes_sent += strlen(buf); + total_bytes_sent += ap_proxy_bputs2(buf, con->client, c); *dir = '/'; + } + /* If the caller has determined the current directory, and it differs */ + /* from what the client requested, then show the real name */ + if (cwd == NULL || strncmp (cwd, path, strlen(cwd)) == 0) { + ap_snprintf(buf, sizeof(buf), "</H2>\n<HR><PRE>"); + } else { + ap_snprintf(buf, sizeof(buf), "</H2>\n(%s)\n<HR><PRE>", cwd); } - ap_snprintf(buf, sizeof(buf), "</H2>\n<HR><PRE>"); - ap_bputs(buf, con->client); - if (f2 != NULL) - ap_bputs(buf, f2); - total_bytes_sent += strlen(buf); - - for (hostlen=0; url[hostlen]!='/'; ++hostlen) - continue; - if (url[hostlen] == '/' && url[hostlen+1] == '/') { - for (hostlen+=2; url[hostlen]!='/' && url[hostlen]!='?'; ++hostlen) - continue; - } else - hostlen = 0; + total_bytes_sent += ap_proxy_bputs2(buf, con->client, c); while (!con->aborted) { n = ap_bgets(buf, sizeof buf, f); if (n == -1) { /* input error */ - if (f2 != NULL) - f2 = ap_proxy_cache_error(c); + if (c != NULL) + c = ap_proxy_cache_error(c); break; } if (n == 0) @@ -364,20 +331,19 @@ if (buf[0] == 'l' && (filename=strstr(buf, " -> ")) != NULL) { char *link_ptr = filename; - do + do { filename--; - while (filename[0] != ' '); - *(filename++) = 0; - *(link_ptr++) = 0; + } while (filename[0] != ' '); + *(filename++) = '\0'; + *(link_ptr++) = '\0'; if ((n = strlen(link_ptr)) > 1 && link_ptr[n - 1] == '\n') link_ptr[n - 1] = '\0'; - ap_snprintf(urlptr, sizeof(urlptr), "%s%s%s", url+hostlen, (url[strlen(url) - 1] == '/' ? "" : "/"), filename); ap_snprintf(buf2, sizeof(buf2), "%s <A HREF=\"%s\">%s %s</A>\n", buf, filename, filename, link_ptr); ap_cpystrn(buf, buf2, sizeof(buf)); n = strlen(buf); } - else if (buf[0] == 'd' || buf[0] == '-' || buf[0] == 'l' || isdigit(buf[0])) { - if (isdigit(buf[0])) { /* handle DOS dir */ + else if (buf[0] == 'd' || buf[0] == '-' || buf[0] == 'l' || ap_isdigit(buf[0])) { + if (ap_isdigit(buf[0])) { /* handle DOS dir */ searchptr = strchr(buf, '<'); if (searchptr != NULL) *searchptr = '['; @@ -416,9 +382,8 @@ o = 0; total_bytes_sent += n; - if (f2 != NULL) - if (ap_bwrite(f2, buf, n) != n) - f2 = ap_proxy_cache_error(c); + if (c != NULL && c->fp && ap_bwrite(c->fp, buf, n) != n) + c = ap_proxy_cache_error(c); while (n && !r->connection->aborted) { w = ap_bwrite(con->client, &buf[o], n); @@ -429,52 +394,71 @@ o += w; } } - site = "</PRE><HR>\n"; - ap_bputs(site, con->client); - if (f2 != NULL) - ap_bputs(site, f2); - total_bytes_sent += strlen(site); - - sig = ap_psignature("", r); - ap_bputs(sig, con->client); - if (f2 != NULL) - ap_bputs(sig, f2); - total_bytes_sent += strlen(sig); - - site = "</BODY></HTML>\n"; - ap_bputs(site, con->client); - if (f2 != NULL) - ap_bputs(site, f2); - total_bytes_sent += strlen(site); + + total_bytes_sent += ap_proxy_bputs2("</PRE><HR>\n", con->client, c); + total_bytes_sent += ap_proxy_bputs2(ap_psignature("", r), con->client, c); + total_bytes_sent += ap_proxy_bputs2("</BODY></HTML>\n", con->client, c); + ap_bflush(con->client); return total_bytes_sent; } +/* Common routine for failed authorization (i.e., missing or wrong password) + * to an ftp service. This causes most browsers to retry the request + * with username and password (which was presumably queried from the user) + * supplied in the Authorization: header. + * Note that we "invent" a realm name which consists of the + * ftp://[EMAIL PROTECTED] part of the reqest (sans password -if supplied but invalid-) + */ +static int ftp_unauthorized (request_rec *r, int log_it) +{ + r->proxyreq = 0; + /* Log failed requests if they supplied a password + * (log username/password guessing attempts) + */ + if (log_it) + ap_log_rerror(APLOG_MARK, APLOG_INFO|APLOG_NOERRNO, r, + "proxy: missing or failed auth to %s", + ap_unparse_uri_components(r->pool, + &r->parsed_uri, UNP_OMITPATHINFO)); + + ap_table_setn(r->err_headers_out, "WWW-Authenticate", + ap_pstrcat(r->pool, "Basic realm=\"", + ap_unparse_uri_components(r->pool, &r->parsed_uri, + UNP_OMITPASSWORD|UNP_OMITPATHINFO), + "\"", NULL)); + + return HTTP_UNAUTHORIZED; +} + /* * Handles direct access of ftp:// URLs * Original (Non-PASV) version from * Troy Morrison <[EMAIL PROTECTED]> * PASV added by Chuck */ -int ap_proxy_ftp_handler(request_rec *r, struct cache_req *c, char *url) +int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url) { - char *host, *path, *strp, *user, *password, *parms; + char *host, *path, *strp, *parms; + char *cwd = NULL; + char *user = NULL; +/* char *account = NULL; how to supply an account in a URL? */ + const char *password = NULL; const char *err; - int port, userlen, i, j, len, sock, dsock, rc, nocache; - int passlen = 0; + int port, i, j, len, sock, dsock, rc, nocache = 0; int csd = 0; struct sockaddr_in server; struct hostent server_hp; - struct hdr_entry *hdr; struct in_addr destaddr; - array_header *resp_hdrs; - BUFF *f, *cache; + table *resp_hdrs; + BUFF *f; BUFF *data = NULL; pool *p = r->pool; int one = 1; const PRUint32 zero = 0L; NET_SIZE_T clen; + struct tbl_do_args tdo; void *sconf = r->server->module_config; proxy_server_conf *conf = @@ -492,8 +476,7 @@ char *pstr; /* stuff for responses */ - char *resp; - int resplen; + char resp[MAX_STRING_LEN]; char *size = NULL; /* we only support GET and HEAD */ @@ -501,50 +484,48 @@ if (r->method_number != M_GET) return HTTP_NOT_IMPLEMENTED; -/* allocate a buffer for the response message */ - resplen = MAX_STRING_LEN; - resp = (char *)ap_palloc(r->pool, resplen); - /* We break the URL into host, port, path-search */ - - host = ap_pstrdup(p, url + 6); - port = DEFAULT_FTP_PORT; - path = strchr(host, '/'); - if (path == NULL) - path = ""; - else - *(path++) = '\0'; - user = password = NULL; - nocache = 0; - strp = strchr(host, '@'); - if (strp != NULL) { - (*strp++) = '\0'; - user = host; - host = strp; -/* find password */ - strp = strchr(user, ':'); - if (strp != NULL) { - *(strp++) = '\0'; - password = strp; - passlen = decodeenc(password); + host = r->parsed_uri.hostname; + port = (r->parsed_uri.port != 0) + ? r->parsed_uri.port + : ap_default_port_for_request(r); + path = ap_pstrdup(p, r->parsed_uri.path); + path = (path != NULL && path[0] != '\0') ? &path[1] : ""; + + /* The "Authorization:" header must be checked first. + * We allow the user to "override" the URL-coded user [ & password ] + * in the Browsers' User&Password Dialog. + * NOTE that this is only marginally more secure than having the + * password travel in plain as part of the URL, because Basic Auth + * simply uuencodes the plain text password. + * But chances are still smaller that the URL is logged regularly. + */ + if ((password = ap_table_get(r->headers_in, "Authorization")) != NULL + && strcasecmp(ap_getword(r->pool, &password, ' '), "Basic") == 0 + && (password = ap_uudecode(r->pool, password))[0] != ':') { + /* Note that this allocation has to be made from r->connection->pool + * because it has the lifetime of the connection. The other allocations + * are temporary and can be tossed away any time. + */ + user = ap_getword_nulls (r->connection->pool, &password, ':'); + r->connection->ap_auth_type = "Basic"; + r->connection->user = r->parsed_uri.user = user; + nocache = 1; /* This resource only accessible with username/password */ + } + else if ((user = r->parsed_uri.user) != NULL) { + user = ap_pstrdup(p, user); + decodeenc(user); + if ((password = r->parsed_uri.password) != NULL) { + char *tmp = ap_pstrdup(p, password); + decodeenc(tmp); + password = tmp; } - userlen = decodeenc(user); - nocache = 1; /* don't cache when a username is supplied */ + nocache = 1; /* This resource only accessible with username/password */ } else { user = "anonymous"; - userlen = 9; - password = "apache_proxy@"; - passlen = strlen(password); - } - - strp = strchr(host, ':'); - if (strp != NULL) { - *(strp++) = '\0'; - if (isdigit(*strp)) - port = atoi(strp); } /* check if ProxyBlock directive on this host */ @@ -552,7 +533,7 @@ for (i = 0; i < conf->noproxies->nelts; i++) { if ((npent[i].name != NULL && strstr(host, npent[i].name) != NULL) || destaddr.s_addr == npent[i].addr.s_addr || npent[i].name[0] == '*') - return ap_proxyerror(r, "Connect to remote machine blocked"); + return ap_proxyerror(r, /*HTTP_FORBIDDEN*/ "Connect to remote machine blocked"); } Explain2("FTP: connect to %s:%d", host, port); @@ -570,24 +551,23 @@ sock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error creating socket"); return HTTP_INTERNAL_SERVER_ERROR; } - if (conf->recv_buffer_size) { - if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, + if (conf->recv_buffer_size > 0 + && setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (const char *) &conf->recv_buffer_size, sizeof(int)) == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default"); - } } if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &one, sizeof(one)) == -1) { #ifndef _OSD_POSIX /* BS2000 has this option "always on" */ - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error setting reuseaddr option: setsockopt(SO_REUSEADDR)"); ap_pclosesocket(p, sock); return HTTP_INTERNAL_SERVER_ERROR; @@ -631,38 +611,64 @@ ap_bsetflag(f, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 1); #endif /*CHARSET_EBCDIC*/ -/* possible results: 120, 220, 421 */ +/* possible results: */ + /* 120 Service ready in nnn minutes. */ + /* 220 Service ready for new user. */ + /* 421 Service not available, closing control connection. */ ap_hard_timeout("proxy ftp", r); - i = ftp_getrc(f); + i = ftp_getrc_msg(f, resp, sizeof resp); Explain1("FTP: returned status %d", i); if (i == -1) { + ap_kill_timeout(r); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); + } +#if 0 + if (i == 120) { ap_kill_timeout(r); - return ap_proxyerror(r, "Error reading from remote server"); + /* RFC2068 states: + * 14.38 Retry-After + * + * The Retry-After response-header field can be used with a 503 (Service + * Unavailable) response to indicate how long the service is expected to + * be unavailable to the requesting client. The value of this field can + * be either an HTTP-date or an integer number of seconds (in decimal) + * after the time of the response. + * Retry-After = "Retry-After" ":" ( HTTP-date | delta-seconds ) + */ + ap_set_header("Retry-After", ap_psprintf(p, "%u", 60*wait_mins); + return ap_proxyerror(r, /*HTTP_SERVICE_UNAVAILABLE*/ resp); } +#endif if (i != 220) { ap_kill_timeout(r); - return HTTP_BAD_GATEWAY; + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ resp); } Explain0("FTP: connected."); - ap_bputs("USER ", f); - ap_bwrite(f, user, userlen); - ap_bputs(CRLF, f); + ap_bvputs(f, "USER ", user, CRLF, NULL); ap_bflush(f); /* capture any errors */ Explain1("FTP: USER %s", user); /* possible results; 230, 331, 332, 421, 500, 501, 530 */ /* states: 1 - error, 2 - success; 3 - send password, 4,5 fail */ + /* 230 User logged in, proceed. */ + /* 331 User name okay, need password. */ + /* 332 Need account for login. */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* (This may include errors such as command line too long.) */ + /* 501 Syntax error in parameters or arguments. */ + /* 530 Not logged in. */ i = ftp_getrc(f); Explain1("FTP: returned status %d", i); if (i == -1) { ap_kill_timeout(r); - return ap_proxyerror(r, "Error sending to remote server"); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); } if (i == 530) { ap_kill_timeout(r); - return ap_proxyerror(r, "Not logged in"); + return ftp_unauthorized (r, 1); /* log it: user name guessing attempt? */ } if (i != 230 && i != 331) { ap_kill_timeout(r); @@ -670,27 +676,34 @@ } if (i == 331) { /* send password */ - if (password == NULL) - return HTTP_FORBIDDEN; - ap_bputs("PASS ", f); - ap_bwrite(f, password, passlen); - ap_bputs(CRLF, f); + if (password == NULL) { + return ftp_unauthorized (r, 0); + } + ap_bvputs(f, "PASS ", password, CRLF, NULL); ap_bflush(f); Explain1("FTP: PASS %s", password); /* possible results 202, 230, 332, 421, 500, 501, 503, 530 */ + /* 230 User logged in, proceed. */ + /* 332 Need account for login. */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 503 Bad sequence of commands. */ + /* 530 Not logged in. */ i = ftp_getrc(f); Explain1("FTP: returned status %d", i); if (i == -1) { ap_kill_timeout(r); - return ap_proxyerror(r, "Error sending to remote server"); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); } if (i == 332) { ap_kill_timeout(r); - return ap_proxyerror(r, "Need account for login"); + return ap_proxyerror(r, /*HTTP_UNAUTHORIZED*/ "Need account for login"); } + /* @@@ questionable -- we might as well return a 403 Forbidden here */ if (i == 530) { ap_kill_timeout(r); - return ap_proxyerror(r, "Not logged in"); + return ftp_unauthorized (r, 1); /* log it: passwd guessing attempt? */ } if (i != 230 && i != 202) { ap_kill_timeout(r); @@ -698,8 +711,8 @@ } } -/* set the directory */ -/* this is what we must do if we don't know the OS type of the remote +/* set the directory (walk directory component by component): + * this is what we must do if we don't know the OS type of the remote * machine */ for (;;) { @@ -709,18 +722,23 @@ *strp = '\0'; len = decodeenc(path); - ap_bputs("CWD ", f); - ap_bwrite(f, path, len); - ap_bputs(CRLF, f); + ap_bvputs(f, "CWD ", path, CRLF, NULL); ap_bflush(f); Explain1("FTP: CWD %s", path); + *strp = '/'; /* responses: 250, 421, 500, 501, 502, 530, 550 */ -/* 1,3 error, 2 success, 4,5 failure */ + /* 250 Requested file action okay, completed. */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 502 Command not implemented. */ + /* 530 Not logged in. */ + /* 550 Requested action not taken. */ i = ftp_getrc(f); Explain1("FTP: returned status %d", i); if (i == -1) { ap_kill_timeout(r); - return ap_proxyerror(r, "Error sending to remote server"); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); } if (i == 550) { ap_kill_timeout(r); @@ -753,11 +771,17 @@ ap_bflush(f); Explain0("FTP: TYPE I"); /* responses: 200, 421, 500, 501, 504, 530 */ + /* 200 Command okay. */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 504 Command not implemented for that parameter. */ + /* 530 Not logged in. */ i = ftp_getrc(f); Explain1("FTP: returned status %d", i); if (i == -1) { ap_kill_timeout(r); - return ap_proxyerror(r, "Error sending to remote server"); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); } if (i != 200 && i != 504) { ap_kill_timeout(r); @@ -771,7 +795,7 @@ /* try to set up PASV data connection first */ dsock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP); if (dsock == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error creating PASV socket"); ap_bclose(f); ap_kill_timeout(r); @@ -781,7 +805,7 @@ if (conf->recv_buffer_size) { if (setsockopt(dsock, SOL_SOCKET, SO_RCVBUF, (const char *) &conf->recv_buffer_size, sizeof(int)) == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default"); } } @@ -790,10 +814,15 @@ ap_bflush(f); Explain0("FTP: PASV command issued"); /* possible results: 227, 421, 500, 501, 502, 530 */ + /* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 502 Command not implemented. */ + /* 530 Not logged in. */ i = ap_bgets(pasv, sizeof(pasv), f); - if (i == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r, "PASV: control connection is toast"); ap_pclosesocket(p, dsock); ap_bclose(f); @@ -848,7 +877,7 @@ if (!pasvmode) { /* set up data connection */ clen = sizeof(struct sockaddr_in); if (getsockname(sock, (struct sockaddr *) &server, &clen) < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error getting socket address"); ap_bclose(f); ap_kill_timeout(r); @@ -857,7 +886,7 @@ dsock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP); if (dsock == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error creating socket"); ap_bclose(f); ap_kill_timeout(r); @@ -867,7 +896,7 @@ if (setsockopt(dsock, SOL_SOCKET, SO_REUSEADDR, (void *) &one, sizeof(one)) == -1) { #ifndef _OSD_POSIX /* BS2000 has this option "always on" */ - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error setting reuseaddr option"); ap_pclosesocket(p, dsock); ap_bclose(f); @@ -881,7 +910,7 @@ char buff[22]; ap_snprintf(buff, sizeof(buff), "%s:%d", inet_ntoa(server.sin_addr), server.sin_port); - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error binding to ftp data socket %s", buff); ap_bclose(f); ap_pclosesocket(p, dsock); @@ -890,7 +919,7 @@ listen(dsock, 2); /* only need a short queue */ } -/* set request */ +/* set request; "path" holds last path component */ len = decodeenc(path); /* TM - if len == 0 then it must be a directory (you can't RETR nothing) */ @@ -899,27 +928,31 @@ parms = "d"; } else { - ap_bputs("SIZE ", f); - ap_bwrite(f, path, len); - ap_bputs(CRLF, f); + ap_bvputs(f, "SIZE ", path, CRLF, NULL); ap_bflush(f); Explain1("FTP: SIZE %s", path); - i = ftp_getrc_msg(f, resp, resplen); + i = ftp_getrc_msg(f, resp, sizeof resp); Explain2("FTP: returned status %d with response %s", i, resp); if (i != 500) { /* Size command not recognized */ if (i == 550) { /* Not a regular file */ Explain0("FTP: SIZE shows this is a directory"); parms = "d"; - ap_bputs("CWD ", f); - ap_bwrite(f, path, len); - ap_bputs(CRLF, f); + ap_bvputs(f, "CWD ", path, CRLF, NULL); ap_bflush(f); Explain1("FTP: CWD %s", path); i = ftp_getrc(f); + /* possible results: 250, 421, 500, 501, 502, 530, 550 */ + /* 250 Requested file action okay, completed. */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 502 Command not implemented. */ + /* 530 Not logged in. */ + /* 550 Requested action not taken. */ Explain1("FTP: returned status %d", i); if (i == -1) { ap_kill_timeout(r); - return ap_proxyerror(r, "Error sending to remote server"); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); } if (i == 550) { ap_kill_timeout(r); @@ -933,7 +966,7 @@ len = 0; } else if (i == 213) { /* Size command ok */ - for (j = 0; j < resplen && isdigit(resp[j]); j++) + for (j = 0; j < sizeof resp && ap_isdigit(resp[j]); j++) ; resp[j] = '\0'; if (resp[0] != '\0') @@ -942,41 +975,86 @@ } } +#ifdef AUTODETECT_PWD + ap_bvputs(f, "PWD", CRLF, NULL); + ap_bflush(f); + Explain0("FTP: PWD"); +/* responses: 257, 500, 501, 502, 421, 550 */ + /* 257 "<directory-name>" <commentary> */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 502 Command not implemented. */ + /* 550 Requested action not taken. */ + i = ftp_getrc_msg(f, resp, sizeof resp); + Explain1("FTP: PWD returned status %d", i); + if (i == -1 || i == 421) { + ap_kill_timeout(r); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); + } + if (i == 550) { + ap_kill_timeout(r); + return HTTP_NOT_FOUND; + } + if (i == 257) { + const char *dirp = resp; + cwd = ap_getword_conf(r->pool, &dirp); + } +#endif /*AUTODETECT_PWD*/ + if (parms[0] == 'd') { if (len != 0) - ap_bputs("LIST ", f); + ap_bvputs(f, "LIST ", path, CRLF, NULL); else - ap_bputs("LIST -lag", f); + ap_bputs("LIST -lag" CRLF, f); Explain1("FTP: LIST %s", (len == 0 ? "" : path)); } else { - ap_bputs("RETR ", f); + ap_bvputs(f, "RETR ", path, CRLF, NULL); Explain1("FTP: RETR %s", path); } - ap_bwrite(f, path, len); - ap_bputs(CRLF, f); ap_bflush(f); /* RETR: 110, 125, 150, 226, 250, 421, 425, 426, 450, 451, 500, 501, 530, 550 NLST: 125, 150, 226, 250, 421, 425, 426, 450, 451, 500, 501, 502, 530 */ + /* 110 Restart marker reply. */ + /* 125 Data connection already open; transfer starting. */ + /* 150 File status okay; about to open data connection. */ + /* 226 Closing data connection. */ + /* 250 Requested file action okay, completed. */ + /* 421 Service not available, closing control connection. */ + /* 425 Can't open data connection. */ + /* 426 Connection closed; transfer aborted. */ + /* 450 Requested file action not taken. */ + /* 451 Requested action aborted. Local error in processing. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 530 Not logged in. */ + /* 550 Requested action not taken. */ rc = ftp_getrc(f); Explain1("FTP: returned status %d", rc); if (rc == -1) { ap_kill_timeout(r); - return ap_proxyerror(r, "Error sending to remote server"); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); } if (rc == 550) { Explain0("FTP: RETR failed, trying LIST instead"); parms = "d"; - ap_bputs("CWD ", f); - ap_bwrite(f, path, len); - ap_bputs(CRLF, f); + ap_bvputs(f, "CWD ", path, CRLF, NULL); ap_bflush(f); Explain1("FTP: CWD %s", path); + /* possible results: 250, 421, 500, 501, 502, 530, 550 */ + /* 250 Requested file action okay, completed. */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 502 Command not implemented. */ + /* 530 Not logged in. */ + /* 550 Requested action not taken. */ rc = ftp_getrc(f); Explain1("FTP: returned status %d", rc); if (rc == -1) { ap_kill_timeout(r); - return ap_proxyerror(r, "Error sending to remote server"); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); } if (rc == 550) { ap_kill_timeout(r); @@ -987,35 +1065,64 @@ return HTTP_BAD_GATEWAY; } +#ifdef AUTODETECT_PWD + ap_bvputs(f, "PWD", CRLF, NULL); + ap_bflush(f); + Explain0("FTP: PWD"); +/* responses: 257, 500, 501, 502, 421, 550 */ + /* 257 "<directory-name>" <commentary> */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 502 Command not implemented. */ + /* 550 Requested action not taken. */ + i = ftp_getrc_msg(f, resp, sizeof resp); + Explain1("FTP: PWD returned status %d", i); + if (i == -1 || i == 421) { + ap_kill_timeout(r); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); + } + if (i == 550) { + ap_kill_timeout(r); + return HTTP_NOT_FOUND; + } + if (i == 257) { + const char *dirp = resp; + cwd = ap_getword_conf(r->pool, &dirp); + } +#endif /*AUTODETECT_PWD*/ + ap_bputs("LIST -lag" CRLF, f); ap_bflush(f); Explain0("FTP: LIST -lag"); rc = ftp_getrc(f); Explain1("FTP: returned status %d", rc); if (rc == -1) - return ap_proxyerror(r, "Error sending to remote server"); + return ap_proxyerror(r, /*HTTP_BAD_GATEWAY*/ "Error reading from remote server"); } ap_kill_timeout(r); if (rc != 125 && rc != 150 && rc != 226 && rc != 250) return HTTP_BAD_GATEWAY; - r->status = 200; + r->status = HTTP_OK; r->status_line = "200 OK"; - resp_hdrs = ap_make_array(p, 2, sizeof(struct hdr_entry)); + resp_hdrs = ap_make_table(p, 2); + c->hdrs = resp_hdrs; + if (parms[0] == 'd') - ap_proxy_add_header(resp_hdrs, "Content-Type", "text/html", HDR_REP); + ap_table_set(resp_hdrs, "Content-Type", "text/html"); else { if (r->content_type != NULL) { - ap_proxy_add_header(resp_hdrs, "Content-Type", r->content_type, - HDR_REP); + ap_table_set(resp_hdrs, "Content-Type", r->content_type); Explain1("FTP: Content-Type set to %s", r->content_type); } else { - ap_proxy_add_header(resp_hdrs, "Content-Type", "text/plain", HDR_REP); + ap_table_set(resp_hdrs, "Content-Type", "text/plain"); } if (parms[0] != 'a' && size != NULL) { - ap_proxy_add_header(resp_hdrs, "Content-Length", size, HDR_REP); + /* We "trust" the ftp server to really serve (size) bytes... */ + ap_table_set(resp_hdrs, "Content-Length", size); Explain1("FTP: Content-Length set to %s", size); } } @@ -1034,7 +1141,6 @@ ap_bclose(f); return i; } - cache = c->fp; if (!pasvmode) { /* wait for connection */ ap_hard_timeout("proxy ftp data connect", r); @@ -1043,12 +1149,13 @@ csd = accept(dsock, (struct sockaddr *) &server, &clen); while (csd == -1 && errno == EINTR); if (csd == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: failed to accept data connection"); ap_pclosesocket(p, dsock); ap_bclose(f); ap_kill_timeout(r); - ap_proxy_cache_error(c); + if (c != NULL) + c = ap_proxy_cache_error(c); return HTTP_BAD_GATEWAY; } ap_note_cleanups_for_socket(p, csd); @@ -1070,45 +1177,38 @@ /* write status line */ if (!r->assbackwards) ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL); - if (cache != NULL) - if (ap_bvputs(cache, "HTTP/1.0 ", r->status_line, CRLF, - NULL) == -1) - cache = ap_proxy_cache_error(c); + if (c != NULL && c->fp != NULL + && ap_bvputs(c->fp, "HTTP/1.0 ", r->status_line, CRLF, NULL) == -1) + c = ap_proxy_cache_error(c); /* send headers */ - len = resp_hdrs->nelts; - hdr = (struct hdr_entry *) resp_hdrs->elts; - for (i = 0; i < len; i++) { - if (hdr[i].field == NULL || hdr[i].value == NULL || - hdr[i].value[0] == '\0') - continue; - if (!r->assbackwards) - ap_rvputs(r, hdr[i].field, ": ", hdr[i].value, CRLF, NULL); - if (cache != NULL) - if (ap_bvputs(cache, hdr[i].field, ": ", hdr[i].value, CRLF, - NULL) == -1) - cache = ap_proxy_cache_error(c); - } + tdo.req = r; + tdo.cache = c; + ap_table_do(ap_proxy_send_hdr_line, &tdo, resp_hdrs, NULL); if (!r->assbackwards) ap_rputs(CRLF, r); - if (cache != NULL) - if (ap_bputs(CRLF, cache) == -1) - cache = ap_proxy_cache_error(c); + if (c != NULL && c->fp != NULL && ap_bputs(CRLF, c->fp) == -1) + c = ap_proxy_cache_error(c); ap_bsetopt(r->connection->client, BO_BYTECT, &zero); r->sent_bodyct = 1; /* send body */ if (!r->header_only) { - if (parms[0] != 'd') - ap_proxy_send_fb(data, r, cache, c); - else - send_dir(data, r, cache, c, url); + if (parms[0] != 'd') { +/* we need to set this for ap_proxy_send_fb()... */ + if (c != NULL) + c->cache_completion = 0; + ap_proxy_send_fb(data, r, c); + } else + send_dir(data, r, c, cwd); if (rc == 125 || rc == 150) rc = ftp_getrc(f); + + /* XXX: we checked for 125||150||226||250 above. This is redundant. */ if (rc != 226 && rc != 250) - ap_proxy_cache_error(c); + c = ap_proxy_cache_error(c); } else { /* abort the transfer */ @@ -1118,6 +1218,12 @@ ap_bclose(data); Explain0("FTP: ABOR"); /* responses: 225, 226, 421, 500, 501, 502 */ + /* 225 Data connection open; no transfer in progress. */ + /* 226 Closing data connection. */ + /* 421 Service not available, closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + /* 501 Syntax error in parameters or arguments. */ + /* 502 Command not implemented. */ i = ftp_getrc(f); Explain1("FTP: returned status %d", i); } @@ -1130,6 +1236,10 @@ ap_bflush(f); Explain0("FTP: QUIT"); /* responses: 221, 500 */ + /* 221 Service closing control connection. */ + /* 500 Syntax error, command unrecognized. */ + i = ftp_getrc(f); + Explain1("FTP: QUIT: status %d", i); if (pasvmode) ap_bclose(data); 1.3 +115 -59 apache-2.0/apache-nspr/modules/proxy/proxy_http.c Index: proxy_http.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/proxy/proxy_http.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- proxy_http.c 1998/06/30 08:57:09 1.2 +++ proxy_http.c 1998/09/22 18:05:27 1.3 @@ -145,9 +145,9 @@ while (*next) { name = next; - while (*next && !isspace(*next) && (*next != ',')) + while (*next && !ap_isspace(*next) && (*next != ',')) ++next; - while (*next && (isspace(*next) || (*next == ','))) { + while (*next && (ap_isspace(*next) || (*next == ','))) { *next = '\0'; ++next; } @@ -165,26 +165,29 @@ * we return DECLINED so that we can try another proxy. (Or the direct * route.) */ -int ap_proxy_http_handler(request_rec *r, struct cache_req *c, char *url, +int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, const char *proxyhost, int proxyport) { const char *strp; char *strp2; const char *err, *desthost; int i, j, sock, len, backasswards; - array_header *reqhdrs_arr, *resp_hdrs; + array_header *reqhdrs_arr; + table *resp_hdrs; table_entry *reqhdrs; struct sockaddr_in server; struct in_addr destaddr; struct hostent server_hp; - BUFF *f, *cache; - struct hdr_entry *hdr; + BUFF *f; char buffer[HUGE_STRING_LEN]; + char portstr[32]; pool *p = r->pool; const PRUint32 zero = 0L; int destport = 0; char *destportstr = NULL; const char *urlptr = NULL; + const char *datestr; + struct tbl_do_args tdo; void *sconf = r->server->module_config; proxy_server_conf *conf = @@ -219,7 +222,7 @@ strp2 = strchr(desthost, ':'); if (strp2 != NULL) { *(strp2++) = '\0'; - if (isdigit(*strp2)) { + if (ap_isdigit(*strp2)) { destport = atoi(strp2); destportstr = strp2; } @@ -248,7 +251,7 @@ sock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error creating socket"); return HTTP_INTERNAL_SERVER_ERROR; } @@ -257,7 +260,7 @@ if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (const char *) &conf->recv_buffer_size, sizeof(int)) == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default"); } } @@ -301,19 +304,48 @@ ap_hard_timeout("proxy send", r); ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.0" CRLF, NULL); - ap_bvputs(f, "Host: ", desthost, NULL); if (destportstr != NULL && destport != DEFAULT_HTTP_PORT) - ap_bvputs(f, ":", destportstr, CRLF, NULL); + ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL); else - ap_bputs(CRLF, f); + ap_bvputs(f, "Host: ", desthost, CRLF, NULL); + if (conf->viaopt == via_block) { + /* Block all outgoing Via: headers */ + ap_table_unset(r->headers_in, "Via"); + } else if (conf->viaopt != via_off) { + /* Create a "Via:" request header entry and merge it */ + i = ap_get_server_port(r); + if (ap_is_default_port(i,r)) { + strcpy(portstr,""); + } else { + ap_snprintf(portstr, sizeof portstr, ":%d", i); + } + /* Generate outgoing Via: header with/without server comment: */ + ap_table_mergen(r->headers_in, "Via", + (conf->viaopt == via_full) + ? ap_psprintf(p, "%d.%d %s%s (%s)", + HTTP_VERSION_MAJOR(r->proto_num), + HTTP_VERSION_MINOR(r->proto_num), + ap_get_server_name(r), portstr, + SERVER_BASEVERSION) + : ap_psprintf(p, "%d.%d %s%s", + HTTP_VERSION_MAJOR(r->proto_num), + HTTP_VERSION_MINOR(r->proto_num), + ap_get_server_name(r), portstr) + ); + } + reqhdrs_arr = ap_table_elts(r->headers_in); reqhdrs = (table_entry *) reqhdrs_arr->elts; for (i = 0; i < reqhdrs_arr->nelts; i++) { if (reqhdrs[i].key == NULL || reqhdrs[i].val == NULL /* Clear out headers not to send */ || !strcasecmp(reqhdrs[i].key, "Host") /* Already sent */ - ||!strcasecmp(reqhdrs[i].key, "Proxy-Authorization")) + /* XXX: @@@ FIXME: "Proxy-Authorization" should *only* be + * suppressed if THIS server requested the authentication, + * not when a frontend proxy requested it! + */ + || !strcasecmp(reqhdrs[i].key, "Proxy-Authorization")) continue; ap_bvputs(f, reqhdrs[i].key, ": ", reqhdrs[i].val, CRLF, NULL); } @@ -322,7 +354,7 @@ /* send the request data, if any. N.B. should we trap SIGPIPE ? */ if (ap_should_client_block(r)) { - while ((i = ap_get_client_block(r, buffer, HUGE_STRING_LEN)) > 0) + while ((i = ap_get_client_block(r, buffer, sizeof buffer)) > 0) ap_bwrite(f, buffer, i); } ap_bflush(f); @@ -330,16 +362,25 @@ ap_hard_timeout("proxy receive", r); - len = ap_bgets(buffer, HUGE_STRING_LEN - 1, f); + len = ap_bgets(buffer, sizeof buffer - 1, f); if (len == -1 || len == 0) { ap_bclose(f); ap_kill_timeout(r); + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, + "ap_bgets() - proxy receive - Error reading from remote server %s", + proxyhost ? proxyhost : desthost); return ap_proxyerror(r, "Error reading from remote server"); } /* Is it an HTTP/1 response? This is buggy if we ever see an HTTP/1.10 */ if (ap_checkmask(buffer, "HTTP/#.# ###*")) { -/* If not an HTTP/1 messsage or if the status line was > 8192 bytes */ + int major, minor; + if (2 != sscanf(buffer, "HTTP/%u.%u", &major, &minor)) { + major = 1; + minor = 0; + } + +/* If not an HTTP/1 message or if the status line was > 8192 bytes */ if (buffer[5] != '1' || buffer[len - 1] != '\n') { ap_bclose(f); ap_kill_timeout(r); @@ -357,9 +398,36 @@ /* N.B. for HTTP/1.0 clients, we have to fold line-wrapped headers */ /* Also, take care with headers with multiple occurences. */ - resp_hdrs = ap_proxy_read_headers(p, buffer, HUGE_STRING_LEN, f); + resp_hdrs = ap_proxy_read_headers(r, buffer, HUGE_STRING_LEN, f); + if (resp_hdrs == NULL) { + ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, r->server, + "proxy: Bad HTTP/%d.%d header returned by %s (%s)", + major, minor, r->uri, r->method); + resp_hdrs = ap_make_table(p, 20); + nocache = 1; /* do not cache this broken file */ + } + + if (conf->viaopt != via_off && conf->viaopt != via_block) { + /* Create a "Via:" response header entry and merge it */ + i = ap_get_server_port(r); + if (ap_is_default_port(i,r)) { + strcpy(portstr,""); + } else { + ap_snprintf(portstr, sizeof portstr, ":%d", i); + } + ap_table_mergen((table *)resp_hdrs, "Via", + (conf->viaopt == via_full) + ? ap_psprintf(p, "%d.%d %s%s (%s)", + major, minor, + ap_get_server_name(r), portstr, + SERVER_BASEVERSION) + : ap_psprintf(p, "%d.%d %s%s", + major, minor, + ap_get_server_name(r), portstr) + ); + } - clear_connection(p, (table *) resp_hdrs); /* Strip Connection hdrs */ + clear_connection(p, resp_hdrs); /* Strip Connection hdrs */ } else { /* an http/0.9 response */ @@ -368,30 +436,29 @@ r->status_line = "200 OK"; /* no headers */ - resp_hdrs = ap_make_array(p, 2, sizeof(struct hdr_entry)); + resp_hdrs = ap_make_table(p, 20); } + c->hdrs = resp_hdrs; + ap_kill_timeout(r); /* * HTTP/1.0 requires us to accept 3 types of dates, but only generate * one type */ + if ((datestr = ap_table_get(resp_hdrs, "Date")) != NULL) + ap_table_set(resp_hdrs, "Date", ap_proxy_date_canon(p, datestr)); + if ((datestr = ap_table_get(resp_hdrs, "Last-Modified")) != NULL) + ap_table_set(resp_hdrs, "Last-Modified", ap_proxy_date_canon(p, datestr)); + if ((datestr = ap_table_get(resp_hdrs, "Expires")) != NULL) + ap_table_set(resp_hdrs, "Expires", ap_proxy_date_canon(p, datestr)); + + if ((datestr = ap_table_get(resp_hdrs, "Location")) != NULL) + ap_table_set(resp_hdrs, "Location", proxy_location_reverse_map(r, datestr)); + if ((datestr = ap_table_get(resp_hdrs, "URI")) != NULL) + ap_table_set(resp_hdrs, "URI", proxy_location_reverse_map(r, datestr)); - hdr = (struct hdr_entry *) resp_hdrs->elts; - for (i = 0; i < resp_hdrs->nelts; i++) { - if (hdr[i].value[0] == '\0') - continue; - strp = hdr[i].field; - if (strcasecmp(strp, "Date") == 0 || - strcasecmp(strp, "Last-Modified") == 0 || - strcasecmp(strp, "Expires") == 0) - hdr[i].value = ap_proxy_date_canon(p, hdr[i].value); - if (strcasecmp(strp, "Location") == 0 || - strcasecmp(strp, "URI") == 0) - hdr[i].value = proxy_location_reverse_map(r, hdr[i].value); - } - /* check if NoCache directive on this host */ for (i = 0; i < conf->nocaches->nelts; i++) { if ((ncent[i].name != NULL && strstr(desthost, ncent[i].name) != NULL) @@ -405,46 +472,32 @@ return i; } - cache = c->fp; - ap_hard_timeout("proxy receive", r); /* write status line */ if (!r->assbackwards) ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL); - if (cache != NULL) - if (ap_bvputs(cache, "HTTP/1.0 ", r->status_line, CRLF, NULL) == -1) - cache = ap_proxy_cache_error(c); + if (c != NULL && c->fp != NULL && + ap_bvputs(c->fp, "HTTP/1.0 ", r->status_line, CRLF, NULL) == -1) + c = ap_proxy_cache_error(c); /* send headers */ - for (i = 0; i < resp_hdrs->nelts; i++) { - if (hdr[i].field == NULL || hdr[i].value == NULL || - hdr[i].value[0] == '\0') - continue; - if (!r->assbackwards) { - ap_rvputs(r, hdr[i].field, ": ", hdr[i].value, CRLF, NULL); - ap_table_set(r->headers_out, hdr[i].field, hdr[i].value); - } - if (cache != NULL) - if (ap_bvputs(cache, hdr[i].field, ": ", hdr[i].value, CRLF, - NULL) == -1) - cache = ap_proxy_cache_error(c); - } + tdo.req = r; + tdo.cache = c; + ap_table_do(ap_proxy_send_hdr_line, &tdo, resp_hdrs, NULL); if (!r->assbackwards) ap_rputs(CRLF, r); - if (cache != NULL) - if (ap_bputs(CRLF, cache) == -1) - cache = ap_proxy_cache_error(c); + if (c != NULL && c->fp != NULL && ap_bputs(CRLF, c->fp) == -1) + c = ap_proxy_cache_error(c); ap_bsetopt(r->connection->client, BO_BYTECT, &zero); r->sent_bodyct = 1; /* Is it an HTTP/0.9 respose? If so, send the extra data */ if (backasswards) { ap_bwrite(r->connection->client, buffer, len); - if (cache != NULL) - if (ap_bwrite(f, buffer, len) != len) - cache = ap_proxy_cache_error(c); + if (c != NULL && c->fp != NULL && ap_bwrite(c->fp, buffer, len) != len) + c = ap_proxy_cache_error(c); } ap_kill_timeout(r); @@ -459,8 +512,11 @@ /* send body */ /* if header only, then cache will be NULL */ /* HTTP/1.0 tells us to read to EOF, rather than content-length bytes */ - if (!r->header_only) - ap_proxy_send_fb(f, r, cache, c); + if (!r->header_only) { +/* we need to set this for ap_proxy_send_fb()... */ + c->cache_completion = conf->cache.cache_completion; + ap_proxy_send_fb(f, r, c); + } ap_proxy_cache_tidy(c); 1.3 +0 -176 apache-2.0/apache-nspr/modules/standard/Makefile.tmpl Index: Makefile.tmpl =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/Makefile.tmpl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile.tmpl 1998/06/30 08:57:09 1.2 +++ Makefile.tmpl 1998/09/22 18:05:31 1.3 @@ -4,179 +4,3 @@ $(OBJS) $(OBJS_PIC): Makefile # DO NOT REMOVE -mod_access.o: mod_access.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_request.h -mod_actions.o: mod_actions.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_main.h $(INCDIR)/http_log.h \ - $(INCDIR)/util_script.h -mod_alias.o: mod_alias.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h -mod_asis.o: mod_asis.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_log.h $(INCDIR)/util_script.h \ - $(INCDIR)/http_main.h $(INCDIR)/http_request.h -mod_auth.o: mod_auth.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_protocol.h -mod_auth_anon.o: mod_auth_anon.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_request.h -mod_auth_db.o: mod_auth_db.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_protocol.h -mod_auth_dbm.o: mod_auth_dbm.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_protocol.h -mod_autoindex.o: mod_autoindex.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_request.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_main.h \ - $(INCDIR)/util_script.h -mod_cern_meta.o: mod_cern_meta.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/util_script.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_request.h -mod_cgi.o: mod_cgi.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_main.h $(INCDIR)/http_log.h \ - $(INCDIR)/util_script.h $(INCDIR)/http_conf_globals.h -mod_digest.o: mod_digest.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/util_md5.h $(INCDIR)/ap_md5.h -mod_dir.o: mod_dir.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_request.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_main.h \ - $(INCDIR)/util_script.h -mod_env.o: mod_env.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h -mod_expires.o: mod_expires.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_log.h -mod_headers.o: mod_headers.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h -mod_imap.o: mod_imap.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_main.h $(INCDIR)/http_log.h \ - $(INCDIR)/util_script.h -mod_include.o: mod_include.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_protocol.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_main.h \ - $(INCDIR)/util_script.h -mod_info.o: mod_info.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h $(INCDIR)/http_main.h \ - $(INCDIR)/http_protocol.h $(INCDIR)/util_script.h \ - $(INCDIR)/http_conf_globals.h -mod_log_agent.o: mod_log_agent.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_log.h -mod_log_config.o: mod_log_config.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h -mod_log_referer.o: mod_log_referer.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_log.h -mod_mime.o: mod_mime.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_log.h -mod_mime_magic.o: mod_mime_magic.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_protocol.h -mod_negotiation.o: mod_negotiation.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_log.h \ - $(INCDIR)/util_script.h -mod_rewrite.o: mod_rewrite.c mod_rewrite.h $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_log.h \ - $(INCDIR)/http_vhost.h -mod_setenvif.o: mod_setenvif.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_log.h -mod_so.o: mod_so.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_log.h -mod_speling.o: mod_speling.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_config.h \ - $(INCDIR)/http_log.h -mod_status.o: mod_status.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \ - $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h \ - $(INCDIR)/http_protocol.h $(INCDIR)/http_main.h \ - $(INCDIR)/util_script.h $(INCDIR)/scoreboard.h \ - $(INCDIR)/http_log.h -mod_unique_id.o: mod_unique_id.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_log.h -mod_userdir.o: mod_userdir.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h -mod_usertrack.o: mod_usertrack.c $(INCDIR)/httpd.h \ - $(INCDIR)/conf.h $(OSDIR)/os.h $(INCDIR)/alloc.h \ - $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \ - $(INCDIR)/http_config.h $(INCDIR)/http_core.h 1.3 +7 -7 apache-2.0/apache-nspr/modules/standard/mod_access.c Index: mod_access.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_access.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_access.c 1998/06/30 08:57:09 1.2 +++ mod_access.c 1998/09/22 18:05:31 1.3 @@ -142,7 +142,7 @@ static int is_ip(const char *host) { - while ((*host == '.') || isdigit(*host)) + while ((*host == '.') || ap_isdigit(*host)) host++; return (*host == '\0'); } @@ -210,7 +210,7 @@ a->x.ip.mask = mask; } - else if (isdigit(*where) && is_ip(where)) { + else if (ap_isdigit(*where) && is_ip(where)) { /* legacy syntax for ip addrs: a.b.c. ==> a.b.c.0/24 for example */ int shift; char *t; @@ -224,11 +224,11 @@ shift = 24; while (*s) { t = s; - if (!isdigit(*t)) { + if (!ap_isdigit(*t)) { a->type = T_FAIL; return "invalid ip address"; } - while (isdigit(*t)) { + while (ap_isdigit(*t)) { ++t; } if (*t == '.') { @@ -381,9 +381,9 @@ if (ret == FORBIDDEN && (ap_satisfies(r) != SATISFY_ANY || !ap_some_auth_required(r))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, - "client %pI denied by server configuration: %s", - &r->connection->remote_addr, r->filename); + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, + "client denied by server configuration: %s", + r->filename); } return ret; 1.3 +1 -1 apache-2.0/apache-nspr/modules/standard/mod_actions.c Index: mod_actions.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_actions.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_actions.c 1998/06/30 08:57:09 1.2 +++ mod_actions.c 1998/09/22 18:05:32 1.3 @@ -191,7 +191,7 @@ action ? action : ap_default_type(r)))) { script = t; if (!r->file_exists) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "File does not exist: %s", r->filename); return NOT_FOUND; } 1.3 +3 -3 apache-2.0/apache-nspr/modules/standard/mod_asis.c Index: mod_asis.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_asis.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_asis.c 1998/06/30 08:57:09 1.2 +++ mod_asis.c 1998/09/22 18:05:32 1.3 @@ -72,7 +72,7 @@ if (r->method_number != M_GET) return DECLINED; if (!r->file_exists) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "File does not exist: %s", r->filename); return NOT_FOUND; } @@ -80,7 +80,7 @@ f = ap_pfopen(r->pool, r->filename, "r"); if (f == NULL) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "file permissions deny server access: %s", r->filename); return FORBIDDEN; } @@ -89,7 +89,7 @@ location = ap_table_get(r->headers_out, "Location"); if (location && location[0] == '/' && - ((r->status == HTTP_OK) || is_HTTP_REDIRECT(r->status))) { + ((r->status == HTTP_OK) || ap_is_HTTP_REDIRECT(r->status))) { ap_pfclose(r->pool, f); 1.3 +10 -5 apache-2.0/apache-nspr/modules/standard/mod_auth.c Index: mod_auth.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_auth.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_auth.c 1998/06/30 08:57:09 1.2 +++ mod_auth.c 1998/09/22 18:05:32 1.3 @@ -126,7 +126,7 @@ const char *rpw, *w; if (!(f = ap_pcfg_openfile(r->pool, auth_pwfile))) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "Could not open password file: %s", auth_pwfile); return NULL; } @@ -201,7 +201,8 @@ auth_config_rec *sec = (auth_config_rec *) ap_get_module_config(r->per_dir_config, &auth_module); conn_rec *c = r->connection; - char *sent_pw, *real_pw; + const char *sent_pw; + char *real_pw; int res; if ((res = ap_get_basic_auth_pw(r, &sent_pw))) @@ -213,14 +214,14 @@ if (!(real_pw = get_pw(r, c->user, sec->auth_pwfile))) { if (!(sec->auth_authoritative)) return DECLINED; - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "user %s not found: %s", c->user, r->uri); ap_note_basic_auth_failure(r); return AUTH_REQUIRED; } /* anyone know where the prototype for crypt is? */ if (strcmp(real_pw, (char *) crypt(sent_pw, real_pw))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "user %s: password mismatch: %s", c->user, r->uri); ap_note_basic_auth_failure(r); return AUTH_REQUIRED; @@ -240,7 +241,7 @@ register int x; const char *t, *w; table *grpstatus; - array_header *reqs_arr = ap_requires(r); + const array_header *reqs_arr = ap_requires(r); require_line *reqs; /* BUG FIX: tadc, 11-Nov-1995. If there is no "requires" directive, @@ -291,6 +292,10 @@ if (!(sec->auth_authoritative)) return DECLINED; + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, + "access to %s failed, reason: user %s not allowed access", + r->uri, user); + ap_note_basic_auth_failure(r); return AUTH_REQUIRED; } 1.3 +162 -97 apache-2.0/apache-nspr/modules/standard/mod_autoindex.c Index: mod_autoindex.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_autoindex.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_autoindex.c 1998/06/30 08:57:09 1.2 +++ mod_autoindex.c 1998/09/22 18:05:33 1.3 @@ -94,6 +94,9 @@ #define SUPPRESS_PREAMBLE 64 #define SUPPRESS_COLSORT 128 +#define K_PAD 1 +#define K_NOPAD 0 + /* * Define keys for sorting. */ @@ -111,6 +114,11 @@ #define DEFAULT_ICON_WIDTH 20 #define DEFAULT_ICON_HEIGHT 22 +/* + * Other default dimensions. + */ +#define DEFAULT_NAME_WIDTH 23 + struct item { char *type; char *apply_to; @@ -121,11 +129,14 @@ typedef struct autoindex_config_struct { char *default_icon; + int opts; + int name_width; + int name_adjust; int icon_width; int icon_height; array_header *icon_list, *alt_list, *desc_list, *ign_list; - array_header *hdr_list, *rdme_list, *opts_list; + array_header *hdr_list, *rdme_list; } autoindex_config_rec; @@ -271,17 +282,20 @@ return NULL; } - -static const char *add_opts_int(cmd_parms *cmd, void *d, int opts) -{ - push_item(((autoindex_config_rec *) d)->opts_list, (char *) (long) opts, - NULL, cmd->path, NULL); - return NULL; -} - +/* A legacy directive, FancyIndexing is superseded by the IndexOptions + * keyword. But for compatibility.. + */ static const char *fancy_indexing(cmd_parms *cmd, void *d, int arg) { - return add_opts_int(cmd, d, arg ? FANCY_INDEXING : 0); + int curopts; + int newopts; + autoindex_config_rec *cfg; + + cfg = (autoindex_config_rec *) d; + curopts = cfg->opts; + newopts = (arg ? (curopts | FANCY_INDEXING) : (curopts & !FANCY_INDEXING)); + cfg->opts = newopts; + return NULL; } static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr) @@ -319,35 +333,37 @@ else if (!strcasecmp(w, "None")) { opts = 0; } - else if (!strncasecmp(w, "IconWidth", 9)) { - if (strchr(w, '=') != NULL) { - const char *x = ap_pstrdup(cmd->pool, w); - char *val; - val = ap_getword(cmd->pool, &x, '='); - val = ap_getword(cmd->pool, &x, '='); - d_cfg->icon_width = atoi(val); - } - else { - d_cfg->icon_width = DEFAULT_ICON_WIDTH; - } + else if (!strcasecmp(w, "IconWidth")) { + d_cfg->icon_width = DEFAULT_ICON_WIDTH; + } + else if (!strncasecmp(w, "IconWidth=", 10)) { + d_cfg->icon_width = atoi(&w[10]); + } + else if (!strcasecmp(w, "IconHeight")) { + d_cfg->icon_height = DEFAULT_ICON_HEIGHT; + } + else if (!strncasecmp(w, "IconHeight=", 11)) { + d_cfg->icon_height = atoi(&w[11]); } - else if (!strncasecmp(w, "IconHeight", 10)) { - if (strchr(w, '=') != NULL) { - const char *x = ap_pstrdup(cmd->pool, w); - char *val; - val = ap_getword(cmd->pool, &x, '='); - val = ap_getword(cmd->pool, &x, '='); - d_cfg->icon_height = atoi(val); + else if (!strncasecmp(w, "NameWidth=", 10)) { + if (w[10] == '*') { + d_cfg->name_adjust = 1; } else { - d_cfg->icon_height = DEFAULT_ICON_HEIGHT; + int width = atoi(&w[10]); + + if (width < 1) { + return "NameWidth value must be greater than 1"; + } + d_cfg->name_width = width; } } else { return "Invalid directory indexing option"; } } - return add_opts_int(cmd, d, opts); + d_cfg->opts = opts; + return NULL; } #define DIR_CMD_PERMS OR_INDEXES @@ -389,13 +405,15 @@ new->icon_width = 0; new->icon_height = 0; + new->name_width = DEFAULT_NAME_WIDTH; + new->name_adjust = 0; new->icon_list = ap_make_array(p, 4, sizeof(struct item)); new->alt_list = ap_make_array(p, 4, sizeof(struct item)); new->desc_list = ap_make_array(p, 4, sizeof(struct item)); new->ign_list = ap_make_array(p, 4, sizeof(struct item)); new->hdr_list = ap_make_array(p, 4, sizeof(struct item)); new->rdme_list = ap_make_array(p, 4, sizeof(struct item)); - new->opts_list = ap_make_array(p, 4, sizeof(struct item)); + new->opts = 0; return (void *) new; } @@ -418,7 +436,9 @@ new->desc_list = ap_append_arrays(p, add->desc_list, base->desc_list); new->icon_list = ap_append_arrays(p, add->icon_list, base->icon_list); new->rdme_list = ap_append_arrays(p, add->rdme_list, base->rdme_list); - new->opts_list = ap_append_arrays(p, add->opts_list, base->opts_list); + new->opts = add->opts; + new->name_width = add->name_width; + new->name_adjust = add->name_adjust; return new; } @@ -495,7 +515,7 @@ #define find_header(d,p) find_item(p,d->hdr_list,0) #define find_readme(d,p) find_item(p,d->rdme_list,0) -static char *find_default_icon(autoindex_config_rec * d, char *bogus_name) +static char *find_default_icon(autoindex_config_rec *d, char *bogus_name) { request_rec r; @@ -510,7 +530,7 @@ return find_item(&r, d->icon_list, 1); } -static int ignore_entry(autoindex_config_rec * d, char *path) +static int ignore_entry(autoindex_config_rec *d, char *path) { array_header *list = d->ign_list; struct item *items = (struct item *) list->elts; @@ -555,23 +575,6 @@ return 0; } -static int find_opts(autoindex_config_rec * d, request_rec *r) -{ - char *path = r->filename; - array_header *list = d->opts_list; - struct item *items = (struct item *) list->elts; - int i; - - for (i = 0; i < list->nelts; ++i) { - struct item *p = &items[i]; - - if (!ap_strcmp_match(path, p->apply_path)) { - return (int) (long) p->type; - } - } - return 0; -} - /***************************************************************** * * Actually generating output @@ -593,7 +596,7 @@ cfg = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config, &autoindex_module); - autoindex_opts = find_opts(cfg, r); + autoindex_opts = cfg->opts; /* XXX: this is a load of crap, it needs to do a full sub_req_lookup_uri */ fn = ap_make_full_path(r->pool, name, readme_fname); fn = ap_pstrcat(r->pool, fn, ".html", NULL); @@ -690,7 +693,7 @@ } titlebuf[n] = '\0'; for (x = 0, p = 0; titlebuf[x]; x++) { - if (toupper(titlebuf[x]) == find[p]) { + if (ap_toupper(titlebuf[x]) == find[p]) { if (!find[++p]) { if ((p = ap_ind(&titlebuf[++x], '<')) != -1) { titlebuf[x + p] = '\0'; @@ -739,8 +742,8 @@ p->alt = NULL; p->desc = NULL; p->lm_valid = 0; - p->key = toupper(keyid); - p->ascending = (toupper(direction) == D_ASCENDING); + p->key = ap_toupper(keyid); + p->ascending = (ap_toupper(direction) == D_ASCENDING); if (autoindex_opts & FANCY_INDEXING) { request_rec *rr = ap_sub_req_lookup_file(name, r); @@ -776,7 +779,7 @@ return (p); } -static char *terminate_description(autoindex_config_rec * d, char *desc, +static char *terminate_description(autoindex_config_rec *d, char *desc, int autoindex_opts) { int maxsize = 23; @@ -845,18 +848,70 @@ } } +/* + * Fit a string into a specified buffer width, marking any + * truncation. The size argument is the actual buffer size, including + * the \0 termination byte. The buffer will be prefilled with blanks. + * If the pad argument is false, any extra spaces at the end of the + * buffer are omitted. (Used when constructing anchors.) + */ +static ap_inline char *widthify(const char *s, char *buff, int size, int pad) +{ + int s_len; + + memset(buff, ' ', size); + buff[size - 1] = '\0'; + s_len = strlen(s); + if (s_len > (size - 1)) { + ap_cpystrn(buff, s, size); + if (size > 1) { + buff[size - 2] = '>'; + } + if (size > 2) { + buff[size - 3] = '.'; + } + if (size > 3) { + buff[size - 4] = '.'; + } + } + else { + ap_cpystrn(buff, s, s_len + 1); + if (pad) { + buff[s_len] = ' '; + } + } + return buff; +} + static void output_directories(struct ent **ar, int n, - autoindex_config_rec * d, request_rec *r, - int autoindex_opts, char keyid, char direction) + autoindex_config_rec *d, request_rec *r, + int autoindex_opts, char keyid, char direction) { - int x, len; + int x; char *name = r->uri; char *tp; int static_columns = (autoindex_opts & SUPPRESS_COLSORT); pool *scratch = ap_make_sub_pool(r->pool); + int name_width; + char *name_scratch; - if (name[0] == '\0') + if (name[0] == '\0') { name = "/"; + } + + name_width = d->name_width; + if (d->name_adjust) { + for (x = 0; x < n; x++) { + int t = strlen(ar[x]->name); + if (t > name_width) { + name_width = t; + } + } + } + ++name_width; + name_scratch = ap_palloc(r->pool, name_width + 1); + memset(name_scratch, ' ', name_width); + name_scratch[name_width] = '\0'; if (autoindex_opts & FANCY_INDEXING) { ap_rputs("<PRE>", r); @@ -874,8 +929,18 @@ } ap_rputs("> ", r); } - emit_link(r, "Name", K_NAME, keyid, direction, static_columns); - ap_rputs(" ", r); + emit_link(r, widthify("Name", name_scratch, + (name_width > 5) ? 5 : name_width, K_NOPAD), + K_NAME, keyid, direction, static_columns); + if (name_width > 5) { + memset(name_scratch, ' ', name_width); + name_scratch[name_width] = '\0'; + ap_rputs(&name_scratch[5], r); + } + /* + * Emit the guaranteed-at-least-one-space-between-columns byte. + */ + ap_rputs(" ", r); if (!(autoindex_opts & SUPPRESS_LAST_MOD)) { emit_link(r, "Last modified", K_LAST_MOD, keyid, direction, static_columns); @@ -896,7 +961,9 @@ } for (x = 0; x < n; x++) { - char *anchor = NULL, *t = NULL, *t2 = NULL; + char *anchor, *t, *t2; + char *pad; + int nwidth; ap_clear_pool(scratch); @@ -906,40 +973,21 @@ if (t[0] == '\0') { t = "/"; } - anchor = ap_pstrcat(scratch, "<A HREF=\"", - ap_escape_html(scratch, - ap_os_escape_path(scratch, t, - 0)), - "\">", NULL); - t2 = "Parent Directory</A> "; + /* 1234567890123456 */ + t2 = "Parent Directory"; + pad = name_scratch + 16; + anchor = ap_escape_html(scratch, ap_os_escape_path(scratch, t, 0)); } else { t = ar[x]->name; - len = strlen(t); - if (len > 23) { - t2 = ap_pstrdup(scratch, t); - t2[21] = '.'; - t2[22] = '.'; - t2[23] = '\0'; - t2 = ap_escape_html(scratch, t2); - t2 = ap_pstrcat(scratch, t2, "</A>", NULL); - } - else { - char buff[24] = " "; - t2 = ap_escape_html(scratch, t); - buff[23 - len] = '\0'; - t2 = ap_pstrcat(scratch, t2, "</A>", buff, NULL); - } - anchor = ap_pstrcat(scratch, "<A HREF=\"", - ap_escape_html(scratch, - ap_os_escape_path(scratch, t, - 0)), - "\">", NULL); + pad = name_scratch + strlen(t); + t2 = ap_escape_html(scratch, t); + anchor = ap_escape_html(scratch, ap_os_escape_path(scratch, t, 0)); } if (autoindex_opts & FANCY_INDEXING) { if (autoindex_opts & ICONS_ARE_LINKS) { - ap_rputs(anchor, r); + ap_rvputs(r, "<A HREF=\"", anchor, "\">", NULL); } if ((ar[x]->icon) || d->default_icon) { ap_rvputs(r, "<IMG SRC=\"", @@ -958,7 +1006,22 @@ ap_rputs("</A>", r); } - ap_rvputs(r, " ", anchor, t2, NULL); + ap_rvputs(r, " <A HREF=\"", anchor, "\">", + widthify(t2, name_scratch, name_width, K_NOPAD), + "</A>", NULL); + /* + * We know that widthify() prefilled the buffer with spaces + * before doing its thing, so use them. + */ + nwidth = strlen(t2); + if (nwidth < (name_width - 1)) { + name_scratch[nwidth] = ' '; + ap_rputs(&name_scratch[nwidth], r); + } + /* + * The blank before the storm.. er, before the next field. + */ + ap_rputs(" ", r); if (!(autoindex_opts & SUPPRESS_LAST_MOD)) { if (ar[x]->lm_valid) { char time_str[MAX_STRING_LEN]; @@ -987,7 +1050,8 @@ } } else { - ap_rvputs(r, "<LI> ", anchor, " ", t2, NULL); + ap_rvputs(r, "<LI><A HREF=\"", anchor, "\"> ", t2, + "</A>", pad, NULL); } ap_rputc('\n', r); } @@ -1026,7 +1090,7 @@ */ if ((*e1)->ascending) { c1 = *e1; - c2 = *e2; + c2 = *e2; } else { c1 = *e2; @@ -1060,7 +1124,8 @@ } -static int index_directory(request_rec *r, autoindex_config_rec * autoindex_conf) +static int index_directory(request_rec *r, + autoindex_config_rec *autoindex_conf) { char *title_name = ap_escape_html(r->pool, r->uri); char *title_endp; @@ -1072,12 +1137,12 @@ struct ent **ar = NULL; char *tmp; const char *qstring; - int autoindex_opts = find_opts(autoindex_conf, r); + int autoindex_opts = autoindex_conf->opts; char keyid; char direction; if (!(d = ap_popendir(r->pool, name))) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "Can't open directory for index: %s", r->filename); return HTTP_FORBIDDEN; } @@ -1209,7 +1274,7 @@ return index_directory(r, d); } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Directory index forbidden by rule: %s", r->filename); return HTTP_FORBIDDEN; } 1.3 +13 -7 apache-2.0/apache-nspr/modules/standard/mod_cern_meta.c Index: mod_cern_meta.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_cern_meta.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_cern_meta.c 1998/06/30 08:57:09 1.2 +++ mod_cern_meta.c 1998/09/22 18:05:33 1.3 @@ -226,12 +226,17 @@ {NULL} }; -static int scan_meta_file(request_rec *r, BUFF *f) +/* XXX: this is very similar to ap_scan_script_header_err_core... + * are the differences deliberate, or just a result of bit rot? + */ +static int scan_meta_file(request_rec *r, FILE *f) { char w[MAX_STRING_LEN]; char *l; int p; + table *tmp_headers; + tmp_headers = ap_make_table(r->pool, 5); while (ap_bgets(w, sizeof(w) - 1, f) > 0) { /* Delete terminal (CR?)LF */ @@ -251,13 +256,13 @@ /* if we see a bogus header don't ignore it. Shout and scream */ if (!(l = strchr(w, ':'))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "malformed header in meta file: %s", r->filename); return SERVER_ERROR; } *l++ = '\0'; - while (*l && isspace(*l)) + while (*l && ap_isspace(*l)) ++l; if (!strcasecmp(w, "Content-type")) { @@ -265,7 +270,7 @@ /* Nuke trailing whitespace */ char *endp = l + strlen(l) - 1; - while (endp > l && isspace(*endp)) + while (endp > l && ap_isspace(*endp)) *endp-- = '\0'; tmp = ap_pstrdup(r->pool, l); @@ -277,9 +282,10 @@ r->status_line = ap_pstrdup(r->pool, l); } else { - ap_table_set(r->headers_out, w, l); + ap_table_set(tmp_headers, w, l); } } + ap_overlap_tables(r->headers_out, tmp_headers, AP_OVERLAP_TABLES_SET); return OK; } @@ -325,7 +331,7 @@ } else { /* no last slash, buh?! */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "internal error in mod_cern_meta: %s", r->filename); /* should really barf, but hey, let's be friends... */ return DECLINED; @@ -354,7 +360,7 @@ if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) { return DECLINED; } - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "meta file permissions deny server access: %s", metafilename); return FORBIDDEN; }; 1.4 +6 -3 apache-2.0/apache-nspr/modules/standard/mod_cgi.c Index: mod_cgi.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_cgi.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- mod_cgi.c 1998/09/19 19:15:45 1.3 +++ mod_cgi.c 1998/09/22 18:05:34 1.4 @@ -173,7 +173,7 @@ char timebuf[MAX_STRING_LEN]; cgi_server_conf *conf; - ap_log_error(APLOG_MARK, show_errno|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, show_errno|APLOG_ERR, r, "%s: %s", error, r->filename); conf = ap_get_module_config(r->server->module_config, &cgi_module); @@ -314,7 +314,7 @@ return log_scripterror(r, FORBIDDEN, APLOG_NOERRNO, "attempt to include NPH CGI script"); -#if defined(__EMX__) || defined(WIN32) +#if defined(OS2) || defined(WIN32) /* Allow for cgi files without the .EXE extension on them under OS/2 */ if (!r->file_exists) { PRFileInfo finfo; @@ -393,8 +393,11 @@ * those later. */ if (PR_DetachProcess(pid) != PR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_INFO, r->server, + ap_log_rerror(APLOG_MARK, APLOG_INFO, r, "(ignored) error detaching process: %s", r->filename); + PR_Close(parent_out); + PR_Close(parent_in); + return HTTP_INTERNAL_SERVER_ERROR; } /* XXX: this is where we'd set up timeouts for reads/writes to the CGI, 1.3 +13 -10 apache-2.0/apache-nspr/modules/standard/mod_digest.c Index: mod_digest.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_digest.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_digest.c 1998/06/30 08:57:11 1.2 +++ mod_digest.c 1998/09/22 18:05:34 1.3 @@ -112,7 +112,7 @@ char *w, *x; if (!(f = ap_pcfg_openfile(r->pool, auth_pwfile))) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "Could not open password file: %s", auth_pwfile); return NULL; } @@ -141,13 +141,15 @@ : "Authorization"); int l; int s, vk = 0, vv = 0; - char *t, *key, *value; + const char *t; + char *key, *value; + const char *scheme; if (!(t = ap_auth_type(r)) || strcasecmp(t, "Digest")) return DECLINED; if (!ap_auth_name(r)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "need AuthName: %s", r->uri); return SERVER_ERROR; } @@ -157,10 +159,11 @@ return AUTH_REQUIRED; } - if (strcasecmp(ap_getword(r->pool, &auth_line, ' '), "Digest")) { + if (strcasecmp(scheme=ap_getword(r->pool, &auth_line, ' '), "Digest")) { /* Client tried to authenticate using wrong auth scheme */ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, - "client used wrong authentication scheme: %s", r->uri); + "client used wrong authentication scheme: %s for %s", + scheme, r->uri); ap_note_digest_auth_failure(r); return AUTH_REQUIRED; } @@ -196,7 +199,7 @@ break; case D_VALUE: - if (isalnum(auth_line[0])) { + if (ap_isalnum(auth_line[0])) { value[vv] = auth_line[0]; vv++; } @@ -224,7 +227,7 @@ break; case D_KEY: - if (isalnum(auth_line[0])) { + if (ap_isalnum(auth_line[0])) { key[vk] = auth_line[0]; vk++; } @@ -296,13 +299,13 @@ return DECLINED; if (!(a1 = get_hash(r, c->user, sec->pwfile))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "user %s not found: %s", c->user, r->uri); ap_note_digest_auth_failure(r); return AUTH_REQUIRED; } if (strcmp(response->digest, find_digest(r, response, a1))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "user %s: password mismatch: %s", c->user, r->uri); ap_note_digest_auth_failure(r); return AUTH_REQUIRED; @@ -320,7 +323,7 @@ register int x; const char *t; char *w; - array_header *reqs_arr; + const array_header *reqs_arr; require_line *reqs; if (!(t = ap_auth_type(r)) || strcasecmp(t, "Digest")) 1.3 +1 -1 apache-2.0/apache-nspr/modules/standard/mod_dir.c Index: mod_dir.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_dir.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_dir.c 1998/06/30 08:57:11 1.2 +++ mod_dir.c 1998/09/22 18:05:35 1.3 @@ -176,7 +176,7 @@ /* If the request returned a redirect, propagate it to the client */ - if (is_HTTP_REDIRECT(rr->status) || + if (ap_is_HTTP_REDIRECT(rr->status) || (rr->status == HTTP_NOT_ACCEPTABLE && num_names == 1)) { error_notfound = rr->status; 1.3 +10 -7 apache-2.0/apache-nspr/modules/standard/mod_expires.c Index: mod_expires.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_expires.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_expires.c 1998/06/30 08:57:11 1.2 +++ mod_expires.c 1998/09/22 18:05:35 1.3 @@ -283,7 +283,7 @@ while (word[0]) { /* <num> */ - if (isdigit(word[0])) { + if (ap_isdigit(word[0])) { num = atoi(word); } else { @@ -406,18 +406,15 @@ time_t expires; char age[20]; - if (is_HTTP_ERROR(r->status)) /* Don't add Expires headers to errors */ + if (ap_is_HTTP_ERROR(r->status)) /* Don't add Expires headers to errors */ return DECLINED; if (r->main != NULL) /* Say no to subrequests */ return DECLINED; - if (!r->file_exists) /* no file ? shame. */ - return DECLINED; - conf = (expires_dir_config *) ap_get_module_config(r->per_dir_config, &expires_module); if (conf == NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "internal error: %s", r->filename); return SERVER_ERROR; }; @@ -453,6 +450,12 @@ switch (code[0]) { case 'M': + if (r->finfo.st_mode == 0) { + /* file doesn't exist on disk, so we can't do anything based on + * modification time. Note that this does _not_ log an error. + */ + return DECLINED; + } base = r->finfo.st_mtime; additional = atoi(&code[1]); break; @@ -467,7 +470,7 @@ /* expecting the add_* routines to be case-hardened this * is just a reminder that module is beta */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "internal error: bad expires code: %s", r->filename); return SERVER_ERROR; }; 1.3 +11 -11 apache-2.0/apache-nspr/modules/standard/mod_imap.c Index: mod_imap.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_imap.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_imap.c 1998/06/30 08:57:11 1.2 +++ mod_imap.c 1998/09/22 18:05:36 1.3 @@ -263,7 +263,7 @@ return (-1); /* in case we aren't passed anything */ } - while (*args && !isdigit(*args) && *args != ',') { + while (*args && !ap_isdigit(*args) && *args != ',') { args++; /* jump to the first digit, but not past a comma or end */ } @@ -295,7 +295,7 @@ start_of_y++; /* start looking at the character after the comma */ - while (*start_of_y && !isdigit(*start_of_y)) { + while (*start_of_y && !ap_isdigit(*start_of_y)) { start_of_y++; /* jump to the first digit, but not past the end */ } @@ -326,7 +326,7 @@ /* assume there's no quoted part */ *quoted_part = NULL; - while (isspace(*strp)) { + while (ap_isspace(*strp)) { strp++; /* go along string until non-whitespace */ } @@ -385,7 +385,7 @@ } string_pos_const = value; - while (isalpha(*string_pos_const)) { + while (ap_isalpha(*string_pos_const)) { string_pos_const++; /* go along the URL from the map until a non-letter */ } @@ -406,7 +406,7 @@ /* must be a relative URL to be combined with base */ if (strchr(base, '/') == NULL && (!strncmp(value, "../", 3) || !strcmp(value, ".."))) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "invalid base directive in map file: %s", r->uri); return NULL; } @@ -466,7 +466,7 @@ value */ } else if (directory) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "invalid directory name in map file: %s", r->uri); return NULL; } @@ -744,17 +744,17 @@ sscanf(string_pos, "%lf%*[, ]%lf", &pointarray[vertex][X], &pointarray[vertex][Y]) == 2) { /* Now skip what we just read... we can't use ANSIism %n */ - while (isspace(*string_pos)) { /* past whitespace */ + while (ap_isspace(*string_pos)) { /* past whitespace */ string_pos++; } - while (isdigit(*string_pos)) { /* and the 1st number */ + while (ap_isdigit(*string_pos)) { /* and the 1st number */ string_pos++; } string_pos++; /* skip the ',' */ - while (isspace(*string_pos)) { /* past any more whitespace */ + while (ap_isspace(*string_pos)) { /* past any more whitespace */ string_pos++; } - while (isdigit(*string_pos)) { /* 2nd number */ + while (ap_isdigit(*string_pos)) { /* 2nd number */ string_pos++; } vertex++; @@ -865,7 +865,7 @@ we failed. They lose! */ need_2_fields: - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "map file %s, line %d syntax error: requires at " "least two fields", r->uri, imap->line_number); /* fall through */ 1.3 +89 -70 apache-2.0/apache-nspr/modules/standard/mod_include.c Index: mod_include.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_include.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_include.c 1998/06/30 08:57:11 1.2 +++ mod_include.c 1998/09/22 18:05:36 1.3 @@ -343,7 +343,7 @@ /* is it numeric ? */ if (s[1] == '#') { - for (j = 2, val = 0; j < i && isdigit(s[j]); j++) { + for (j = 2, val = 0; j < i && ap_isdigit(s[j]); j++) { val = val * 10 + s[j] - '0'; } s += i; @@ -396,7 +396,7 @@ do { /* skip whitespace */ GET_CHAR(in, c, NULL, p); - } while (isspace(c)); + } while (ap_isspace(c)); /* tags can't start with - */ if (c == '-') { @@ -404,7 +404,7 @@ if (c == '-') { do { GET_CHAR(in, c, NULL, p); - } while (isspace(c)); + } while (ap_isspace(c)); if (c == '>') { ap_cpystrn(tag, "done", tagbuf_len); return tag; @@ -419,17 +419,17 @@ *t = '\0'; return NULL; } - if (c == '=' || isspace(c)) { + if (c == '=' || ap_isspace(c)) { break; } - *(t++) = tolower(c); + *(t++) = ap_tolower(c); GET_CHAR(in, c, NULL, p); } *t++ = '\0'; tag_val = t; - while (isspace(c)) { + while (ap_isspace(c)) { GET_CHAR(in, c, NULL, p); /* space before = */ } if (c != '=') { @@ -439,7 +439,7 @@ do { GET_CHAR(in, c, NULL, p); /* space after = */ - } while (isspace(c)); + } while (ap_isspace(c)); /* we should allow a 'name' as a value */ @@ -484,7 +484,7 @@ /* skip initial whitespace */ while (1) { GET_CHAR(in, c, 1, p); - if (!isspace(c)) { + if (!ap_isspace(c)) { break; } } @@ -493,9 +493,9 @@ if (d - dest == len) { return 1; } - *d++ = tolower(c); + *d++ = ap_tolower(c); GET_CHAR(in, c, 1, p); - if (isspace(c)) { + if (ap_isspace(c)) { break; } } @@ -547,8 +547,8 @@ start_of_var_name = in; in = strchr(in, '}'); if (in == NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, - r->server, "Missing '}' on variable \"%s\"", + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, + r, "Missing '}' on variable \"%s\"", expansion); *next = '\0'; return; @@ -558,7 +558,7 @@ } else { start_of_var_name = in; - while (isalnum(*in) || *in == '_') { + while (ap_isalnum(*in) || *in == '_') { ++in; } end_of_var_name = in; @@ -640,7 +640,7 @@ /* Run it. */ rr_status = ap_run_sub_req(rr); - if (is_HTTP_REDIRECT(rr_status)) { + if (ap_is_HTTP_REDIRECT(rr_status)) { const char *location = ap_table_get(rr->headers_out, "Location"); location = ap_escape_html(rr->pool, location); ap_rvputs(r, "<A HREF=\"", location, "\">", location, "</A>", NULL); @@ -745,8 +745,8 @@ ap_chdir_file(r->filename); #endif if (error_fmt) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, - r->server, error_fmt, tag_val, r->filename); + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, + r, error_fmt, tag_val, r->filename); ap_rputs(error, r); } @@ -761,7 +761,7 @@ return 0; } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unknown parameter \"%s\" to tag include in %s", tag, r->filename); ap_rputs(error, r); @@ -843,7 +843,7 @@ if (!ap_bspawn_child(r->pool, include_cmd_child, &arg, kill_after_timeout, NULL, &script_in, NULL)) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "couldn't spawn include command"); return -1; } @@ -869,7 +869,7 @@ if (!strcmp(tag, "cmd")) { parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 1); if (include_cmd(parsed_string, r) == -1) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "execution failure for parameter \"%s\" " "to tag exec in file %s", tag, r->filename); @@ -883,7 +883,7 @@ else if (!strcmp(tag, "cgi")) { parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0); if (include_cgi(parsed_string, r) == -1) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "invalid CGI ref \"%s\" in %s", tag_val, file); ap_rputs(error, r); } @@ -896,7 +896,7 @@ return 0; } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unknown parameter \"%s\" to tag exec in %s", tag, file); ap_rputs(error, r); @@ -928,7 +928,7 @@ return 0; } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unknown parameter \"%s\" to tag echo in %s", tag, r->filename); ap_rputs(error, r); @@ -940,12 +940,13 @@ static int handle_perl(BUFF *in, request_rec *r, const char *error) { char tag[MAX_STRING_LEN]; + char parsed_string[MAX_STRING_LEN]; char *tag_val; SV *sub = Nullsv; AV *av = newAV(); if (!(ap_allow_options(r) & OPT_INCLUDES)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "httpd: #perl SSI disallowed by IncludesNoExec in %s", r->filename); return DECLINED; @@ -958,7 +959,8 @@ sub = newSVpv(tag_val, 0); } else if (strnEQ(tag, "arg", 3)) { - av_push(av, newSVpv(tag_val, 0)); + parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0); + av_push(av, newSVpv(parsed_string, 0)); } else if (strnEQ(tag, "done", 4)) { break; @@ -1016,7 +1018,7 @@ return 0; } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unknown parameter \"%s\" to tag config in %s", tag, r->filename); ap_rputs(error, r); @@ -1029,22 +1031,39 @@ char *tag_val, PRFileInfo *finfo, const char *error) { char *to_send; + request_rec *rr; + int ret=0; if (!strcmp(tag, "file")) { ap_getparents(tag_val); /* get rid of any nasties */ - to_send = ap_make_full_path(r->pool, "./", tag_val); - if (PR_GetFileInfo(to_send, finfo) != PR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, - "unable to get information about \"%s\" " + + rr = ap_sub_req_lookup_file(tag_val, r); + + if (rr->status == HTTP_OK && rr->finfo.st_mode != 0) { + to_send = rr->filename; + if ((ret = stat(to_send, finfo)) == -1) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, + "unable to get information about \"%s\" " + "in parsed file %s", + to_send, r->filename); + ap_rputs(error, r); + } + } + else { + ret = -1; + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, + "unable to lookup information about \"%s\" " "in parsed file %s", - to_send, r->filename); + tag_val, r->filename); ap_rputs(error, r); - return -1; } - return 0; + + ap_destroy_sub_req(rr); + + return ret; } else if (!strcmp(tag, "virtual")) { - request_rec *rr = ap_sub_req_lookup_uri(tag_val, r); + rr = ap_sub_req_lookup_uri(tag_val, r); if (rr->status == HTTP_OK && rr->file_exists) { *finfo = rr->finfo; @@ -1052,7 +1071,7 @@ return 0; } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unable to get information about \"%s\" " "in parsed file %s", tag_val, r->filename); @@ -1062,7 +1081,7 @@ } } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unknown parameter \"%s\" to tag %s in %s", tag, directive, r->filename); ap_rputs(error, r); @@ -1137,7 +1156,7 @@ compiled = ap_pregcomp(r->pool, rexp, REG_EXTENDED | REG_NOSUB); if (compiled == NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unable to compile pattern \"%s\"", rexp); return -1; } @@ -1171,7 +1190,7 @@ return (char *) NULL; } while ((ch = *string++)) { - if (!isspace(ch)) { + if (!ap_isspace(ch)) { break; } } @@ -1260,7 +1279,7 @@ continue; } if (!qs) { - if (isspace(ch)) { + if (ap_isspace(ch)) { goto TOKEN_DONE; } switch (ch) { @@ -1382,7 +1401,7 @@ current = current->right = new; break; default: - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1396,7 +1415,7 @@ ap_rputs(" Token: and/or\n", r); #endif if (current == (struct parse_node *) NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1421,7 +1440,7 @@ case token_lbrace: break; default: - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1466,7 +1485,7 @@ case token_lt: break; default: - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1498,7 +1517,7 @@ ap_rputs(" Token: eq/ne/ge/gt/le/lt\n", r); #endif if (current == (struct parse_node *) NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1523,7 +1542,7 @@ case token_le: case token_lt: default: - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1557,7 +1576,7 @@ current = current->parent; } if (current == (struct parse_node *) NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Unmatched ')' in \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1590,7 +1609,7 @@ case token_string: case token_group: default: - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1638,7 +1657,7 @@ #endif if (current->left == (struct parse_node *) NULL || current->right == (struct parse_node *) NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1703,7 +1722,7 @@ (current->right == (struct parse_node *) NULL) || (current->left->token.type != token_string) || (current->right->token.type != token_string)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1724,7 +1743,7 @@ current->right->token.value[len - 1] = '\0'; } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid rexp \"%s\" in file %s", current->right->token.value, r->filename); ap_rputs(error, r); @@ -1768,7 +1787,7 @@ (current->right == (struct parse_node *) NULL) || (current->left->token.type != token_string) || (current->right->token.type != token_string)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid expression \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); @@ -1851,21 +1870,21 @@ break; case token_lbrace: - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Unmatched '(' in \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); goto RETURN; case token_rbrace: - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Unmatched ')' in \"%s\" in file %s", expr, r->filename); ap_rputs(error, r); goto RETURN; default: - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "bad token type"); ap_rputs(error, r); goto RETURN; @@ -1893,7 +1912,7 @@ } else if (!strcmp(tag, "done")) { if (expr == NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "missing expr in if statement: %s", r->filename); ap_rputs(error, r); @@ -1913,7 +1932,7 @@ #endif } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unknown parameter \"%s\" to tag if in %s", tag, r->filename); ap_rputs(error, r); @@ -1944,7 +1963,7 @@ return (0); } if (expr == NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "missing expr in elif statement: %s", r->filename); ap_rputs(error, r); @@ -1964,7 +1983,7 @@ #endif } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "unknown parameter \"%s\" to tag if in %s", tag, r->filename); ap_rputs(error, r); @@ -1990,7 +2009,7 @@ return 0; } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "else directive does not take tags in %s", r->filename); if (*printing) { @@ -2018,7 +2037,7 @@ return 0; } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "endif directive does not take tags in %s", r->filename); ap_rputs(error, r); @@ -2046,7 +2065,7 @@ } else if (!strcmp(tag, "value")) { if (var == (char *) NULL) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "variable must precede value in set directive in %s", r->filename); ap_rputs(error, r); @@ -2061,7 +2080,7 @@ } } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Invalid tag for set directive in %s", r->filename); ap_rputs(error, r); return -1; @@ -2094,7 +2113,7 @@ return 0; } else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "printenv directive does not take tags in %s", r->filename); ap_rputs(error, r); @@ -2139,7 +2158,7 @@ while (1) { if (!find_string(f, STARTING_SEQUENCE, r, printing)) { if (get_directive(f, directive, sizeof(directive), r->pool)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "mod_include: error reading directive in %s", r->filename); ap_rputs(error, r); @@ -2185,7 +2204,7 @@ } if (!strcmp(directive, "exec")) { if (noexec) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "httpd: exec used but not allowed in %s", r->filename); if (printing) { @@ -2224,7 +2243,7 @@ } #endif else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "httpd: unknown directive \"%s\" " "in parsed doc %s", directive, r->filename); @@ -2234,7 +2253,7 @@ ret = find_string(f, ENDING_SEQUENCE, r, 0); } if (ret) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "httpd: premature EOF in parsed file %s", r->filename); return; @@ -2306,7 +2325,7 @@ return DECLINED; } if (!r->file_exists) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "File does not exist: %s", (r->path_info ? ap_pstrcat(r->pool, r->filename, r->path_info, NULL) @@ -2315,14 +2334,14 @@ } if (!(f = ap_bopenf(r->pool, r->filename, PR_RDONLY, 0))) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "file permissions deny server access: %s", r->filename); return HTTP_FORBIDDEN; } if ((*state == xbithack_full) /* XXX: how do we do xbithack under NSPR? */ -#if 0 /* !defined(__EMX__) && !defined(WIN32) */ +#if 0 /* !defined(OS2) && !defined(WIN32) */ /* OS/2 dosen't support Groups. */ && (r->finfo.st_mode & S_IXGRP) #endif @@ -2387,7 +2406,7 @@ static int xbithack_handler(request_rec *r) { /* XXX: how do we do xbithack under NSPR? */ -#if 1 /* defined(__EMX__) || defined(WIN32) */ +#if 1 /* defined(OS2) || defined(WIN32) */ /* OS/2 dosen't currently support the xbithack. This is being worked on. */ return DECLINED; #else 1.3 +3 -3 apache-2.0/apache-nspr/modules/standard/mod_info.c Index: mod_info.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_info.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_info.c 1998/06/30 08:57:12 1.2 +++ mod_info.c 1998/09/22 18:05:37 1.3 @@ -171,7 +171,7 @@ fp = ap_pcfg_openfile(p, filename); if (!fp) { - ap_log_error(APLOG_MARK, APLOG_WARNING, r->server, + ap_log_rerror(APLOG_MARK, APLOG_WARNING, r, "mod_info: couldn't open config file %s", filename); return NULL; @@ -405,8 +405,8 @@ "<font size=+1><tt>%s</tt></a></font><br>\n", ap_get_server_built()); ap_rprintf(r, "<strong>API Version:</strong> " - "<tt>%d</tt><br>\n", - MODULE_MAGIC_NUMBER); + "<tt>%d:%d</tt><br>\n", + MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); ap_rprintf(r, "<strong>Run Mode:</strong> <tt>%s</tt><br>\n", (ap_standalone ? "standalone" : "inetd")); ap_rprintf(r, "<strong>User/Group:</strong> " 1.3 +4 -5 apache-2.0/apache-nspr/modules/standard/mod_log_config.c Index: mod_log_config.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_log_config.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_log_config.c 1998/06/30 08:57:12 1.2 +++ mod_log_config.c 1998/09/22 18:05:37 1.3 @@ -198,10 +198,9 @@ * multi_log_state is our per-(virtual)-server configuration. We store * an array of the logs we are going to use, each of type config_log_state. * If a default log format is given by LogFormat, store in default_format - * (backward compat. with mod_log_config). We also store a pointer to - * the logs specified for the main server for virtual servers, so that - * if this vhost has now logs defined, we can use the main server's - * logs instead. + * (backward compat. with mod_log_config). We also store for each virtual + * server a pointer to the logs specified for the main server, so that if this + * vhost has no logs defined, we can use the main server's logs instead. * * So, for the main server, config_logs contains a list of the log files * and server_config_logs in empty. For a vhost, server_config_logs @@ -594,7 +593,7 @@ case '8': case '9': i = *s - '0'; - while (isdigit(*++s)) { + while (ap_isdigit(*++s)) { i = i * 10 + (*s) - '0'; } if (!it->conditions) { 1.3 +1 -1 apache-2.0/apache-nspr/modules/standard/mod_mime.c Index: mod_mime.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_mime.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_mime.c 1998/06/30 08:57:12 1.2 +++ mod_mime.c 1998/09/22 18:05:38 1.3 @@ -199,7 +199,7 @@ * equivalent to 27 in ASCII, and makes it work in EBCDIC. */ #define MIME_HASHSIZE ('z'-'a'+2) -#define hash(i) (isalpha(i) ? (tolower(i)) - 'a' : (MIME_HASHSIZE-1)) +#define hash(i) (ap_isalpha(i) ? (ap_tolower(i)) - 'a' : (MIME_HASHSIZE-1)) static table *hash_buckets[MIME_HASHSIZE]; 1.3 +64 -74 apache-2.0/apache-nspr/modules/standard/mod_mime_magic.c Index: mod_mime_magic.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_mime_magic.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_mime_magic.c 1998/06/30 08:57:12 1.2 +++ mod_mime_magic.c 1998/09/22 18:05:38 1.3 @@ -572,7 +572,7 @@ /* make sure we have a list to put it in */ if (!req_dat) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r, MODNAME ": request config should not be NULL"); if (!(req_dat = magic_set_config(r))) { /* failure */ @@ -674,7 +674,7 @@ /* clean up and return */ result[res_pos] = 0; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": rsl_strdup() %d chars: %s", res_pos - 1, result); #endif return result; @@ -718,7 +718,7 @@ frag = frag->next, cur_frag++) { /* loop through the characters in the fragment */ for (cur_pos = 0; frag->str[cur_pos]; cur_pos++) { - if (isspace(frag->str[cur_pos])) { + if (ap_isspace(frag->str[cur_pos])) { /* process whitespace actions for each state */ if (state == rsl_leading_space) { /* eat whitespace in this state */ @@ -746,7 +746,7 @@ else { /* should not be possible */ /* abandon malfunctioning module */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r, MODNAME ": bad state %d (ws)", state); return DECLINED; } @@ -790,7 +790,7 @@ else { /* should not be possible */ /* abandon malfunctioning module */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r, MODNAME ": bad state %d (ns)", state); return DECLINED; } @@ -865,7 +865,7 @@ if ((fd = ap_popenfd(r->pool, r->filename, PR_RDONLY, 0)) < 0) { /* We can't open it, but we were able to stat it. */ - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, MODNAME ": can't read `%s'", r->filename); /* let some other handler decide what the problem is */ return DECLINED; @@ -875,7 +875,7 @@ * try looking at the first HOWMANY bytes */ if ((nbytes = PR_Read(fd, (char *) buf, sizeof(buf) - 1)) == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, MODNAME ": read failed: %s", r->filename); return HTTP_INTERNAL_SERVER_ERROR; } @@ -920,8 +920,7 @@ magic_rsl_puts(r, MIME_BINARY_UNKNOWN); } -#define EATAB {while (isascii((unsigned char) *l) && \ - isspace((unsigned char) *l)) ++l;} +#define EATAB {while (ap_isspace((unsigned char) *l)) ++l;} /* * apprentice - load configuration from the magic file r @@ -964,7 +963,7 @@ /* skip leading whitespace */ ws_offset = 0; - while (line[ws_offset] && isspace(line[ws_offset])) { + while (line[ws_offset] && ap_isspace(line[ws_offset])) { ws_offset++; } @@ -1007,10 +1006,10 @@ ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, s, MODNAME ": apprentice test"); for (m = conf->magic; m; m = m->next) { - if (isprint((((unsigned long) m) >> 24) & 255) && - isprint((((unsigned long) m) >> 16) & 255) && - isprint((((unsigned long) m) >> 8) & 255) && - isprint(((unsigned long) m) & 255)) { + if (ap_isprint((((unsigned long) m) >> 24) & 255) && + ap_isprint((((unsigned long) m) >> 16) & 255) && + ap_isprint((((unsigned long) m) >> 8) & 255) && + ap_isprint(((unsigned long) m) & 255)) { ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, s, MODNAME ": apprentice: POINTER CLOBBERED! " "m=\"%c%c%c%c\" line=%d", @@ -1138,7 +1137,7 @@ s = l; if (*l == '+' || *l == '-') l++; - if (isdigit((unsigned char) *l)) { + if (ap_isdigit((unsigned char) *l)) { m->in.offset = strtol(l, &t, 0); if (*s == '-') m->in.offset = -m->in.offset; @@ -1153,7 +1152,7 @@ } - while (isascii((unsigned char) *l) && isdigit((unsigned char) *l)) + while (ap_isdigit((unsigned char) *l)) ++l; EATAB; @@ -1251,8 +1250,7 @@ } /* FALL THROUGH */ default: - if (*l == 'x' && isascii((unsigned char) l[1]) && - isspace((unsigned char) l[1])) { + if (*l == 'x' && ap_isspace((unsigned char) l[1])) { m->reln = *l; ++l; goto GetDesc; /* Bill The Cat */ @@ -1324,7 +1322,7 @@ register int val; while ((c = *s++) != '\0') { - if (isspace((unsigned char) c)) + if (ap_isspace((unsigned char) c)) break; if (p >= pmax) { ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, serv, @@ -1427,9 +1425,7 @@ /* Single hex char to int; -1 if not a hex char. */ static int hextoint(int c) { - if (!isascii((unsigned char) c)) - return -1; - if (isdigit((unsigned char) c)) + if (ap_isdigit((unsigned char) c)) return c - '0'; if ((c >= 'a') && (c <= 'f')) return c + 10 - 'a'; @@ -1519,7 +1515,7 @@ struct magic *m; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": match conf=%x file=%s m=%s m->next=%s last=%s", conf, conf->magicfile ? conf->magicfile : "NULL", @@ -1530,11 +1526,11 @@ #if MIME_MAGIC_DEBUG for (m = conf->magic; m; m = m->next) { - if (isprint((((unsigned long) m) >> 24) & 255) && - isprint((((unsigned long) m) >> 16) & 255) && - isprint((((unsigned long) m) >> 8) & 255) && - isprint(((unsigned long) m) & 255)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + if (ap_isprint((((unsigned long) m) >> 24) & 255) && + ap_isprint((((unsigned long) m) >> 16) & 255) && + ap_isprint((((unsigned long) m) >> 8) & 255) && + ap_isprint(((unsigned long) m) & 255)) { + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": match: POINTER CLOBBERED! " "m=\"%c%c%c%c\"", (((unsigned long) m) >> 24) & 255, @@ -1549,7 +1545,7 @@ for (m = conf->magic; m; m = m->next) { #if MIME_MAGIC_DEBUG rule_counter++; - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": line=%d desc=%s", m->lineno, m->desc); #endif @@ -1569,7 +1565,7 @@ while (m_cont && (m_cont->cont_level != 0)) { #if MIME_MAGIC_DEBUG rule_counter++; - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": line=%d mc=%x mc->next=%x cont=%d desc=%s", m_cont->lineno, m_cont, m_cont->next, m_cont->cont_level, @@ -1588,7 +1584,7 @@ /* if we get here, the main entry rule was a match */ /* this will be the last run through the loop */ #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": rule matched, line=%d type=%d %s", m->lineno, m->type, (m->type == STRING) ? m->value.s : ""); @@ -1612,7 +1608,7 @@ m = m->next; while (m && (m->cont_level != 0)) { #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": match line=%d cont=%d type=%d %s", m->lineno, m->cont_level, m->type, (m->type == STRING) ? m->value.s : ""); @@ -1656,13 +1652,13 @@ m = m->next; } #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": matched after %d rules", rule_counter); #endif return 1; /* all through */ } #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": failed after %d rules", rule_counter); #endif return 0; /* no match at all */ @@ -1704,7 +1700,7 @@ /* who cares about the time when we're generating mime-types? */ return; default: - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r, MODNAME ": invalid m->type (%d) in mprint().", m->type); return; @@ -1750,7 +1746,7 @@ ((p->hl[3] << 24) | (p->hl[2] << 16) | (p->hl[1] << 8) | (p->hl[0])); return 1; default: - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r, MODNAME ": invalid type %d in mconvert().", m->type); return 0; } @@ -1802,7 +1798,7 @@ int matched; if ((m->value.s[0] == 'x') && (m->value.s[1] == '\0')) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r, MODNAME ": BOINK"); return 1; } @@ -1847,7 +1843,7 @@ break; default: /* bogosity, pretend that it just wasn't a match */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r, MODNAME ": invalid type %d in mcheck().", m->type); return 0; } @@ -1857,7 +1853,7 @@ switch (m->reln) { case 'x': #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, "%lu == *any* = 1", v); #endif matched = 1; @@ -1866,7 +1862,7 @@ case '!': matched = v != l; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, "%lu != %lu = %d", v, l, matched); #endif break; @@ -1874,7 +1870,7 @@ case '=': matched = v == l; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, "%lu == %lu = %d", v, l, matched); #endif break; @@ -1883,14 +1879,14 @@ if (m->flag & UNSIGNED) { matched = v > l; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, "%lu > %lu = %d", v, l, matched); #endif } else { matched = (long) v > (long) l; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, "%ld > %ld = %d", v, l, matched); #endif } @@ -1900,14 +1896,14 @@ if (m->flag & UNSIGNED) { matched = v < l; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, "%lu < %lu = %d", v, l, matched); #endif } else { matched = (long) v < (long) l; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, "%ld < %ld = %d", v, l, matched); #endif } @@ -1916,7 +1912,7 @@ case '&': matched = (v & l) == l; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, "((%lx & %lx) == %lx) = %d", v, l, l, matched); #endif break; @@ -1924,7 +1920,7 @@ case '^': matched = (v & l) != l; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, "((%lx & %lx) != %lx) = %d", v, l, l, matched); #endif break; @@ -1932,7 +1928,7 @@ default: /* bogosity, pretend it didn't match */ matched = 0; - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r, MODNAME ": mcheck: can't happen: invalid relation %d.", m->reln); break; @@ -1946,7 +1942,7 @@ static int ascmagic(request_rec *r, unsigned char *buf, int nbytes) { - int i, has_escapes = 0; + int has_escapes = 0; unsigned char *s; char nbuf[HOWMANY + 1]; /* one extra for terminating '\0' */ char *token; @@ -1963,16 +1959,15 @@ if (*buf == '.') { unsigned char *tp = buf + 1; - while (isascii(*tp) && isspace(*tp)) + while (ap_isspace(*tp)) ++tp; /* skip leading whitespace */ - if ((isascii(*tp) && (isalnum(*tp) || *tp == '\\') && - isascii(*(tp + 1)) && (isalnum(*(tp + 1)) || *tp == '"'))) { + if ((ap_isalnum(*tp) || *tp == '\\') && + (ap_isalnum(*(tp + 1)) || *tp == '"')) { magic_rsl_puts(r, "application/x-troff"); return 1; } } - if ((*buf == 'c' || *buf == 'C') && - isascii(*(buf + 1)) && isspace(*(buf + 1))) { + if ((*buf == 'c' || *buf == 'C') && ap_isspace(*(buf + 1))) { /* Fortran */ magic_rsl_puts(r, "text/plain"); return 1; @@ -2009,11 +2004,6 @@ return 1; } - for (i = 0; i < nbytes; i++) { - if (!isascii(*(buf + i))) - return 0; /* not all ascii */ - } - /* all else fails, but it is ascii... */ if (has_escapes) { /* text with escape sequences */ @@ -2115,7 +2105,7 @@ return (child_pid); #else execvp(compr[parm->method].argv[0], compr[parm->method].argv); - ap_log_error(APLOG_MARK, APLOG_ERR, parm->r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, parm->r, MODNAME ": could not execute `%s'.", compr[parm->method].argv[0]); return -1; @@ -2145,14 +2135,14 @@ if (!ap_bspawn_child(sub_pool, uncompress_child, &parm, kill_always, &bin, &bout, NULL)) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, MODNAME ": couldn't spawn uncompress process: %s", r->uri); return -1; } if (ap_bwrite(bin, old, n) != n) { ap_destroy_pool(sub_pool); - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, MODNAME ": write failed."); return -1; } @@ -2160,7 +2150,7 @@ *newch = (unsigned char *) ap_palloc(r->pool, n); if ((n = ap_bread(bout, *newch, n)) <= 0) { ap_destroy_pool(sub_pool); - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, MODNAME ": read failed %s", r->filename); return -1; } @@ -2234,7 +2224,7 @@ { register long value; - while (isspace(*where)) { /* Skip spaces */ + while (ap_isspace(*where)) { /* Skip spaces */ where++; if (--digs <= 0) return -1; /* All blank field */ @@ -2245,7 +2235,7 @@ --digs; } - if (digs > 0 && *where && !isspace(*where)) + if (digs > 0 && *where && !ap_isspace(*where)) return -1; /* Ended on non-space/nul */ return value; @@ -2268,16 +2258,16 @@ request_rec *sub; #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": revision_suffix checking %s", r->filename); #endif /* MIME_MAGIC_DEBUG */ /* check for recognized revision suffix */ suffix_pos = strlen(r->filename) - 1; - if (!isdigit(r->filename[suffix_pos])) { + if (!ap_isdigit(r->filename[suffix_pos])) { return 0; } - while (suffix_pos >= 0 && isdigit(r->filename[suffix_pos])) + while (suffix_pos >= 0 && ap_isdigit(r->filename[suffix_pos])) suffix_pos--; if (suffix_pos < 0 || r->filename[suffix_pos] != '@') { return 0; @@ -2287,7 +2277,7 @@ result = 0; sub_filename = ap_pstrndup(r->pool, r->filename, suffix_pos); #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": subrequest lookup for %s", sub_filename); #endif /* MIME_MAGIC_DEBUG */ sub = ap_sub_req_lookup_file(sub_filename, r); @@ -2296,7 +2286,7 @@ if (sub->content_type) { r->content_type = ap_pstrdup(r->pool, sub->content_type); #if MIME_MAGIC_DEBUG - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, r, MODNAME ": subrequest %s got %s", sub_filename, r->content_type); #endif /* MIME_MAGIC_DEBUG */ @@ -2345,10 +2335,10 @@ ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, s, MODNAME ": magic_init 1 test"); for (m = conf->magic; m; m = m->next) { - if (isprint((((unsigned long) m) >> 24) & 255) && - isprint((((unsigned long) m) >> 16) & 255) && - isprint((((unsigned long) m) >> 8) & 255) && - isprint(((unsigned long) m) & 255)) { + if (ap_isprint((((unsigned long) m) >> 24) & 255) && + ap_isprint((((unsigned long) m) >> 16) & 255) && + ap_isprint((((unsigned long) m) >> 8) & 255) && + ap_isprint(((unsigned long) m) & 255)) { ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, s, MODNAME ": magic_init 1: POINTER CLOBBERED! " "m=\"%c%c%c%c\" line=%d", 1.3 +15 -15 apache-2.0/apache-nspr/modules/standard/mod_negotiation.c Index: mod_negotiation.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_negotiation.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_negotiation.c 1998/06/30 08:57:12 1.2 +++ mod_negotiation.c 1998/09/22 18:05:39 1.3 @@ -346,8 +346,8 @@ /* Look for 'var = value' --- and make sure the var is in lcase. */ - for (cp = parm; (*cp && !isspace(*cp) && *cp != '='); ++cp) { - *cp = tolower(*cp); + for (cp = parm; (*cp && !ap_isspace(*cp) && *cp != '='); ++cp) { + *cp = ap_tolower(*cp); } if (!*cp) { @@ -355,7 +355,7 @@ } *cp++ = '\0'; /* Delimit var */ - while (*cp && (isspace(*cp) || *cp == '=')) { + while (*cp && (ap_isspace(*cp) || *cp == '=')) { ++cp; } @@ -366,7 +366,7 @@ end++); } else { - for (end = cp; (*end && !isspace(*end)); end++); + for (end = cp; (*end && !ap_isspace(*end)); end++); } if (*end) { *end = '\0'; /* strip ending quote or return */ @@ -583,7 +583,7 @@ /* If blank, just return it --- this ends information on this variant */ - for (cp = buffer; (*cp && isspace(*cp)); ++cp) { + for (cp = buffer; (*cp && ap_isspace(*cp)); ++cp) { continue; } @@ -604,13 +604,13 @@ continue; } } - else if (isspace(c)) { + else if (ap_isspace(c)) { /* Leading whitespace. POSSIBLE continuation line * Also, possibly blank --- if so, we ungetc() the final newline * so that we will pick up the blank line the next time 'round. */ - while (c != EOF && c != '\n' && isspace(c)) { + while (c != EOF && c != '\n' && ap_isspace(c)) { c = ap_bgetc(map); } @@ -677,21 +677,21 @@ char *cp = header; for ( ; *cp && *cp != ':' ; ++cp) { - *cp = tolower(*cp); + *cp = ap_tolower(*cp); } if (!*cp) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Syntax error in type map --- no ':': %s", r->filename); return NULL; } do { ++cp; - } while (*cp && isspace(*cp)); + } while (*cp && ap_isspace(*cp)); if (!*cp) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Syntax error in type map --- no header body: %s", r->filename); return NULL; @@ -713,7 +713,7 @@ map = ap_bopenf(neg->pool, rr->filename, PR_RDONLY, 0); if (map == NULL) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "cannot access type map file: %s", rr->filename); return HTTP_FORBIDDEN; } @@ -805,7 +805,7 @@ dirp = ap_popendir(neg->pool, neg->dir_name); if (dirp == NULL) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "cannot read directory for multi: %s", neg->dir_name); return HTTP_FORBIDDEN; } @@ -2052,7 +2052,7 @@ } if (!best) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "no acceptable variant: %s", r->filename); set_neg_headers(r, neg, na_result); @@ -2139,7 +2139,7 @@ } if (!best) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "no acceptable variant: %s", r->filename); set_neg_headers(r, neg, na_result); 1.3 +58 -35 apache-2.0/apache-nspr/modules/standard/mod_rewrite.c Index: mod_rewrite.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_rewrite.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_rewrite.c 1998/06/30 08:57:12 1.2 +++ mod_rewrite.c 1998/09/22 18:05:39 1.3 @@ -850,10 +850,10 @@ else if (strcasecmp(val, "seeother") == 0) { status = HTTP_SEE_OTHER; } - else if (isdigit(*val)) { + else if (ap_isdigit(*val)) { status = atoi(val); } - if (!is_HTTP_REDIRECT(status)) { + if (!ap_is_HTTP_REDIRECT(status)) { return "RewriteRule: invalid HTTP response code " "for flag 'R'"; } @@ -1001,6 +1001,7 @@ char buf[512]; char docroot[512]; char *cp, *cp2; + const char *ccp; unsigned int port; int n; int l; @@ -1095,7 +1096,7 @@ * we can actually use it! */ if (!proxy_available) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "attempt to make remote request from mod_rewrite " "without proxy enabled: %s", r->filename); return FORBIDDEN; @@ -1155,7 +1156,7 @@ } /* determine HTTP redirect response code */ - if (is_HTTP_REDIRECT(r->status)) { + if (ap_is_HTTP_REDIRECT(r->status)) { n = r->status; r->status = HTTP_OK; /* make Apache kernel happy */ } @@ -1228,8 +1229,8 @@ */ n = prefix_stat(r->filename); if (n == 0) { - if ((cp = ap_document_root(r)) != NULL) { - l = ap_cpystrn(docroot, cp, sizeof(docroot)) - docroot; + if ((ccp = ap_document_root(r)) != NULL) { + l = ap_cpystrn(docroot, ccp, sizeof(docroot)) - docroot; /* always NOT have a trailing slash */ if (docroot[l-1] == '/') { @@ -1302,6 +1303,7 @@ rewrite_perdir_conf *dconf; char *cp; char *cp2; + const char *ccp; char *prefix; int l; int n; @@ -1332,7 +1334,7 @@ */ if (!(ap_allow_options(r) & (OPT_SYM_LINKS | OPT_SYM_OWNER))) { /* FollowSymLinks is mandatory! */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Options FollowSymLinks or SymLinksIfOwnerMatch is off " "which implies that RewriteRule directive is forbidden: " "%s", r->filename); @@ -1444,7 +1446,7 @@ } /* determine HTTP redirect response code */ - if (is_HTTP_REDIRECT(r->status)) { + if (ap_is_HTTP_REDIRECT(r->status)) { n = r->status; r->status = HTTP_OK; /* make Apache kernel happy */ } @@ -1519,8 +1521,8 @@ * for this webserver and only try to remove the * document_root if it is prefix */ - if ((cp = ap_document_root(r)) != NULL) { - prefix = ap_pstrdup(r->pool, cp); + if ((ccp = ap_document_root(r)) != NULL) { + prefix = ap_pstrdup(r->pool, ccp); /* always NOT have a trailing slash */ l = strlen(prefix); if (prefix[l-1] == '/') { @@ -1726,6 +1728,7 @@ { char *uri; char *output; + const char *vary; char newuri[MAX_STRING_LEN]; char env[MAX_STRING_LEN]; regex_t *regexp; @@ -1839,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 { @@ -1864,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 @@ -2153,7 +2174,7 @@ } else if (strcmp(p->pattern, "-l") == 0) { /* XXX: how do we do lstat in NSPR? */ -#if 0 /* !defined(__EMX__) && !defined(WIN32) */ +#if 0 /* !defined(OS2) && !defined(WIN32) */ if (lstat(input, &sb) == 0) { if (S_ISLNK(sb.st_mode)) { rc = 1; @@ -2329,21 +2350,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++) ; @@ -2594,8 +2615,8 @@ if (cpT != NULL) { n = strlen(cpT); if (cpO + n >= newuri + sizeof(newuri)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, - r->server, "insufficient space in " + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, + r, "insufficient space in " "expand_map_lookups, aborting"); return; } @@ -2605,8 +2626,8 @@ else { n = strlen(defaultvalue); if (cpO + n >= newuri + sizeof(newuri)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, - r->server, "insufficient space in " + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, + r, "insufficient space in " "expand_map_lookups, aborting"); return; } @@ -2620,8 +2641,8 @@ cpT = cpI+strlen(cpI); n = cpT-cpI; if (cpO + n >= newuri + sizeof(newuri)) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, - r->server, "insufficient space in " + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, + r, "insufficient space in " "expand_map_lookups, aborting"); return; } @@ -2671,7 +2692,7 @@ if (strcmp(s->name, name) == 0) { if (s->type == MAPTYPE_TXT) { if (PR_GetFileInfo(s->checkfile, &st) != PR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "mod_rewrite: can't access text RewriteMap " "file %s", s->checkfile); rewritelog(r, 1, "can't open RewriteMap file, " @@ -2706,7 +2727,7 @@ else if (s->type == MAPTYPE_DBM) { #ifndef NO_DBM_REWRITEMAP if (PR_GetFileInfo(s->checkfile, &st) != PR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "mod_rewrite: can't access DBM RewriteMap " "file %s", s->checkfile); rewritelog(r, 1, "can't open DBM RewriteMap file, " @@ -2769,7 +2790,7 @@ } else if (s->type == MAPTYPE_RND) { if (PR_GetFileInfo(s->checkfile, &st) != PR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "mod_rewrite: can't access text RewriteMap " "file %s", s->checkfile); rewritelog(r, 1, "can't open RewriteMap file, " @@ -2936,7 +2957,7 @@ for (cp = value = ap_pstrdup(r->pool, key); cp != NULL && *cp != '\0'; cp++) { - *cp = toupper(*cp); + *cp = ap_toupper(*cp); } return value; } @@ -2947,7 +2968,7 @@ for (cp = value = ap_pstrdup(r->pool, key); cp != NULL && *cp != '\0'; cp++) { - *cp = tolower(*cp); + *cp = ap_tolower(*cp); } return value; } @@ -3419,7 +3440,7 @@ child_pid = pi.dwProcessId; } } -#elif defined(__EMX__) +#elif defined(OS2) /* IBM OS/2 */ execl(SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); #else @@ -3595,7 +3616,8 @@ result = ap_get_server_version(); } else if (strcasecmp(var, "API_VERSION") == 0) { /* non-standard */ - ap_snprintf(resultbuf, sizeof(resultbuf), "%d", MODULE_MAGIC_NUMBER); + ap_snprintf(resultbuf, sizeof(resultbuf), "%d:%d", + MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); result = resultbuf; } @@ -3745,6 +3767,7 @@ continue; } if (strcasecmp(hdrs[i].key, name) == 0) { + ap_table_merge(r->notes, VARY_KEY_THIS, name); return hdrs[i].val; } } @@ -4100,7 +4123,7 @@ #endif if (rc < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "mod_rewrite: failed to lock file descriptor"); exit(1); } @@ -4130,7 +4153,7 @@ #endif if (rc < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "mod_rewrite: failed to unlock file descriptor"); exit(1); } 1.3 +10 -2 apache-2.0/apache-nspr/modules/standard/mod_rewrite.h Index: mod_rewrite.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_rewrite.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_rewrite.h 1998/06/30 08:57:12 1.2 +++ mod_rewrite.h 1998/09/22 18:05:40 1.3 @@ -96,11 +96,19 @@ /* 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" #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, @@ -118,7 +126,7 @@ /* The locking support: * Try to determine whether we should use fcntl() or flock(). - * Would be better conf.h could provide this... :-( + * Would be better ap_config.h could provide this... :-( */ #if defined(USE_FCNTL_SERIALIZED_ACCEPT) #define USE_FCNTL 1 @@ -217,7 +225,7 @@ #define LONG_STRING_LEN 2048 #endif -#define MAX_ENV_FLAGS 5 +#define MAX_ENV_FLAGS 15 #define MAX_NMATCH 10 1.3 +4 -0 apache-2.0/apache-nspr/modules/standard/mod_so.c Index: mod_so.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_so.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_so.c 1998/06/30 08:57:12 1.2 +++ mod_so.c 1998/09/22 18:05:40 1.3 @@ -153,6 +153,10 @@ soc = (so_server_conf *)ap_pcalloc(p, sizeof(so_server_conf)); soc->loaded_modules = ap_make_array(p, DYNAMIC_MODULE_LIMIT, sizeof(moduleinfo)); +#ifndef NO_DLOPEN + ap_os_dso_init(); +#endif + return (void *)soc; } 1.3 +146 -66 apache-2.0/apache-nspr/modules/standard/mod_speling.c Index: mod_speling.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_speling.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_speling.c 1998/06/30 08:57:13 1.2 +++ mod_speling.c 1998/09/22 18:05:41 1.3 @@ -68,7 +68,8 @@ * capitalizations. If it finds a match, it sends a redirect. * * 08-Aug-1997 <[EMAIL PROTECTED]> - * o Upgraded module interface to apache_1.3a2-dev API (more NULL's in speling_module). + * o Upgraded module interface to apache_1.3a2-dev API (more NULL's in + * speling_module). * o Integrated tcsh's "spelling correction" routine which allows one * misspelling (character insertion/omission/typo/transposition). * Rewrote it to ignore case as well. This ought to catch the majority @@ -84,29 +85,64 @@ MODULE_VAR_EXPORT module speling_module; -/* We use the "unconventional" mod_userdir approach here. And heck, - * here it's just one int! +typedef struct { + int enabled; +} spconfig; + +/* + * Create a configuration specific to this module for a server or directory + * location, and fill it with the default settings. + * + * The API says that in the absence of a merge function, the record for the + * closest ancestor is used exclusively. That's what we want, so we don't + * bother to have such a function. + */ + +static void *mkconfig(pool *p) +{ + spconfig *cfg = ap_pcalloc(p, sizeof(spconfig)); + + cfg->enabled = 0; + return cfg; +} + +/* + * Respond to a callback to create configuration record for a server or + * vhost environment. */ +static void *create_mconfig_for_server(pool *p, server_rec *s) +{ + return mkconfig(p); +} -static void *create_speling_config(pool *dummy, server_rec *s) +/* + * Respond to a callback to create a config record for a specific directory. + */ +static void *create_mconfig_for_directory(pool *p, char *dir) { - return (void *) 0; + return mkconfig(p); } -static const char *set_speling(cmd_parms *cmd, void *dummy, int arg) +/* + * Handler for the CheckSpelling directive, which is FLAG. + */ +static const char *set_speling(cmd_parms *cmd, void *mconfig, int arg) { - void *server_conf = cmd->server->module_config; + spconfig *cfg = (spconfig *) mconfig; - /* any non-NULL pointer means speling is enabled */ - ap_set_module_config(server_conf, &speling_module, arg ? (void *) &speling_module : NULL); + cfg->enabled = arg; return NULL; } +/* + * Define the directives specific to this module. This structure is referenced + * later by the 'module' structure. + */ static const command_rec speling_cmds[] = { - {"CheckSpelling", set_speling, NULL, RSRC_CONF, FLAG, - "whether or not to fix miscapitalized/misspelled requests"}, - {NULL} + { "CheckSpelling", set_speling, NULL, OR_OPTIONS, FLAG, + "whether or not to fix miscapitalized/misspelled requests" }, + { NULL } }; typedef enum { @@ -156,22 +192,29 @@ static sp_reason spdist(const char *s, const char *t) { - for (; tolower(*s) == tolower(*t); t++, s++) - if (*t == '\0') + for (; ap_tolower(*s) == ap_tolower(*t); t++, s++) { + if (*t == '\0') { return SP_MISCAPITALIZED; /* exact match (sans case) */ + } + } if (*s) { if (*t) { - if (s[1] && t[1] && tolower(*s) == tolower(t[1]) && - tolower(*t) == tolower(s[1]) && strcasecmp(s + 2, t + 2) == 0) + if (s[1] && t[1] && ap_tolower(*s) == ap_tolower(t[1]) + && ap_tolower(*t) == ap_tolower(s[1]) + && strcasecmp(s + 2, t + 2) == 0) { return SP_TRANSPOSITION; /* transposition */ - if (strcasecmp(s + 1, t + 1) == 0) + } + if (strcasecmp(s + 1, t + 1) == 0) { return SP_SIMPLETYPO; /* 1 char mismatch */ + } } - if (strcasecmp(s + 1, t) == 0) + if (strcasecmp(s + 1, t) == 0) { return SP_EXTRACHAR; /* extra character */ + } } - if (*t && strcasecmp(s, t + 1) == 0) + if (*t && strcasecmp(s, t + 1) == 0) { return SP_MISSINGCHAR; /* missing character */ + } return SP_VERYDIFFERENT; /* distance too large to fix. */ } @@ -183,27 +226,32 @@ static int check_speling(request_rec *r) { - void *server_conf = r->server->module_config; + spconfig *cfg; char *good, *bad, *postgood, *url; int filoc, dotloc, urlen, pglen; PRDir *dirp; PRDirEntry *dir_entry; array_header *candidates = NULL; - if (!ap_get_module_config(server_conf, &speling_module)) + cfg = ap_get_module_config(r->per_dir_config, &speling_module); + if (!cfg->enabled) { return DECLINED; + } /* We only want to worry about GETs */ - if (r->method_number != M_GET) + if (r->method_number != M_GET) { return DECLINED; + } /* We've already got a file of some kind or another */ if (r->proxyreq || r->file_exists) return DECLINED; + } /* This is a sub request - don't mess with it */ - if (r->main) + if (r->main) { return DECLINED; + } /* * The request should end up looking like this: @@ -214,9 +262,13 @@ */ filoc = ap_rind(r->filename, '/'); - /* Don't do anything if the request doesn't contain a slash, or requests "/" */ - if (filoc == -1 || strcmp(r->uri, "/") == 0) + /* + * Don't do anything if the request doesn't contain a slash, or + * requests "/" + */ + if (filoc == -1 || strcmp(r->uri, "/") == 0) { return DECLINED; + } /* good = /correct-file */ good = ap_pstrndup(r->pool, r->filename, filoc); @@ -229,22 +281,25 @@ pglen = strlen(postgood); /* Check to see if the URL pieces add up */ - if (strcmp(postgood, r->uri + (urlen - pglen))) + if (strcmp(postgood, r->uri + (urlen - pglen))) { return DECLINED; + } /* url = /correct-url */ url = ap_pstrndup(r->pool, r->uri, (urlen - pglen)); /* Now open the directory and do ourselves a check... */ dirp = ap_popendir(r->pool, good); - if (dirp == NULL) /* Oops, not a directory... */ + if (dirp == NULL) { /* Oops, not a directory... */ return DECLINED; + } candidates = ap_make_array(r->pool, 2, sizeof(misspelled_file)); dotloc = ap_ind(bad, '.'); - if (dotloc == -1) + if (dotloc == -1) { dotloc = strlen(bad); + } while ((dir_entry = PR_ReadDir(dirp, PR_SKIP_NONE)) != NULL) { sp_reason q; @@ -263,7 +318,9 @@ * file, upper case request) */ else if (strcasecmp(bad, dir_entry->name) == 0) { - misspelled_file *sp_new = (misspelled_file *) ap_push_array(candidates); + misspelled_file *sp_new; + + sp_new = (misspelled_file *) ap_push_array(candidates); sp_new->name = ap_pstrdup(r->pool, dir_entry->name); sp_new->quality = SP_MISCAPITALIZED; } @@ -272,26 +329,31 @@ * missing/extra/transposed char) */ else if ((q = spdist(bad, dir_entry->name)) != SP_VERYDIFFERENT) { - misspelled_file *sp_new = (misspelled_file *) ap_push_array(candidates); + misspelled_file *sp_new; + + sp_new = (misspelled_file *) ap_push_array(candidates); sp_new->name = ap_pstrdup(r->pool, dir_entry->name); sp_new->quality = q; } - /* The spdist() should have found the majority of the misspelled requests. - * it is of questionable use to continue looking for files with the same - * base name, but potentially of totally wrong type (index.html <-> index.db) - * I would propose to not set the WANT_BASENAME_MATCH define. + /* + * The spdist() should have found the majority of the misspelled + * requests. It is of questionable use to continue looking for + * files with the same base name, but potentially of totally wrong + * type (index.html <-> index.db). + * I would propose to not set the WANT_BASENAME_MATCH define. * 08-Aug-1997 <[EMAIL PROTECTED]> * * However, Alexei replied giving some reasons to add it anyway: * > Oh, by the way, I remembered why having the * > extension-stripping-and-matching stuff is a good idea: * > - * > If you're using MultiViews, and have a file named foobar.html, which you - * > refer to as "foobar", and someone tried to access "Foobar", mod_speling - * > won't find it, because it won't find anything matching that - * > spelling. With the extension-munging, it would locate "foobar.html". Not - * > perfect, but I ran into that problem when I first wrote the module. - */ + * > If you're using MultiViews, and have a file named foobar.html, + * > which you refer to as "foobar", and someone tried to access + * > "Foobar", mod_speling won't find it, because it won't find + * > anything matching that spelling. With the extension-munging, + * > it would locate "foobar.html". Not perfect, but I ran into + * > that problem when I first wrote the module. + */ else { #ifdef WANT_BASENAME_MATCH /* @@ -311,7 +373,9 @@ if ((dotloc == entloc) && !strncasecmp(bad, dir_entry->name, dotloc)) { - misspelled_file *sp_new = (misspelled_file *) ap_push_array(candidates); + misspelled_file *sp_new; + + sp_new = (misspelled_file *) ap_push_array(candidates); sp_new->name = ap_pstrdup(r->pool, dir_entry->name); sp_new->quality = SP_VERYDIFFERENT; } @@ -335,23 +399,26 @@ /* * Conditions for immediate redirection: * a) the first candidate was not found by stripping the suffix - * AND b) there exists only one candidate OR the best match is not ambigous + * AND b) there exists only one candidate OR the best match is not + * ambiguous * then return a redirection right away. */ - if (variant[0].quality != SP_VERYDIFFERENT && - (candidates->nelts == 1 || variant[0].quality != variant[1].quality)) { + if (variant[0].quality != SP_VERYDIFFERENT + && (candidates->nelts == 1 + || variant[0].quality != variant[1].quality)) { nuri = ap_pstrcat(r->pool, url, variant[0].name, r->path_info, r->parsed_uri.query ? "?" : "", - r->parsed_uri.query ? r->parsed_uri.query : "", NULL); + r->parsed_uri.query ? r->parsed_uri.query : "", + NULL); ap_table_setn(r->headers_out, "Location", - ap_construct_url(r->pool, nuri, r)); + ap_construct_url(r->pool, nuri, r)); - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r->server, - ref ? "Fixed spelling: %s to %s from %s" - : "Fixed spelling: %s to %s", - r->uri, nuri, ref); + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r, + ref ? "Fixed spelling: %s to %s from %s" + : "Fixed spelling: %s to %s", + r->uri, nuri, ref); return HTTP_MOVED_PERMANENTLY; } @@ -374,7 +441,8 @@ } /* Generate the response text. */ - /* Since the text is expanded by repeated calls of + /* + * Since the text is expanded by repeated calls of * t = pstrcat(p, t, ".."), we can avoid a little waste * of memory by adding the header AFTER building the list. * XXX: FIXME: find a way to build a string concatenation @@ -387,12 +455,15 @@ /* The format isn't very neat... */ t = ap_pstrcat(p, t, "<li><a href=\"", url, - variant[i].name, r->path_info, "\">", variant[i].name, r->path_info, r->parsed_uri.query ? "?" : "", r->parsed_uri.query ? r->parsed_uri.query : "", + "\">", variant[i].name, r->path_info, + r->parsed_uri.query ? "?" : "", + r->parsed_uri.query ? r->parsed_uri.query : "", "</a> (", - sp_reason_str[(int) (variant[i].quality)], ")\n", NULL); + sp_reason_str[(int) (variant[i].quality)], + ")\n", NULL); /* * when we have printed the "close matches" and there are @@ -404,26 +475,35 @@ if (i > 0 && i < candidates->nelts - 1 && variant[i].quality != SP_VERYDIFFERENT && variant[i + 1].quality == SP_VERYDIFFERENT) { - t = ap_pstrcat(p, t, "</ul>\nFurthermore, the following related documents were found:\n<ul>\n", NULL); + t = ap_pstrcat(p, t, + "</ul>\nFurthermore, the following related " + "documents were found:\n<ul>\n", NULL); } } t = ap_pstrcat(p, "The document name you requested (<code>", - r->uri, "</code>) could not be found on this server.\n" - "However, we found documents with names similar to the one you requested.<p>" - "Available documents:\n<ul>\n", t, "</ul>\n", NULL); + r->uri, + "</code>) could not be found on this server.\n" + "However, we found documents with names similar " + "to the one you requested.<p>" + "Available documents:\n<ul>\n", t, "</ul>\n", NULL); /* If we know there was a referring page, add a note: */ - if (ref != NULL) - t = ap_pstrcat(p, t, "Please consider informing the owner of the <a href=\"", - ref, "\">referring page</a> about the broken link.\n", NULL); + if (ref != NULL) { + t = ap_pstrcat(p, t, + "Please consider informing the owner of the " + "<a href=\"", ref, + "\">referring page</a> " + "about the broken link.\n", + NULL); + } /* Pass our table to http_protocol.c (see mod_negotiation): */ ap_table_setn(notes, "variant-list", t); - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r->server, - ref ? "Spelling fix: %s: %d candidates from %s" - : "Spelling fix: %s: %d candidates", - r->uri, candidates->nelts, ref); + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r, + ref ? "Spelling fix: %s: %d candidates from %s" + : "Spelling fix: %s: %d candidates", + r->uri, candidates->nelts, ref); return HTTP_MULTIPLE_CHOICES; } @@ -436,9 +516,9 @@ { STANDARD_MODULE_STUFF, NULL, /* initializer */ - NULL, /* create per-dir config */ + create_mconfig_for_directory, /* create per-dir config */ NULL, /* merge per-dir config */ - create_speling_config, /* server config */ + create_mconfig_for_server, /* server config */ NULL, /* merge server config */ speling_cmds, /* command table */ NULL, /* handlers */ 1.4 +193 -149 apache-2.0/apache-nspr/modules/standard/mod_status.c Index: mod_status.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_status.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- mod_status.c 1998/09/22 16:12:07 1.3 +++ mod_status.c 1998/09/22 18:05:41 1.4 @@ -91,27 +91,16 @@ * piece in short reports [Ben Laurie] * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if * extended STATUS is enabled) [George Burgyan/Jim J.] + * 10.8.98 Allow for extended status info at runtime (no more STATUS) + * [Jim J.] */ -/* - * Module definition information - the part between the -START and -END - * lines below is used by Configure. This could be stored in a separate - * instead. - * - * MODULE-DEFINITION-START - * Name: status_module - * ConfigStart - if [ "$RULE_STATUS" = "yes" ]; then - CFLAGS="$CFLAGS -DSTATUS" - fi - * ConfigEnd - * MODULE-DEFINITION-END - */ - +#define CORE_PRIVATE #include "httpd.h" #include "http_config.h" #include "http_core.h" #include "http_protocol.h" +#include "http_conf_globals.h" /* for ap_extended_status */ #include "http_main.h" #include "util_script.h" #include <time.h> @@ -145,9 +134,33 @@ module MODULE_VAR_EXPORT status_module; -#ifdef STATUS -/* Format the number of bytes nicely */ +/* + *command-related code. This is here to prevent use of ExtendedStatus + * without status_module included. + */ +static const char *set_extended_status(cmd_parms *cmd, void *dummy, char *arg) +{ + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); + if (err != NULL) { + return err; + } + if (!strcasecmp(arg, "off") || !strcmp(arg, "0")) { + ap_extended_status = 0; + } + else { + ap_extended_status = 1; + } + return NULL; +} + +static const command_rec status_module_cmds[] = +{ + { "ExtendedStatus", set_extended_status, NULL, RSRC_CONF, TAKE1, + "\"On\" to enable extended status information, \"Off\" to disable" }, + {NULL} +}; +/* Format the number of bytes nicely */ static void format_byte_out(request_rec *r, unsigned long bytes) { if (bytes < (5 * KBYTE)) @@ -169,9 +182,8 @@ else ap_rprintf(r, "%.1f GB", (float) kbytes / MBYTE); } - -#endif +/* XXX: I'm sure this shouldn't be a long */ static void show_time(request_rec *r, long tsecs) { long days, hrs, mins, secs; @@ -225,7 +237,6 @@ int i, res; int ready = 0; int busy = 0; -#if defined(STATUS) unsigned long count = 0; unsigned long lres, bytes; unsigned long my_lres, my_bytes, conn_bytes; @@ -233,18 +244,19 @@ unsigned long bcount = 0; unsigned long kbcount = 0; PRTime req_time; -#endif /* STATUS */ + long req_time; int short_report = 0; int no_table_report = 0; short_score score_record; parent_score ps_record; char stat_buffer[HARD_SERVER_LIMIT]; + int pid_buffer[HARD_SERVER_LIMIT]; clock_t tu, ts, tcu, tcs; tu = ts = tcu = tcs = 0; if (!ap_exists_scoreboard_image()) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Server status unavailable in inetd mode"); return HTTP_INTERNAL_SERVER_ERROR; } @@ -265,10 +277,12 @@ switch (status_options[i].id) { case STAT_OPT_REFRESH: if (*(loc + strlen(status_options[i].form_data_str)) == '=') - ap_table_set(r->headers_out, status_options[i].hdr_out_str, - loc + strlen(status_options[i].hdr_out_str) + 1); + ap_table_set(r->headers_out, + status_options[i].hdr_out_str, + loc + strlen(status_options[i].hdr_out_str) + 1); else - ap_table_set(r->headers_out, status_options[i].hdr_out_str, "1"); + ap_table_set(r->headers_out, + status_options[i].hdr_out_str, "1"); break; case STAT_OPT_NOTABLE: no_table_report = 1; @@ -293,28 +307,29 @@ ps_record = ap_scoreboard_image->parent[i]; res = score_record.status; stat_buffer[i] = status_flags[res]; + pid_buffer[i] = (int) ps_record.pid; if (res == SERVER_READY) ready++; else if (res != SERVER_DEAD) busy++; -#if defined(STATUS) - lres = score_record.access_count; - bytes = score_record.bytes_served; - if (lres != 0 || (res != SERVER_READY && res != SERVER_DEAD)) { + if (ap_extended_status) { + lres = score_record.access_count; + bytes = score_record.bytes_served; + if (lres != 0 || (res != SERVER_READY && res != SERVER_DEAD)) { #ifndef NO_TIMES - tu += score_record.times.tms_utime; - ts += score_record.times.tms_stime; - tcu += score_record.times.tms_cutime; - tcs += score_record.times.tms_cstime; + tu += score_record.times.tms_utime; + ts += score_record.times.tms_stime; + tcu += score_record.times.tms_cutime; + tcs += score_record.times.tms_cstime; #endif /* NO_TIMES */ - count += lres; - bcount += bytes; - if (bcount >= KBYTE) { - kbcount += (bcount >> 10); - bcount = bcount & 0x3ff; + count += lres; + bcount += bytes; + if (bcount >= KBYTE) { + kbcount += (bcount >> 10); + bcount = bcount & 0x3ff; + } } } -#endif /* STATUS */ } up_time = nowtime - ap_restart_time; @@ -324,73 +339,80 @@ ap_rputs("<HTML><HEAD>\n<TITLE>Apache Status</TITLE>\n</HEAD><BODY>\n", r); ap_rputs("<H1>Apache Server Status for ", r); ap_rvputs(r, ap_get_server_name(r), "</H1>\n\n", NULL); - ap_rvputs(r, "Server Version: ", ap_get_server_version(), "<br>\n", - NULL); - ap_rvputs(r, "Server Built: ", ap_get_server_built(), "<br>\n<hr>\n", - NULL); - - ap_rvputs(r, "Current Time: ", ap_ht_time(r->pool, nowtime, DEFAULT_TIME_FORMAT, 0), + ap_rvputs(r, "Server Version: ", + ap_get_server_version(), "<br>\n", NULL); + ap_rvputs(r, "Server Built: ", + ap_get_server_built(), "<br>\n<hr>\n", NULL); + ap_rvputs(r, "Current Time: ", + ap_ht_time(r->pool, nowtime, DEFAULT_TIME_FORMAT, 0), "<br>\n", NULL); - ap_rvputs(r, "Restart Time: ", ap_ht_time(r->pool, ap_restart_time, DEFAULT_TIME_FORMAT, 0), + ap_rvputs(r, "Restart Time: ", + ap_ht_time(r->pool, ap_restart_time, DEFAULT_TIME_FORMAT, 0), "<br>\n", NULL); ap_rputs("Server uptime: ", r); show_time(r, (long)up_time); ap_rputs("<br>\n", r); } -#if defined(STATUS) - if (short_report) { - ap_rprintf(r, "Total Accesses: %lu\nTotal kBytes: %lu\n", count, kbcount); + if (ap_extended_status) { + if (short_report) { + ap_rprintf(r, "Total Accesses: %lu\nTotal kBytes: %lu\n", + count, kbcount); #ifndef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - if (ts || tu || tcu || tcs) - ap_rprintf(r, "CPULoad: %g\n", (tu + ts + tcu + tcs) / tick / up_time * 100.); + /* Allow for OS/2 not having CPU stats */ + if (ts || tu || tcu || tcs) + ap_rprintf(r, "CPULoad: %g\n", + (tu + ts + tcu + tcs) / tick / up_time * 100.); #endif - - ap_rprintf(r, "Uptime: %ld\n", (long) (up_time)); - if (up_time > 0) - ap_rprintf(r, "ReqPerSec: %g\n", (float) count / (float) up_time); - if (up_time > 0) - ap_rprintf(r, "BytesPerSec: %g\n", KBYTE * (float) kbcount / (float) up_time); + ap_rprintf(r, "Uptime: %ld\n", (long) (up_time)); + if (up_time > 0) + ap_rprintf(r, "ReqPerSec: %g\n", + (float) count / (float) up_time); - if (count > 0) - ap_rprintf(r, "BytesPerReq: %g\n", KBYTE * (float) kbcount / (float) count); - } - else { /* !short_report */ - ap_rprintf(r, "Total accesses: %lu - Total Traffic: ", count); - format_kbyte_out(r, kbcount); + if (up_time > 0) + ap_rprintf(r, "BytesPerSec: %g\n", + KBYTE * (float) kbcount / (float) up_time); + + if (count > 0) + ap_rprintf(r, "BytesPerReq: %g\n", + KBYTE * (float) kbcount / (float) count); + } + else { /* !short_report */ + ap_rprintf(r, "Total accesses: %lu - Total Traffic: ", count); + format_kbyte_out(r, kbcount); #ifndef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rputs("<br>\n", r); - ap_rprintf(r, "CPU Usage: u%g s%g cu%g cs%g", - tu / tick, ts / tick, tcu / tick, tcs / tick); + /* Allow for OS/2 not having CPU stats */ + ap_rputs("<br>\n", r); + ap_rprintf(r, "CPU Usage: u%g s%g cu%g cs%g", + tu / tick, ts / tick, tcu / tick, tcs / tick); - if (ts || tu || tcu || tcs) - ap_rprintf(r, " - %.3g%% CPU load", (tu + ts + tcu + tcs) / tick / up_time * 100.); + if (ts || tu || tcu || tcs) + ap_rprintf(r, " - %.3g%% CPU load", + (tu + ts + tcu + tcs) / tick / up_time * 100.); #endif - ap_rputs("<br>\n", r); + ap_rputs("<br>\n", r); - if (up_time > 0) - ap_rprintf(r, "%.3g requests/sec - ", - (float) count / (float) up_time); + if (up_time > 0) + ap_rprintf(r, "%.3g requests/sec - ", + (float) count / (float) up_time); - if (up_time > 0) { - format_byte_out(r, KBYTE * (float) kbcount / (float) up_time); - ap_rputs("/second - ", r); - } + if (up_time > 0) { + format_byte_out(r, KBYTE * (float) kbcount / (float) up_time); + ap_rputs("/second - ", r); + } - if (count > 0) { - format_byte_out(r, KBYTE * (float) kbcount / (float) count); - ap_rputs("/request", r); - } + if (count > 0) { + format_byte_out(r, KBYTE * (float) kbcount / (float) count); + ap_rputs("/request", r); + } - ap_rputs("<br>\n", r); - } /* short_report */ -#endif /* STATUS */ + ap_rputs("<br>\n", r); + } /* short_report */ + } /* ap_extended_status */ if (!short_report) ap_rprintf(r, "\n%d requests currently being processed, %d idle servers\n" @@ -425,51 +447,70 @@ ap_rputs("\"<B><code>L</code></B>\" Logging, \n", r); ap_rputs("\"<B><code>G</code></B>\" Gracefully finishing, \n", r); ap_rputs("\"<B><code>.</code></B>\" Open slot with no current process<P>\n", r); + ap_rputs("<P>\n", r); + if (!ap_extended_status) { + int j = 0; + ap_rputs("PID Key: <br>\n", r); + ap_rputs("<PRE>\n", r); + for (i = 0; i < HARD_SERVER_LIMIT; ++i) { + if (stat_buffer[i] != '.') { + ap_rprintf(r, " %d in state: %c ", pid_buffer[i], + stat_buffer[i]); + if (++j >= 3) { + ap_rputs("\n", r); + j = 0; + } else + ap_rputs(",", r); + } + } + ap_rputs("\n", r); + ap_rputs("</PRE>\n", r); + } } -#if defined(STATUS) - if (!short_report) { - if (no_table_report) - ap_rputs("<p><hr><h2>Server Details</h2>\n\n", r); - else + if (ap_extended_status) { + if (!short_report) { + if (no_table_report) + ap_rputs("<p><hr><h2>Server Details</h2>\n\n", r); + else #ifdef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>Acc<th>M\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n", r); + /* Allow for OS/2 not having CPU stats */ + ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<th>VHost<th>Request</tr>\n\n", r); #else - ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>Acc<th>M<th>CPU\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n", r); + ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M<th>CPU\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<th>VHost<th>Request</tr>\n\n", r); #endif - } - - for (i = 0; i < HARD_SERVER_LIMIT; ++i) { - score_record = ap_scoreboard_image->servers[i]; - ps_record = ap_scoreboard_image->parent[i]; - - if (score_record.start_time == (PRTime)0 || - score_record.stop_time == (PRTime)0 ) - req_time = 0L; - else { - req_time = score_record.stop_time - score_record.start_time; - req_time = req_time / PR_USEC_PER_MSEC; } - if (req_time < 0L) - req_time = 0L; - lres = score_record.access_count; - my_lres = score_record.my_access_count; - conn_lres = score_record.conn_count; - bytes = score_record.bytes_served; - my_bytes = score_record.my_bytes_served; - conn_bytes = score_record.conn_bytes; - if (lres != 0 || (score_record.status != SERVER_READY - && score_record.status != SERVER_DEAD)) { - if (!short_report) { - if (no_table_report) { - if (score_record.status == SERVER_DEAD) - ap_rprintf(r, "<b>Server %d</b> (-): %d|%lu|%lu [", - i, (int) conn_lres, my_lres, lres); - else - ap_rprintf(r, "<b>Server %d</b>: %d|%lu|%lu [", - i, (int) conn_lres, my_lres, lres); + for (i = 0; i < HARD_SERVER_LIMIT; ++i) { + score_record = ap_scoreboard_image->servers[i]; + ps_record = ap_scoreboard_image->parent[i]; + + if (score_record.start_time == (PRTime)0 || + score_record.stop_time == (PRTime)0 ) + req_time = 0L; + else { + req_time = score_record.stop_time - score_record.start_time; + req_time = req_time / PR_USEC_PER_MSEC; + } + if (req_time < 0L) + req_time = 0L; + + lres = score_record.access_count; + my_lres = score_record.my_access_count; + conn_lres = score_record.conn_count; + bytes = score_record.bytes_served; + my_bytes = score_record.my_bytes_served; + conn_bytes = score_record.conn_bytes; + if (lres != 0 || (score_record.status != SERVER_READY + && score_record.status != SERVER_DEAD)) { + if (!short_report) { + if (no_table_report) { + if (score_record.status == SERVER_DEAD) + ap_rprintf(r, "<b>Server %d</b> (-): %d|%lu|%lu [", + i, (int) conn_lres, my_lres, lres); + else + ap_rprintf(r, "<b>Server %d</b>: %d|%lu|%lu [", + i, (int) conn_lres, my_lres, lres); switch (score_record.status) { case SERVER_READY: @@ -504,11 +545,11 @@ break; } #ifdef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rprintf(r, "]\n %.0f %ld (", + /* Allow for OS/2 not having CPU stats */ + ap_rprintf(r, "]\n %.0f %ld (", #else - ap_rprintf(r, "] u%g s%g cu%g cs%g\n %.0f %ld (", + ap_rprintf(r, "] u%g s%g cu%g cs%g\n %.0f %ld (", score_record.times.tms_utime / tick, score_record.times.tms_stime / tick, score_record.times.tms_cutime / tick, @@ -578,10 +619,10 @@ PR_USEC_PER_SEC, (long)req_time); #else #ifdef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rprintf(r, "\n<td>%.0f<td>%ld", + /* Allow for OS/2 not having CPU stats */ + ap_rprintf(r, "\n<td>%.0f<td>%ld", #else - ap_rprintf(r, "\n<td>%.2f<td>%.0f<td>%ld", + ap_rprintf(r, "\n<td>%.2f<td>%.0f<td>%ld", (score_record.times.tms_utime + score_record.times.tms_stime + score_record.times.tms_cutime + @@ -593,17 +634,22 @@ ap_rprintf(r, "<td>%-1.1f<td>%-2.2f<td>%-2.2f\n", (float) conn_bytes / KBYTE, (float) my_bytes / MBYTE, (float) bytes / MBYTE); - ap_rprintf(r, "<td>%s<td nowrap>%s<td nowrap>%s</tr>\n\n", - score_record.client, score_record.vhost, - ap_escape_html(r->pool, score_record.request)); - } /* no_table_report */ - } /* !short_report */ - } /* if (<active child>) */ - } /* for () */ - - if (!(short_report || no_table_report)) { -#ifdef __EMX__ - ap_rputs("</table>\n \ + if (score_record.status == SERVER_BUSY_READ) + ap_rprintf(r, + "<td>?<td nowrap>?<td nowrap>..reading.. </tr>\n\n"); + else + ap_rprintf(r, + "<td>%s<td nowrap>%s<td nowrap>%s</tr>\n\n", + score_record.client, score_record.vhost, + ap_escape_html(r->pool, score_record.request)); + } /* no_table_report */ + } /* !short_report */ + } /* if (<active child>) */ + } /* for () */ + + if (!(short_report || no_table_report)) { +#ifdef NO_TIMES + ap_rputs("</table>\n \ <hr> \ <table>\n \ <tr><th>Srv<td>Server number\n \ @@ -616,7 +662,7 @@ <tr><th>Slot<td>Total megabytes transferred this slot\n \ </table>\n", r); #else - ap_rputs("</table>\n \ + ap_rputs("</table>\n \ <hr> \ <table>\n \ <tr><th>Srv<td>Server number\n \ @@ -630,16 +676,14 @@ <tr><th>Slot<td>Total megabytes transferred this slot\n \ </table>\n", r); #endif - } + } -#else /* !defined(STATUS) */ + } else { - ap_rputs("<hr>To obtain a full report with current status information and", r); - ap_rputs(" DNS and LOGGING status codes \n", r); - ap_rputs("you need to recompile Apache after adding the line <pre>", r); - ap_rputs("Rule STATUS=yes</pre>into the file <code>Configuration</code>\n", r); + ap_rputs("<hr>To obtain a full report with current status information ", r); + ap_rputs("you need to use the <code>ExtendedStatus On</code> directive. \n", r); -#endif /* STATUS */ + } if (!short_report) { ap_rputs(ap_psignature("<HR>\n",r), r); @@ -678,7 +722,7 @@ NULL, /* dir merger --- default is to override */ NULL, /* server config */ NULL, /* merge server config */ - NULL, /* command table */ + status_module_cmds, /* command table */ status_handlers, /* handlers */ NULL, /* filename translation */ NULL, /* check_user_id */ 1.3 +1 -1 apache-2.0/apache-nspr/modules/standard/mod_userdir.c Index: mod_userdir.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_userdir.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_userdir.c 1998/06/30 08:57:13 1.2 +++ mod_userdir.c 1998/09/22 18:05:41 1.3 @@ -298,7 +298,7 @@ #else /* WIN32 */ struct passwd *pw; if ((pw = getpwnam(w))) { -#ifdef __EMX__ +#ifdef OS2 /* Need to manually add user name for OS/2 */ filename = ap_pstrcat(r->pool, pw->pw_dir, w, "/", userdir, NULL); #else 1.3 +100 -14 apache-2.0/apache-nspr/os/unix/os.c Index: os.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/os/unix/os.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- os.c 1998/09/05 16:54:13 1.2 +++ os.c 1998/09/22 18:05:53 1.3 @@ -3,7 +3,7 @@ * Any inlineable functions should be defined in os-inline.c instead. */ -#include "conf.h" +#include "ap_config.h" #include "os.h" #include "ap.h" @@ -27,29 +27,103 @@ * dynamic shared object (DSO) mechanism */ +#ifdef RHAPSODY +#include <mach-o/dyld.h> +#include "httpd.h" +#include "http_log.h" + +ap_private_extern +void undefined_symbol_handler(const char *symbolName) +{ + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, NULL, + "dyld found undefined symbol: %s\n" + "Aborting.\n", + symbolName); + abort(); +} + +ap_private_extern +NSModule multiple_symbol_handler (NSSymbol s, NSModule old, NSModule new) +{ + /* + * Since we can't unload symbols, we're going to run into this + * every time we reload a module. Workaround here is to just + * rebind to the new symbol, and forget about the old one. + * This is crummy, because it's basically a memory leak. + * (See Radar 2262020 against dyld). + */ + +#ifdef DEBUG + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, NULL, + "dyld found a multiply defined symbol %s in modules:\n" + "%s\n%s\n", + NSNameOfSymbol(s), + NSNameOfModule(old), NSNameOfModule(new)); +#endif + + return(new); +} + +ap_private_extern +void linkEdit_symbol_handler (NSLinkEditErrors c, int errorNumber, + const char *fileName, const char *errorString) +{ + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, NULL, + "dyld errors during link edit for file %s\n%s\n", + fileName, errorString); + abort(); +} + +#endif /*RHAPSODY*/ + +void ap_os_dso_init(void) +{ +#if defined(RHAPSODY) + NSLinkEditErrorHandlers handlers; + + handlers.undefined = undefined_symbol_handler; + handlers.multiple = multiple_symbol_handler; + handlers.linkEdit = linkEdit_symbol_handler; + + NSInstallLinkEditErrorHandlers(&handlers); +#endif +} + void *ap_os_dso_load(const char *path) { #if defined(HPUX) || defined(HPUX10) shl_t handle; handle = shl_load(path, BIND_IMMEDIATE|BIND_VERBOSE|BIND_NOSTART, 0L); return (void *)handle; -#else -#if defined(OSF1) ||\ + +#elif defined(RHAPSODY) + NSObjectFileImage image; + if (NSCreateObjectFileImageFromFile(path, &image) != + NSObjectFileImageSuccess) + return NULL; + return NSLinkModule(image, path, TRUE); + +#elif defined(OSF1) ||\ (defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)) - return dlopen((char *)path, RTLD_NOW); + return dlopen((char *)path, RTLD_NOW | RTLD_GLOBAL); + #else - return dlopen(path, RTLD_NOW); + return dlopen(path, RTLD_NOW | RTLD_GLOBAL); #endif -#endif } -void ap_os_dso_unload(void *handle) +void ap_os_dso_unload(void *handle) { #if defined(HPUX) || defined(HPUX10) shl_unload((shl_t)handle); + +#elif defined(RHAPSODY) + NSUnLinkModule(handle,FALSE); + #else dlclose(handle); #endif + return; } @@ -64,23 +138,35 @@ if (status == -1 && errno == 0) /* try TYPE_DATA instead */ status = shl_findsym((shl_t *)&handle, symname, TYPE_DATA, &symaddr); return (status == -1 ? NULL : symaddr); -#else /* ndef HPUX */ -#ifdef DLSYM_NEEDS_UNDERSCORE - char symbol[256]; - ap_snprintf(symbol, sizeof symbol, "_%s", symname); - return dlsym(handle, symbol); + +#elif defined(RHAPSODY) + NSSymbol symbol; + char *symname2 = (char*)malloc(sizeof(char)*(strlen(symname)+2)); + sprintf(symname2, "_%s", symname); + symbol = NSLookupAndBindSymbol(symname2); + free(symname2); + return NSAddressOfSymbol(symbol); + +#elif defined(DLSYM_NEEDS_UNDERSCORE) + char *symbol = (char*)malloc(sizeof(char)*(strlen(symname)+2)); + void *retval; + sprintf(symbol, "_%s", symname); + retval = dlsym(handle, symbol); + free(symbol); + return retval; + #else return dlsym(handle, symname); #endif -#endif /* ndef HPUX */ } const char *ap_os_dso_error(void) { #if defined(HPUX) || defined(HPUX10) return strerror(errno); +#elif defined(RHAPSODY) + return NULL; #else return dlerror(); #endif } - 1.3 +72 -76 apache-2.0/apache-nspr/os/win32/modules.c Index: modules.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/os/win32/modules.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- modules.c 1998/06/30 08:57:14 1.2 +++ modules.c 1998/09/22 18:05:54 1.3 @@ -1,76 +1,72 @@ -/* modules.c --- automatically generated by Apache - * configuration script. DO NOT HAND EDIT!!!!! - */ - -#include "httpd.h" -#include "http_config.h" - -/* - * For now, exclude cgi_module, asis_module and isapi_module... - * they need some effort to port to NSPR - */ - -extern module core_module; -extern module so_module; -extern module mime_module; -extern module access_module; -extern module auth_module; -extern module negotiation_module; -extern module includes_module; -extern module autoindex_module; -extern module dir_module; -/* extern module cgi_module; */ -extern module userdir_module; -extern module alias_module; -extern module env_module; -extern module config_log_module; -/* extern module asis_module; */ -extern module imap_module; -extern module action_module; -extern module setenvif_module; -/* extern module isapi_module; */ - -module *ap_prelinked_modules[] = { - &core_module, - &so_module, - &mime_module, - &access_module, - &auth_module, - &negotiation_module, - &includes_module, - &autoindex_module, - &dir_module, -/* &cgi_module, */ - &userdir_module, - &alias_module, - &env_module, - &config_log_module, -/* &asis_module, */ - &imap_module, - &action_module, - &setenvif_module, -/* &isapi_module, */ - NULL -}; -module *ap_preloaded_modules[] = { - &core_module, - &so_module, - &mime_module, - &access_module, - &auth_module, - &negotiation_module, - &includes_module, - &autoindex_module, - &dir_module, -/* &cgi_module, */ - &userdir_module, - &alias_module, - &env_module, - &config_log_module, -/* &asis_module, */ - &imap_module, - &action_module, - &setenvif_module, -/* &isapi_module, */ - NULL -}; +/* modules.c --- major modules compiled into Apache for Win32. + * Only insert an entry for a module if it must be compiled into + * the core server + */ + +#include "httpd.h" +#include "http_config.h" + +extern module core_module; +extern module so_module; +extern module mime_module; +extern module access_module; +extern module auth_module; +extern module negotiation_module; +extern module includes_module; +extern module autoindex_module; +extern module dir_module; +extern module cgi_module; +extern module userdir_module; +extern module alias_module; +extern module env_module; +extern module config_log_module; +extern module asis_module; +extern module imap_module; +extern module action_module; +extern module setenvif_module; +extern module isapi_module; + +module *ap_prelinked_modules[] = { + &core_module, + &so_module, + &mime_module, + &access_module, + &auth_module, + &negotiation_module, + &includes_module, + &autoindex_module, + &dir_module, + &cgi_module, + &userdir_module, + &alias_module, + &env_module, + &config_log_module, + &asis_module, + &imap_module, + &action_module, + &setenvif_module, + &isapi_module, + NULL +}; +module *ap_preloaded_modules[] = { + &core_module, + &so_module, + &mime_module, + &access_module, + &auth_module, + &negotiation_module, + &includes_module, + &autoindex_module, + &dir_module, + &cgi_module, + &userdir_module, + &alias_module, + &env_module, + &config_log_module, + &asis_module, + &imap_module, + &action_module, + &setenvif_module, + &isapi_module, + NULL +}; 1.3 +388 -274 apache-2.0/apache-nspr/os/win32/util_win32.c Index: util_win32.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/os/win32/util_win32.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- util_win32.c 1998/06/30 08:57:15 1.2 +++ util_win32.c 1998/09/22 18:05:54 1.3 @@ -1,274 +1,388 @@ -#include <windows.h> -#include <assert.h> -#include <sys/stat.h> -#include <stdarg.h> -#include <process.h> - -#include "httpd.h" - -static void sub_canonical_filename(char *szCanon, const char *szFile) -{ - char buf[HUGE_STRING_LEN]; - int n; - char *szFilePart; - WIN32_FIND_DATA d; - HANDLE h; - - n = GetFullPathName(szFile, sizeof buf, buf, &szFilePart); - assert(n); - assert(n < sizeof buf); - - /* If we have \\machine\share, convert to \\machine\share\ */ - if (buf[0] == '\\' && buf[1] == '\\') { - char *s=strchr(buf+2,'\\'); - if(s && !strchr(s+1,'\\')) - strcat(s+1,"\\"); - } - - if (!strchr(buf, '*') && !strchr(buf, '?')) { - h = FindFirstFile(buf, &d); - if(h != INVALID_HANDLE_VALUE) - FindClose(h); - } - else { - h=INVALID_HANDLE_VALUE; - } - - if (szFilePart < buf+3) { - strcpy(szCanon, buf); - if(szCanon[0] != '\\') { /* a \ at the start means it is UNC, otherwise it is x: */ - assert(isalpha(szCanon[0])); - assert(szCanon[1] == ':'); - szCanon[2] = '/'; - } - else { - char *s; - - assert(szCanon[1] == '\\'); - for(s=szCanon ; *s ; ++s) - if(*s == '\\') - *s='/'; - } - return; - } - if (szFilePart != buf+3) { - char b2[_MAX_PATH]; - assert(szFilePart > buf+3); - - szFilePart[-1]='\0'; - sub_canonical_filename(b2, buf); - - strcpy(szCanon, b2); - strcat(szCanon, "/"); - } - else { - strcpy(szCanon, buf); - szCanon[2] = '/'; - szCanon[3] = '\0'; - } - if (h == INVALID_HANDLE_VALUE) - strcat(szCanon, szFilePart); - else { - strlwr(d.cFileName); - strcat(szCanon, d.cFileName); - } -} - -/* UNC requires backslashes, hence the conversion before canonicalisation. Not sure how - * many backslashes (could be that \\machine\share\some/path/is/ok for example). For now, do - * them all. - */ -API_EXPORT(char *) ap_os_canonical_filename(pool *pPool, const char *szFile) -{ - char buf[HUGE_STRING_LEN]; - char b2[HUGE_STRING_LEN]; - char *s; - - strcpy(b2,szFile); - for(s=b2 ; *s ; ++s) - if(*s == '/') - *s='\\'; - - sub_canonical_filename(buf, b2); - buf[0]=tolower(buf[0]); - - if (*szFile && szFile[strlen(szFile)-1] == '/' && buf[strlen(buf)-1] != '/') - strcat(buf, "/"); - - return ap_pstrdup(pPool, buf); -} - -/* Win95 doesn't like trailing /s. NT and Unix don't mind. This works - * around the problem. - * Errr... except if it is UNC and we are referring to the root of the UNC, we MUST have - * a trailing \ and we can't use /s. Jeez. Not sure if this refers to all UNCs or just roots, - * but I'm going to fix it for all cases for now. (Ben) - */ - -#undef stat -API_EXPORT(int) os_stat(const char *szPath, struct stat *pStat) -{ - int n; - - ap_assert(szPath[1] == ':' || szPath[1] == '/'); // we are dealing with either UNC or a drive - - if(szPath[0] == '/') { - char buf[_MAX_PATH]; - char *s; - int nSlashes=0; - - ap_assert(strlen(szPath) < _MAX_PATH); - strcpy(buf,szPath); - for(s=buf ; *s ; ++s) - if(*s == '/') { - *s='\\'; - ++nSlashes; - } - if(nSlashes == 3) /* then we need to add one more to get \\machine\share\ */ - *s++='\\'; - *s='\0'; - return stat(buf,pStat); - } - - n = strlen(szPath); - if(szPath[n-1] == '\\' || szPath[n-1] == '/') { - char buf[_MAX_PATH]; - - ap_assert(n < _MAX_PATH); - strcpy(buf, szPath); - buf[n-1] = '\0'; - - return stat(buf, pStat); - } - return stat(szPath, pStat); -} - -/* Fix two really crap problems with Win32 spawn[lv]e*: - * - * 1. Win32 doesn't deal with spaces in argv. - * 2. Win95 doesn't like / in cmdname. - */ - -#undef _spawnv -API_EXPORT(int) os_spawnv(int mode, const char *cmdname, const char *const *argv) -{ - int n; - char **aszArgs; - const char *szArg; - char *szCmd; - char *s; - - szCmd = _alloca(strlen(cmdname)+1); - strcpy(szCmd, cmdname); - for (s = szCmd; *s; ++s) - if (*s == '/') - *s = '\\'; - - for (n=0; argv[n]; ++n) - ; - - aszArgs = _alloca((n+1)*sizeof(const char *)); - - for (n = 0; szArg = argv[n]; ++n) - if (strchr(szArg, ' ')) { - int l = strlen(szArg); - - aszArgs[n] = _alloca(l+2+1); - aszArgs[n][0] = '"'; - strcpy(&aszArgs[n][1], szArg); - aszArgs[n][l+1] = '"'; - aszArgs[n][l+2] = '\0'; - } - else { - aszArgs[n] = (char *)szArg; - } - - aszArgs[n] = NULL; - - return _spawnv(mode, szCmd, aszArgs); -} - -#undef _spawnve -API_EXPORT(int) os_spawnve(int mode, const char *cmdname, const char *const *argv, const char *const *envp) -{ - int n; - char **aszArgs; - const char *szArg; - char *szCmd; - char *s; - - szCmd = _alloca(strlen(cmdname)+1); - strcpy(szCmd, cmdname); - for (s = szCmd; *s; ++s) - if (*s == '/') - *s = '\\'; - - for (n = 0; argv[n] ; ++n) - ; - - aszArgs = _alloca((n+1)*sizeof(const char *)); - - for (n = 0; szArg=argv[n]; ++n) - if (strchr(szArg, ' ')) { - int l = strlen(szArg); - - aszArgs[n] = _alloca(l+2+1); - aszArgs[n][0] = '"'; - strcpy(&aszArgs[n][1], szArg); - aszArgs[n][l+1] = '"'; - aszArgs[n][l+2] = '\0'; - } - else { - aszArgs[n]=(char *)szArg; - } - - aszArgs[n] = NULL; - - return _spawnve(mode, szCmd, aszArgs, envp); -} - -API_EXPORT(int) os_spawnle(int mode, const char *cmdname,...) -{ - int n; - va_list vlist; - char **aszArgs; - const char *szArg; - const char *const *aszEnv; - char *szCmd; - char *s; - - szCmd = _alloca(strlen(cmdname)+1); - strcpy(szCmd, cmdname); - for (s = szCmd; *s; ++s) - if(*s == '/') - *s = '\\'; - - va_start(vlist, cmdname); - for (n = 0; va_arg(vlist, const char *); ++n) - ; - va_end(vlist); - - aszArgs = _alloca((n+1)*sizeof(const char *)); - - va_start(vlist, cmdname); - for (n = 0 ; szArg = va_arg(vlist, const char *) ; ++n) - if (strchr(szArg,' ')) { - int l = strlen(szArg); - - aszArgs[n] = _alloca(l+2+1); - aszArgs[n][0] = '"'; - strcpy(&aszArgs[n][1],szArg); - aszArgs[n][l+1] = '"'; - aszArgs[n][l+2] = '\0'; - } - else { - aszArgs[n]=(char *)szArg; - } - - aszArgs[n] = NULL; - - aszEnv = va_arg(vlist, const char *const *); - va_end(vlist); - - return _spawnve(mode, szCmd, aszArgs, aszEnv); -} +#include <windows.h> +#include <sys/stat.h> +#include <stdarg.h> + +#include "httpd.h" +#include "http_log.h" + +/* Returns TRUE if the path is real, FALSE if it is PATH_INFO */ +static BOOL sub_canonical_filename(char *szCanon, unsigned nCanon, + const char *szInFile) +{ + char buf[HUGE_STRING_LEN]; + int n; + char *szFilePart; + char *s; + int nSlashes; + WIN32_FIND_DATA d; + HANDLE h; + const char *szFile; + + szFile = szInFile; + s = strrchr(szFile, '\\'); + for (nSlashes = 0; s > szFile && s[-1] == '\\'; ++nSlashes, --s) + ; + + n = GetFullPathName(szFile, sizeof buf, buf, &szFilePart); + ap_assert(n); + ap_assert(n < sizeof buf); + + /* + * There is an implicit assumption that szInFile will contain a '\'. + * If this is not true (as in the case of <Directory *> or + * <File .htaccess>) we would assert in some of the code below. Therefore, + * if we don't get any '\' in the file name, then use the file name we get + * from GetFullPathName, because it will have at least one '\'. If there + * is no '\' in szInFile, it must just be a file name, so it should be + * valid to use the name from GetFullPathName. Be sure to adjust the + * 's' variable so the rest of the code functions normally. + */ + if (!s) { + szFile = buf; + s = strrchr(szFile, '\\'); + } + + /* If we have \\machine\share, convert to \\machine\share\ */ + if (buf[0] == '\\' && buf[1] == '\\') { + char *s = strchr(buf + 2, '\\'); + if (s && !strchr(s + 1, '\\')) { + strcat(s + 1, "\\"); + } + } + + if (!strchr(buf, '*') && !strchr(buf, '?')) { + h = FindFirstFile(buf, &d); + if (h != INVALID_HANDLE_VALUE) { + FindClose(h); + } + } + else { + h = INVALID_HANDLE_VALUE; + } + + if (szFilePart < buf + 3) { + ap_assert(strlen(buf) < nCanon); + strcpy(szCanon, buf); + /* a \ at the start means it is UNC, otherwise it is x: */ + if (szCanon[0] != '\\') { + ap_assert(ap_isalpha(szCanon[0])); + ap_assert(szCanon[1] == ':'); + szCanon[2] = '/'; + } + else { + char *s; + + ap_assert(szCanon[1] == '\\'); + for (s = szCanon; *s; ++s) { + if (*s == '\\') { + *s = '/'; + } + } + } + return TRUE; + } + if (szFilePart != buf + 3) { + char b2[_MAX_PATH]; + char b3[_MAX_PATH]; + ap_assert(szFilePart > buf + 3); + /* avoid SEGVs on things like "Directory *" */ + ap_assert(s >= szFile && "this is a known bug"); + + memcpy(b3, szFile, s - szFile); + b3[s - szFile] = '\0'; + +/* szFilePart[-1] = '\0'; */ + sub_canonical_filename(b2, sizeof b2, b3); + + ap_assert(strlen(b2)+1 < nCanon); + strcpy(szCanon, b2); + strcat(szCanon, "/"); + } + else { + ap_assert(strlen(buf) < nCanon); + strcpy(szCanon, buf); + szCanon[2] = '/'; + szCanon[3] = '\0'; + } + if (h == INVALID_HANDLE_VALUE) { + ap_assert(strlen(szCanon) + strlen(szFilePart) + nSlashes < nCanon); + for (n = 0; n < nSlashes; ++n) { + strcat(szCanon, "/"); + } + strcat(szCanon, szFilePart); + return FALSE; + } + else { + ap_assert(strlen(szCanon)+strlen(d.cFileName) < nCanon); + strlwr(d.cFileName); + strcat(szCanon, d.cFileName); + return TRUE; + } +} + +/* UNC requires backslashes, hence the conversion before canonicalisation. + * Not sure how * many backslashes (could be that + * \\machine\share\some/path/is/ok for example). For now, do them all. + */ +API_EXPORT(char *) ap_os_canonical_filename(pool *pPool, const char *szFile) +{ + char buf[HUGE_STRING_LEN]; + char b2[HUGE_STRING_LEN]; + const char *s; + char *d; + int nSlashes = 0; + + ap_assert(strlen(szFile) < sizeof b2); + + /* Eliminate directories consisting of three or more dots. + * These act like ".." but are not detected by other machinery. + * Also get rid of trailing .s on any path component, which are ignored + * by the filesystem. Simultaneously, rewrite / to \. + * This is a bit of a kludge - Ben. + */ + if (strlen(szFile) == 1) { + /* + * If the file is only one char (like in the case of / or .) then + * just pass that through to sub_canonical_filename. Convert a + * '/' to '\\' if necessary. + */ + if (szFile[0] == '/') { + b2[0] = '\\'; + } + else { + b2[0] = szFile[0]; + } + + b2[1] = '\0'; + } + else { + for (s = szFile, d = b2; (*d = *s); ++d, ++s) { + if (*s == '/') { + *d = '\\'; + } + if (*s == '.' && (s[1] == '/' || s[1] == '\\' || !s[1])) { + while (*d == '.') { + --d; + } + if (*d == '\\') { + --d; + } + } + } + + /* Finally, a trailing slash(es) screws thing, so blow them away */ + for (nSlashes = 0; d > b2 && d[-1] == '\\'; --d, ++nSlashes) + ; + /* XXXX this breaks '/' and 'c:/' cases */ + *d = '\0'; + } + sub_canonical_filename(buf, sizeof buf, b2); + + buf[0] = ap_tolower(buf[0]); + + ap_assert(strlen(buf)+nSlashes < sizeof buf); + while (nSlashes--) { + strcat(buf, "/"); + } + + return ap_pstrdup(pPool, buf); +} + +/* Win95 doesn't like trailing /s. NT and Unix don't mind. This works + * around the problem. + * Errr... except if it is UNC and we are referring to the root of + * the UNC, we MUST have a trailing \ and we can't use /s. Jeez. + * Not sure if this refers to all UNCs or just roots, + * but I'm going to fix it for all cases for now. (Ben) + */ + +#undef stat +API_EXPORT(int) os_stat(const char *szPath, struct stat *pStat) +{ + int n; + + /* be sure it is has a drive letter or is a UNC path; everything + * _must_ be canonicalized before getting to this point. + */ + if (szPath[1] != ':' && szPath[1] != '/') { + ap_log_error(APLOG_MARK, APLOG_ERR, NULL, + "Invalid path in os_stat: \"%s\", " + "should have a drive letter or be a UNC path", + szPath); + return (-1); + } + + if (szPath[0] == '/') { + char buf[_MAX_PATH]; + char *s; + int nSlashes = 0; + + ap_assert(strlen(szPath) < _MAX_PATH); + strcpy(buf, szPath); + for (s = buf; *s; ++s) { + if (*s == '/') { + *s = '\\'; + ++nSlashes; + } + } + /* then we need to add one more to get \\machine\share\ */ + if (nSlashes == 3) { + *s++ = '\\'; + } + *s = '\0'; + return stat(buf, pStat); + } + + n = strlen(szPath); + if (szPath[n - 1] == '\\' || szPath[n - 1] == '/') { + char buf[_MAX_PATH]; + + ap_assert(n < _MAX_PATH); + strcpy(buf, szPath); + buf[n - 1] = '\0'; + + return stat(buf, pStat); + } + return stat(szPath, pStat); +} + +/* Fix two really crap problems with Win32 spawn[lv]e*: + * + * 1. Win32 doesn't deal with spaces in argv. + * 2. Win95 doesn't like / in cmdname. + */ + +#undef _spawnv +API_EXPORT(int) os_spawnv(int mode, const char *cmdname, + const char *const *argv) +{ + int n; + char **aszArgs; + const char *szArg; + char *szCmd; + char *s; + + szCmd = _alloca(strlen(cmdname)+1); + strcpy(szCmd, cmdname); + for (s = szCmd; *s; ++s) { + if (*s == '/') { + *s = '\\'; + } + } + + for (n = 0; argv[n]; ++n) + ; + + aszArgs = _alloca((n + 1) * sizeof(const char *)); + + for (n = 0; szArg = argv[n]; ++n) { + if (strchr(szArg, ' ')) { + int l = strlen(szArg); + + aszArgs[n] = _alloca(l + 2 + 1); + aszArgs[n][0] = '"'; + strcpy(&aszArgs[n][1], szArg); + aszArgs[n][l + 1] = '"'; + aszArgs[n][l + 2] = '\0'; + } + else { + aszArgs[n] = (char *)szArg; + } + } + + aszArgs[n] = NULL; + + return _spawnv(mode, szCmd, aszArgs); +} + +#undef _spawnve +API_EXPORT(int) os_spawnve(int mode, const char *cmdname, + const char *const *argv, const char *const *envp) +{ + int n; + char **aszArgs; + const char *szArg; + char *szCmd; + char *s; + + szCmd = _alloca(strlen(cmdname)+1); + strcpy(szCmd, cmdname); + for (s = szCmd; *s; ++s) { + if (*s == '/') { + *s = '\\'; + } + } + + for (n = 0; argv[n]; ++n) + ; + + aszArgs = _alloca((n + 1)*sizeof(const char *)); + + for (n = 0; szArg = argv[n]; ++n){ + if (strchr(szArg, ' ')) { + int l = strlen(szArg); + + aszArgs[n] = _alloca(l + 2 + 1); + aszArgs[n][0] = '"'; + strcpy(&aszArgs[n][1], szArg); + aszArgs[n][l + 1] = '"'; + aszArgs[n][l + 2] = '\0'; + } + else { + aszArgs[n] = (char *)szArg; + } + } + + aszArgs[n] = NULL; + + return _spawnve(mode, szCmd, aszArgs, envp); +} + +API_EXPORT(int) os_spawnle(int mode, const char *cmdname, ...) +{ + int n; + va_list vlist; + char **aszArgs; + const char *szArg; + const char *const *aszEnv; + char *szCmd; + char *s; + + szCmd = _alloca(strlen(cmdname)+1); + strcpy(szCmd, cmdname); + for (s = szCmd; *s; ++s) { + if (*s == '/') { + *s = '\\'; + } + } + + va_start(vlist, cmdname); + for (n = 0; va_arg(vlist, const char *); ++n) + ; + va_end(vlist); + + aszArgs = _alloca((n + 1) * sizeof(const char *)); + + va_start(vlist, cmdname); + for (n = 0; szArg = va_arg(vlist, const char *); ++n) { + if (strchr(szArg, ' ')) { + int l = strlen(szArg); + + aszArgs[n] = _alloca(l + 2 + 1); + aszArgs[n][0] = '"'; + strcpy(&aszArgs[n][1], szArg); + aszArgs[n][l + 1] = '"'; + aszArgs[n][l + 2] = '\0'; + } + else { + aszArgs[n] = (char *)szArg; + } + } + + aszArgs[n] = NULL; + + aszEnv = va_arg(vlist, const char *const *); + va_end(vlist); + + return _spawnve(mode, szCmd, aszArgs, aszEnv); +}