1
0
mirror of https://github.com/apache/httpd.git synced 2025-09-11 09:30:48 +03:00

269 Commits

Author SHA1 Message Date
Ruediger Pluem
aa4b05ee05 * Always trust content types that we set literally
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918814 13f79535-47bb-0310-9956-ffa450edef68
2024-07-02 06:35:53 +00:00
Joe Orton
c14406763c * modules/generators/mod_cgi.c, mod_cgid.c: Since
r1916769 adds #include <util_script.h> to cgi_common.h,
  remove it here.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1916998 13f79535-47bb-0310-9956-ffa450edef68
2024-04-15 09:49:56 +00:00
Giovanni Bechis
4859071fd0 log an error when ap_runtime_dir_relative fails.
spotted by rpluem@


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908984 13f79535-47bb-0310-9956-ffa450edef68
2023-04-05 09:05:24 +00:00
Giovanni Bechis
51a3e29505 Fix a possible NULL pointer dereference of ap_runtime_dir_relative()
ap_runtime_dir_relative() will return NULL on failure. However cgid_init()
does not check the return value of ap_runtime_dir_relative() and use it
directly.

Fix this bug by adding a NULL check.

Submitted by: Zhou Qingyang <zhou1615@umn.edu>

Github: closes #304


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908972 13f79535-47bb-0310-9956-ffa450edef68
2023-04-04 21:43:46 +00:00
Joe Orton
f7e848dd28 * modules/generators/mod_cgid.c (cgid_server): Register cleanup for
socket earlier to avoid possible leaks on error paths.  (highlighted
  by Coverity scan)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1887727 13f79535-47bb-0310-9956-ffa450edef68
2021-03-16 15:31:58 +00:00
Joe Orton
ce01739011 Enable mod_cgid stderr handling via Unix socket fd transfer by
default, rather than as an opt-in configure flag.  (This has been
tested in Fedora for >12 months without seeing any new problems)

* configure.in: Check for CMSG_DATA here, and define HAVE_FDPASSING
  and $ap_has_fdpassing if fd passing is supported.
    
* modules/generator/config5.m4,
  modules/generator/mod_cgid.c: Drop configure flag for mod_cgid
  fdpassing support, instead enable where possible by default.
    
* modules/proxy/config.m4: Rely on configure test for CMSG_DATA.
    
* .travis.yml: Switch test for cgid fdpassing for testing w/o
  CMSG_DATA.

Github: closes #172
PR: 54221


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1886912 13f79535-47bb-0310-9956-ffa450edef68
2021-02-25 09:11:57 +00:00
Joe Orton
eabfcda175 Further re-unification of code duplicated across mod_cgi/mod_cgid into
cgi_common.h.  Functional changes:

- brings the PR 61980 fix to mod_cgid as well, and 
- some mod_cgid-specific APLOGNOs are dropped in favour of the
  code used in the equivalent error path in mod_cgi

... otherwise no user-visible changes (intended).

* modules/generators/cgi_common.h (log_scripterror, log_script_err): Move
  here from mod_cgi.
  (cgi_handle_exec): Move here, renamed from mod_cgi's handle_exec.
  (cgi_optfns_retrieve): New function, split out from mod_cgi's cgi_post_config.
  
* modules/generators/mod_cgid.c: Adjust accordingly, update to pass
  logno separately.
  (register_hooks): Register cgi_optfns_retrieve.

* modules/generators/mod_cgi.c: Adjust accordingly.
  (register_hooks): Register cgi_optfns_retrieve.

Github: closes #141


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1881559 13f79535-47bb-0310-9956-ffa450edef68
2020-09-08 14:08:22 +00:00
Joe Orton
edb644302a * modules/generators/mod_cgid.c (get_cgi_pid): Fix test for pid=0.
(cgid_handler): Remove duplicated test for pid=0 here added in
  r1879119.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879860 13f79535-47bb-0310-9956-ffa450edef68
2020-07-14 16:25:43 +00:00
Joe Orton
1d85117875 * modules/generators/mod_cgid.c (get_req): Add basic sanity
checking for the structure received in the CGI daemon.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879136 13f79535-47bb-0310-9956-ffa450edef68
2020-06-24 07:32:36 +00:00
Joe Orton
279af56a53 * modules/generators/mod_cgid.c (cgid_handler): Bail immediately with
a 503 response on errors when talking to the daemon.  Check the pid
  returned is not zero.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879119 13f79535-47bb-0310-9956-ffa450edef68
2020-06-23 16:39:25 +00:00
Yann Ylavic
f461bcf12c Add missing pool tags to help debugging.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1876599 13f79535-47bb-0310-9956-ffa450edef68
2020-04-16 12:32:33 +00:00
Joe Orton
82b87850ee * modules/generators/cgi_common.h (cgi_handle_request): Factor out
near-identical common code from mod_cgid, mod_cgi.

* modules/generators/mod_cgid.c (cgid_handler),
  modules/generators/mod_cgi.c (cgi_handler):
  Adjust to use cgi_handle_request.

Github: closes #97


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874491 13f79535-47bb-0310-9956-ffa450edef68
2020-02-25 12:34:00 +00:00
Joe Orton
f0abf76803 Fix build broken w/o --enable-cgid-fdpassing by r1867968:
* modules/generators/cgi_common.h: Only define CGI bucket type
  if WANT_CGI_BUCKET is defined.

* modules/generators/mod_cgi.c: Always include cgi_common.h, defining
  WANT_CGI_BUCKET iff APR_FILES_AS_SOCKETS is defined

* modules/generators/mod_cgid.c: Always include cgi_common.h, defining
  WANT_CGI_BUCKET iff HAVE_CGID_FDPASSING (--enable-cgid-fdpassing).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867971 13f79535-47bb-0310-9956-ffa450edef68
2019-10-04 09:56:42 +00:00
Joe Orton
54c71d419a Move common (and near-identical) code for CGI response output handling
to cgi_common.h; the diff between the modules for this code was as
follows:

https://people.apache.org/~jorton/mod_cgi-to-cgid-handler.diff

Change from previous: mod_cgi will now explicitly discard output when
returning HTTP_MOVED_TEMPORARILY for relative redirects (should not be
functionally different), TRACE1 logging of ap_pass_brigade failures
for mod_cgid is dropped.

* modules/generators/cgi_common.h (cgi_handle_response): New function,
  factored out from mod_cgid.
  (discard_script_output): Copied function from mod_cgi/d unchanged.

* modules/generator/mod_cgid.c (cgid_handler),
  modules/generator/mod_cgi.c (cgi_handler): Use cgi_handle_response.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867968 13f79535-47bb-0310-9956-ffa450edef68
2019-10-04 09:20:33 +00:00
Joe Orton
2715cad0f9 * modules/generators/mod_cgid.c (sock_readhdr): Only set up control
message block when required; add some additional error handling.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867878 13f79535-47bb-0310-9956-ffa450edef68
2019-10-02 09:58:01 +00:00
Joe Orton
eda8ddfc71 mod_cgid: Continuation of r1862968, experimental fd passing support.
Split out CGI bucket implementation from mod_cgi and use in both
mod_cgi and mod_cgid, bringing stderr handling in mod_cgid up to par
with mod_cgi.  (There is a lot of code which has been copied between
mod_cgi{,d} so there's scope for further reduction of source
duplication between the modules using this header)

* modules/generators/cgi_common.h: Copied from mod_cgi.c, removed
  everything but the CGI bucket implementation with only one change:
  (struct cgi_bucket_data, cgi_bucket_create, cgi_bucket_read): Take a
  timeout on bucket creation, store and use on reads.

* modules/generators/mod_cgi.c [APR_FILES_AS_SOCKETS]: Include
  cgi_common.h.
  (cgi_handler): Pass configured timeout to CGI bucket.

* modules/generators/mod_cgid.c: Include cgi_common.h.
  (log_script_err): Copy from mod_cgi.c.
  (log_script): Use log_script_err.
  (send_req): Take fd for stderr.
  (cgid_child_errfn): Handle fd-passing case by writing error
  to stderr for client to pass through ap_log_rerror.
  (cgid_handler): Create pipe for stderr, pass write-end to
  server via send_req, use read-end to create CGI bucket.  Handle
  stderr output in failure paths.

PR: 54221


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1863191 13f79535-47bb-0310-9956-ffa450edef68
2019-07-17 07:51:53 +00:00
Joe Orton
fa36c0e2d7 Add experimental support for fd passing in mod_cgid. Attaches CGI
script stderr to the error log specific to the vhost, by passing the
appropriate fd over the AF_UNIX socket from the request handling
thread to the cgid server process.

* modules/generators/config5.m4: Add --enable-cgid-fdpassing.

* modules/generators/mod_cgid.c (sock_readhdr): New function, also
  returns auxiliary control data (the stderr fd) if available.
  (sock_write): Take optional aux fd argument, send it as control
  data.  (send_req, get_req): Adjust accordingly to pass/receive the
  stderr fd.
  (cgid_server): Use passed fd if available, limit the lifetime.
  
PR: 60692


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1862968 13f79535-47bb-0310-9956-ffa450edef68
2019-07-12 12:09:04 +00:00
Yann Ylavic
019efb6465 Follow up to r1739201.
These APR_TIMEUP special cases are now handled by ap_map_http_request_error().


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1766998 13f79535-47bb-0310-9956-ffa450edef68
2016-10-28 10:56:03 +00:00
Eric Covener
99d569e788 Stash the cgi PID earlier in mod_cgid
In some cases, a 2nd CGI using the same c->id can get into
the mod_cgid handler before cleanups have been run, causing
the new CGI pid to be used by the first CGI's cleanup function.

Instead of stashing c->id in the request processing thread,
just use it before leaving the handler to get the pid.

May indirectly fix PR57771, but it must have a slightly different
cause because stashing the conn_id slightly differently was 
supposed to be sufficient there.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1758083 13f79535-47bb-0310-9956-ffa450edef68
2016-08-27 23:15:11 +00:00
Luca Toscano
4eb7f3d264 mod_cgi/mod_cgid documentation about environment variables added (like DOCUMENT_ROOT).
Bug: 58305



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1726506 13f79535-47bb-0310-9956-ffa450edef68
2016-01-24 16:39:30 +00:00
Rainer Jung
685dc52f64 Remove APLOGNO after moving log message to
TRACE1 in r1724847.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725516 13f79535-47bb-0310-9956-ffa450edef68
2016-01-19 13:37:42 +00:00
Rainer Jung
af14d158a3 Added many log numbers to log statements that
had none.

Those were not detected by the coccinelle script.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725485 13f79535-47bb-0310-9956-ffa450edef68
2016-01-19 12:02:41 +00:00
Eric Covener
b20446d9e2 flush errors are TRACE1 in the core output filter now.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1724847 13f79535-47bb-0310-9956-ffa450edef68
2016-01-15 16:29:59 +00:00
Yann Ylavic
4bfe0a6bba Follow up to r1715880: revert more abusive ap_casecmpstr[n]() usages.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1722150 13f79535-47bb-0310-9956-ffa450edef68
2015-12-29 15:32:27 +00:00
Yann Ylavic
c80e6b2a34 Use new ap_casecmpstr[n]() functions where appropriate (not exhaustive).
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1715876 13f79535-47bb-0310-9956-ffa450edef68
2015-11-23 16:46:01 +00:00
Yann Ylavic
3c9ddf44bf Revert r1715789: will re-commit without spurious functional changes.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1715869 13f79535-47bb-0310-9956-ffa450edef68
2015-11-23 16:28:36 +00:00
Yann Ylavic
29843dc73f Use new ap_casecmpstr[n]() functions where appropriate (not exhaustive).
[Reverted by r1715869]


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1715789 13f79535-47bb-0310-9956-ffa450edef68
2015-11-23 12:33:09 +00:00
Eric Covener
280ed85190 Followup to r1667385, my sandbox was out of date.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1667386 13f79535-47bb-0310-9956-ffa450edef68
2015-03-17 20:13:39 +00:00
Eric Covener
c27569bfd3 Retry ENOENT like ECONNREFUSED, but only near a server restart.
PR57685

Submitted By: Edward Lu
Committed By: covener




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1667385 13f79535-47bb-0310-9956-ffa450edef68
2015-03-17 20:12:19 +00:00
Yann Ylavic
0a431ef862 core, modules: like r1657897 but for core and other modules than mod_proxy.
More uses of ap_map_http_request_error() and AP_FILTER_ERROR so that we never
return an HTTP error status from a handler if some filter generated a response
already.

That is, from a handler, either ap_get_brigade() (an input filter) returned
AP_FILTER_ERROR and we must forward it to ap_die(), or ap_pass_brigade() (an
output filter) failed with any status and we must return AP_FILTER_ERROR in
any case for ap_die() to determine whether a response is needed or not.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1665625 13f79535-47bb-0310-9956-ffa450edef68
2015-03-10 17:25:17 +00:00
Christophe Jaillet
66989ec303 Add missing APLOGNO + fix a typo in a comment
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1610518 13f79535-47bb-0310-9956-ffa450edef68
2014-07-14 20:44:21 +00:00
Eric Covener
c0be5abcd3 SECURITY: CVE-2014-0231 (cve.mitre.org): Part two of two, with r1535125:
mod_cgid: Fix a denial of service against CGI scripts that do
   not consume stdin that could lead to lingering HTTPD child processes
   filling up the scoreboard and eventually hanging the server.
   [Rainer Jung, Eric Covener, Yann Ylavic]

Submitted By: rjung, covener, ylavic
Reviewed By: trawick, jorton, covener, jim
   


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1610509 13f79535-47bb-0310-9956-ffa450edef68
2014-07-14 20:08:25 +00:00
Jeff Trawick
e451f92748 follow-up to r1096569:
remove unnecessary total_modules calculation


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1565711 13f79535-47bb-0310-9956-ffa450edef68
2014-02-07 16:15:20 +00:00
Eric Covener
41488e891d SECURITY (CVE-2014-0231): Fix for DoS due to hang waiting for CGI script.
Patch one of two.

Permit a read timeout to be used in mod_cgid to give up on a slow CGI script.

In trunk, it defaults to the servers Timeout.  PR43494 

Submitted By: Eric Covener, Toshikuni Fukaya
Reviewed By: Eric Covener



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1535125 13f79535-47bb-0310-9956-ffa450edef68
2013-10-23 19:26:08 +00:00
Graham Leggett
9bc9d79079 core: Stop the HTTP_IN filter from attempting to write error buckets
to the output filters, which is bogus in the proxy case. Create a
clean mapping from APR codes to HTTP status codes, and use it where
needed.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1482522 13f79535-47bb-0310-9956-ffa450edef68
2013-05-14 18:58:06 +00:00
Stefan Fritsch
8ec0c56b02 Code clean up (remove useless memory allocation)
Submitted by: Christophe JAILLET <christophe jaillet wanadoo fr>
PR: 52648


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1361803 13f79535-47bb-0310-9956-ffa450edef68
2012-07-15 21:19:54 +00:00
Stefan Fritsch
fe4f92509b Replace use of apr_file_write() with apr_file_write_full() to prevent
incomplete writes.

Add comments in some places where error handling/logging is missing.

PR: 53131.
Submitted by: Nicolas Viennot <apache viennot biz>, Stefan Fritsch


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1331110 13f79535-47bb-0310-9956-ffa450edef68
2012-04-26 21:44:51 +00:00
Jim Jagielski
5caa336986 Move away from DEFAULT_REL_RUNTIMEDIR and use ap_runtime_dir_relative()
API

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1299718 13f79535-47bb-0310-9956-ffa450edef68
2012-03-12 15:45:03 +00:00
Stefan Fritsch
92e366007c Add lots of unique tags to error log messages
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1209766 13f79535-47bb-0310-9956-ffa450edef68
2011-12-02 23:02:04 +00:00
Jim Jagielski
427c85bd23 Cleanup effort in prep for GA push:
Trim trailing whitespace... no func change



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1174751 13f79535-47bb-0310-9956-ffa450edef68
2011-09-23 13:39:32 +00:00
Eric Covener
f08932bf97 PR51371: cross-compile issues with cgi and apr_procattr_limit_*.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1172019 13f79535-47bb-0310-9956-ffa450edef68
2011-09-17 17:01:15 +00:00
Stefan Fritsch
beb3ea9c11 Add more (trace) logging to the ap_scan_script_header*() functions
Add ap_scan_script_header*_ex() functions that take a module index for
logging.
Make mod_cgi, mod_cgid, mod_proxy_fcgi, mod_proxy_scgi, mod_isapi use the
new functions.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1147493 13f79535-47bb-0310-9956-ffa450edef68
2011-07-16 21:53:18 +00:00
Stefan Fritsch
c9fd2623da Introduce ap_(get|set)_core_module_config() functions/macros and use them
everywhere.

We know that the core module has module_index 0. Therefore we can save
some pointer operations in ap_get_module_config(cv, &core_module) and
ap_set_module_config(cv, &core_module, val). As these are called rather often,
this may actually have some (small) measurable effect.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1132781 13f79535-47bb-0310-9956-ffa450edef68
2011-06-06 21:26:56 +00:00
Stefan Fritsch
65c04f6b24 Replace some "apr_p[c]alloc / memcpy" constructions into a single apr_pmemdup()s
PR: 51214
Submitted by: Christophe Jaillet <christophe jaillet wanadoo fr>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1125818 13f79535-47bb-0310-9956-ffa450edef68
2011-05-21 21:06:15 +00:00
Jeff Trawick
782c711893 fix some dead assignments found by the clang analyzer
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1098162 13f79535-47bb-0310-9956-ffa450edef68
2011-04-30 21:18:58 +00:00
Stefan Fritsch
bf07c1867c Add new ap_reserve_module_slots/ap_reserve_module_slots_directive API,
necessary if a module (like mod_perl) registers additional modules later than the
EXEC_ON_READ phase.

Tested by: Torsten Foertsch <torsten foertsch gmx net>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1096569 13f79535-47bb-0310-9956-ffa450edef68
2011-04-25 19:22:04 +00:00
Daniel Earl Poirier
eb6ad4da0a Fix typo in RLIMIT_NPROC
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1082237 13f79535-47bb-0310-9956-ffa450edef68
2011-03-16 17:58:42 +00:00
Jeff Trawick
46bdc28bf4 fix some logging calls to include the server_rec
(and even the conn_rec in a couple of places)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1074871 13f79535-47bb-0310-9956-ffa450edef68
2011-02-26 15:32:01 +00:00
Stefan Fritsch
385da96d50 Use ap_state_query() to fix many modules that were not correctly initializing
if they were not active during server startup but got enabled later during a
graceful restart (in which case they need to do all work during a single
config run).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1070153 13f79535-47bb-0310-9956-ffa450edef68
2011-02-12 21:23:56 +00:00
Igor Galić
d5024cd27c In comments: s@ XX @ XXX: @ so they can actually be found seen.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1053668 13f79535-47bb-0310-9956-ffa450edef68
2010-12-29 16:25:12 +00:00