summaryrefslogtreecommitdiff
path: root/src/mod_cgi.c
Commit message (Collapse)AuthorAgeFilesLines
* [mod_cgi] reset upload_temp_file_size in CGI closeGlenn Strauss2023-05-031-2/+6
| | | | reset upload_temp_file_size in cgi_connection_close if p->tempfile_accum
* [mod_cgi] reuse fd already opened to /dev/nullGlenn Strauss2023-05-031-4/+11
| | | | | | lighttpd STDIN_FILENO is reopened to /dev/null at server startup Let CGI inherit fd STDIN_FILENO when (0 == r->reqbody_length)
* [mod_cgi] doubly-linked list of CGI pidsGlenn Strauss2023-05-031-0/+2
| | | | (issue in lighttpd 1.4.60 - 1.4.69)
* [mod_cgi] cgi_create_err() cold err handling funcGlenn Strauss2023-05-031-73/+64
| | | | | collect error handling code for cgi_create_env() (for code reuse and consistency; also reduces code size)
* [mod_cgi] do not issue trace if CGI closes inputGlenn Strauss2023-05-031-0/+8
| | | | It is not necessarily an error for CGI to close its input early
* [mod_cgi] reduce code sizeGlenn Strauss2023-05-031-9/+8
| | | | | | | .text segment was slightly over (2) 4k pages; tweak code to be slightly less than (2) 4k pages (when compiled optimized -O2) (likely smaller when compiled -Os)
* [mod_cgi] move fd count to cgi_create_env()Glenn Strauss2023-05-031-8/+5
|
* [mod_cgi] comment about caching target dirnameGlenn Strauss2023-05-031-0/+17
| | | | | | | comment code about caching target dirname using stat_cache In simple performance tests, using stat_cache here makes little difference, as the overhead of process creation is orders of magnitude larger.
* [build] _WIN32 __declspec(dllexport) *_plugin_initGlenn Strauss2023-05-031-0/+1
| | | | _WIN32 __declspec(dllexport) on mod_*_plugin_init()
* [tests] _WIN32 cygwin test supportGlenn Strauss2023-05-031-2/+22
|
* [multiple] _WIN32 use fdevent_kill()Glenn Strauss2023-05-031-5/+1
|
* [core] _WIN32 use log_serror() for WSAGetLastErrorGlenn Strauss2023-05-031-2/+2
|
* [mod_cgi] _WIN32 use socketpair instead of pipeGlenn Strauss2023-05-031-30/+67
| | | | _WIN32 select(), WSAPoll() operate only on sockets
* [core] _WIN32 fdevent_createprocess()Glenn Strauss2023-05-031-7/+16
|
* [core] _WIN32 sys-wait.h to wrap <sys/wait.h>Glenn Strauss2023-05-031-0/+1
|
* [core] _WIN32 sys-unistd.h to wrap <unistd.h>Glenn Strauss2023-05-031-4/+1
| | | | (selective implementations; not complete)
* [core] _WIN32 signal-related compatGlenn Strauss2023-05-031-2/+23
| | | | Note: behavior under bash.exe might be different than under cmd.exe
* [multiple] _WIN32 protect code w/ HAVE_FORKGlenn Strauss2023-05-031-0/+4
| | | | wrap fork() and kill()
* [multiple] optimistic client read only if HTTP/1.xGlenn Strauss2023-05-031-1/+2
| | | | skip optimistic client read if http version >= HTTP/2
* [core] HTTP_VERSION_3 enum valueGlenn Strauss2023-04-291-1/+2
|
* [mod_cgi] cygwin supports CGI file I/O redirectionGlenn Strauss2023-02-041-2/+0
| | | | remove the special-case which disabled this for issue in older cygwin
* [core] pass fdn to fdevent_sched_close,_unregisterGlenn Strauss2023-01-231-4/+4
| | | | remove issock flag; on _WIN32, select(), WSAPoll() work only on sockets
* [multiple] employ ck_calloc, ck_malloc shared codeGlenn Strauss2022-12-101-14/+4
| | | | | employ ck_calloc(), ck_malloc() shared code to slightly reduce code size (centralize the ck_assert() to check that memory allocation succeeded)
* [multiple] mark mod_*_plugin_init() funcs coldGlenn Strauss2022-12-071-0/+1
|
* [mod_proxy,mod_cgi] fix dummy Sec-WebSocket-KeyShulyaka2022-10-231-1/+1
| | | | | | | | | | fix dummy Sec-WebSocket-Key value to remove excess '\n' x-ref: "Fix websocket HTTP/2 to HTTP/1.1 proxy" https://github.com/lighttpd/lighttpd1.4/pull/123 github: closes #123
* [core] manually calculate off_t max (fixes #3171)Glenn Strauss2022-09-151-1/+2
| | | | | | | | | | | | | manually calculate off_t max for broken cross-compilation systems which fail to enable large file support (so sizeof(off_t) != sizeof(int64_t)) If sizeof(off_t) != sizeof(int64_t), a negative number could end up in cq->upload_temp_file_size when it was assigned INTMAX_MAX, leading to excessive new temporary file creation occurring on each and every write. x-ref: "File upload regression with --disable-lfs" https://redmine.lighttpd.net/issues/3171
* [mod_cgi] fix detection of failing error handler (fixes #3157)Glenn Strauss2022-05-171-0/+1
| | | | | | | | | | | | | | | | (thx sparlane) failing error handler produced no output and POLLRDHUP received with POLLIN. commit dd23fcb2 changed return value from HANDER_FINISHED to HANDLER_GO_ON when introducing cgi_process_rd_revents(), and POLLRDHUP case which previously fell through needed to continue to return HANDLER_FINISHED after calling cgi_connection_close() x-ref: "fall-back with cgi error handler no longer works" https://redmine.lighttpd.net/issues/3157
* [mod_cgi] immed start CGI if UpgradeGlenn Strauss2022-03-251-4/+5
|
* [mod_cgi] disable input optim if might UpgradeGlenn Strauss2022-03-251-6/+14
| | | | | | | | (thx pegasus) disable CGI stdin input optimizations if CGI might Upgrade connection, since if we upgrade protocols, the original Content-Length -- expected to be 0 for Upgrade -- does not represent the end of the input.
* [multiple] immed connect to backend for streamingGlenn Strauss2022-03-251-11/+9
| | | | | | connect to backend (mod_cgi, mod_proxy, mod_sockproxy, mod_wstunnel) for streaming request body without waiting for initial data in request body. Useful for things like websockets when data starts on server-side
* [multiple] WebSockets over HTTP/2 (fixes #3151)Glenn Strauss2022-03-251-3/+57
| | | | | | | | | | | | | | | | | Add support for WebSockets over HTTP/2 to lighttpd core and to mod_cgi w/ config: cgi.upgrade = "enable" mod_proxy w/ config: proxy.header += ("upgrade" => "enable") mod_wstunnel HTTP/2 CONNECT extension defined in RFC8441 is translated to HTTP/1.1 'Upgrade: websocket' requests to mod_cgi or mod_proxy, and is handled directly in mod_wstunnel. x-ref: WebSockets over HTTP/2 https://redmine.lighttpd.net/issues/3151 Bootstrapping WebSockets with HTTP/2 https://datatracker.ietf.org/doc/html/rfc8441
* [mod_cgi] cgi.local-redir request_reset thru fnptrGlenn Strauss2022-02-191-1/+1
| | | | | | | cgi.local-redir call plugins_request_reset through fn ptr (isolate plugins_* funcs to server; should not be called directly from plugins/modules)
* [multiple] remove buffer_init_string()Glenn Strauss2022-01-071-3/+3
| | | | remove (minor) convenience func; easy to replace
* [mod_cgi] check fd-to-cgi not -1 before closeGlenn Strauss2021-11-041-0/+1
| | | | sanity check
* [core] thwart h2c smuggling when Upgrade enabledGlenn Strauss2021-10-271-4/+7
| | | | | | | | | | | | | | | | | Existing behavior: mod_proxy *does not* forward Upgrade header unless explicitly enabled in lighttpd.conf (default: not enabled) (proxy.header += ("upgrade" => "enable")) mod_cgi previously used to forward Upgrade request header, but would remove Upgrade response header if cgi.upgrade was not explicitly enabled (cgi.upgrade = "enable") This patch thwarts h2c smuggling when lighttpd.conf has also been explicitly configured to pass "Upgrade" request header x-ref: "h2c Smuggling: Request Smuggling Via HTTP/2 Cleartext (h2c)" https://labs.bishopfox.com/tech-blog/h2c-smuggling-request-smuggling-via-http/2-cleartext-h2c
* [mod_cgi] improve chunk buffer reuse from backendsGlenn Strauss2021-09-301-24/+41
| | | | | mark and temporarily defer event handling of backend events in order to handle at same time as the associated front-end connection events
* [multiple] check feature flags funcs; code reuseGlenn Strauss2021-09-301-5/+1
| | | | | config_feature_bool() config_feature_int()
* [multiple] _WIN32 fdevent_pipe_cloexec()Glenn Strauss2021-09-301-17/+7
| | | | | | Note: Under _WIN32, serious limitation in Windows APIs: select() and WSAPoll() operate only on sockets (not pipes) (directly affects mod_cgi; not currently handled)
* [multiple] internal control for backend read bytesGlenn Strauss2021-09-281-0/+7
| | | | | | | | | | | | | separate internal control for backend max_per_read When not streaming, large reads will be flushed to temp files on disk. When streaming, use a smaller buffer to help reduce memory usage. When not streaming, attempt to read and empty kernel socket bufs. (e.g. MAX_READ_LIMIT 256k) When writing to sockets (or pipes) attempt to fill kernel socket bufs. (e.g. MAX_WRITE_LIMIT 256k)
* [multiple] de-dup file and piped loggers (fixes #3101)Glenn Strauss2021-09-131-1/+2
| | | | | | | | de-dup file and piped loggers for error logs and access logs x-ref: "RFE: de-dup file and piped loggers" https://redmine.lighttpd.net/issues/3101
* [multiple] quiet coverity warningsGlenn Strauss2021-09-091-0/+3
|
* [mod_cgi] cgi.limits "tcp-fin-propagate" => "SIG"Glenn Strauss2021-09-081-7/+92
| | | | | | | cgi.limits += ("tcp-fin-propagate" => "<signal>") (e.g. "SIGTERM") send specified signal to CGI if TCP FIN is received from client (default: do not send signal to CGI)
* [core] remove server.upload-temp-file-size limitGlenn Strauss2021-09-081-5/+1
| | | | | | previously undocumented server.upload-temp-file-size in lighttpd 1.4.38 preceded introduction of lighttpd streaming options in lighttpd 1.4.40 (server.stream-request-body and server.stream-response-body)
* [mod_cgi] improve CGI offloadingGlenn Strauss2021-09-081-12/+79
| | | | | | | | | | | improve CGI offloading when not streaming request body If not streaming request body, collect request body into single tempfile and use fd to tempfile as stdin to CGI (in lieu of input pipe()). For prior behavior, set the following config option, enabled by default: server.feature-flags += ("cgi.tempfile-accum" => "disable") If there is no request body, open /dev/null instead of creating pipe().
* [mod_cgi] use linked list for process listGlenn Strauss2021-09-081-56/+52
| | | | | (avoids persistent memory allocation for list struct) (reduce possibility of long-term memory fragmentation due to mod_cgi)
* [mod_cgi] reuse chunk buffersGlenn Strauss2021-09-081-37/+41
| | | | | reuse chunk buffers rather than persistent allocated memory (reduce possibility of long-term memory fragmentation due to mod_cgi)
* [core] remove connection_list_append()Glenn Strauss2021-09-081-1/+0
| | | | | | | | | | | | merge connection_list_append() into connection_fdwaitqueue_append() (not converted to singly-linked-list since fdwaitqueue is not expected to be used during normal operation (except extreme overload condition), so use allocated list of pointers (allocated when needed) instead of adding ptr member to (every) allocated struct connection) remove connections-glue.c remove inclusion of connections.h by non-base files
* [mod_cgi] cgi.limits "read-timeout" "write-timeout" (#3086)Glenn Strauss2021-09-081-1/+116
| | | | | | | | | | | implement write(), read() timeouts for CGI "write-timeout" "read-timeout" x-ref: "sockets disabled, out-of-fds with proxy module" https://redmine.lighttpd.net/issues/3086
* [core] quiet compiler warningsGlenn Strauss2021-09-041-2/+1
| | | | | | | | | | cast away signedness warning in request_check_hostname() mod_gnutls https_add_ssl_client_entries crts allocated if crt_size != 0 (which is already checked earlier in routine) report from FaceBook Infer static analysis tool (https://fbinfer.com/) - quiet dead store warnings - check return != NULL from allocation funcs
* [multiple] reduce redundant NULL buffer checksGlenn Strauss2021-08-271-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a large set of code changes and results in removal of hundreds, perhaps thousands, of CPU instructions, a portion of which are on hot code paths. Most (buffer *) used by lighttpd are not NULL, especially since buffers were inlined into numerous larger structs such as request_st and chunk. In the small number of instances where that is not the case, a NULL check is often performed earlier in a function where that buffer is later used with a buffer_* func. In the handful of cases that remained, a NULL check was added, e.g. with r->http_host and r->conf.server_tag. - check for empty strings at config time and set value to NULL if blank string will be ignored at runtime; at runtime, simple pointer check for NULL can be used to check for a value that has been set and is not blank ("") - use buffer_is_blank() instead of buffer_string_is_empty(), and use buffer_is_unset() instead of buffer_is_empty(), where buffer is known not to be NULL so that NULL check can be skipped - use buffer_clen() instead of buffer_string_length() when buffer is known not to be NULL (to avoid NULL check at runtime) - use buffer_truncate() instead of buffer_string_set_length() to truncate string, and use buffer_extend() to extend Examples where buffer known not to be NULL: - cpv->v.b from config_plugin_values_init is not NULL if T_CONFIG_BOOL (though we might set it to NULL if buffer_is_blank(cpv->v.b)) - address of buffer is arg (&foo) (compiler optimizer detects this in most, but not all, cases) - buffer is checked for NULL earlier in func - buffer is accessed in same scope without a NULL check (e.g. b->ptr) internal behavior change: callers must not pass a NULL buffer to some funcs. - buffer_init_buffer() requires non-null args - buffer_copy_buffer() requires non-null args - buffer_append_string_buffer() requires non-null args - buffer_string_space() requires non-null arg