Commit Graph

5089 Commits

Author SHA1 Message Date
Glenn Strauss 07493ea5ff [mod_cgi] move fd count to cgi_create_env() 2023-05-03 23:11:35 -04:00
Glenn Strauss cc3814db53 [core] rename http_kv funcs, reorder http_versions
rename http_kv funcs for consistency ("http_" prefix)
reorder http_versions[]
2023-05-03 23:11:35 -04:00
Glenn Strauss 8277111dbe [core] noinline stat_cache_sptree_find() 2023-05-03 23:11:35 -04:00
Glenn Strauss 6fd3fe2b63 [mod_proxy] match "map-host-response" "-" w/ Host
match "map-host-response" with authority provided in (request) Host
for "-" in response map and when no other "map-host-request" mapped
request to a different authority.  This is a bit friendlier for use
with bidirectional https-remap.
2023-05-03 23:11:35 -04:00
Glenn Strauss a5c170e341 [TLS] $SERVER["socket"] inherit global ssl.engine
$SERVER["socket"] inherits ssl.engine = "enable" from global scope

fixes issue of TLS-enabled socket, but missing config,
if ssl.engine = "enable" in global scope
and $SERVER["socket"] does not contain ssl.engine = "enable"

e.g. default TLS-enabled, and explicitly disabled on specific sockets
server.port = 443
ssl.engine = "enable"
ssl.pemfile = ...
ssl.privkey = ...
$SERVER["socket"] ==     ":80"  { ssl.engine = "disable" }
$SERVER["socket"] == "[::]:80"  { ssl.engine = "disable" }
$SERVER["socket"] == "    :443" { }
$SERVER["socket"] == "[::]:443" { }
2023-05-03 23:11:35 -04:00
Glenn Strauss 01da9c088c [core] noinline connection shutdown, reset
slightly reduces code size for less-hot code
better collects shutdown process for r->http_version > HTTP_VERSION_1_1
2023-05-03 23:11:35 -04:00
Glenn Strauss a7b7010752 [core] h1.[ch] collect some HTTP/1.x specific code 2023-05-03 23:11:35 -04:00
Glenn Strauss 58080f3382 [mod_auth] warn if auth.require path never matches
warn if auth.require path never matches due to an earlier, shorter path
2023-05-03 23:11:35 -04:00
Glenn Strauss 478d5d2f62 [meson] check FORCE_{WOLFSSL,MBEDTLS}_CRYPTO

todo: should also apply to lighttpd autoconf, CMake, SCONS builds
2023-05-03 23:11:35 -04:00
Glenn Strauss b2249d2f36 [meson] update comment with build flags 2023-05-03 23:11:35 -04:00
Glenn Strauss b706546c77 [mod_cgi] comment about caching target dirname
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.
2023-05-03 23:11:35 -04:00
Glenn Strauss fd142a53eb [core] use posix_spawn() where available
use posix_spawn() where available
use posix_spawn_file_actions_addfchdir_np() where available

Using posix_spawn() reduces initial execution overhead of CGI programs;
posix_spawn() is often faster than application code wrapping and calling
traditional fork(),execve().

(history: fdevent.c posix_spawn code based on fdio.c:fdio_ipc_spawn()
 from 2015 on one of my unpublished branches.  The inability to chdir()
 delayed inclusion in lighttpd, as the CGI specification says:
 "The current working directory for the script SHOULD be set
  to the directory containing the script."
 e.g. chdir() to target program directory before CGI execution)

posix_spawn_file_actions_addfchdir_np() is a new(er) extension supported
in glibc 2.29+, musl libc, FreeBSD ≥ 13.1, macOS ≥ 10.15 according to

POSIX Issue 8 plans to include posix_spawn_file_actions_addfchdir():
2023-05-03 23:11:35 -04:00
Glenn Strauss 5ca09e56a7 [tests] _WIN32 skip time-sensitive tests during CI 2023-05-03 23:11:35 -04:00
Glenn Strauss eae1bbac18 [build] _WIN32 shared dll build (autotools, cmake)
There are likely better and cleaner ways to do this; patches welcome.

_WIN32 symbol imports and exports

MS Visual Studio (_MSC_VER) does not appear to export global data
symbols even when exporting all functions.

Annotating any symbols with __declspec(dllexport) in any translation
unit appears to change default dll symbol implict export behavior.

Currently, src/ and CMakeLists.txt take different approaches
(implib versus linking against executable which has exported symbols)

  (improved solutions might possibly be constructed using these docs)
2023-05-03 23:11:35 -04:00
Glenn Strauss 350fda32ef [build] _WIN32 __declspec(dllexport) *_plugin_init
_WIN32 __declspec(dllexport) on mod_*_plugin_init()
2023-05-03 23:11:35 -04:00
Glenn Strauss b3ebaef3e8 [meson] static build option under cygwin
- static build option under cygwin
- _WIN32 build more modules with BUILD_STATIC
- _WIN32 remove older build config
2023-05-03 23:11:34 -04:00
Glenn Strauss 6a4cf9400f [core] _WIN32 use WSASend for writev-equiv on sock
2023-05-03 23:11:34 -04:00
Glenn Strauss 353b216d95 [cmake] _WIN32 remove older build config
(e.g. LI_DECLARE_EXPORTS is not currently used)
2023-05-03 23:11:34 -04:00
Glenn Strauss 51bed94fd7 [cmake] _WIN32 build more mods with BUILD_STATIC 2023-05-03 23:11:34 -04:00
Glenn Strauss 551e87e489 [core] _WIN32 scream UTF-8 at MS (does not matter)
alas, does not seem to make a difference;
across many core interfaces, MS handles non-ASCII UTF-8 poorly
2023-05-03 23:11:34 -04:00
Glenn Strauss 05b3d156c3 [core] _WIN32 custom fs funcs on UTF-8 paths
open(), stat(), mkdir() on UTF-8 paths

lighttpd provides large file support and 64-bit time,
so provide override to use _stati64() (and _wstati64())

Additionally, provide custom function to support stat on UTF-8 path,
which must first be converted to wide-char and _wstati64(),
since _stati64() is naive and does not properly support UTF-8.
2023-05-03 23:11:34 -04:00
Glenn Strauss 3f4e686cdc [core] _WIN32 lighttpd winsvc 2023-05-03 23:11:34 -04:00
Glenn Strauss 651e0d216c [core] _WIN32 prefer WSAPoll()
Note: TCP half-close is reported by WSAPoll() as POLLHUP event.
(e.g. TCP half-close from shutdown(fd, SHUT_WR))

TODO: If performance tests of select() vs WSAPoll() do not show a
a measurable difference, select() may be preferred over WSAPoll().

For now, make both "poll" and "select" available options in _WIN32.
(On other platforms, lighttpd build does not built code to use select()
 when poll() is available on the platform.)
2023-05-03 23:11:34 -04:00
Glenn Strauss a3bf0cd22e [core] _WIN32 close chunk temp files before unlink 2023-05-03 23:11:34 -04:00
Glenn Strauss 5db8a01e4d [tests] _WIN32 close files before unlink
Also, adjust mod_ssi to remove assumption that "/tmp" is temp directory
2023-05-03 23:11:34 -04:00
Glenn Strauss 699e0e4631 [mod_dirlisting] _WIN32 close files before unlink 2023-05-03 23:11:34 -04:00
Glenn Strauss 88607b497b [mod_deflate] _WIN32 disable deflate.cache-dir
_WIN32 disable deflate.cache-dir due to NTFS filesystem limitations
deflate.cache-dir renames files into place and this fails if the
files are open (source or destination).  deflate.cache-dir would
have to be reworked to fail gracefully and continue serving request
if the final rename fails.
2023-05-03 23:11:34 -04:00
Glenn Strauss 06050c7d99 [tests] _WIN32 cygwin test support 2023-05-03 23:11:34 -04:00
Glenn Strauss b5a691b27a [core] _WIN32 stat(), '/' and '\\' adjustments
The adjustments are minimal; not intended to be complete.
2023-05-03 23:11:34 -04:00
Glenn Strauss 186c28bd10 [multiple] _WIN32 use fdevent_kill() 2023-05-03 23:11:34 -04:00
Glenn Strauss c6f021b2ec [core] _WIN32 fdevent_kill() 2023-05-03 23:11:34 -04:00
Glenn Strauss e3c97fc2c2 [core] _WIN32 use rand_s() to init pseudo RNG 2023-05-03 23:11:34 -04:00
Glenn Strauss cf85bc56df [core] _WIN32 use log_serror() for WSAGetLastError 2023-05-03 23:11:34 -04:00
Glenn Strauss bbb54cf1bf [core] _WIN32 log_serror() for WSAGetLastError() 2023-05-03 23:11:34 -04:00
Glenn Strauss b9c0424514 [core] _WIN32 log_perror() with GetLastError() 2023-05-03 23:11:34 -04:00
Glenn Strauss 7553c09da9 [core] _WIN32 reset std streams at startup 2023-05-03 23:11:34 -04:00
Glenn Strauss 57d40773c2 [tests] _WIN32 adjustments in
separate cygwin paths from Windows native paths
2023-05-03 23:11:34 -04:00
Glenn Strauss 58d557219f [multiple] __MINGW32__ missing strftime() "%F %T"
mingw does not support strftime() "%F %T"
2023-05-03 23:11:34 -04:00
Glenn Strauss c2540871fb [build] _WIN32 mingw build
use -lws2_32 instead of -lwsock32
2023-05-03 23:11:34 -04:00
Glenn Strauss b86d4117be [tests] _WIN32 use TMPDIR (or TEMP) for test files 2023-05-03 23:11:34 -04:00
Glenn Strauss 96c1b1ddc1 [core] _WIN32 casts to quiet some VS warnings 2023-05-03 23:11:34 -04:00
Glenn Strauss 5e5ba0408a [core] _WIN32 rename __WIN32 to _WIN32 2023-05-03 23:11:34 -04:00
Glenn Strauss 79752c5ffe [tests] _WIN32 fcgi-responder.c, scgi-responder.c 2023-05-03 23:11:34 -04:00
Glenn Strauss de8bf2863d [core] _WIN32 basic (very limited) getopt() impl 2023-05-03 23:11:34 -04:00
Glenn Strauss 8e4718ac0b [core] _WIN32 alternative fdarray for Windows
_WIN32 SOCKET (long long unsigned) handles are assigned differently
from how POSIX allocates file descriptors (lowest number available).

On _WIN32, the SOCKET descriptor should not be used to index an array
of (fdnode *), so this commit provides an alternative method to store
(fdnode *) for use by select() and by WSAPoll().

select(): commonly used unix select() idioms may be incorrect on _WIN32

As of Windows 10 version 2004, when a TCP socket fails to connect,
(note: this was broken in WSAPoll() in all earlier Windows versions)
2023-05-03 23:11:34 -04:00
Glenn Strauss 635560092f [core] _WIN32 clock ticks and time 2023-05-03 23:11:34 -04:00
Glenn Strauss 00877719ff [mod_cgi] _WIN32 use socketpair instead of pipe
_WIN32 select(), WSAPoll() operate only on sockets
2023-05-03 23:11:34 -04:00
Glenn Strauss 707febe286 [core] _WIN32 check WSAGetLastError() w/ sockets
check WSAGetLastError() after socket operations return non-zero

Notably, MS winsock2 returns WSAEWOULDBLOCK instead of WSAEINPROGRESS
for connect() if socket is configured nonblocking
2023-05-03 23:11:34 -04:00
Glenn Strauss abaf0a5f4d [core] _WIN32 socket-compat, filesystem-compat
_WIN32 is sufficiently different -- *different*; not better -- that
isolating _WIN32 code is clearer than #ifdef _WIN32 in almost every
func in fdevent.c

_WIN32-specific fdevent_socket_* funcs
  _WIN32 SOCKET fds must be closed with closesocket(), not close()
_WIN32 use _sopen_s() without _O_TEMPORARY
  Use _sopen_s() without _O_TEMPORARY in fdevent_mkostemp().
  _O_TEMPORARY would remove file once last handle to file is closed.
  Temporary files in chunkqueue may be closed for large request/response
_WIN32 fdevent_rename() using MoveFileExA
  _WIN32 rename() fails if the target file already exists.
  Alternatives are MoveFileExA() or ReplaceFileA().
  Both of the above fail if either oldfile or newfile are open, so
  - not atomic
  - may fail sporadically
2023-05-03 23:11:34 -04:00
Glenn Strauss 9b9dd8efaf [core] _WIN32 fdevent_createprocess() 2023-05-03 23:11:34 -04:00