diff options
| author | Arno Töll <debian@toell.net> | 2012-01-08 22:53:17 +0100 |
|---|---|---|
| committer | Arno Töll <debian@toell.net> | 2012-01-08 22:53:17 +0100 |
| commit | e072a2dd866b7cb9f14319b80326a4e7fd16fcdf (patch) | |
| tree | a49dfc56d94a26011fe157835ff6cbe14edbd8a9 /modules/generators | |
| parent | 0890390c00801651d08d3794e13b31a5dabbf5ef (diff) | |
| download | apache2-e072a2dd866b7cb9f14319b80326a4e7fd16fcdf.tar.gz | |
Imported Upstream version 2.3.16-beta
Diffstat (limited to 'modules/generators')
26 files changed, 828 insertions, 2533 deletions
diff --git a/modules/generators/NWGNUautoindex b/modules/generators/NWGNUautoindex index 86f0b110..e8080c36 100644 --- a/modules/generators/NWGNUautoindex +++ b/modules/generators/NWGNUautoindex @@ -19,8 +19,8 @@ XINCDIRS += \ $(APR)/include \ $(APRUTIL)/include \ $(AP_WORK)/include \ + $(AP_WORK)/modules/http \ $(NWOS) \ - $(HTTPD) \ $(EOLIST) # @@ -95,7 +95,7 @@ endif NLM_NAME = autoindex # -# This is used by the link '-desc ' directive. +# This is used by the link '-desc ' directive. # If left blank, NLM_NAME will be used. # NLM_DESCRIPTION = Apache $(VERSION_STR) Autoindex Module @@ -107,7 +107,7 @@ NLM_DESCRIPTION = Apache $(VERSION_STR) Autoindex Module NLM_THREAD_NAME = Autoindex Module # -# If this is specified, it will override VERSION value in +# If this is specified, it will override VERSION value in # $(AP_WORK)/build/NWGNUenvironment.inc # NLM_VERSION = @@ -139,11 +139,11 @@ NLM_CHECK_SYM = NLM_FLAGS = # -# If this is specified it will be linked in with the XDCData option in the def +# If this is specified it will be linked in with the XDCData option in the def # file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled # by setting APACHE_UNIPROC in the environment # -XDCDATA = +XDCDATA = # # If there is an NLM target, put it here @@ -187,7 +187,7 @@ FILES_nlm_modules = \ # If the nlm has a msg file, put it's path here # FILE_nlm_msg = - + # # If the nlm has a hlp file put it's path here # @@ -206,15 +206,15 @@ FILES_nlm_Ximports = \ @httpd.imp \ @libc.imp \ $(EOLIST) - -# + +# # Any symbols exported to here # FILES_nlm_exports = \ autoindex_module \ $(EOLIST) -# +# # These are the OBJ files needed to create the LIB target above. # Paths must all use the '/' character # @@ -230,7 +230,7 @@ libs :: $(OBJDIR) $(TARGET_lib) nlms :: libs $(TARGET_nlm) # -# Updated this target to create necessary directories and copy files to the +# Updated this target to create necessary directories and copy files to the # correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) # install :: nlms FORCE diff --git a/modules/generators/NWGNUinfo b/modules/generators/NWGNUinfo index 9d60ac5b..810db8a2 100644 --- a/modules/generators/NWGNUinfo +++ b/modules/generators/NWGNUinfo @@ -94,7 +94,7 @@ endif NLM_NAME = info # -# This is used by the link '-desc ' directive. +# This is used by the link '-desc ' directive. # If left blank, NLM_NAME will be used. # NLM_DESCRIPTION = Apache $(VERSION_STR) Info Module @@ -106,7 +106,7 @@ NLM_DESCRIPTION = Apache $(VERSION_STR) Info Module NLM_THREAD_NAME = Info Module # -# If this is specified, it will override VERSION value in +# If this is specified, it will override VERSION value in # $(AP_WORK)/build/NWGNUenvironment.inc # NLM_VERSION = @@ -138,11 +138,11 @@ NLM_CHECK_SYM = NLM_FLAGS = # -# If this is specified it will be linked in with the XDCData option in the def +# If this is specified it will be linked in with the XDCData option in the def # file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled # by setting APACHE_UNIPROC in the environment # -XDCDATA = +XDCDATA = # # If there is an NLM target, put it here @@ -186,7 +186,7 @@ FILES_nlm_modules = \ # If the nlm has a msg file, put it's path here # FILE_nlm_msg = - + # # If the nlm has a hlp file put it's path here # @@ -205,15 +205,15 @@ FILES_nlm_Ximports = \ @httpd.imp \ @libc.imp \ $(EOLIST) - -# + +# # Any symbols exported to here # FILES_nlm_exports = \ info_module \ $(EOLIST) -# +# # These are the OBJ files needed to create the LIB target above. # Paths must all use the '/' character # @@ -229,7 +229,7 @@ libs :: $(OBJDIR) $(TARGET_lib) nlms :: libs $(TARGET_nlm) # -# Updated this target to create necessary directories and copy files to the +# Updated this target to create necessary directories and copy files to the # correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) # install :: nlms FORCE diff --git a/modules/generators/NWGNUmakefile b/modules/generators/NWGNUmakefile index 1a6cb98a..df9cfeca 100644 --- a/modules/generators/NWGNUmakefile +++ b/modules/generators/NWGNUmakefile @@ -3,7 +3,7 @@ # SUBDIRS = \ - $(EOLIST) + $(EOLIST) # # Get the 'head' of the build environment. This includes default targets and @@ -98,7 +98,7 @@ endif NLM_NAME = # -# This is used by the link '-desc ' directive. +# This is used by the link '-desc ' directive. # If left blank, NLM_NAME will be used. # NLM_DESCRIPTION = @@ -110,7 +110,7 @@ NLM_DESCRIPTION = NLM_THREAD_NAME = # -# If this is specified, it will override VERSION value in +# If this is specified, it will override VERSION value in # $(AP_WORK)/build/NWGNUenvironment.inc # NLM_VERSION = @@ -142,11 +142,11 @@ NLM_CHECK_SYM = NLM_FLAGS = # -# If this is specified it will be linked in with the XDCData option in the def +# If this is specified it will be linked in with the XDCData option in the def # file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled # by setting APACHE_UNIPROC in the environment # -XDCDATA = +XDCDATA = # # If there is an NLM target, put it here @@ -190,7 +190,7 @@ FILES_nlm_modules = \ # If the nlm has a msg file, put it's path here # FILE_nlm_msg = - + # # If the nlm has a hlp file put it's path here # @@ -206,14 +206,14 @@ FILE_nlm_copyright = # FILES_nlm_Ximports = \ $(EOLIST) - -# + +# # Any symbols exported to here # FILES_nlm_exports = \ $(EOLIST) -# +# # These are the OBJ files needed to create the LIB target above. # Paths must all use the '/' character # @@ -229,7 +229,7 @@ libs :: $(OBJDIR) $(TARGET_lib) nlms :: libs $(TARGET_nlm) # -# Updated this target to create necessary directories and copy files to the +# Updated this target to create necessary directories and copy files to the # correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) # install :: nlms FORCE diff --git a/modules/generators/NWGNUmod_asis b/modules/generators/NWGNUmod_asis index d8ab0d1c..c7df5ae8 100644 --- a/modules/generators/NWGNUmod_asis +++ b/modules/generators/NWGNUmod_asis @@ -19,8 +19,8 @@ XINCDIRS += \ $(APR)/include \ $(APRUTIL)/include \ $(AP_WORK)/include \ + $(AP_WORK)/modules/http \ $(NWOS) \ - $(HTTPD) \ $(EOLIST) # @@ -95,7 +95,7 @@ endif NLM_NAME = mod_asis # -# This is used by the link '-desc ' directive. +# This is used by the link '-desc ' directive. # If left blank, NLM_NAME will be used. # NLM_DESCRIPTION = Apache $(VERSION_STR) ASIS Module @@ -107,7 +107,7 @@ NLM_DESCRIPTION = Apache $(VERSION_STR) ASIS Module NLM_THREAD_NAME = Mod_asis Module # -# If this is specified, it will override VERSION value in +# If this is specified, it will override VERSION value in # $(AP_WORK)/build/NWGNUenvironment.inc # NLM_VERSION = @@ -139,11 +139,11 @@ NLM_CHECK_SYM = NLM_FLAGS = # -# If this is specified it will be linked in with the XDCData option in the def +# If this is specified it will be linked in with the XDCData option in the def # file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled # by setting APACHE_UNIPROC in the environment # -XDCDATA = +XDCDATA = # # If there is an NLM target, put it here @@ -187,7 +187,7 @@ FILES_nlm_modules = \ # If the nlm has a msg file, put it's path here # FILE_nlm_msg = - + # # If the nlm has a hlp file put it's path here # @@ -206,15 +206,15 @@ FILES_nlm_Ximports = \ @httpd.imp \ @libc.imp \ $(EOLIST) - -# + +# # Any symbols exported to here # FILES_nlm_exports = \ asis_module \ $(EOLIST) -# +# # These are the OBJ files needed to create the LIB target above. # Paths must all use the '/' character # @@ -230,7 +230,7 @@ libs :: $(OBJDIR) $(TARGET_lib) nlms :: libs $(TARGET_nlm) # -# Updated this target to create necessary directories and copy files to the +# Updated this target to create necessary directories and copy files to the # correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) # install :: nlms FORCE diff --git a/modules/generators/NWGNUmod_cgi b/modules/generators/NWGNUmod_cgi index 2c4330c7..bbb95784 100644 --- a/modules/generators/NWGNUmod_cgi +++ b/modules/generators/NWGNUmod_cgi @@ -19,9 +19,9 @@ XINCDIRS += \ $(APR)/include \ $(APRUTIL)/include \ $(AP_WORK)/include \ + $(AP_WORK)/modules/http \ + $(AP_WORK)/modules/filters \ $(NWOS) \ - $(HTTPD) \ - $(STDMOD)/filters \ $(EOLIST) # @@ -57,7 +57,7 @@ XDEFINES += \ $(EOLIST) XLFLAGS += \ - $(EOLIST) + $(EOLIST) endif ifeq "$(RELEASE)" "noopt" @@ -71,7 +71,7 @@ XDEFINES += \ $(EOLIST) XLFLAGS += \ - $(EOLIST) + $(EOLIST) endif ifeq "$(RELEASE)" "release" @@ -96,7 +96,7 @@ endif NLM_NAME = mod_cgi # -# This is used by the link '-desc ' directive. +# This is used by the link '-desc ' directive. # If left blank, NLM_NAME will be used. # NLM_DESCRIPTION = Apache $(VERSION_STR) CGI Module @@ -108,7 +108,7 @@ NLM_DESCRIPTION = Apache $(VERSION_STR) CGI Module NLM_THREAD_NAME = Mod_cgi Module # -# If this is specified, it will override VERSION value in +# If this is specified, it will override VERSION value in # $(AP_WORK)/build/NWGNUenvironment.inc # NLM_VERSION = @@ -140,11 +140,11 @@ NLM_CHECK_SYM = NLM_FLAGS = # -# If this is specified it will be linked in with the XDCData option in the def +# If this is specified it will be linked in with the XDCData option in the def # file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled # by setting APACHE_UNIPROC in the environment # -XDCDATA = +XDCDATA = # # If there is an NLM target, put it here @@ -188,7 +188,7 @@ FILES_nlm_modules = \ # If the nlm has a msg file, put it's path here # FILE_nlm_msg = - + # # If the nlm has a hlp file put it's path here # @@ -207,15 +207,15 @@ FILES_nlm_Ximports = \ @httpd.imp \ @libc.imp \ $(EOLIST) - -# + +# # Any symbols exported to here # FILES_nlm_exports = \ cgi_module \ $(EOLIST) -# +# # These are the OBJ files needed to create the LIB target above. # Paths must all use the '/' character # @@ -231,7 +231,7 @@ libs :: $(OBJDIR) $(TARGET_lib) nlms :: libs $(TARGET_nlm) # -# Updated this target to create necessary directories and copy files to the +# Updated this target to create necessary directories and copy files to the # correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) # install :: nlms FORCE @@ -247,4 +247,3 @@ install :: nlms FORCE include $(APBUILD)/NWGNUtail.inc - diff --git a/modules/generators/NWGNUstatus b/modules/generators/NWGNUstatus index 630edb80..1dc850e2 100644 --- a/modules/generators/NWGNUstatus +++ b/modules/generators/NWGNUstatus @@ -94,7 +94,7 @@ endif NLM_NAME = status # -# This is used by the link '-desc ' directive. +# This is used by the link '-desc ' directive. # If left blank, NLM_NAME will be used. # NLM_DESCRIPTION = Apache $(VERSION_STR) Status Module @@ -106,7 +106,7 @@ NLM_DESCRIPTION = Apache $(VERSION_STR) Status Module NLM_THREAD_NAME = Status Module # -# If this is specified, it will override VERSION value in +# If this is specified, it will override VERSION value in # $(AP_WORK)/build/NWGNUenvironment.inc # NLM_VERSION = @@ -138,11 +138,11 @@ NLM_CHECK_SYM = NLM_FLAGS = # -# If this is specified it will be linked in with the XDCData option in the def +# If this is specified it will be linked in with the XDCData option in the def # file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled # by setting APACHE_UNIPROC in the environment # -XDCDATA = +XDCDATA = # # If there is an NLM target, put it here @@ -186,7 +186,7 @@ FILES_nlm_modules = \ # If the nlm has a msg file, put it's path here # FILE_nlm_msg = - + # # If the nlm has a hlp file put it's path here # @@ -205,15 +205,15 @@ FILES_nlm_Ximports = \ @httpd.imp \ @libc.imp \ $(EOLIST) - -# + +# # Any symbols exported to here # FILES_nlm_exports = \ status_module \ $(EOLIST) -# +# # These are the OBJ files needed to create the LIB target above. # Paths must all use the '/' character # @@ -229,7 +229,7 @@ libs :: $(OBJDIR) $(TARGET_lib) nlms :: libs $(TARGET_nlm) # -# Updated this target to create necessary directories and copy files to the +# Updated this target to create necessary directories and copy files to the # correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) # install :: nlms FORCE diff --git a/modules/generators/config5.m4 b/modules/generators/config5.m4 index feb7120e..bf295217 100644 --- a/modules/generators/config5.m4 +++ b/modules/generators/config5.m4 @@ -6,7 +6,7 @@ APACHE_MODPATH_INIT(generators) APACHE_MODULE(status, process/thread monitoring, , , yes) APACHE_MODULE(autoindex, directory listing, , , yes) -APACHE_MODULE(asis, as-is filetypes, , , yes) +APACHE_MODULE(asis, as-is filetypes, , , ) APACHE_MODULE(info, server information, , , most) APACHE_MODULE(suexec, set uid and gid for spawned processes, , , no, [ other_targets=suexec ] ) @@ -32,11 +32,50 @@ case $host in esac if test $cgid_needed = "yes"; then - APACHE_MODULE(cgid, CGI scripts, , , yes) - APACHE_MODULE(cgi, CGI scripts, , , no) + APACHE_MODULE(cgid, CGI scripts. Enabled by default with threaded MPMs, , , most, [ + case $host in + *-solaris2*) + case `uname -r` in + 5.10) + dnl Does the system have the appropriate patches? + case `uname -p` in + i386) + patch_id="120665" + ;; + sparc) + patch_id="120664" + ;; + *) + AC_MSG_WARN([Unknown platform]) + patch_id="120664" + ;; + esac + AC_MSG_CHECKING([for Solaris patch $patch_id]) + showrev -p | grep "$patch_id" >/dev/null 2>&1 + if test $? -eq 1; then + dnl Solaris 11 (next release) as of snv_19 doesn't have this problem. + dnl It may be possible to use /kernel/drv/tl from later releases. + AC_MSG_ERROR([Please apply either patch # 120664 (Sparc) or # 120665 (x86). +Without these patches, mod_cgid is non-functional on Solaris 10 due to an OS +bug with AF_UNIX sockets. +If you can not apply these patches, you can do one of the following: + - run configure with --disable-cgid + - switch to the prefork MPM +For more info: <http://issues.apache.org/bugzilla/show_bug.cgi?id=34264>]) + else + AC_MSG_RESULT(yes) + fi + ;; + esac + ;; + esac + ]) + APACHE_MODULE(cgi, CGI scripts. Enabled by default with non-threaded MPMs, , , no) else - APACHE_MODULE(cgi, CGI scripts, , , yes) - APACHE_MODULE(cgid, CGI scripts, , , no) + APACHE_MODULE(cgi, CGI scripts. Enabled by default with non-threaded MPMs, , , most) + APACHE_MODULE(cgid, CGI scripts. Enabled by default with threaded MPMs, , , no) fi +APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current]) + APACHE_MODPATH_FINISH diff --git a/modules/generators/mod_asis.c b/modules/generators/mod_asis.c index 1ed2f670..1fc14389 100644 --- a/modules/generators/mod_asis.c +++ b/modules/generators/mod_asis.c @@ -30,31 +30,33 @@ static int asis_handler(request_rec *r) { - conn_rec *c = r->connection; - apr_file_t *f = NULL; + apr_file_t *f; apr_status_t rv; const char *location; - if(strcmp(r->handler,ASIS_MAGIC_TYPE) && strcmp(r->handler,"send-as-is")) + if (strcmp(r->handler, ASIS_MAGIC_TYPE) && strcmp(r->handler, "send-as-is")) { return DECLINED; + } r->allowed |= (AP_METHOD_BIT << M_GET); - if (r->method_number != M_GET) + if (r->method_number != M_GET) { return DECLINED; - if (r->finfo.filetype == 0) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + } + + if (r->finfo.filetype == APR_NOFILE) { + ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(01233) "File does not exist: %s", r->filename); return HTTP_NOT_FOUND; } if ((rv = apr_file_open(&f, r->filename, APR_READ, APR_OS_DEFAULT, r->pool)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01234) "file permissions deny server access: %s", r->filename); return HTTP_FORBIDDEN; } - ap_scan_script_header_err(r, f, NULL); + ap_scan_script_header_err_ex(r, f, NULL, APLOG_MODULE_INDEX); location = apr_table_get(r->headers_out, "Location"); if (location && location[0] == '/' && @@ -76,13 +78,14 @@ static int asis_handler(request_rec *r) } if (!r->header_only) { + conn_rec *c = r->connection; apr_bucket_brigade *bb; apr_bucket *b; apr_off_t pos = 0; rv = apr_file_seek(f, APR_CUR, &pos); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01235) "mod_asis: failed to find end-of-headers position " "for %s", r->filename); apr_file_close(f); @@ -90,33 +93,13 @@ static int asis_handler(request_rec *r) } bb = apr_brigade_create(r->pool, c->bucket_alloc); -#if APR_HAS_LARGE_FILES - if (r->finfo.size - pos > AP_MAX_SENDFILE) { - /* APR_HAS_LARGE_FILES issue; must split into mutiple buckets, - * no greater than MAX(apr_size_t), and more granular than that - * in case the brigade code/filters attempt to read it directly. - */ - apr_off_t fsize = r->finfo.size - pos; - b = apr_bucket_file_create(f, pos, AP_MAX_SENDFILE, - r->pool, c->bucket_alloc); - while (fsize > AP_MAX_SENDFILE) { - APR_BRIGADE_INSERT_TAIL(bb, b); - apr_bucket_copy(b, &b); - b->start += AP_MAX_SENDFILE; - fsize -= AP_MAX_SENDFILE; - } - b->length = (apr_size_t)fsize; /* Resize just the last bucket */ - } - else -#endif - b = apr_bucket_file_create(f, pos, (apr_size_t) (r->finfo.size - pos), - r->pool, c->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(bb, b); + apr_brigade_insert_file(bb, f, pos, r->finfo.size - pos, r->pool); + b = apr_bucket_eos_create(c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); rv = ap_pass_brigade(r->output_filters, bb); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01236) "mod_asis: ap_pass_brigade failed for file %s", r->filename); return HTTP_INTERNAL_SERVER_ERROR; } @@ -133,7 +116,7 @@ static void register_hooks(apr_pool_t *p) ap_hook_handler(asis_handler,NULL,NULL,APR_HOOK_MIDDLE); } -module AP_MODULE_DECLARE_DATA asis_module = +AP_DECLARE_MODULE(asis) = { STANDARD20_MODULE_STUFF, NULL, /* create per-directory config structure */ diff --git a/modules/generators/mod_asis.dep b/modules/generators/mod_asis.dep deleted file mode 100644 index 3f151ba0..00000000 --- a/modules/generators/mod_asis.dep +++ /dev/null @@ -1,31 +0,0 @@ -# Microsoft Developer Studio Generated Dependency File, included by mod_asis.mak - -..\..\build\win32\httpd.rc : \ - "..\..\include\ap_release.h"\ - - -.\mod_asis.c : \ - "..\..\include\ap_config.h"\ - "..\..\include\ap_mmn.h"\ - "..\..\include\ap_regex.h"\ - "..\..\include\ap_release.h"\ - "..\..\include\http_config.h"\ - "..\..\include\http_log.h"\ - "..\..\include\http_main.h"\ - "..\..\include\http_protocol.h"\ - "..\..\include\http_request.h"\ - "..\..\include\httpd.h"\ - "..\..\include\mod_core.h"\ - "..\..\include\os.h"\ - "..\..\include\util_cfgtree.h"\ - "..\..\include\util_filter.h"\ - "..\..\include\util_script.h"\ - "..\..\srclib\apr-util\include\apr_hooks.h"\ - "..\..\srclib\apr-util\include\apr_optional.h"\ - "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ - "..\..\srclib\apr-util\include\apr_uri.h"\ - "..\..\srclib\apr\include\apr_mmap.h"\ - "..\..\srclib\apr\include\apr_poll.h"\ - "..\..\srclib\apr\include\apr_portable.h"\ - "..\..\srclib\apr\include\apr_strings.h"\ - diff --git a/modules/generators/mod_asis.mak b/modules/generators/mod_asis.mak deleted file mode 100644 index 79bf9f55..00000000 --- a/modules/generators/mod_asis.mak +++ /dev/null @@ -1,353 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on mod_asis.dsp -!IF "$(CFG)" == "" -CFG=mod_asis - Win32 Release -!MESSAGE No configuration specified. Defaulting to mod_asis - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "mod_asis - Win32 Release" && "$(CFG)" != "mod_asis - Win32 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "mod_asis.mak" CFG="mod_asis - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "mod_asis - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "mod_asis - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "mod_asis - Win32 Release" - -OUTDIR=.\Release -INTDIR=.\Release -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_asis.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_asis.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_asis.obj" - -@erase "$(INTDIR)\mod_asis.res" - -@erase "$(INTDIR)\mod_asis_src.idb" - -@erase "$(INTDIR)\mod_asis_src.pdb" - -@erase "$(OUTDIR)\mod_asis.exp" - -@erase "$(OUTDIR)\mod_asis.lib" - -@erase "$(OUTDIR)\mod_asis.pdb" - -@erase "$(OUTDIR)\mod_asis.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_asis_src" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_asis.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_asis.so" /d LONG_NAME="asis_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_asis.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_asis.pdb" /debug /out:"$(OUTDIR)\mod_asis.so" /implib:"$(OUTDIR)\mod_asis.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_asis.so /opt:ref -LINK32_OBJS= \ - "$(INTDIR)\mod_asis.obj" \ - "$(INTDIR)\mod_asis.res" \ - "..\..\srclib\apr\Release\libapr-1.lib" \ - "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ - "..\..\Release\libhttpd.lib" - -"$(OUTDIR)\mod_asis.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Release\mod_asis.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_asis.so" - if exist .\Release\mod_asis.so.manifest mt.exe -manifest .\Release\mod_asis.so.manifest -outputresource:.\Release\mod_asis.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "mod_asis - Win32 Debug" - -OUTDIR=.\Debug -INTDIR=.\Debug -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_asis.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_asis.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_asis.obj" - -@erase "$(INTDIR)\mod_asis.res" - -@erase "$(INTDIR)\mod_asis_src.idb" - -@erase "$(INTDIR)\mod_asis_src.pdb" - -@erase "$(OUTDIR)\mod_asis.exp" - -@erase "$(OUTDIR)\mod_asis.lib" - -@erase "$(OUTDIR)\mod_asis.pdb" - -@erase "$(OUTDIR)\mod_asis.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_asis_src" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_asis.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_asis.so" /d LONG_NAME="asis_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_asis.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_asis.pdb" /debug /out:"$(OUTDIR)\mod_asis.so" /implib:"$(OUTDIR)\mod_asis.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_asis.so -LINK32_OBJS= \ - "$(INTDIR)\mod_asis.obj" \ - "$(INTDIR)\mod_asis.res" \ - "..\..\srclib\apr\Debug\libapr-1.lib" \ - "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ - "..\..\Debug\libhttpd.lib" - -"$(OUTDIR)\mod_asis.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Debug\mod_asis.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_asis.so" - if exist .\Debug\mod_asis.so.manifest mt.exe -manifest .\Debug\mod_asis.so.manifest -outputresource:.\Debug\mod_asis.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("mod_asis.dep") -!INCLUDE "mod_asis.dep" -!ELSE -!MESSAGE Warning: cannot find "mod_asis.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "mod_asis - Win32 Release" || "$(CFG)" == "mod_asis - Win32 Debug" - -!IF "$(CFG)" == "mod_asis - Win32 Release" - -"libapr - Win32 Release" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" - cd "..\..\modules\generators" - -"libapr - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_asis - Win32 Debug" - -"libapr - Win32 Debug" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" - cd "..\..\modules\generators" - -"libapr - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_asis - Win32 Release" - -"libaprutil - Win32 Release" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" - cd "..\..\modules\generators" - -"libaprutil - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_asis - Win32 Debug" - -"libaprutil - Win32 Debug" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" - cd "..\..\modules\generators" - -"libaprutil - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_asis - Win32 Release" - -"libhttpd - Win32 Release" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" - cd ".\modules\generators" - -"libhttpd - Win32 ReleaseCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ELSEIF "$(CFG)" == "mod_asis - Win32 Debug" - -"libhttpd - Win32 Debug" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" - cd ".\modules\generators" - -"libhttpd - Win32 DebugCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ENDIF - -SOURCE=..\..\build\win32\httpd.rc - -!IF "$(CFG)" == "mod_asis - Win32 Release" - - -"$(INTDIR)\mod_asis.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_asis.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "NDEBUG" /d BIN_NAME="mod_asis.so" /d LONG_NAME="asis_module for Apache" $(SOURCE) - - -!ELSEIF "$(CFG)" == "mod_asis - Win32 Debug" - - -"$(INTDIR)\mod_asis.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_asis.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "_DEBUG" /d BIN_NAME="mod_asis.so" /d LONG_NAME="asis_module for Apache" $(SOURCE) - - -!ENDIF - -SOURCE=.\mod_asis.c - -"$(INTDIR)\mod_asis.obj" : $(SOURCE) "$(INTDIR)" - - - -!ENDIF - diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index 5c03d99f..bf8005ed 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -71,7 +71,8 @@ module AP_MODULE_DECLARE_DATA autoindex_module; #define IGNORE_CASE (1 << 16) #define EMIT_XHTML (1 << 17) #define SHOW_FORBIDDEN (1 << 18) -#define OPTION_UNSET (1 << 19) +#define ADDALTCLASS (1 << 19) +#define OPTION_UNSET (1 << 20) #define K_NOADJUST 0 #define K_ADJUST 1 @@ -121,6 +122,8 @@ typedef struct autoindex_config_struct { char *default_icon; char *style_sheet; char *head_insert; + char *header; + char *readme; apr_int32_t opts; apr_int32_t incremented_opts; apr_int32_t decremented_opts; @@ -137,8 +140,7 @@ typedef struct autoindex_config_struct { apr_array_header_t *alt_list; apr_array_header_t *desc_list; apr_array_header_t *ign_list; - apr_array_header_t *hdr_list; - apr_array_header_t *rdme_list; + int ign_noinherit; char *ctype; char *charset; @@ -150,6 +152,14 @@ static char c_by_encoding, c_by_type, c_by_path; #define BY_TYPE &c_by_type #define BY_PATH &c_by_path +static APR_INLINE int response_is_html(request_rec *r) +{ + char *ctype = ap_field_noparam(r->pool, r->content_type); + ap_str_tolower(ctype); + return !strcmp(ctype, "text/html") + || !strcmp(ctype, "application/xhtml+xml"); +} + /* * This routine puts the standard HTML header at the top of the index page. * We include the DOCTYPE because we may be using features therefrom (i.e., @@ -314,20 +324,6 @@ static const char *add_ignore(cmd_parms *cmd, void *d, const char *ext) return NULL; } -static const char *add_header(cmd_parms *cmd, void *d, const char *name) -{ - push_item(((autoindex_config_rec *) d)->hdr_list, 0, NULL, cmd->path, - name); - return NULL; -} - -static const char *add_readme(cmd_parms *cmd, void *d, const char *name) -{ - push_item(((autoindex_config_rec *) d)->rdme_list, 0, NULL, cmd->path, - name); - return NULL; -} - static const char *add_opts(cmd_parms *cmd, void *d, int argc, char *const argv[]) { int i; @@ -406,6 +402,9 @@ static const char *add_opts(cmd_parms *cmd, void *d, int argc, char *const argv[ else if (!strcasecmp(w, "ShowForbidden")) { option = SHOW_FORBIDDEN; } + else if (!strcasecmp(w, "AddAltClass")) { + option = ADDALTCLASS; + } else if (!strcasecmp(w, "None")) { if (action != '\0') { return "Cannot combine '+' or '-' with 'None' keyword"; @@ -584,12 +583,18 @@ static const command_rec autoindex_cmds[] = "{Ascending,Descending} {Name,Size,Description,Date}"), AP_INIT_ITERATE("IndexIgnore", add_ignore, NULL, DIR_CMD_PERMS, "one or more file extensions"), + AP_INIT_FLAG("IndexIgnoreReset", ap_set_flag_slot, + (void *)APR_OFFSETOF(autoindex_config_rec, ign_noinherit), + DIR_CMD_PERMS, + "Reset the inherited list of IndexIgnore filenames"), AP_INIT_ITERATE2("AddDescription", add_desc, BY_PATH, DIR_CMD_PERMS, "Descriptive text followed by one or more filenames"), - AP_INIT_TAKE1("HeaderName", add_header, NULL, DIR_CMD_PERMS, - "a filename"), - AP_INIT_TAKE1("ReadmeName", add_readme, NULL, DIR_CMD_PERMS, - "a filename"), + AP_INIT_TAKE1("HeaderName", ap_set_string_slot, + (void *)APR_OFFSETOF(autoindex_config_rec, header), + DIR_CMD_PERMS, "a filename"), + AP_INIT_TAKE1("ReadmeName", ap_set_string_slot, + (void *)APR_OFFSETOF(autoindex_config_rec, readme), + DIR_CMD_PERMS, "a filename"), AP_INIT_RAW_ARGS("FancyIndexing", ap_set_deprecated, NULL, OR_ALL, "The FancyIndexing directive is no longer supported. " "Use IndexOptions FancyIndexing."), @@ -620,8 +625,6 @@ static void *create_autoindex_config(apr_pool_t *p, char *dummy) new->alt_list = apr_array_make(p, 4, sizeof(struct item)); new->desc_list = apr_array_make(p, 4, sizeof(ai_desc_t)); new->ign_list = apr_array_make(p, 4, sizeof(struct item)); - new->hdr_list = apr_array_make(p, 4, sizeof(struct item)); - new->rdme_list = apr_array_make(p, 4, sizeof(struct item)); new->opts = OPTION_UNSET; new->incremented_opts = 0; new->decremented_opts = 0; @@ -644,6 +647,10 @@ static void *merge_autoindex_configs(apr_pool_t *p, void *basev, void *addv) : base->style_sheet; new->head_insert = add->head_insert ? add->head_insert : base->head_insert; + new->header = add->header ? add->header + : base->header; + new->readme = add->readme ? add->readme + : base->readme; new->icon_height = add->icon_height ? add->icon_height : base->icon_height; new->icon_width = add->icon_width ? add->icon_width : base->icon_width; @@ -651,11 +658,9 @@ static void *merge_autoindex_configs(apr_pool_t *p, void *basev, void *addv) new->charset = add->charset ? add->charset : base->charset; new->alt_list = apr_array_append(p, add->alt_list, base->alt_list); - new->ign_list = apr_array_append(p, add->ign_list, base->ign_list); - new->hdr_list = apr_array_append(p, add->hdr_list, base->hdr_list); new->desc_list = apr_array_append(p, add->desc_list, base->desc_list); new->icon_list = apr_array_append(p, add->icon_list, base->icon_list); - new->rdme_list = apr_array_append(p, add->rdme_list, base->rdme_list); + new->ign_list = add->ign_noinherit ? add->ign_list : apr_array_append(p, add->ign_list, base->ign_list); if (add->opts == NO_OPTIONS) { /* * If the current directory explicitly says 'no options' then we also @@ -751,12 +756,9 @@ struct ent { int isdir; }; -static char *find_item(request_rec *r, apr_array_header_t *list, int path_only) +static char *find_item(const char *content_type, const char *content_encoding, + char *path, apr_array_header_t *list, int path_only) { - const char *content_type = ap_field_noparam(r->pool, r->content_type); - const char *content_encoding = r->content_encoding; - char *path = r->filename; - struct item *items = (struct item *) list->elts; int i; @@ -797,25 +799,16 @@ static char *find_item(request_rec *r, apr_array_header_t *list, int path_only) return NULL; } -#define find_icon(d,p,t) find_item(p,d->icon_list,t) -#define find_alt(d,p,t) find_item(p,d->alt_list,t) -#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_item(char *bogus_name, apr_array_header_t *list) +static char *find_item_by_request(request_rec *r, apr_array_header_t *list, int path_only) { - request_rec r; - /* Bleah. I tried to clean up find_item, and it lead to this bit - * of ugliness. Note that the fields initialized are precisely - * those that find_item looks at... - */ - r.filename = bogus_name; - r.content_type = r.content_encoding = NULL; - return find_item(&r, list, 1); + return find_item(ap_field_noparam(r->pool, r->content_type), + r->content_encoding, r->filename, list, path_only); } -#define find_default_icon(d,n) find_default_item(n, d->icon_list) -#define find_default_alt(d,n) find_default_item(n, d->alt_list) +#define find_icon(d,p,t) find_item_by_request(p,d->icon_list,t) +#define find_alt(d,p,t) find_item_by_request(p,d->alt_list,t) +#define find_default_icon(d,n) find_item(NULL, NULL, n, d->icon_list, 1) +#define find_default_alt(d,n) find_item(NULL, NULL, n, d->alt_list, 1) /* * Look through the list of pattern/description pairs and return the first one @@ -1005,6 +998,7 @@ static void do_emit_plain(request_rec *r, apr_file_t *f) static void emit_head(request_rec *r, char *header_fname, int suppress_amble, int emit_xhtml, char *title) { + autoindex_config_rec *d; apr_table_t *hdrs = r->headers_in; apr_file_t *f = NULL; request_rec *rr = NULL; @@ -1038,8 +1032,7 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, * SSIs. */ if (rr->content_type != NULL) { - if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type), - "text/html")) { + if (response_is_html(rr)) { ap_filter_t *f; /* Hope everything will work... */ emit_amble = 0; @@ -1108,8 +1101,16 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, if (emit_amble) { emit_preamble(r, emit_xhtml, title); } + + d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config, &autoindex_module); + if (emit_H1) { - ap_rvputs(r, "<h1>Index of ", title, "</h1>\n", NULL); + if (d->style_sheet != NULL) { + /* Insert style id if stylesheet used */ + ap_rvputs(r, " <h1 id=\"indextitle\">Index of ", title, "</h1>\n", NULL); + } else { + ap_rvputs(r, "<h1>Index of ", title, "</h1>\n", NULL); + } } if (rr != NULL) { ap_destroy_sub_req(rr); @@ -1149,8 +1150,7 @@ static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble) * SSIs. */ if (rr->content_type != NULL) { - if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type), - "text/html")) { + if (response_is_html(rr)) { ap_filter_t *f; for (f=rr->output_filters; f->frec != ap_subreq_core_filter_handle; f = f->next); @@ -1200,8 +1200,7 @@ static char *find_title(request_rec *r) return NULL; } if ((r->content_type != NULL) - && (!strcasecmp(ap_field_noparam(r->pool, r->content_type), - "text/html") + && (response_is_html(r) || !strcmp(r->content_type, INCLUDES_MAGIC_TYPE)) && !r->content_encoding) { if (apr_file_open(&thefile, r->filename, APR_READ, @@ -1287,7 +1286,9 @@ static struct ent *make_parent_entry(apr_int32_t autoindex_opts, } if (!(p->alt = find_default_alt(d, testpath))) { if (!(p->alt = find_default_alt(d, "^^DIRECTORY^^"))) { - p->alt = "DIR"; + /* Special alt text for parent dir to distinguish it from other directories + this is essential when trying to style this dir entry via AddAltClass */ + p->alt = "PARENTDIR"; } } p->desc = find_desc(d, testpath); @@ -1503,7 +1504,6 @@ static void output_directories(struct ent **ar, int n, { int x; apr_size_t rv; - char *name = r->uri; char *tp; int static_columns = !!(autoindex_opts & SUPPRESS_COLSORT); apr_pool_t *scratch; @@ -1514,9 +1514,6 @@ static void output_directories(struct ent **ar, int n, char *breakrow = ""; apr_pool_create(&scratch, r->pool); - if (name[0] == '\0') { - name = "/"; - } name_width = d->name_width; desc_width = d->desc_width; @@ -1550,9 +1547,14 @@ static void output_directories(struct ent **ar, int n, if (autoindex_opts & TABLE_INDEXING) { int cols = 1; - ap_rputs("<table><tr>", r); + if (d->style_sheet != NULL) { + /* Emit table with style id */ + ap_rputs(" <table id=\"indexlist\">\n <tr class=\"indexhead\">", r); + } else { + ap_rputs(" <table>\n <tr>", r); + } if (!(autoindex_opts & SUPPRESS_ICON)) { - ap_rputs("<th>", r); + ap_rvputs(r, "<th", (d->style_sheet != NULL) ? " class=\"indexcolicon\">" : " valign=\"top\">", NULL); if ((tp = find_default_icon(d, "^^BLANKICON^^"))) { ap_rvputs(r, "<img src=\"", ap_escape_html(scratch, tp), "\" alt=\"[ICO]\"", NULL); @@ -1574,34 +1576,36 @@ static void output_directories(struct ent **ar, int n, ++cols; } - ap_rputs("<th>", r); + ap_rvputs(r, "<th", (d->style_sheet != NULL) ? " class=\"indexcolname\">" : ">", NULL); emit_link(r, "Name", K_NAME, keyid, direction, colargs, static_columns); if (!(autoindex_opts & SUPPRESS_LAST_MOD)) { - ap_rputs("</th><th>", r); + ap_rvputs(r, "</th><th", (d->style_sheet != NULL) ? " class=\"indexcollastmod\">" : ">", NULL); emit_link(r, "Last modified", K_LAST_MOD, keyid, direction, colargs, static_columns); ++cols; } if (!(autoindex_opts & SUPPRESS_SIZE)) { - ap_rputs("</th><th>", r); + ap_rvputs(r, "</th><th", (d->style_sheet != NULL) ? " class=\"indexcolsize\">" : ">", NULL); emit_link(r, "Size", K_SIZE, keyid, direction, colargs, static_columns); ++cols; } if (!(autoindex_opts & SUPPRESS_DESC)) { - ap_rputs("</th><th>", r); + ap_rvputs(r, "</th><th", (d->style_sheet != NULL) ? " class=\"indexcoldesc\">" : ">", NULL); emit_link(r, "Description", K_DESC, keyid, direction, colargs, static_columns); ++cols; } if (!(autoindex_opts & SUPPRESS_RULES)) { breakrow = apr_psprintf(r->pool, - "<tr><th colspan=\"%d\">" - "<hr%s></th></tr>\n", cols, + " <tr%s><th colspan=\"%d\">" + "<hr%s></th></tr>\n", + (d->style_sheet != NULL) ? " class=\"indexbreakrow\"" : "", + cols, (autoindex_opts & EMIT_XHTML) ? " /" : ""); } - ap_rvputs(r, "</th></tr>", breakrow, NULL); + ap_rvputs(r, "</th></tr>\n", breakrow, NULL); } else if (autoindex_opts & FANCY_INDEXING) { ap_rputs("<pre>", r); @@ -1678,9 +1682,23 @@ static void output_directories(struct ent **ar, int n, } if (autoindex_opts & TABLE_INDEXING) { - ap_rputs("<tr>", r); + /* Even/Odd rows for IndexStyleSheet */ + if (d->style_sheet != NULL) { + if (ar[x]->alt && (autoindex_opts & ADDALTCLASS)) { + /* Include alt text in class name, distinguish between odd and even rows */ + char *altclass = apr_pstrdup(scratch, ar[x]->alt); + ap_str_tolower(altclass); + ap_rvputs(r, " <tr class=\"", ( x & 0x1) ? "odd-" : "even-", altclass, "\">", NULL); + } else { + /* Distinguish between odd and even rows */ + ap_rvputs(r, " <tr class=\"", ( x & 0x1) ? "odd" : "even", "\">", NULL); + } + } else { + ap_rputs("<tr>", r); + } + if (!(autoindex_opts & SUPPRESS_ICON)) { - ap_rputs("<td valign=\"top\">", r); + ap_rvputs(r, "<td", (d->style_sheet != NULL) ? " class=\"indexcolicon\">" : " valign=\"top\">", NULL); if (autoindex_opts & ICONS_ARE_LINKS) { ap_rvputs(r, "<a href=\"", anchor, "\">", NULL); } @@ -1714,7 +1732,7 @@ static void output_directories(struct ent **ar, int n, } } if (d->name_adjust == K_ADJUST) { - ap_rvputs(r, "<td><a href=\"", anchor, "\">", + ap_rvputs(r, "<td", (d->style_sheet != NULL) ? " class=\"indexcolname\">" : ">", "<a href=\"", anchor, "\">", ap_escape_html(scratch, t2), "</a>", NULL); } else { @@ -1728,7 +1746,7 @@ static void output_directories(struct ent **ar, int n, t2 = name_scratch; nwidth = name_width; } - ap_rvputs(r, "<td><a href=\"", anchor, "\">", + ap_rvputs(r, "<td", (d->style_sheet != NULL) ? " class=\"indexcolname\">" : ">", "<a href=\"", anchor, "\">", ap_escape_html(scratch, t2), "</a>", pad_scratch + nwidth, NULL); } @@ -1738,26 +1756,26 @@ static void output_directories(struct ent **ar, int n, apr_time_exp_t ts; apr_time_exp_lt(&ts, ar[x]->lm); apr_strftime(time_str, &rv, MAX_STRING_LEN, - "</td><td align=\"right\">%d-%b-%Y %H:%M ", + "%Y-%m-%d %H:%M ", &ts); - ap_rputs(time_str, r); + ap_rvputs(r, "</td><td", (d->style_sheet != NULL) ? " class=\"indexcollastmod\">" : " align=\"right\">",time_str, NULL); } else { - ap_rputs("</td><td> ", r); + ap_rvputs(r, "</td><td", (d->style_sheet != NULL) ? " class=\"indexcollastmod\"> " : "> ", NULL); } } if (!(autoindex_opts & SUPPRESS_SIZE)) { char buf[5]; - ap_rvputs(r, "</td><td align=\"right\">", + ap_rvputs(r, "</td><td", (d->style_sheet != NULL) ? " class=\"indexcolsize\">" : " align=\"right\">", apr_strfsize(ar[x]->size, buf), NULL); } if (!(autoindex_opts & SUPPRESS_DESC)) { if (ar[x]->desc) { if (d->desc_adjust == K_ADJUST) { - ap_rvputs(r, "</td><td>", ar[x]->desc, NULL); + ap_rvputs(r, "</td><td", (d->style_sheet != NULL) ? " class=\"indexcoldesc\">" : ">", ar[x]->desc, NULL); } else { - ap_rvputs(r, "</td><td>", + ap_rvputs(r, "</td><td", (d->style_sheet != NULL) ? " class=\"indexcoldesc\">" : ">", terminate_description(d, ar[x]->desc, autoindex_opts, desc_width), NULL); @@ -1826,11 +1844,11 @@ static void output_directories(struct ent **ar, int n, apr_time_exp_t ts; apr_time_exp_lt(&ts, ar[x]->lm); apr_strftime(time_str, &rv, MAX_STRING_LEN, - "%d-%b-%Y %H:%M ", &ts); + "%Y-%m-%d %H:%M ", &ts); ap_rputs(time_str, r); } else { - /*Length="22-Feb-1998 23:42 " (see 4 lines above) */ + /*Length="1975-04-07 01:23 " (see 4 lines above) */ ap_rputs(" ", r); } } @@ -2005,7 +2023,7 @@ static int index_directory(request_rec *r, char *charset; if ((status = apr_dir_open(&thedir, name, r->pool)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(01275) "Can't open directory for index: %s", r->filename); return HTTP_FORBIDDEN; } @@ -2171,7 +2189,7 @@ static int index_directory(request_rec *r, *title_endp-- = '\0'; } - emit_head(r, find_header(autoindex_conf, r), + emit_head(r, autoindex_conf->header, autoindex_opts & SUPPRESS_PREAMBLE, autoindex_opts & EMIT_XHTML, title_name); @@ -2243,7 +2261,7 @@ static int index_directory(request_rec *r, keyid, direction, colargs); apr_dir_close(thedir); - emit_tail(r, find_readme(autoindex_conf, r), + emit_tail(r, autoindex_conf->readme, autoindex_opts & SUPPRESS_PREAMBLE); return 0; @@ -2290,9 +2308,14 @@ static int handle_autoindex(request_rec *r) return index_directory(r, d); } else { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, - "Directory index forbidden by " - "Options directive: %s", r->filename); + const char *index_names = apr_table_get(r->notes, "dir-index-names"); + + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01276) + "Cannot serve directory %s: No matching DirectoryIndex (%s) found, and " + "server-generated directory index forbidden by " + "Options directive", + r->filename, + index_names ? index_names : "none"); return HTTP_FORBIDDEN; } } @@ -2302,7 +2325,7 @@ static void register_hooks(apr_pool_t *p) ap_hook_handler(handle_autoindex,NULL,NULL,APR_HOOK_MIDDLE); } -module AP_MODULE_DECLARE_DATA autoindex_module = +AP_DECLARE_MODULE(autoindex) = { STANDARD20_MODULE_STUFF, create_autoindex_config, /* dir config creater */ diff --git a/modules/generators/mod_autoindex.dep b/modules/generators/mod_autoindex.dep deleted file mode 100644 index 0f465085..00000000 --- a/modules/generators/mod_autoindex.dep +++ /dev/null @@ -1,35 +0,0 @@ -# Microsoft Developer Studio Generated Dependency File, included by mod_autoindex.mak - -..\..\build\win32\httpd.rc : \ - "..\..\include\ap_release.h"\ - - -.\mod_autoindex.c : \ - "..\..\include\ap_config.h"\ - "..\..\include\ap_mmn.h"\ - "..\..\include\ap_regex.h"\ - "..\..\include\ap_release.h"\ - "..\..\include\http_config.h"\ - "..\..\include\http_core.h"\ - "..\..\include\http_log.h"\ - "..\..\include\http_main.h"\ - "..\..\include\http_protocol.h"\ - "..\..\include\http_request.h"\ - "..\..\include\httpd.h"\ - "..\..\include\mod_core.h"\ - "..\..\include\os.h"\ - "..\..\include\util_cfgtree.h"\ - "..\..\include\util_filter.h"\ - "..\..\include\util_script.h"\ - "..\..\srclib\apr-util\include\apr_hooks.h"\ - "..\..\srclib\apr-util\include\apr_optional.h"\ - "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ - "..\..\srclib\apr-util\include\apr_uri.h"\ - "..\..\srclib\apr\include\apr_fnmatch.h"\ - "..\..\srclib\apr\include\apr_hash.h"\ - "..\..\srclib\apr\include\apr_lib.h"\ - "..\..\srclib\apr\include\apr_mmap.h"\ - "..\..\srclib\apr\include\apr_poll.h"\ - "..\..\srclib\apr\include\apr_portable.h"\ - "..\..\srclib\apr\include\apr_strings.h"\ - diff --git a/modules/generators/mod_autoindex.mak b/modules/generators/mod_autoindex.mak deleted file mode 100644 index baf714b8..00000000 --- a/modules/generators/mod_autoindex.mak +++ /dev/null @@ -1,353 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on mod_autoindex.dsp -!IF "$(CFG)" == "" -CFG=mod_autoindex - Win32 Release -!MESSAGE No configuration specified. Defaulting to mod_autoindex - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "mod_autoindex - Win32 Release" && "$(CFG)" != "mod_autoindex - Win32 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "mod_autoindex.mak" CFG="mod_autoindex - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "mod_autoindex - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "mod_autoindex - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "mod_autoindex - Win32 Release" - -OUTDIR=.\Release -INTDIR=.\Release -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_autoindex.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_autoindex.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_autoindex.obj" - -@erase "$(INTDIR)\mod_autoindex.res" - -@erase "$(INTDIR)\mod_autoindex_src.idb" - -@erase "$(INTDIR)\mod_autoindex_src.pdb" - -@erase "$(OUTDIR)\mod_autoindex.exp" - -@erase "$(OUTDIR)\mod_autoindex.lib" - -@erase "$(OUTDIR)\mod_autoindex.pdb" - -@erase "$(OUTDIR)\mod_autoindex.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_autoindex_src" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_autoindex.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_autoindex.so" /d LONG_NAME="autoindex_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_autoindex.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_autoindex.pdb" /debug /out:"$(OUTDIR)\mod_autoindex.so" /implib:"$(OUTDIR)\mod_autoindex.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_autoindex.so /opt:ref -LINK32_OBJS= \ - "$(INTDIR)\mod_autoindex.obj" \ - "$(INTDIR)\mod_autoindex.res" \ - "..\..\srclib\apr\Release\libapr-1.lib" \ - "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ - "..\..\Release\libhttpd.lib" - -"$(OUTDIR)\mod_autoindex.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Release\mod_autoindex.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_autoindex.so" - if exist .\Release\mod_autoindex.so.manifest mt.exe -manifest .\Release\mod_autoindex.so.manifest -outputresource:.\Release\mod_autoindex.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "mod_autoindex - Win32 Debug" - -OUTDIR=.\Debug -INTDIR=.\Debug -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_autoindex.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_autoindex.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_autoindex.obj" - -@erase "$(INTDIR)\mod_autoindex.res" - -@erase "$(INTDIR)\mod_autoindex_src.idb" - -@erase "$(INTDIR)\mod_autoindex_src.pdb" - -@erase "$(OUTDIR)\mod_autoindex.exp" - -@erase "$(OUTDIR)\mod_autoindex.lib" - -@erase "$(OUTDIR)\mod_autoindex.pdb" - -@erase "$(OUTDIR)\mod_autoindex.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_autoindex_src" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_autoindex.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_autoindex.so" /d LONG_NAME="autoindex_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_autoindex.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_autoindex.pdb" /debug /out:"$(OUTDIR)\mod_autoindex.so" /implib:"$(OUTDIR)\mod_autoindex.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_autoindex.so -LINK32_OBJS= \ - "$(INTDIR)\mod_autoindex.obj" \ - "$(INTDIR)\mod_autoindex.res" \ - "..\..\srclib\apr\Debug\libapr-1.lib" \ - "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ - "..\..\Debug\libhttpd.lib" - -"$(OUTDIR)\mod_autoindex.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Debug\mod_autoindex.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_autoindex.so" - if exist .\Debug\mod_autoindex.so.manifest mt.exe -manifest .\Debug\mod_autoindex.so.manifest -outputresource:.\Debug\mod_autoindex.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("mod_autoindex.dep") -!INCLUDE "mod_autoindex.dep" -!ELSE -!MESSAGE Warning: cannot find "mod_autoindex.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "mod_autoindex - Win32 Release" || "$(CFG)" == "mod_autoindex - Win32 Debug" - -!IF "$(CFG)" == "mod_autoindex - Win32 Release" - -"libapr - Win32 Release" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" - cd "..\..\modules\generators" - -"libapr - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_autoindex - Win32 Debug" - -"libapr - Win32 Debug" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" - cd "..\..\modules\generators" - -"libapr - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_autoindex - Win32 Release" - -"libaprutil - Win32 Release" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" - cd "..\..\modules\generators" - -"libaprutil - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_autoindex - Win32 Debug" - -"libaprutil - Win32 Debug" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" - cd "..\..\modules\generators" - -"libaprutil - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_autoindex - Win32 Release" - -"libhttpd - Win32 Release" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" - cd ".\modules\generators" - -"libhttpd - Win32 ReleaseCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ELSEIF "$(CFG)" == "mod_autoindex - Win32 Debug" - -"libhttpd - Win32 Debug" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" - cd ".\modules\generators" - -"libhttpd - Win32 DebugCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ENDIF - -SOURCE=..\..\build\win32\httpd.rc - -!IF "$(CFG)" == "mod_autoindex - Win32 Release" - - -"$(INTDIR)\mod_autoindex.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_autoindex.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "NDEBUG" /d BIN_NAME="mod_autoindex.so" /d LONG_NAME="autoindex_module for Apache" $(SOURCE) - - -!ELSEIF "$(CFG)" == "mod_autoindex - Win32 Debug" - - -"$(INTDIR)\mod_autoindex.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_autoindex.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "_DEBUG" /d BIN_NAME="mod_autoindex.so" /d LONG_NAME="autoindex_module for Apache" $(SOURCE) - - -!ENDIF - -SOURCE=.\mod_autoindex.c - -"$(INTDIR)\mod_autoindex.obj" : $(SOURCE) "$(INTDIR)" - - - -!ENDIF - diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index f9980f9d..385bb364 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -39,8 +39,6 @@ #define APR_WANT_MEMFUNC #include "apr_want.h" -#define CORE_PRIVATE - #include "util_filter.h" #include "ap_config.h" #include "httpd.h" @@ -55,6 +53,12 @@ #include "mod_core.h" #include "mod_cgi.h" +#if APR_HAVE_STRUCT_RLIMIT +#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#define AP_CGI_USE_RLIMIT +#endif +#endif + module AP_MODULE_DECLARE_DATA cgi_module; static APR_OPTIONAL_FN_TYPE(ap_register_include_handler) *cgi_pfn_reg_with_ssi; @@ -206,7 +210,7 @@ static apr_status_t log_script_err(request_rec *r, apr_file_t *script_err) if (newline) { *newline = '\0'; } - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01215) "%s", argsbuffer); } @@ -384,11 +388,8 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, apr_proc_t *procnew; apr_status_t rc = APR_SUCCESS; -#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \ - defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS) - - core_dir_config *conf = ap_get_module_config(r->per_dir_config, - &core_module); +#ifdef AP_CGI_USE_RLIMIT + core_dir_config *conf = ap_get_core_module_config(r->per_dir_config); #endif #ifdef DEBUG_CGI @@ -413,6 +414,7 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, fprintf(dbg, "Environment: \n"); for (i = 0; env[i]; ++i) fprintf(dbg, "'%s'\n", env[i]); + fclose(dbg); #endif /* Transmute ourselves into the script. @@ -426,15 +428,15 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, ((rc = apr_procattr_dir_set(procattr, ap_make_dirstr_parent(r->pool, r->filename))) != APR_SUCCESS) || -#ifdef RLIMIT_CPU +#if defined(RLIMIT_CPU) && defined(AP_CGI_USE_RLIMIT) ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, conf->limit_cpu)) != APR_SUCCESS) || #endif -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#if defined(AP_CGI_USE_RLIMIT) && (defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)) ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_MEM, conf->limit_mem)) != APR_SUCCESS) || #endif -#ifdef RLIMIT_NPROC +#if RLIMIT_NPROC && defined(AP_CGI_USE_RLIMIT) ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC, conf->limit_nproc)) != APR_SUCCESS) || #endif @@ -447,7 +449,7 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, e_info->addrspace)) != APR_SUCCESS) || ((rc = apr_procattr_child_errfn_set(procattr, cgi_child_errfn)) != APR_SUCCESS)) { /* Something bad happened, tell the world. */ - ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, APLOGNO(01216) "couldn't set child process attributes: %s", r->filename); } else { @@ -482,9 +484,6 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, } } } -#ifdef DEBUG_CGI - fclose(dbg); -#endif return (rc); } @@ -587,7 +586,11 @@ static apr_bucket *cgi_bucket_create(request_rec *r, /* Create the pollset */ rv = apr_pollset_create(&data->pollset, 2, r->pool, 0); - AP_DEBUG_ASSERT(rv == APR_SUCCESS); + if (rv != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01217) + "apr_pollset_create(); check system or user limits"); + return NULL; + } fd.desc_type = APR_POLL_FILE; fd.reqevents = APR_POLLIN; @@ -595,12 +598,20 @@ static apr_bucket *cgi_bucket_create(request_rec *r, fd.desc.f = out; /* script's stdout */ fd.client_data = (void *)1; rv = apr_pollset_add(data->pollset, &fd); - AP_DEBUG_ASSERT(rv == APR_SUCCESS); + if (rv != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01218) + "apr_pollset_add(); check system or user limits"); + return NULL; + } fd.desc.f = err; /* script's stderr */ fd.client_data = (void *)2; rv = apr_pollset_add(data->pollset, &fd); - AP_DEBUG_ASSERT(rv == APR_SUCCESS); + if (rv != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01219) + "apr_pollset_add(); check system or user limits"); + return NULL; + } data->r = r; b->data = data; @@ -679,7 +690,7 @@ static apr_status_t cgi_bucket_read(apr_bucket *b, const char **str, rv = apr_pollset_poll(data->pollset, timeout, &num, &results); if (APR_STATUS_IS_TIMEUP(rv)) { if (timeout) { - ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, data->r, + ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, data->r, APLOGNO(01220) "Timeout waiting for output from CGI script %s", data->r->filename); return rv; @@ -692,7 +703,7 @@ static apr_status_t cgi_bucket_read(apr_bucket *b, const char **str, continue; } else if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, data->r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, data->r, APLOGNO(01221) "poll failed waiting for CGI child"); return rv; } @@ -747,10 +758,13 @@ static int cgi_handler(request_rec *r) cgi_server_conf *conf; apr_status_t rv; cgi_exec_info_t e_info; - conn_rec *c = r->connection; + conn_rec *c; - if(strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) + if (strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) { return DECLINED; + } + + c = r->connection; is_included = !strcmp(r->protocol, "INCLUDED"); @@ -767,7 +781,7 @@ static int cgi_handler(request_rec *r) return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, "attempt to include NPH CGI script"); - if (r->finfo.filetype == 0) + if (r->finfo.filetype == APR_NOFILE) return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, "script not found or unable to stat"); if (r->finfo.filetype == APR_DIR) @@ -806,7 +820,7 @@ static int cgi_handler(request_rec *r) /* build the command line */ if ((rv = cgi_build_command(&command, &argv, r, p, &e_info)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01222) "don't know how to spawn child process: %s", r->filename); return HTTP_INTERNAL_SERVER_ERROR; @@ -815,7 +829,7 @@ static int cgi_handler(request_rec *r) /* run the script in its own process */ if ((rv = run_cgi_child(&script_out, &script_in, &script_err, command, argv, r, p, &e_info)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01223) "couldn't spawn child process: %s", r->filename); return HTTP_INTERNAL_SERVER_ERROR; } @@ -837,7 +851,12 @@ static int cgi_handler(request_rec *r) APR_BLOCK_READ, HUGE_STRING_LEN); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + if (APR_STATUS_IS_TIMEUP(rv)) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01224) + "Timeout during reading request entity data"); + return HTTP_REQUEST_TIME_OUT; + } + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01225) "Error reading request entity data"); return HTTP_INTERNAL_SERVER_ERROR; } @@ -910,6 +929,8 @@ static int cgi_handler(request_rec *r) apr_file_pipe_timeout_set(script_err, 0); b = cgi_bucket_create(r, script_in, script_err, c->bucket_alloc); + if (b == NULL) + return HTTP_INTERNAL_SERVER_ERROR; #else b = apr_bucket_pipe_create(script_in, c->bucket_alloc); #endif @@ -923,7 +944,9 @@ static int cgi_handler(request_rec *r) char sbuf[MAX_STRING_LEN]; int ret; - if ((ret = ap_scan_script_header_err_brigade(r, bb, sbuf))) { + if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf, + APLOG_MODULE_INDEX))) + { ret = log_script(r, conf, ret, dbuf, sbuf, bb, script_err); /* @@ -983,7 +1006,7 @@ static int cgi_handler(request_rec *r) return OK; } else if (location && r->status == 200) { - /* XX Note that if a script wants to produce its own Redirect + /* XXX: Note that if a script wants to produce its own Redirect * body, it now has to explicitly *say* "Status: 302" */ return HTTP_MOVED_TEMPORARILY; @@ -1107,7 +1130,7 @@ static apr_status_t include_cmd(include_ctx_t *ctx, ap_filter_t *f, if ((rv = cgi_build_command(&command, &argv, r, r->pool, &e_info)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01226) "don't know how to spawn cmd child process: %s", r->filename); return rv; @@ -1117,7 +1140,7 @@ static apr_status_t include_cmd(include_ctx_t *ctx, ap_filter_t *f, if ((rv = run_cgi_child(&script_out, &script_in, &script_err, command, argv, r, r->pool, &e_info)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01227) "couldn't spawn child process: %s", r->filename); return rv; } @@ -1160,7 +1183,7 @@ static apr_status_t handle_exec(include_ctx_t *ctx, ap_filter_t *f, } if (ctx->flags & SSI_FLAG_NO_EXEC) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "exec used but not allowed " + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01228) "exec used but not allowed " "in %s", r->filename); SSI_CREATE_ERROR_BUCKET(ctx, f, bb); return APR_SUCCESS; @@ -1180,7 +1203,7 @@ static apr_status_t handle_exec(include_ctx_t *ctx, ap_filter_t *f, rv = include_cmd(ctx, f, bb, parsed_string); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "execution failure " + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01229) "execution failure " "for parameter \"%s\" to tag exec in file %s", tag, r->filename); SSI_CREATE_ERROR_BUCKET(ctx, f, bb); @@ -1195,14 +1218,14 @@ static apr_status_t handle_exec(include_ctx_t *ctx, ap_filter_t *f, rv = include_cgi(ctx, f, bb, parsed_string); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "invalid CGI ref " + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01230) "invalid CGI ref " "\"%s\" in %s", tag_val, file); SSI_CREATE_ERROR_BUCKET(ctx, f, bb); break; } } else { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "unknown parameter " + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01231) "unknown parameter " "\"%s\" to tag exec in %s", tag, file); SSI_CREATE_ERROR_BUCKET(ctx, f, bb); break; @@ -1251,7 +1274,7 @@ static void register_hooks(apr_pool_t *p) ap_hook_post_config(cgi_post_config, aszPre, NULL, APR_HOOK_REALLY_FIRST); } -module AP_MODULE_DECLARE_DATA cgi_module = +AP_DECLARE_MODULE(cgi) = { STANDARD20_MODULE_STUFF, NULL, /* dir config creater */ diff --git a/modules/generators/mod_cgi.dep b/modules/generators/mod_cgi.dep deleted file mode 100644 index 69df8afa..00000000 --- a/modules/generators/mod_cgi.dep +++ /dev/null @@ -1,37 +0,0 @@ -# Microsoft Developer Studio Generated Dependency File, included by mod_cgi.mak - -..\..\build\win32\httpd.rc : \ - "..\..\include\ap_release.h"\ - - -.\mod_cgi.c : \ - "..\..\include\ap_config.h"\ - "..\..\include\ap_mmn.h"\ - "..\..\include\ap_mpm.h"\ - "..\..\include\ap_regex.h"\ - "..\..\include\ap_release.h"\ - "..\..\include\http_config.h"\ - "..\..\include\http_core.h"\ - "..\..\include\http_log.h"\ - "..\..\include\http_main.h"\ - "..\..\include\http_protocol.h"\ - "..\..\include\http_request.h"\ - "..\..\include\httpd.h"\ - "..\..\include\mod_core.h"\ - "..\..\include\mod_include.h"\ - "..\..\include\os.h"\ - "..\..\include\util_cfgtree.h"\ - "..\..\include\util_filter.h"\ - "..\..\include\util_script.h"\ - "..\..\srclib\apr-util\include\apr_hooks.h"\ - "..\..\srclib\apr-util\include\apr_optional.h"\ - "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ - "..\..\srclib\apr-util\include\apr_uri.h"\ - "..\..\srclib\apr\include\apr_hash.h"\ - "..\..\srclib\apr\include\apr_lib.h"\ - "..\..\srclib\apr\include\apr_mmap.h"\ - "..\..\srclib\apr\include\apr_poll.h"\ - "..\..\srclib\apr\include\apr_portable.h"\ - "..\..\srclib\apr\include\apr_strings.h"\ - ".\mod_cgi.h"\ - diff --git a/modules/generators/mod_cgi.h b/modules/generators/mod_cgi.h index 2192dd18..424c6f29 100644 --- a/modules/generators/mod_cgi.h +++ b/modules/generators/mod_cgi.h @@ -17,7 +17,7 @@ /** * @file mod_cgi.h * @brief CGI Script Execution Extension Module for Apache - * + * * @defgroup MOD_CGI mod_cgi * @ingroup APACHE_MODS * @{ @@ -51,18 +51,15 @@ typedef struct { * @param argv Pointer to the arguments to pass (may be overridden) * @param r The current request * @param p The pool to allocate correct cmd/argv elements within. - * @param process_cgi Set true if processing r->filename and r->args - * as a CGI invocation, otherwise false - * @param type Set to APR_SHELLCMD or APR_PROGRAM on entry, may be - * changed to invoke the program with alternate semantics. - * @param detach Should the child start in detached state? Default is no. - * @remark This callback may be registered by the os-specific module + * @param e_info pass e_info.cmd_type (Set to APR_SHELLCMD or APR_PROGRAM on entry) + and e_info.detached (Should the child start in detached state?) + * @remark This callback may be registered by the os-specific module * to correct the command and arguments for apr_proc_create invocation * on a given os. mod_cgi will call the function if registered. */ -APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_cgi_build_command, +APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_cgi_build_command, (const char **cmd, const char ***argv, - request_rec *r, apr_pool_t *p, + request_rec *r, apr_pool_t *p, cgi_exec_info_t *e_info)); #endif /* _MOD_CGI_H */ diff --git a/modules/generators/mod_cgi.mak b/modules/generators/mod_cgi.mak deleted file mode 100644 index 0fe345b9..00000000 --- a/modules/generators/mod_cgi.mak +++ /dev/null @@ -1,353 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on mod_cgi.dsp -!IF "$(CFG)" == "" -CFG=mod_cgi - Win32 Release -!MESSAGE No configuration specified. Defaulting to mod_cgi - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "mod_cgi - Win32 Release" && "$(CFG)" != "mod_cgi - Win32 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "mod_cgi.mak" CFG="mod_cgi - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "mod_cgi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "mod_cgi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "mod_cgi - Win32 Release" - -OUTDIR=.\Release -INTDIR=.\Release -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_cgi.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_cgi.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_cgi.obj" - -@erase "$(INTDIR)\mod_cgi.res" - -@erase "$(INTDIR)\mod_cgi_src.idb" - -@erase "$(INTDIR)\mod_cgi_src.pdb" - -@erase "$(OUTDIR)\mod_cgi.exp" - -@erase "$(OUTDIR)\mod_cgi.lib" - -@erase "$(OUTDIR)\mod_cgi.pdb" - -@erase "$(OUTDIR)\mod_cgi.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_cgi_src" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_cgi.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_cgi.so" /d LONG_NAME="cgi_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_cgi.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_cgi.pdb" /debug /out:"$(OUTDIR)\mod_cgi.so" /implib:"$(OUTDIR)\mod_cgi.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_cgi.so /opt:ref -LINK32_OBJS= \ - "$(INTDIR)\mod_cgi.obj" \ - "$(INTDIR)\mod_cgi.res" \ - "..\..\srclib\apr\Release\libapr-1.lib" \ - "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ - "..\..\Release\libhttpd.lib" - -"$(OUTDIR)\mod_cgi.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Release\mod_cgi.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_cgi.so" - if exist .\Release\mod_cgi.so.manifest mt.exe -manifest .\Release\mod_cgi.so.manifest -outputresource:.\Release\mod_cgi.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "mod_cgi - Win32 Debug" - -OUTDIR=.\Debug -INTDIR=.\Debug -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_cgi.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_cgi.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_cgi.obj" - -@erase "$(INTDIR)\mod_cgi.res" - -@erase "$(INTDIR)\mod_cgi_src.idb" - -@erase "$(INTDIR)\mod_cgi_src.pdb" - -@erase "$(OUTDIR)\mod_cgi.exp" - -@erase "$(OUTDIR)\mod_cgi.lib" - -@erase "$(OUTDIR)\mod_cgi.pdb" - -@erase "$(OUTDIR)\mod_cgi.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_cgi_src" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_cgi.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_cgi.so" /d LONG_NAME="cgi_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_cgi.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_cgi.pdb" /debug /out:"$(OUTDIR)\mod_cgi.so" /implib:"$(OUTDIR)\mod_cgi.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_cgi.so -LINK32_OBJS= \ - "$(INTDIR)\mod_cgi.obj" \ - "$(INTDIR)\mod_cgi.res" \ - "..\..\srclib\apr\Debug\libapr-1.lib" \ - "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ - "..\..\Debug\libhttpd.lib" - -"$(OUTDIR)\mod_cgi.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Debug\mod_cgi.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_cgi.so" - if exist .\Debug\mod_cgi.so.manifest mt.exe -manifest .\Debug\mod_cgi.so.manifest -outputresource:.\Debug\mod_cgi.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("mod_cgi.dep") -!INCLUDE "mod_cgi.dep" -!ELSE -!MESSAGE Warning: cannot find "mod_cgi.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "mod_cgi - Win32 Release" || "$(CFG)" == "mod_cgi - Win32 Debug" - -!IF "$(CFG)" == "mod_cgi - Win32 Release" - -"libapr - Win32 Release" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" - cd "..\..\modules\generators" - -"libapr - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_cgi - Win32 Debug" - -"libapr - Win32 Debug" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" - cd "..\..\modules\generators" - -"libapr - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_cgi - Win32 Release" - -"libaprutil - Win32 Release" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" - cd "..\..\modules\generators" - -"libaprutil - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_cgi - Win32 Debug" - -"libaprutil - Win32 Debug" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" - cd "..\..\modules\generators" - -"libaprutil - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_cgi - Win32 Release" - -"libhttpd - Win32 Release" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" - cd ".\modules\generators" - -"libhttpd - Win32 ReleaseCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ELSEIF "$(CFG)" == "mod_cgi - Win32 Debug" - -"libhttpd - Win32 Debug" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" - cd ".\modules\generators" - -"libhttpd - Win32 DebugCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ENDIF - -SOURCE=..\..\build\win32\httpd.rc - -!IF "$(CFG)" == "mod_cgi - Win32 Release" - - -"$(INTDIR)\mod_cgi.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_cgi.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "NDEBUG" /d BIN_NAME="mod_cgi.so" /d LONG_NAME="cgi_module for Apache" $(SOURCE) - - -!ELSEIF "$(CFG)" == "mod_cgi - Win32 Debug" - - -"$(INTDIR)\mod_cgi.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_cgi.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "_DEBUG" /d BIN_NAME="mod_cgi.so" /d LONG_NAME="cgi_module for Apache" $(SOURCE) - - -!ENDIF - -SOURCE=.\mod_cgi.c - -"$(INTDIR)\mod_cgi.obj" : $(SOURCE) "$(INTDIR)" - - - -!ENDIF - diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index 6f39ff66..1e4aaf67 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -49,8 +49,6 @@ #include <sys/types.h> #endif -#define CORE_PRIVATE - #include "util_filter.h" #include "httpd.h" #include "http_config.h" @@ -61,7 +59,7 @@ #include "http_log.h" #include "util_script.h" #include "ap_mpm.h" -#include "unixd.h" +#include "mpm_common.h" #include "mod_suexec.h" #include "../filters/mod_include.h" @@ -72,6 +70,11 @@ #include <sys/stat.h> #include <sys/un.h> /* for sockaddr_un */ +#if APR_HAVE_STRUCT_RLIMIT +#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#define AP_CGID_USE_RLIMIT +#endif +#endif module AP_MODULE_DECLARE_DATA cgid_module; @@ -90,6 +93,8 @@ static int daemon_should_exit = 0; static server_rec *root_server = NULL; static apr_pool_t *root_pool = NULL; static const char *sockname; +static struct sockaddr_un *server_addr; +static apr_socklen_t server_addr_len; static pid_t parent_pid; static ap_unix_identity_t empty_ugid = { (uid_t)-1, (gid_t)-1, -1 }; @@ -168,6 +173,24 @@ typedef struct { int bufbytes; } cgid_server_conf; +#ifdef AP_CGID_USE_RLIMIT +typedef struct { +#ifdef RLIMIT_CPU + int limit_cpu_set; + struct rlimit limit_cpu; +#endif +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) + int limit_mem_set; + struct rlimit limit_mem; +#endif +#ifdef RLIMIT_NPROC + int limit_nproc_set; + struct rlimit limit_nproc; +#endif + +} cgid_rlimit_t; +#endif + typedef struct { int req_type; /* request type (CGI_REQ, SSI_REQ, etc.) */ unsigned long conn_id; /* connection id; daemon uses this as a hash value @@ -177,7 +200,6 @@ typedef struct { pid_t ppid; /* sanity check for config problems leading to * wrong cgid socket use */ - int core_module_index; int env_count; ap_unix_identity_t ugid; apr_size_t filename_len; @@ -185,6 +207,10 @@ typedef struct { apr_size_t uri_len; apr_size_t args_len; int loglevel; /* to stuff in server_rec */ + +#ifdef AP_CGID_USE_RLIMIT + cgid_rlimit_t limits; +#endif } cgid_req_t; /* This routine is called to create the argument list to be passed @@ -264,11 +290,11 @@ static void cgid_maint(int reason, void *data, apr_wait_t status) } if (!stopping) { if (status == DAEMON_STARTUP_ERROR) { - ap_log_error(APLOG_MARK, APLOG_CRIT, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_CRIT, 0, ap_server_conf, APLOGNO(01238) "cgid daemon failed to initialize"); } else { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(01239) "cgid daemon process died, restarting"); cgid_start(root_pool, root_server, proc); } @@ -293,7 +319,7 @@ static void cgid_maint(int reason, void *data, apr_wait_t status) * guarantee the same permissions as when the socket was created. */ if (unlink(sockname) < 0 && errno != ENOENT) { - ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL, + ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf, APLOGNO(01240) "Couldn't unlink unix domain socket %s", sockname); } @@ -302,6 +328,13 @@ static void cgid_maint(int reason, void *data, apr_wait_t status) } #endif +static apr_status_t close_unix_socket(void *thefd) +{ + int fd = (int)((long)thefd); + + return close(fd); +} + /* deal with incomplete reads and signals * assume you really have to read buf_size bytes */ @@ -350,14 +383,12 @@ static apr_status_t sock_writev(int fd, request_rec *r, int count, ...) int rc; struct iovec *vec; int i; - int total_bytes = 0; vec = (struct iovec *)apr_palloc(r->pool, count * sizeof(struct iovec)); va_start(ap, count); for (i = 0; i < count; i++) { vec[i].iov_base = va_arg(ap, caddr_t); vec[i].iov_len = va_arg(ap, apr_size_t); - total_bytes += vec[i].iov_len; } va_end(ap); @@ -387,17 +418,17 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env, if (stat != APR_SUCCESS) { return stat; } - r->server->loglevel = req->loglevel; + r->server->log.level = req->loglevel; if (req->req_type == GETPID_REQ) { /* no more data sent for this request */ return APR_SUCCESS; } /* handle module indexes and such */ - rconf = (void **) apr_pcalloc(r->pool, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT)); + rconf = (void **)ap_create_request_config(r->pool); temp_core = (core_request_config *)apr_palloc(r->pool, sizeof(core_module)); - rconf[req->core_module_index] = (void *)temp_core; + rconf[AP_CORE_MODULE_INDEX] = (void *)temp_core; r->request_config = (ap_conf_vector_t *)rconf; ap_set_module_config(r->request_config, &cgid_module, (void *)&req->ugid); @@ -433,39 +464,9 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env, } *env = environ; -#if 0 -#ifdef RLIMIT_CPU - sock_read(fd, &j, sizeof(int)); - if (j) { - temp_core->limit_cpu = (struct rlimit *)apr_palloc (sizeof(struct rlimit)); - sock_read(fd, temp_core->limit_cpu, sizeof(struct rlimit)); - } - else { - temp_core->limit_cpu = NULL; - } -#endif - -#if defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) - sock_read(fd, &j, sizeof(int)); - if (j) { - temp_core->limit_mem = (struct rlimit *)apr_palloc(r->pool, sizeof(struct rlimit)); - sock_read(fd, temp_core->limit_mem, sizeof(struct rlimit)); - } - else { - temp_core->limit_mem = NULL; - } -#endif - -#ifdef RLIMIT_NPROC - sock_read(fd, &j, sizeof(int)); - if (j) { - temp_core->limit_nproc = (struct rlimit *)apr_palloc(r->pool, sizeof(struct rlimit)); - sock_read(fd, temp_core->limit_nproc, sizeof(struct rlimit)); - } - else { - temp_core->limit_nproc = NULL; - } -#endif +#ifdef AP_CGID_USE_RLIMIT + if ((stat = sock_read(fd, &(req->limits), sizeof(cgid_rlimit_t))) != APR_SUCCESS) + return stat; #endif return APR_SUCCESS; @@ -478,6 +479,8 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env, cgid_req_t req = {0}; apr_status_t stat; ap_unix_identity_t * ugid = ap_run_get_suexec_identity(r); + core_dir_config *core_conf = ap_get_core_module_config(r->per_dir_config); + if (ugid == NULL) { req.ugid = empty_ugid; @@ -488,7 +491,6 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env, req.req_type = req_type; req.ppid = parent_pid; req.conn_id = r->connection->id; - req.core_module_index = core_module.module_index; for (req.env_count = 0; env[req.env_count]; req.env_count++) { continue; } @@ -496,7 +498,7 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env, req.argv0_len = strlen(argv0); req.uri_len = strlen(r->uri); req.args_len = r->args ? strlen(r->args) : 0; - req.loglevel = r->server->loglevel; + req.loglevel = r->server->log.level; /* Write the request header */ if (req.args_len) { @@ -527,44 +529,42 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env, return stat; } } - -#if 0 -#ifdef RLIMIT_CPU - if (conf->limit_cpu) { - len = 1; - stat = sock_write(fd, &len, sizeof(int)); - stat = sock_write(fd, conf->limit_cpu, sizeof(struct rlimit)); +#if defined(RLIMIT_CPU) && defined(AP_CGID_USE_RLIMIT) + if (core_conf->limit_cpu) { + req.limits.limit_cpu = *(core_conf->limit_cpu); + req.limits.limit_cpu_set = 1; } else { - len = 0; - stat = sock_write(fd, &len, sizeof(int)); + req.limits.limit_cpu_set = 0; } #endif -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) - if (conf->limit_mem) { - len = 1; - stat = sock_write(fd, &len, sizeof(int)); - stat = sock_write(fd, conf->limit_mem, sizeof(struct rlimit)); +#if defined(AP_CGID_USE_RLIMIT) && (defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)) + if (core_conf->limit_mem) { + req.limits.limit_mem = *(core_conf->limit_mem); + req.limits.limit_mem_set = 1; } else { - len = 0; - stat = sock_write(fd, &len, sizeof(int)); + req.limits.limit_mem_set = 0; } + #endif -#ifdef RLIMIT_NPROC - if (conf->limit_nproc) { - len = 1; - stat = sock_write(fd, &len, sizeof(int)); - stat = sock_write(fd, conf->limit_nproc, sizeof(struct rlimit)); +#if defined(RLIMIT_NPROC) && defined(AP_CGID_USE_RLIMIT) + if (core_conf->limit_nproc) { + req.limits.limit_nproc = *(core_conf->limit_nproc); + req.limits.limit_nproc_set = 1; } else { - len = 0; - stat = sock_write(fd, &len, sizeof(int)); + req.limits.limit_nproc_set = 0; } #endif + +#ifdef AP_CGID_USE_RLIMIT + if ( (stat = sock_write(fd, &(req.limits), sizeof(cgid_rlimit_t))) != APR_SUCCESS) + return stat; #endif + return APR_SUCCESS; } @@ -588,15 +588,13 @@ static void cgid_child_errfn(apr_pool_t *pool, apr_status_t err, * have r->headers_in and possibly other storage referenced by * ap_log_rerror() */ - ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server, "%s", description); + ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server, APLOGNO(01241) "%s", description); } static int cgid_server(void *data) { - struct sockaddr_un unix_addr; int sd, sd2, rc; mode_t omask; - apr_socklen_t len; apr_pool_t *ptrans; server_rec *main_server = data; apr_hash_t *script_hash = apr_hash_make(pcgi); @@ -616,20 +614,16 @@ static int cgid_server(void *data) apr_hook_sort_all(); if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, + ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, APLOGNO(01242) "Couldn't create unix domain socket"); return errno; } - memset(&unix_addr, 0, sizeof(unix_addr)); - unix_addr.sun_family = AF_UNIX; - apr_cpystrn(unix_addr.sun_path, sockname, sizeof unix_addr.sun_path); - omask = umask(0077); /* so that only Apache can use socket */ - rc = bind(sd, (struct sockaddr *)&unix_addr, sizeof(unix_addr)); + rc = bind(sd, (struct sockaddr *)server_addr, server_addr_len); umask(omask); /* can't fail, so can't clobber errno */ if (rc < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, + ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, APLOGNO(01243) "Couldn't bind unix domain socket %s", sockname); return errno; @@ -638,33 +632,39 @@ static int cgid_server(void *data) /* Not all flavors of unix use the current umask for AF_UNIX perms */ rv = apr_file_perms_set(sockname, APR_FPROT_UREAD|APR_FPROT_UWRITE|APR_FPROT_UEXECUTE); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_CRIT, rv, main_server, + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, main_server, APLOGNO(01244) "Couldn't set permissions on unix domain socket %s", sockname); return rv; } if (listen(sd, DEFAULT_CGID_LISTENBACKLOG) < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, + ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, APLOGNO(01245) "Couldn't listen on unix domain socket"); return errno; } if (!geteuid()) { - if (chown(sockname, unixd_config.user_id, -1) < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, + if (chown(sockname, ap_unixd_config.user_id, -1) < 0) { + ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, APLOGNO(01246) "Couldn't change owner of unix domain socket %s", sockname); return errno; } } - unixd_setup_child(); /* if running as root, switch to configured user/group */ + apr_pool_cleanup_register(pcgi, (void *)((long)sd), + close_unix_socket, close_unix_socket); + + /* if running as root, switch to configured user/group */ + if ((rc = ap_run_drop_privileges(pcgi, ap_server_conf)) != 0) { + return rc; + } while (!daemon_should_exit) { int errfileno = STDERR_FILENO; - char *argv0; - char **env; + char *argv0 = NULL; + char **env = NULL; const char * const *argv; apr_int32_t in_pipe; apr_int32_t out_pipe; @@ -676,6 +676,9 @@ static int cgid_server(void *data) apr_file_t *inout; cgid_req_t cgid_req; apr_status_t stat; + void *key; + apr_socklen_t len; + struct sockaddr_un unix_addr; apr_pool_clear(ptrans); @@ -690,7 +693,7 @@ static int cgid_server(void *data) #endif if (errno != EINTR) { ap_log_error(APLOG_MARK, APLOG_ERR, errno, - (server_rec *)data, + (server_rec *)data, APLOGNO(01247) "Error accepting on cgid socket"); } continue; @@ -702,14 +705,14 @@ static int cgid_server(void *data) stat = get_req(sd2, r, &argv0, &env, &cgid_req); if (stat != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, stat, - main_server, + main_server, APLOGNO(01248) "Error reading request on cgid socket"); close(sd2); continue; } if (cgid_req.ppid != parent_pid) { - ap_log_error(APLOG_MARK, APLOG_CRIT, 0, main_server, + ap_log_error(APLOG_MARK, APLOG_CRIT, 0, main_server, APLOGNO(01249) "CGI request received from wrong server instance; " "see ScriptSock directive"); close(sd2); @@ -718,11 +721,13 @@ static int cgid_server(void *data) if (cgid_req.req_type == GETPID_REQ) { pid_t pid; + apr_status_t rv; pid = (pid_t)((long)apr_hash_get(script_hash, &cgid_req.conn_id, sizeof(cgid_req.conn_id))); - if (write(sd2, &pid, sizeof(pid)) != sizeof(pid)) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, - main_server, + rv = sock_write(sd2, &pid, sizeof(pid)); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, + main_server, APLOGNO(01250) "Error writing pid %" APR_PID_T_FMT " to handler", pid); } close(sd2); @@ -761,13 +766,31 @@ static int cgid_server(void *data) ((rc = apr_procattr_dir_set(procattr, ap_make_dirstr_parent(r->pool, r->filename))) != APR_SUCCESS) || ((rc = apr_procattr_cmdtype_set(procattr, cmd_type)) != APR_SUCCESS) || +#ifdef AP_CGID_USE_RLIMIT +#ifdef RLIMIT_CPU + ( (cgid_req.limits.limit_cpu_set) && ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, + &cgid_req.limits.limit_cpu)) != APR_SUCCESS)) || +#endif +#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) + ( (cgid_req.limits.limit_mem_set) && ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_MEM, + &cgid_req.limits.limit_mem)) != APR_SUCCESS)) || +#endif +#ifdef RLIMIT_NPROC + ( (cgid_req.limits.limit_nproc_set) && ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC, + &cgid_req.limits.limit_nproc)) != APR_SUCCESS)) || +#endif +#endif + ((rc = apr_procattr_child_errfn_set(procattr, cgid_child_errfn)) != APR_SUCCESS)) { /* Something bad happened, tell the world. * ap_log_rerror() won't work because the header table used by * ap_log_rerror() hasn't been replicated in the phony r */ - ap_log_error(APLOG_MARK, APLOG_ERR, rc, r->server, + ap_log_error(APLOG_MARK, APLOG_ERR, rc, r->server, APLOGNO(01251) "couldn't set child process attributes: %s", r->filename); + + procnew->pid = 0; /* no process to clean up */ + close(sd2); } else { apr_pool_userdata_set(r, ERRFN_USERDATA_KEY, apr_pool_cleanup_null, ptrans); @@ -801,34 +824,37 @@ static int cgid_server(void *data) * ap_log_rerror() won't work because the header table used by * ap_log_rerror() hasn't been replicated in the phony r */ - ap_log_error(APLOG_MARK, APLOG_ERR, rc, r->server, + ap_log_error(APLOG_MARK, APLOG_ERR, rc, r->server, APLOGNO(01252) "couldn't create child process: %d: %s", rc, apr_filepath_name_get(r->filename)); - } - else { - /* We don't want to leak storage for the key, so only allocate - * a key if the key doesn't exist yet in the hash; there are - * only a limited number of possible keys (one for each - * possible thread in the server), so we can allocate a copy - * of the key the first time a thread has a cgid request. - * Note that apr_hash_set() only uses the storage passed in - * for the key if it is adding the key to the hash for the - * first time; new key storage isn't needed for replacing the - * existing value of a key. - */ - void *key; - if (apr_hash_get(script_hash, &cgid_req.conn_id, sizeof(cgid_req.conn_id))) { - key = &cgid_req.conn_id; - } - else { - key = apr_pcalloc(pcgi, sizeof(cgid_req.conn_id)); - memcpy(key, &cgid_req.conn_id, sizeof(cgid_req.conn_id)); - } - apr_hash_set(script_hash, key, sizeof(cgid_req.conn_id), - (void *)((long)procnew->pid)); + procnew->pid = 0; /* no process to clean up */ } } + + /* If the script process was created, remember the pid for + * later cleanup. If the script process wasn't created, clear + * out any prior pid with the same key. + * + * We don't want to leak storage for the key, so only allocate + * a key if the key doesn't exist yet in the hash; there are + * only a limited number of possible keys (one for each + * possible thread in the server), so we can allocate a copy + * of the key the first time a thread has a cgid request. + * Note that apr_hash_set() only uses the storage passed in + * for the key if it is adding the key to the hash for the + * first time; new key storage isn't needed for replacing the + * existing value of a key. + */ + + if (apr_hash_get(script_hash, &cgid_req.conn_id, sizeof(cgid_req.conn_id))) { + key = &cgid_req.conn_id; + } + else { + key = apr_pmemdup(pcgi, &cgid_req.conn_id, sizeof(cgid_req.conn_id)); + } + apr_hash_set(script_hash, key, sizeof(cgid_req.conn_id), + (void *)((long)procnew->pid)); } return -1; /* should be <= 0 to distinguish from startup errors */ } @@ -839,7 +865,7 @@ static int cgid_start(apr_pool_t *p, server_rec *main_server, daemon_should_exit = 0; /* clear setting from previous generation */ if ((daemon_pid = fork()) < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, + ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, APLOGNO(01253) "mod_cgid: Couldn't spawn cgid daemon process"); return DECLINED; } @@ -869,7 +895,6 @@ static int cgid_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *main_server) { apr_proc_t *procnew = NULL; - int first_time = 0; const char *userdata_key = "cgid_init"; module **m; int ret = OK; @@ -880,7 +905,6 @@ static int cgid_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, apr_pool_userdata_get(&data, userdata_key, main_server->process->pool); if (!data) { - first_time = 1; procnew = apr_pcalloc(main_server->process->pool, sizeof(*procnew)); procnew->pid = -1; procnew->err = procnew->in = procnew->out = NULL; @@ -891,13 +915,27 @@ static int cgid_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, procnew = data; } - if (!first_time) { + if (ap_state_query(AP_SQ_MAIN_STATE) != AP_SQ_MS_CREATE_PRE_CONFIG) { + char *tmp_sockname; total_modules = 0; for (m = ap_preloaded_modules; *m != NULL; m++) total_modules++; parent_pid = getpid(); - sockname = ap_server_root_relative(p, sockname); + tmp_sockname = ap_server_root_relative(p, sockname); + if (strlen(tmp_sockname) > sizeof(server_addr->sun_path) - 1) { + tmp_sockname[sizeof(server_addr->sun_path)] = '\0'; + ap_log_error(APLOG_MARK, APLOG_ERR, 0, main_server, APLOGNO(01254) + "The length of the ScriptSock path exceeds maximum, " + "truncating to %s", tmp_sockname); + } + sockname = tmp_sockname; + + server_addr_len = APR_OFFSETOF(struct sockaddr_un, sun_path) + strlen(sockname); + server_addr = (struct sockaddr_un *)apr_palloc(p, server_addr_len + 1); + server_addr->sun_family = AF_UNIX; + strcpy(server_addr->sun_path, sockname); + ret = cgid_start(p, main_server, procnew); if (ret != OK ) { return ret; @@ -1140,36 +1178,24 @@ static int log_script(request_rec *r, cgid_server_conf * conf, int ret, return ret; } -static apr_status_t close_unix_socket(void *thefd) -{ - int fd = (int)((long)thefd); - - return close(fd); -} - static int connect_to_daemon(int *sdptr, request_rec *r, cgid_server_conf *conf) { - struct sockaddr_un unix_addr; int sd; int connect_tries; apr_interval_time_t sliding_timer; - memset(&unix_addr, 0, sizeof(unix_addr)); - unix_addr.sun_family = AF_UNIX; - apr_cpystrn(unix_addr.sun_path, sockname, sizeof unix_addr.sun_path); - connect_tries = 0; sliding_timer = 100000; /* 100 milliseconds */ while (1) { ++connect_tries; if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { return log_scripterror(r, conf, HTTP_INTERNAL_SERVER_ERROR, errno, - "unable to create socket to cgi daemon"); + APLOGNO(01255) "unable to create socket to cgi daemon"); } - if (connect(sd, (struct sockaddr *)&unix_addr, sizeof(unix_addr)) < 0) { + if (connect(sd, (struct sockaddr *)server_addr, server_addr_len) < 0) { if (errno == ECONNREFUSED && connect_tries < DEFAULT_CONNECT_ATTEMPTS) { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, errno, r, + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, errno, r, APLOGNO(01256) "connect #%d to cgi daemon failed, sleeping before retry", connect_tries); close(sd); @@ -1180,7 +1206,7 @@ static int connect_to_daemon(int *sdptr, request_rec *r, } else { close(sd); - return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, + return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, APLOGNO(01257) "unable to connect to cgi daemon after multiple tries"); } } @@ -1191,7 +1217,7 @@ static int connect_to_daemon(int *sdptr, request_rec *r, } /* gotta try again, but make sure the cgid daemon is still around */ if (kill(daemon_pid, 0) != 0) { - return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, + return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, APLOGNO(01258) "cgid daemon is gone; is Apache terminating?"); } } @@ -1265,14 +1291,14 @@ static apr_status_t cleanup_nonchild_process(request_rec *r, pid_t pid) if (dead_yet(pid, apr_time_from_sec(3)) == APR_SUCCESS) { return APR_SUCCESS; } - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01259) "CGI process %" APR_PID_T_FMT " didn't exit, sending SIGKILL", pid); kill(pid, SIGKILL); if (dead_yet(pid, apr_time_from_sec(3)) == APR_SUCCESS) { return APR_SUCCESS; } - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01260) "CGI process %" APR_PID_T_FMT " didn't exit, sending SIGKILL again", pid); kill(pid, SIGKILL); @@ -1312,7 +1338,7 @@ static apr_status_t cleanup_script(void *vptr) } if (pid == 0) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, info->r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, info->r, APLOGNO(01261) "daemon couldn't find CGI process for connection %lu", info->conn_id); return APR_EGENERAL; @@ -1322,9 +1348,8 @@ static apr_status_t cleanup_script(void *vptr) static int cgid_handler(request_rec *r) { - conn_rec *c = r->connection; - int retval, nph, dbpos = 0; - char *argv0, *dbuf = NULL; + int retval, nph, dbpos; + char *argv0, *dbuf; apr_bucket_brigade *bb; apr_bucket *b; cgid_server_conf *conf; @@ -1336,51 +1361,59 @@ static int cgid_handler(request_rec *r) struct cleanup_script_info *info; apr_status_t rv; - if (strcmp(r->handler,CGI_MAGIC_TYPE) && strcmp(r->handler,"cgi-script")) + if (strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) { return DECLINED; + } conf = ap_get_module_config(r->server->module_config, &cgid_module); is_included = !strcmp(r->protocol, "INCLUDED"); - if ((argv0 = strrchr(r->filename, '/')) != NULL) + if ((argv0 = strrchr(r->filename, '/')) != NULL) { argv0++; - else + } + else { argv0 = r->filename; + } nph = !(strncmp(argv0, "nph-", 4)); argv0 = r->filename; - if (!(ap_allow_options(r) & OPT_EXECCGI) && !is_scriptaliased(r)) - return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, - "Options ExecCGI is off in this directory"); - if (nph && is_included) - return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, - "attempt to include NPH CGI script"); + if (!(ap_allow_options(r) & OPT_EXECCGI) && !is_scriptaliased(r)) { + return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(01262) + "Options ExecCGI is off in this directory"); + } + + if (nph && is_included) { + return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(01263) + "attempt to include NPH CGI script"); + } #if defined(OS2) || defined(WIN32) #error mod_cgid does not work on this platform. If you teach it to, look #error at mod_cgi.c for required code in this path. #else - if (r->finfo.filetype == 0) - return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, - "script not found or unable to stat"); + if (r->finfo.filetype == APR_NOFILE) { + return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, APLOGNO(01264) + "script not found or unable to stat"); + } #endif - if (r->finfo.filetype == APR_DIR) - return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, - "attempt to invoke directory as script"); + if (r->finfo.filetype == APR_DIR) { + return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(01265) + "attempt to invoke directory as script"); + } if ((r->used_path_info == AP_REQ_REJECT_PATH_INFO) && r->path_info && *r->path_info) { /* default to accept */ - return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, + return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, APLOGNO(01266) "AcceptPathInfo off disallows user's path"); } /* if (!ap_suexec_enabled) { if (!ap_can_exec(&r->finfo)) - return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, + return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(01267) "file permissions deny server execution"); } */ @@ -1394,7 +1427,7 @@ static int cgid_handler(request_rec *r) rv = send_req(sd, r, argv0, env, CGI_REQ); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01268) "write to cgi daemon process"); } @@ -1414,20 +1447,16 @@ static int cgid_handler(request_rec *r) apr_os_pipe_put_ex(&tempsock, &sd, 1, r->pool); apr_pool_cleanup_kill(r->pool, (void *)((long)sd), close_unix_socket); - if ((argv0 = strrchr(r->filename, '/')) != NULL) - argv0++; - else - argv0 = r->filename; - /* Transfer any put/post args, CERN style... * Note that we already ignore SIGPIPE in the core server. */ bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); seen_eos = 0; child_stopped_reading = 0; + dbuf = NULL; + dbpos = 0; if (conf->logname) { dbuf = apr_palloc(r->pool, conf->bufbytes + 1); - dbpos = 0; } do { apr_bucket *bucket; @@ -1436,7 +1465,12 @@ static int cgid_handler(request_rec *r) APR_BLOCK_READ, HUGE_STRING_LEN); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + if (APR_STATUS_IS_TIMEUP(rv)) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01269) + "Timeout during reading request entity data"); + return HTTP_REQUEST_TIME_OUT; + } + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01270) "Error reading request entity data"); return HTTP_INTERNAL_SERVER_ERROR; } @@ -1505,6 +1539,7 @@ static int cgid_handler(request_rec *r) /* Handle script return... */ if (!nph) { + conn_rec *c = r->connection; const char *location; char sbuf[MAX_STRING_LEN]; int ret; @@ -1515,7 +1550,9 @@ static int cgid_handler(request_rec *r) b = apr_bucket_eos_create(c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); - if ((ret = ap_scan_script_header_err_brigade(r, bb, sbuf))) { + if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf, + APLOG_MODULE_INDEX))) + { ret = log_script(r, conf, ret, dbuf, sbuf, bb, NULL); /* @@ -1569,7 +1606,7 @@ static int cgid_handler(request_rec *r) return OK; } else if (location && r->status == 200) { - /* XX Note that if a script wants to produce its own Redirect + /* XXX: Note that if a script wants to produce its own Redirect * body, it now has to explicitly *say* "Status: 302" */ discard_script_output(bb); @@ -1581,6 +1618,7 @@ static int cgid_handler(request_rec *r) } if (nph) { + conn_rec *c = r->connection; struct ap_filter_t *cur; /* get rid of all filters up through protocol... since we @@ -1772,7 +1810,7 @@ static apr_status_t handle_exec(include_ctx_t *ctx, ap_filter_t *f, } if (ctx->flags & SSI_FLAG_NO_EXEC) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "exec used but not allowed " + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01271) "exec used but not allowed " "in %s", r->filename); SSI_CREATE_ERROR_BUCKET(ctx, f, bb); return APR_SUCCESS; @@ -1792,7 +1830,7 @@ static apr_status_t handle_exec(include_ctx_t *ctx, ap_filter_t *f, rv = include_cmd(ctx, f, bb, parsed_string); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01272) "execution failure for parameter \"%s\" " "to tag exec in file %s", tag, r->filename); SSI_CREATE_ERROR_BUCKET(ctx, f, bb); @@ -1807,14 +1845,14 @@ static apr_status_t handle_exec(include_ctx_t *ctx, ap_filter_t *f, rv = include_cgi(ctx, f, bb, parsed_string); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "invalid CGI ref " + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01273) "invalid CGI ref " "\"%s\" in %s", tag_val, file); SSI_CREATE_ERROR_BUCKET(ctx, f, bb); break; } } else { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "unknown parameter " + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01274) "unknown parameter " "\"%s\" to tag exec in %s", tag, file); SSI_CREATE_ERROR_BUCKET(ctx, f, bb); break; @@ -1839,7 +1877,7 @@ static void register_hook(apr_pool_t *p) ap_hook_handler(cgid_handler, NULL, NULL, APR_HOOK_MIDDLE); } -module AP_MODULE_DECLARE_DATA cgid_module = { +AP_DECLARE_MODULE(cgid) = { STANDARD20_MODULE_STUFF, NULL, /* dir config creater */ NULL, /* dir merger --- default is to override */ diff --git a/modules/generators/mod_info.c b/modules/generators/mod_info.c index 297953fd..b685560b 100644 --- a/modules/generators/mod_info.c +++ b/modules/generators/mod_info.c @@ -45,12 +45,12 @@ #include "apr_strings.h" #include "apr_lib.h" #include "apr_version.h" +#if APR_MAJOR_VERSION < 2 #include "apu_version.h" +#endif #define APR_WANT_STRFUNC #include "apr_want.h" -#define CORE_PRIVATE - #include "httpd.h" #include "http_config.h" #include "http_core.h" @@ -61,6 +61,7 @@ #include "http_request.h" #include "util_script.h" #include "ap_mpm.h" +#include <stdio.h> typedef struct { @@ -75,6 +76,11 @@ typedef struct module AP_MODULE_DECLARE_DATA info_module; +/* current file name when doing -DDUMP_CONFIG */ +const char *dump_config_fn_info; +/* file handle when doing -DDUMP_CONFIG */ +apr_file_t *out = NULL; + static void *create_info_config(apr_pool_t * p, server_rec * s) { info_svr_conf *conf = @@ -100,34 +106,74 @@ static void put_int_flush_right(request_rec * r, int i, int field) { if (field > 1 || i > 9) put_int_flush_right(r, i / 10, field - 1); - if (i) - ap_rputc('0' + i % 10, r); + if (i) { + if (r) + ap_rputc('0' + i % 10, r); + else + apr_file_putc('0' + i % 10, out); + } + else { + if (r) + ap_rputs(" ", r); + else + apr_file_printf(out, " "); + } +} + +static void set_fn_info(request_rec *r, const char *name) +{ + if (r) + ap_set_module_config(r->request_config, &info_module, (void *)name); else - ap_rputs(" ", r); + dump_config_fn_info = name; } +static const char *get_fn_info(request_rec *r) +{ + if (r) + return ap_get_module_config(r->request_config, &info_module); + else + return dump_config_fn_info; +} + + static void mod_info_indent(request_rec * r, int nest, const char *thisfn, int linenum) { int i; - const char *prevfn = - ap_get_module_config(r->request_config, &info_module); + const char *prevfn = get_fn_info(r); if (thisfn == NULL) thisfn = "*UNKNOWN*"; if (prevfn == NULL || 0 != strcmp(prevfn, thisfn)) { - thisfn = ap_escape_html(r->pool, thisfn); - ap_rprintf(r, "<dd><tt><strong>In file: %s</strong></tt></dd>\n", + if (r) { + thisfn = ap_escape_html(r->pool, thisfn); + ap_rprintf(r, "<dd><tt><strong>In file: %s</strong></tt></dd>\n", thisfn); - ap_set_module_config(r->request_config, &info_module, - (void *) thisfn); + } + else { + apr_file_printf(out, "# In file: %s\n", thisfn); + } + set_fn_info(r, thisfn); } - ap_rputs("<dd><tt>", r); - put_int_flush_right(r, linenum > 0 ? linenum : 0, 4); - ap_rputs(": ", r); + if (r) { + ap_rputs("<dd><tt>", r); + put_int_flush_right(r, linenum > 0 ? linenum : 0, 4); + ap_rputs(": ", r); + } + else if (linenum > 0) { + for (i = 1; i <= nest; ++i) + apr_file_printf(out, " "); + apr_file_putc('#', out); + put_int_flush_right(r, linenum, 4); + apr_file_printf(out, ":\n"); + } for (i = 1; i <= nest; ++i) { - ap_rputs(" ", r); + if (r) + ap_rputs(" ", r); + else + apr_file_printf(out, " "); } } @@ -135,18 +181,24 @@ static void mod_info_show_cmd(request_rec * r, const ap_directive_t * dir, int nest) { mod_info_indent(r, nest, dir->filename, dir->line_num); - ap_rprintf(r, "%s <i>%s</i></tt></dd>\n", - ap_escape_html(r->pool, dir->directive), - ap_escape_html(r->pool, dir->args)); + if (r) + ap_rprintf(r, "%s <i>%s</i></tt></dd>\n", + ap_escape_html(r->pool, dir->directive), + ap_escape_html(r->pool, dir->args)); + else + apr_file_printf(out, "%s %s\n", dir->directive, dir->args); } static void mod_info_show_open(request_rec * r, const ap_directive_t * dir, int nest) { mod_info_indent(r, nest, dir->filename, dir->line_num); - ap_rprintf(r, "%s %s</tt></dd>\n", - ap_escape_html(r->pool, dir->directive), - ap_escape_html(r->pool, dir->args)); + if (r) + ap_rprintf(r, "%s %s</tt></dd>\n", + ap_escape_html(r->pool, dir->directive), + ap_escape_html(r->pool, dir->args)); + else + apr_file_printf(out, "%s %s\n", dir->directive, dir->args); } static void mod_info_show_close(request_rec * r, const ap_directive_t * dir, @@ -155,11 +207,17 @@ static void mod_info_show_close(request_rec * r, const ap_directive_t * dir, const char *dirname = dir->directive; mod_info_indent(r, nest, dir->filename, 0); if (*dirname == '<') { - ap_rprintf(r, "</%s></tt></dd>", - ap_escape_html(r->pool, dirname + 1)); + if (r) + ap_rprintf(r, "</%s></tt></dd>", + ap_escape_html(r->pool, dirname + 1)); + else + apr_file_printf(out, "</%s>\n", dirname + 1); } else { - ap_rprintf(r, "/%s</tt></dd>", ap_escape_html(r->pool, dirname)); + if (r) + ap_rprintf(r, "/%s</tt></dd>", ap_escape_html(r->pool, dirname)); + else + apr_file_printf(out, "/%s\n", dirname); } } @@ -189,7 +247,7 @@ static int mod_info_module_cmds(request_rec * r, const command_rec * cmds, int shown = from; ap_directive_t *dir; if (level == 0) - ap_set_module_config(r->request_config, &info_module, NULL); + set_fn_info(r, NULL); for (dir = node; dir; dir = dir->next) { if (dir->first_child != NULL) { if (level < mod_info_module_cmds(r, cmds, dir->first_child, @@ -238,6 +296,7 @@ typedef struct static hook_lookup_t startup_hooks[] = { {"Pre-Config", ap_hook_get_pre_config}, + {"Check Configuration", ap_hook_get_check_config}, {"Test Configuration", ap_hook_get_test_config}, {"Post Configuration", ap_hook_get_post_config}, {"Open Logs", ap_hook_get_open_logs}, @@ -359,12 +418,14 @@ static int show_server_settings(request_rec * r) ap_rprintf(r, "<dt><strong>Compiled with APR Version:</strong> " "<tt>%s</tt></dt>\n", APR_VERSION_STRING); +#if APR_MAJOR_VERSION < 2 ap_rprintf(r, "<dt><strong>Server loaded APU Version:</strong> " "<tt>%s</tt></dt>\n", apu_version_string()); ap_rprintf(r, "<dt><strong>Compiled with APU Version:</strong> " "<tt>%s</tt></dt>\n", APU_VERSION_STRING); +#endif ap_rprintf(r, "<dt><strong>Module Magic Number:</strong> " "<tt>%d:%d</tt></dt>\n", MODULE_MAGIC_NUMBER_MAJOR, @@ -417,10 +478,6 @@ static int show_server_settings(request_rec * r) ap_rputs(" -D OS=\"" OS "\"\n", r); #endif -#ifdef APACHE_MPM_DIR - ap_rputs(" -D APACHE_MPM_DIR=\"" APACHE_MPM_DIR "\"\n", r); -#endif - #ifdef HAVE_SHMGET ap_rputs(" -D HAVE_SHMGET\n", r); #endif @@ -504,10 +561,6 @@ static int show_server_settings(request_rec * r) ap_rputs(" -D NEED_HASHBANG_EMUL\n", r); #endif -#ifdef SHARED_CORE - ap_rputs(" -D SHARED_CORE\n", r); -#endif - /* This list displays the compiled in default paths: */ #ifdef HTTPD_ROOT ap_rputs(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n", r); @@ -517,10 +570,6 @@ static int show_server_settings(request_rec * r) ap_rputs(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n", r); #endif -#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR) - ap_rputs(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n", r); -#endif - #ifdef DEFAULT_PIDLOG ap_rputs(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n", r); #endif @@ -529,10 +578,6 @@ static int show_server_settings(request_rec * r) ap_rputs(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n", r); #endif -#ifdef DEFAULT_LOCKFILE - ap_rputs(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n", r); -#endif - #ifdef DEFAULT_ERRORLOG ap_rputs(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n", r); #endif @@ -608,18 +653,18 @@ static int show_active_hooks(request_rec * r) static int display_info(request_rec * r) { - module *modp = NULL; - server_rec *serv = r->server; + module *modp; const char *more_info; - const command_rec *cmd = NULL; - int comma = 0; + const command_rec *cmd; - if (strcmp(r->handler, "server-info")) + if (strcmp(r->handler, "server-info")) { return DECLINED; + } r->allowed |= (AP_METHOD_BIT << M_GET); - if (r->method_number != M_GET) + if (r->method_number != M_GET) { return DECLINED; + } ap_set_content_type(r, "text/html; charset=ISO-8859-1"); @@ -639,12 +684,15 @@ static int display_info(request_rec * r) ap_rputs("</tt></dt></dl><hr />", r); ap_rputs("<dl><dt><tt>Sections:<br />", r); - ap_rputs("<a href=\"#server\">Server Settings</a>, " + ap_rputs("<a href=\"#modules\">Loaded Modules</a>, " + "<a href=\"#server\">Server Settings</a>, " "<a href=\"#startup_hooks\">Startup Hooks</a>, " "<a href=\"#request_hooks\">Request Hooks</a>", r); ap_rputs("</tt></dt></dl><hr />", r); - ap_rputs("<dl><dt><tt>Loaded Modules: <br />", r); + ap_rputs("<h2><a name=\"modules\">Loaded Modules</a></h2>" + "<dl><dt><tt>", r); + /* TODO: Sort by Alpha */ for (modp = ap_top_module; modp; modp = modp->next) { ap_rprintf(r, "<a href=\"#%s\">%s</a>", modp->name, @@ -670,6 +718,7 @@ static int display_info(request_rec * r) ap_rputs("</dl><hr />", r); } else { + int comma = 0; for (modp = ap_top_module; modp; modp = modp->next) { if (!r->args || !strcasecmp(modp->name, r->args)) { ap_rprintf(r, @@ -755,7 +804,7 @@ static int display_info(request_rec * r) ("<dt><strong>Module Directives:</strong> <tt>none</tt></dt>", r); } - more_info = find_more_info(serv, modp->name); + more_info = find_more_info(r->server, modp->name); if (more_info) { ap_rputs ("<dt><strong>Additional Information:</strong>\n</dt><dd>", @@ -809,12 +858,25 @@ static const command_rec info_cmds[] = { {NULL} }; +static int check_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, + server_rec *s) +{ + if (ap_exists_config_define("DUMP_CONFIG")) { + apr_file_open_stdout(&out, ptemp); + mod_info_module_cmds(NULL, NULL, ap_conftree, 0, 0); + } + + return DECLINED; +} + + static void register_hooks(apr_pool_t * p) { ap_hook_handler(display_info, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_check_config(check_config, NULL, NULL, APR_HOOK_FIRST); } -module AP_MODULE_DECLARE_DATA info_module = { +AP_DECLARE_MODULE(info) = { STANDARD20_MODULE_STUFF, NULL, /* dir config creater */ NULL, /* dir merger --- default is to override */ diff --git a/modules/generators/mod_info.dep b/modules/generators/mod_info.dep deleted file mode 100644 index 00fa95c6..00000000 --- a/modules/generators/mod_info.dep +++ /dev/null @@ -1,37 +0,0 @@ -# Microsoft Developer Studio Generated Dependency File, included by mod_info.mak - -..\..\build\win32\httpd.rc : \ - "..\..\include\ap_release.h"\ - - -.\mod_info.c : \ - "..\..\include\ap_config.h"\ - "..\..\include\ap_mmn.h"\ - "..\..\include\ap_mpm.h"\ - "..\..\include\ap_regex.h"\ - "..\..\include\ap_release.h"\ - "..\..\include\http_config.h"\ - "..\..\include\http_connection.h"\ - "..\..\include\http_core.h"\ - "..\..\include\http_log.h"\ - "..\..\include\http_main.h"\ - "..\..\include\http_protocol.h"\ - "..\..\include\http_request.h"\ - "..\..\include\httpd.h"\ - "..\..\include\os.h"\ - "..\..\include\util_cfgtree.h"\ - "..\..\include\util_filter.h"\ - "..\..\include\util_script.h"\ - "..\..\srclib\apr-util\include\apr_hooks.h"\ - "..\..\srclib\apr-util\include\apr_optional.h"\ - "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ - "..\..\srclib\apr-util\include\apr_uri.h"\ - "..\..\srclib\apr-util\include\apu_version.h"\ - "..\..\srclib\apr\include\apr_hash.h"\ - "..\..\srclib\apr\include\apr_lib.h"\ - "..\..\srclib\apr\include\apr_mmap.h"\ - "..\..\srclib\apr\include\apr_poll.h"\ - "..\..\srclib\apr\include\apr_portable.h"\ - "..\..\srclib\apr\include\apr_strings.h"\ - "..\..\srclib\apr\include\apr_version.h"\ - diff --git a/modules/generators/mod_info.mak b/modules/generators/mod_info.mak deleted file mode 100644 index 92d30fa9..00000000 --- a/modules/generators/mod_info.mak +++ /dev/null @@ -1,353 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on mod_info.dsp -!IF "$(CFG)" == "" -CFG=mod_info - Win32 Release -!MESSAGE No configuration specified. Defaulting to mod_info - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "mod_info - Win32 Release" && "$(CFG)" != "mod_info - Win32 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "mod_info.mak" CFG="mod_info - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "mod_info - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "mod_info - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "mod_info - Win32 Release" - -OUTDIR=.\Release -INTDIR=.\Release -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_info.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_info.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_info.obj" - -@erase "$(INTDIR)\mod_info.res" - -@erase "$(INTDIR)\mod_info_src.idb" - -@erase "$(INTDIR)\mod_info_src.pdb" - -@erase "$(OUTDIR)\mod_info.exp" - -@erase "$(OUTDIR)\mod_info.lib" - -@erase "$(OUTDIR)\mod_info.pdb" - -@erase "$(OUTDIR)\mod_info.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_info_src" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_info.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_info.so" /d LONG_NAME="info_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_info.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_info.pdb" /debug /out:"$(OUTDIR)\mod_info.so" /implib:"$(OUTDIR)\mod_info.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_info.so /opt:ref -LINK32_OBJS= \ - "$(INTDIR)\mod_info.obj" \ - "$(INTDIR)\mod_info.res" \ - "..\..\srclib\apr\Release\libapr-1.lib" \ - "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ - "..\..\Release\libhttpd.lib" - -"$(OUTDIR)\mod_info.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Release\mod_info.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_info.so" - if exist .\Release\mod_info.so.manifest mt.exe -manifest .\Release\mod_info.so.manifest -outputresource:.\Release\mod_info.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "mod_info - Win32 Debug" - -OUTDIR=.\Debug -INTDIR=.\Debug -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_info.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_info.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_info.obj" - -@erase "$(INTDIR)\mod_info.res" - -@erase "$(INTDIR)\mod_info_src.idb" - -@erase "$(INTDIR)\mod_info_src.pdb" - -@erase "$(OUTDIR)\mod_info.exp" - -@erase "$(OUTDIR)\mod_info.lib" - -@erase "$(OUTDIR)\mod_info.pdb" - -@erase "$(OUTDIR)\mod_info.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_info_src" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_info.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_info.so" /d LONG_NAME="info_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_info.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_info.pdb" /debug /out:"$(OUTDIR)\mod_info.so" /implib:"$(OUTDIR)\mod_info.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_info.so -LINK32_OBJS= \ - "$(INTDIR)\mod_info.obj" \ - "$(INTDIR)\mod_info.res" \ - "..\..\srclib\apr\Debug\libapr-1.lib" \ - "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ - "..\..\Debug\libhttpd.lib" - -"$(OUTDIR)\mod_info.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Debug\mod_info.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_info.so" - if exist .\Debug\mod_info.so.manifest mt.exe -manifest .\Debug\mod_info.so.manifest -outputresource:.\Debug\mod_info.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("mod_info.dep") -!INCLUDE "mod_info.dep" -!ELSE -!MESSAGE Warning: cannot find "mod_info.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "mod_info - Win32 Release" || "$(CFG)" == "mod_info - Win32 Debug" - -!IF "$(CFG)" == "mod_info - Win32 Release" - -"libapr - Win32 Release" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" - cd "..\..\modules\generators" - -"libapr - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_info - Win32 Debug" - -"libapr - Win32 Debug" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" - cd "..\..\modules\generators" - -"libapr - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_info - Win32 Release" - -"libaprutil - Win32 Release" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" - cd "..\..\modules\generators" - -"libaprutil - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_info - Win32 Debug" - -"libaprutil - Win32 Debug" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" - cd "..\..\modules\generators" - -"libaprutil - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_info - Win32 Release" - -"libhttpd - Win32 Release" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" - cd ".\modules\generators" - -"libhttpd - Win32 ReleaseCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ELSEIF "$(CFG)" == "mod_info - Win32 Debug" - -"libhttpd - Win32 Debug" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" - cd ".\modules\generators" - -"libhttpd - Win32 DebugCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ENDIF - -SOURCE=..\..\build\win32\httpd.rc - -!IF "$(CFG)" == "mod_info - Win32 Release" - - -"$(INTDIR)\mod_info.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_info.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "NDEBUG" /d BIN_NAME="mod_info.so" /d LONG_NAME="info_module for Apache" $(SOURCE) - - -!ELSEIF "$(CFG)" == "mod_info - Win32 Debug" - - -"$(INTDIR)\mod_info.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_info.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "_DEBUG" /d BIN_NAME="mod_info.so" /d LONG_NAME="info_module for Apache" $(SOURCE) - - -!ENDIF - -SOURCE=.\mod_info.c - -"$(INTDIR)\mod_info.obj" : $(SOURCE) "$(INTDIR)" - - - -!ENDIF - diff --git a/modules/generators/mod_status.c b/modules/generators/mod_status.c index bcf9b10c..ced19edb 100644 --- a/modules/generators/mod_status.c +++ b/modules/generators/mod_status.c @@ -54,7 +54,6 @@ * [Jim J.] */ -#define CORE_PRIVATE #include "httpd.h" #include "http_config.h" #include "http_core.h" @@ -73,18 +72,6 @@ #include "apr_want.h" #include "apr_strings.h" -#ifdef NEXT -#if (NX_CURRENT_COMPILER_RELEASE == 410) -#ifdef m68k -#define HZ 64 -#else -#define HZ 100 -#endif -#else -#include <machine/param.h> -#endif -#endif /* NEXT */ - #define STATUS_MAXLINE 64 #define KBYTE 1024 @@ -99,7 +86,8 @@ module AP_MODULE_DECLARE_DATA status_module; -static int server_limit, thread_limit; +static int server_limit, thread_limit, threads_per_child, max_servers, + is_async; /* Implement 'ap_run_status_hook'. */ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap, STATUS, int, status_hook, @@ -115,41 +103,6 @@ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap, STATUS, int, status_hook, static pid_t child_pid; #endif -/* - * 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, int arg) -{ - const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) { - return err; - } - ap_extended_status = arg; - return NULL; -} - -static const char *set_reqtail(cmd_parms *cmd, void *dummy, int arg) -{ - const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) { - return err; - } - ap_mod_status_reqtail = arg; - return NULL; -} - - -static const command_rec status_module_cmds[] = -{ - AP_INIT_FLAG("ExtendedStatus", set_extended_status, NULL, RSRC_CONF, - "\"On\" to enable extended status information, \"Off\" to disable"), - AP_INIT_FLAG("SeeRequestTail", set_reqtail, NULL, RSRC_CONF, - "For verbose requests, \"On\" to see the last 63 chars of the request, " - "\"Off\" (default) to see the first 63 in extended status display"), - {NULL} -}; - /* Format the number of bytes nicely */ static void format_byte_out(request_rec *r, apr_off_t bytes) { @@ -220,14 +173,18 @@ static const struct stat_opt status_options[] = /* see #defines above */ {STAT_OPT_END, NULL, NULL} }; -static char status_flags[SERVER_NUM_STATUS]; +/* add another state for slots above the MaxRequestWorkers setting */ +#define SERVER_DISABLED SERVER_NUM_STATUS +#define MOD_STATUS_NUM_STATUS (SERVER_NUM_STATUS+1) + +static char status_flags[MOD_STATUS_NUM_STATUS]; static int status_handler(request_rec *r) { const char *loc; apr_time_t nowtime; apr_interval_time_t up_time; - int j, i, res; + int j, i, res, written; int ready; int busy; unsigned long count; @@ -235,25 +192,33 @@ static int status_handler(request_rec *r) apr_off_t bytes, my_bytes, conn_bytes; apr_off_t bcount, kbcount; long req_time; -#ifdef HAVE_TIMES - float tick; - int times_per_thread = getpid() != child_pid; -#endif int short_report; int no_table_report; worker_score *ws_record; process_score *ps_record; char *stat_buffer; pid_t *pid_buffer, worker_pid; + int *thread_idle_buffer = NULL; + int *thread_busy_buffer = NULL; clock_t tu, ts, tcu, tcs; - ap_generation_t worker_generation; + ap_generation_t mpm_generation, worker_generation; +#ifdef HAVE_TIMES + float tick; + int times_per_thread; +#endif - if (strcmp(r->handler, STATUS_MAGIC_TYPE) && - strcmp(r->handler, "server-status")) { + if (strcmp(r->handler, STATUS_MAGIC_TYPE) && strcmp(r->handler, + "server-status")) { return DECLINED; } #ifdef HAVE_TIMES + times_per_thread = getpid() != child_pid; +#endif + + ap_mpm_query(AP_MPMQ_GENERATION, &mpm_generation); + +#ifdef HAVE_TIMES #ifdef _SC_CLK_TCK tick = sysconf(_SC_CLK_TCK); #else @@ -271,12 +236,16 @@ static int status_handler(request_rec *r) pid_buffer = apr_palloc(r->pool, server_limit * sizeof(pid_t)); stat_buffer = apr_palloc(r->pool, server_limit * thread_limit * sizeof(char)); + if (is_async) { + thread_idle_buffer = apr_palloc(r->pool, server_limit * sizeof(int)); + thread_busy_buffer = apr_palloc(r->pool, server_limit * sizeof(int)); + } nowtime = apr_time_now(); tu = ts = tcu = tcs = 0; if (!ap_exists_scoreboard_image()) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01237) "Server status unavailable in inetd mode"); return HTTP_INTERNAL_SERVER_ERROR; } @@ -304,9 +273,9 @@ static int status_handler(request_rec *r) if (*(loc + len ) == '=') { t = atol(loc + len + 1); } - apr_table_set(r->headers_out, - status_options[i].hdr_out_str, - apr_ltoa(r->pool, t < 1 ? 10 : t)); + apr_table_setn(r->headers_out, + status_options[i].hdr_out_str, + apr_ltoa(r->pool, t < 1 ? 10 : t)); break; } case STAT_OPT_NOTABLE: @@ -330,22 +299,41 @@ static int status_handler(request_rec *r) #endif ps_record = ap_get_scoreboard_process(i); + if (is_async) { + thread_idle_buffer[i] = 0; + thread_busy_buffer[i] = 0; + } for (j = 0; j < thread_limit; ++j) { int indx = (i * thread_limit) + j; - ws_record = ap_get_scoreboard_worker(i, j); + ws_record = ap_get_scoreboard_worker_from_indexes(i, j); res = ws_record->status; - stat_buffer[indx] = status_flags[res]; + + if ((i >= max_servers || j >= threads_per_child) + && (res == SERVER_DEAD)) + stat_buffer[indx] = status_flags[SERVER_DISABLED]; + else + stat_buffer[indx] = status_flags[res]; if (!ps_record->quiescing && ps_record->pid) { - if (res == SERVER_READY - && ps_record->generation == ap_my_generation) - ready++; + if (res == SERVER_READY) { + if (ps_record->generation == mpm_generation) + ready++; + if (is_async) + thread_idle_buffer[i]++; + } else if (res != SERVER_DEAD && res != SERVER_STARTING && - res != SERVER_IDLE_KILL) + res != SERVER_IDLE_KILL) { busy++; + if (is_async) { + if (res == SERVER_GRACEFUL) + thread_idle_buffer[i]++; + else + thread_busy_buffer[i]++; + } + } } /* XXX what about the counters for quiescing/seg faulted @@ -366,7 +354,7 @@ static int status_handler(request_rec *r) proc_tu += tmp_tu; proc_ts += tmp_ts; proc_tcu += tmp_tcu; - proc_tcs += proc_tcs; + proc_tcs += tmp_tcs; } else { if (tmp_tu > proc_tu || @@ -376,7 +364,7 @@ static int status_handler(request_rec *r) proc_tu = tmp_tu; proc_ts = tmp_ts; proc_tcu = tmp_tcu; - proc_tcs = proc_tcs; + proc_tcs = tmp_tcs; } } #endif /* HAVE_TIMES */ @@ -406,10 +394,12 @@ static int status_handler(request_rec *r) if (!short_report) { ap_rputs(DOCTYPE_HTML_3_2 - "<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); + "<html><head>\n" + "<title>Apache Status</title>\n" + "</head><body>\n" + "<h1>Apache Server Status for ", r); + ap_rvputs(r, ap_get_server_name(r), " (via ", r->connection->local_ip, + ")</h1>\n\n", NULL); ap_rvputs(r, "<dl><dt>Server Version: ", ap_get_server_description(), "</dt>\n", NULL); ap_rvputs(r, "<dt>Server Built: ", @@ -422,8 +412,10 @@ static int status_handler(request_rec *r) ap_scoreboard_image->global->restart_time, DEFAULT_TIME_FORMAT, 0), "</dt>\n", NULL); - ap_rprintf(r, "<dt>Parent Server Generation: %d</dt>\n", - (int)ap_my_generation); + ap_rprintf(r, "<dt>Parent Server Config. Generation: %d</dt>\n", + ap_state_query(AP_SQ_CONFIG_GEN)); + ap_rprintf(r, "<dt>Parent Server MPM Generation: %d</dt>\n", + (int)mpm_generation); ap_rputs("<dt>Server uptime: ", r); show_time(r, up_time); ap_rputs("</dt>\n", r); @@ -443,14 +435,13 @@ static int status_handler(request_rec *r) #endif ap_rprintf(r, "Uptime: %ld\n", (long) (up_time)); - if (up_time > 0) + 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); - + } if (count > 0) ap_rprintf(r, "BytesPerReq: %g\n", KBYTE * (float) kbcount / (float) count); @@ -470,11 +461,10 @@ static int status_handler(request_rec *r) (tu + ts + tcu + tcs) / tick / up_time * 100.); #endif - if (up_time > 0) + if (up_time > 0) { ap_rprintf(r, "<dt>%.3g requests/sec - ", (float) count / (float) up_time); - if (up_time > 0) { format_byte_out(r, (unsigned long)(KBYTE * (float) kbcount / (float) up_time)); ap_rputs("/second - ", r); @@ -496,44 +486,109 @@ static int status_handler(request_rec *r) else ap_rprintf(r, "BusyWorkers: %d\nIdleWorkers: %d\n", busy, ready); + if (!short_report) + ap_rputs("</dl>", r); + + if (is_async) { + int write_completion = 0, lingering_close = 0, keep_alive = 0, + connections = 0; + /* + * These differ from 'busy' and 'ready' in how gracefully finishing + * threads are counted. XXX: How to make this clear in the html? + */ + int busy_workers = 0, idle_workers = 0; + if (!short_report) + ap_rputs("\n\n<table rules=\"all\" cellpadding=\"1%\">\n" + "<tr><th rowspan=\"2\">PID</th>" + "<th colspan=\"2\">Connections</th>\n" + "<th colspan=\"2\">Threads</th>" + "<th colspan=\"4\">Async connections</th></tr>\n" + "<tr><th>total</th><th>accepting</th>" + "<th>busy</th><th>idle</th><th>writing</th>" + "<th>keep-alive</th><th>closing</th></tr>\n", r); + for (i = 0; i < server_limit; ++i) { + ps_record = ap_get_scoreboard_process(i); + if (ps_record->pid) { + connections += ps_record->connections; + write_completion += ps_record->write_completion; + keep_alive += ps_record->keep_alive; + lingering_close += ps_record->lingering_close; + busy_workers += thread_busy_buffer[i]; + idle_workers += thread_idle_buffer[i]; + if (!short_report) + ap_rprintf(r, "<tr><td>%" APR_PID_T_FMT "</td><td>%u</td>" + "<td>%s</td><td>%u</td><td>%u</td>" + "<td>%u</td><td>%u</td><td>%u</td>" + "</tr>\n", + ps_record->pid, ps_record->connections, + ps_record->not_accepting ? "no" : "yes", + thread_busy_buffer[i], thread_idle_buffer[i], + ps_record->write_completion, + ps_record->keep_alive, + ps_record->lingering_close); + } + } + if (!short_report) { + ap_rprintf(r, "<tr><td>Sum</td><td>%d</td><td> </td><td>%d</td>" + "<td>%d</td><td>%d</td><td>%d</td><td>%d</td>" + "</tr>\n</table>\n", + connections, busy_workers, idle_workers, + write_completion, keep_alive, lingering_close); + + } + else { + ap_rprintf(r, "ConnsTotal: %d\n" + "ConnsAsyncWriting: %d\n" + "ConnsAsyncKeepAlive: %d\n" + "ConnsAsyncClosing: %d\n", + connections, write_completion, keep_alive, + lingering_close); + } + } + /* send the scoreboard 'table' out */ if (!short_report) - ap_rputs("</dl><pre>", r); + ap_rputs("<pre>", r); else ap_rputs("Scoreboard: ", r); + written = 0; for (i = 0; i < server_limit; ++i) { for (j = 0; j < thread_limit; ++j) { int indx = (i * thread_limit) + j; - ap_rputc(stat_buffer[indx], r); - if ((indx % STATUS_MAXLINE == (STATUS_MAXLINE - 1)) - && !short_report) - ap_rputs("\n", r); + if (stat_buffer[indx] != status_flags[SERVER_DISABLED]) { + ap_rputc(stat_buffer[indx], r); + if ((written % STATUS_MAXLINE == (STATUS_MAXLINE - 1)) + && !short_report) + ap_rputs("\n", r); + written++; + } } } + if (short_report) ap_rputs("\n", r); else { - ap_rputs("</pre>\n", r); - ap_rputs("<p>Scoreboard Key:<br />\n", r); - ap_rputs("\"<b><code>_</code></b>\" Waiting for Connection, \n", r); - ap_rputs("\"<b><code>S</code></b>\" Starting up, \n", r); - ap_rputs("\"<b><code>R</code></b>\" Reading Request,<br />\n", r); - ap_rputs("\"<b><code>W</code></b>\" Sending Reply, \n", r); - ap_rputs("\"<b><code>K</code></b>\" Keepalive (read), \n", r); - ap_rputs("\"<b><code>D</code></b>\" DNS Lookup,<br />\n", r); - ap_rputs("\"<b><code>C</code></b>\" Closing connection, \n", r); - ap_rputs("\"<b><code>L</code></b>\" Logging, \n", r); - ap_rputs("\"<b><code>G</code></b>\" Gracefully finishing,<br /> \n", r); - ap_rputs("\"<b><code>I</code></b>\" Idle cleanup of worker, \n", r); - ap_rputs("\"<b><code>.</code></b>\" Open slot with no current process</p>\n", r); - ap_rputs("<p />\n", r); + ap_rputs("</pre>\n" + "<p>Scoreboard Key:<br />\n" + "\"<b><code>_</code></b>\" Waiting for Connection, \n" + "\"<b><code>S</code></b>\" Starting up, \n" + "\"<b><code>R</code></b>\" Reading Request,<br />\n" + "\"<b><code>W</code></b>\" Sending Reply, \n" + "\"<b><code>K</code></b>\" Keepalive (read), \n" + "\"<b><code>D</code></b>\" DNS Lookup,<br />\n" + "\"<b><code>C</code></b>\" Closing connection, \n" + "\"<b><code>L</code></b>\" Logging, \n" + "\"<b><code>G</code></b>\" Gracefully finishing,<br /> \n" + "\"<b><code>I</code></b>\" Idle cleanup of worker, \n" + "\"<b><code>.</code></b>\" Open slot with no current process,<br />\n" + "<p />\n", r); if (!ap_extended_status) { int j; int k = 0; - ap_rputs("PID Key: <br />\n", r); - ap_rputs("<pre>\n", r); + ap_rputs("PID Key: <br />\n" + "<pre>\n", r); for (i = 0; i < server_limit; ++i) { for (j = 0; j < thread_limit; ++j) { int indx = (i * thread_limit) + j; @@ -552,8 +607,8 @@ static int status_handler(request_rec *r) } } - ap_rputs("\n", r); - ap_rputs("</pre>\n", r); + ap_rputs("\n" + "</pre>\n", r); } } @@ -574,7 +629,7 @@ static int status_handler(request_rec *r) for (i = 0; i < server_limit; ++i) { for (j = 0; j < thread_limit; ++j) { - ws_record = ap_get_scoreboard_worker(i, j); + ws_record = ap_get_scoreboard_worker_from_indexes(i, j); if (ws_record->access_count == 0 && (ws_record->status == SERVER_READY || @@ -767,19 +822,15 @@ static int status_handler(request_rec *r) (float)conn_bytes / KBYTE, (float) my_bytes / MBYTE, (float)bytes / MBYTE); - if (ws_record->status == SERVER_BUSY_READ) - ap_rprintf(r, - "</td><td>?</td><td nowrap>?</td><td nowrap>..reading.. </td></tr>\n\n"); - else - ap_rprintf(r, - "</td><td>%s</td><td nowrap>%s</td><td nowrap>%s</td></tr>\n\n", - ap_escape_html(r->pool, - ws_record->client), - ap_escape_html(r->pool, - ws_record->vhost), - ap_escape_html(r->pool, - ap_escape_logitem(r->pool, - ws_record->request))); + ap_rprintf(r, "</td><td>%s</td><td nowrap>%s</td>" + "<td nowrap>%s</td></tr>\n\n", + ap_escape_html(r->pool, + ws_record->client), + ap_escape_html(r->pool, + ws_record->vhost), + ap_escape_html(r->pool, + ap_escape_logitem(r->pool, + ws_record->request))); } /* no_table_report */ } /* for (j...) */ } /* for (i...) */ @@ -832,6 +883,16 @@ static int status_handler(request_rec *r) return 0; } +static int status_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) +{ + /* When mod_status is loaded, default our ExtendedStatus to 'on' + * other modules which prefer verbose scoreboards may play a similar game. + * If left to their own requirements, mpm modules can make do with simple + * scoreboard entries. + */ + ap_extended_status = 1; + return OK; +} static int status_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) @@ -847,8 +908,15 @@ static int status_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, status_flags[SERVER_CLOSING] = 'C'; status_flags[SERVER_GRACEFUL] = 'G'; status_flags[SERVER_IDLE_KILL] = 'I'; + status_flags[SERVER_DISABLED] = ' '; ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit); ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server_limit); + ap_mpm_query(AP_MPMQ_MAX_THREADS, &threads_per_child); + /* work around buggy MPMs */ + if (threads_per_child == 0) + threads_per_child = 1; + ap_mpm_query(AP_MPMQ_MAX_DAEMONS, &max_servers); + ap_mpm_query(AP_MPMQ_IS_ASYNC, &is_async); return OK; } @@ -862,20 +930,21 @@ static void status_child_init(apr_pool_t *p, server_rec *s) static void register_hooks(apr_pool_t *p) { ap_hook_handler(status_handler, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_pre_config(status_pre_config, NULL, NULL, APR_HOOK_LAST); ap_hook_post_config(status_init, NULL, NULL, APR_HOOK_MIDDLE); #ifdef HAVE_TIMES ap_hook_child_init(status_child_init, NULL, NULL, APR_HOOK_MIDDLE); #endif } -module AP_MODULE_DECLARE_DATA status_module = +AP_DECLARE_MODULE(status) = { STANDARD20_MODULE_STUFF, NULL, /* dir config creater */ NULL, /* dir merger --- default is to override */ NULL, /* server config */ NULL, /* merge server config */ - status_module_cmds, /* command table */ + NULL, /* command table */ register_hooks /* register_hooks */ }; diff --git a/modules/generators/mod_status.dep b/modules/generators/mod_status.dep deleted file mode 100644 index 6f85de29..00000000 --- a/modules/generators/mod_status.dep +++ /dev/null @@ -1,34 +0,0 @@ -# Microsoft Developer Studio Generated Dependency File, included by mod_status.mak - -..\..\build\win32\httpd.rc : \ - "..\..\include\ap_release.h"\ - - -.\mod_status.c : \ - "..\..\include\ap_config.h"\ - "..\..\include\ap_mmn.h"\ - "..\..\include\ap_mpm.h"\ - "..\..\include\ap_regex.h"\ - "..\..\include\ap_release.h"\ - "..\..\include\http_config.h"\ - "..\..\include\http_core.h"\ - "..\..\include\http_log.h"\ - "..\..\include\http_main.h"\ - "..\..\include\http_protocol.h"\ - "..\..\include\httpd.h"\ - "..\..\include\os.h"\ - "..\..\include\scoreboard.h"\ - "..\..\include\util_cfgtree.h"\ - "..\..\include\util_filter.h"\ - "..\..\include\util_script.h"\ - "..\..\srclib\apr-util\include\apr_hooks.h"\ - "..\..\srclib\apr-util\include\apr_optional.h"\ - "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ - "..\..\srclib\apr-util\include\apr_uri.h"\ - "..\..\srclib\apr\include\apr_hash.h"\ - "..\..\srclib\apr\include\apr_mmap.h"\ - "..\..\srclib\apr\include\apr_poll.h"\ - "..\..\srclib\apr\include\apr_portable.h"\ - "..\..\srclib\apr\include\apr_strings.h"\ - ".\mod_status.h"\ - diff --git a/modules/generators/mod_status.mak b/modules/generators/mod_status.mak deleted file mode 100644 index 5c5b4190..00000000 --- a/modules/generators/mod_status.mak +++ /dev/null @@ -1,353 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on mod_status.dsp -!IF "$(CFG)" == "" -CFG=mod_status - Win32 Release -!MESSAGE No configuration specified. Defaulting to mod_status - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "mod_status - Win32 Release" && "$(CFG)" != "mod_status - Win32 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "mod_status.mak" CFG="mod_status - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "mod_status - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "mod_status - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "mod_status - Win32 Release" - -OUTDIR=.\Release -INTDIR=.\Release -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_status.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_status.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_status.obj" - -@erase "$(INTDIR)\mod_status.res" - -@erase "$(INTDIR)\mod_status_src.idb" - -@erase "$(INTDIR)\mod_status_src.pdb" - -@erase "$(OUTDIR)\mod_status.exp" - -@erase "$(OUTDIR)\mod_status.lib" - -@erase "$(OUTDIR)\mod_status.pdb" - -@erase "$(OUTDIR)\mod_status.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "STATUS_DECLARE_EXPORT" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_status_src" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_status.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_status.so" /d LONG_NAME="status_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_status.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_status.pdb" /debug /out:"$(OUTDIR)\mod_status.so" /implib:"$(OUTDIR)\mod_status.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_status.so /opt:ref -LINK32_OBJS= \ - "$(INTDIR)\mod_status.obj" \ - "$(INTDIR)\mod_status.res" \ - "..\..\srclib\apr\Release\libapr-1.lib" \ - "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ - "..\..\Release\libhttpd.lib" - -"$(OUTDIR)\mod_status.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Release\mod_status.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_status.so" - if exist .\Release\mod_status.so.manifest mt.exe -manifest .\Release\mod_status.so.manifest -outputresource:.\Release\mod_status.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "mod_status - Win32 Debug" - -OUTDIR=.\Debug -INTDIR=.\Debug -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\mod_status.so" "$(DS_POSTBUILD_DEP)" - -!ELSE - -ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_status.so" "$(DS_POSTBUILD_DEP)" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\mod_status.obj" - -@erase "$(INTDIR)\mod_status.res" - -@erase "$(INTDIR)\mod_status_src.idb" - -@erase "$(INTDIR)\mod_status_src.pdb" - -@erase "$(OUTDIR)\mod_status.exp" - -@erase "$(OUTDIR)\mod_status.lib" - -@erase "$(OUTDIR)\mod_status.pdb" - -@erase "$(OUTDIR)\mod_status.so" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "STATUS_DECLARE_EXPORT" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_status_src" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_status.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_status.so" /d LONG_NAME="status_module for Apache" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_status.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_status.pdb" /debug /out:"$(OUTDIR)\mod_status.so" /implib:"$(OUTDIR)\mod_status.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_status.so -LINK32_OBJS= \ - "$(INTDIR)\mod_status.obj" \ - "$(INTDIR)\mod_status.res" \ - "..\..\srclib\apr\Debug\libapr-1.lib" \ - "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ - "..\..\Debug\libhttpd.lib" - -"$(OUTDIR)\mod_status.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Debug\mod_status.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_status.so" - if exist .\Debug\mod_status.so.manifest mt.exe -manifest .\Debug\mod_status.so.manifest -outputresource:.\Debug\mod_status.so;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("mod_status.dep") -!INCLUDE "mod_status.dep" -!ELSE -!MESSAGE Warning: cannot find "mod_status.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "mod_status - Win32 Release" || "$(CFG)" == "mod_status - Win32 Debug" - -!IF "$(CFG)" == "mod_status - Win32 Release" - -"libapr - Win32 Release" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" - cd "..\..\modules\generators" - -"libapr - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_status - Win32 Debug" - -"libapr - Win32 Debug" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" - cd "..\..\modules\generators" - -"libapr - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr" - $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_status - Win32 Release" - -"libaprutil - Win32 Release" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" - cd "..\..\modules\generators" - -"libaprutil - Win32 ReleaseCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ELSEIF "$(CFG)" == "mod_status - Win32 Debug" - -"libaprutil - Win32 Debug" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" - cd "..\..\modules\generators" - -"libaprutil - Win32 DebugCLEAN" : - cd ".\..\..\srclib\apr-util" - $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN - cd "..\..\modules\generators" - -!ENDIF - -!IF "$(CFG)" == "mod_status - Win32 Release" - -"libhttpd - Win32 Release" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" - cd ".\modules\generators" - -"libhttpd - Win32 ReleaseCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ELSEIF "$(CFG)" == "mod_status - Win32 Debug" - -"libhttpd - Win32 Debug" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" - cd ".\modules\generators" - -"libhttpd - Win32 DebugCLEAN" : - cd ".\..\.." - $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN - cd ".\modules\generators" - -!ENDIF - -SOURCE=..\..\build\win32\httpd.rc - -!IF "$(CFG)" == "mod_status - Win32 Release" - - -"$(INTDIR)\mod_status.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_status.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "NDEBUG" /d BIN_NAME="mod_status.so" /d LONG_NAME="status_module for Apache" $(SOURCE) - - -!ELSEIF "$(CFG)" == "mod_status - Win32 Debug" - - -"$(INTDIR)\mod_status.res" : $(SOURCE) "$(INTDIR)" - $(RSC) /l 0x409 /fo"$(INTDIR)\mod_status.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "_DEBUG" /d BIN_NAME="mod_status.so" /d LONG_NAME="status_module for Apache" $(SOURCE) - - -!ENDIF - -SOURCE=.\mod_status.c - -"$(INTDIR)\mod_status.obj" : $(SOURCE) "$(INTDIR)" - - - -!ENDIF - diff --git a/modules/generators/mod_suexec.c b/modules/generators/mod_suexec.c index 9c5e239c..75e96404 100644 --- a/modules/generators/mod_suexec.c +++ b/modules/generators/mod_suexec.c @@ -14,7 +14,6 @@ * limitations under the License. */ -#define CORE_PRIVATE #include "httpd.h" #include "http_config.h" #include "http_core.h" @@ -60,21 +59,23 @@ static const char *set_suexec_ugid(cmd_parms *cmd, void *mconfig, const char *uid, const char *gid) { suexec_config_t *cfg = (suexec_config_t *) mconfig; - const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE); if (err != NULL) { return err; } - if (unixd_config.suexec_enabled) { - cfg->ugid.uid = ap_uname2id(uid); - cfg->ugid.gid = ap_gname2id(gid); - cfg->ugid.userdir = 0; - cfg->active = 1; - } - else { - fprintf(stderr, - "Warning: SuexecUserGroup directive requires SUEXEC wrapper.\n"); + + if (!ap_unixd_config.suexec_enabled) { + return apr_pstrcat(cmd->pool, "SuexecUserGroup configured, but " + "suEXEC is disabled: ", + ap_unixd_config.suexec_disabled_reason, NULL); } + + cfg->ugid.uid = ap_uname2id(uid); + cfg->ugid.gid = ap_gname2id(gid); + cfg->ugid.userdir = 0; + cfg->active = 1; + return NULL; } @@ -95,8 +96,8 @@ static int suexec_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_userdata_get(&reported, SUEXEC_POST_CONFIG_USERDATA, s->process->pool); - if ((reported == NULL) && unixd_config.suexec_enabled) { - ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, + if ((reported == NULL) && ap_unixd_config.suexec_enabled) { + ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, APLOGNO(01232) "suEXEC mechanism enabled (wrapper: %s)", SUEXEC_BIN); apr_pool_userdata_set((void *)1, SUEXEC_POST_CONFIG_USERDATA, @@ -126,7 +127,7 @@ static void suexec_hooks(apr_pool_t *p) ap_hook_post_config(suexec_post_config,NULL,NULL,APR_HOOK_MIDDLE); } -module AP_MODULE_DECLARE_DATA suexec_module = +AP_DECLARE_MODULE(suexec) = { STANDARD20_MODULE_STUFF, create_mconfig_for_directory, /* create per-dir config */ diff --git a/modules/generators/mod_suexec.h b/modules/generators/mod_suexec.h index ab59d983..80e25041 100644 --- a/modules/generators/mod_suexec.h +++ b/modules/generators/mod_suexec.h @@ -17,7 +17,7 @@ /** * @file mod_suexec.h * @brief SuExec Extension Module for Apache - * + * * @defgroup MOD_SUEXEC mod_suexec * @ingroup APACHE_MODS * @{ |
