aboutsummaryrefslogtreecommitdiff
path: root/networking/httpd.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'busybox' into mergeRon Yorston2026-03-111-1/+1
|\
| * *: placate warnings where strchr/strstr returns constant pointerDenys Vlasenko2026-02-151-1/+1
| | | | | | | | | | | | | | | | | | Newer glibc is now smarter and can propagate const-ness from those! function old new delta readtoken1 3111 3108 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2026-02-101-14/+29
|\|
| * httpd: handle bare "Location: URL" redirects from CGIsDenys Vlasenko2026-01-281-14/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Many sites on the Web give those as valid CGI examples - no "Status:", just "Location:". function old new delta cgi_io_loop_and_exit 620 684 +64 log_cgi_status - 49 +49 .rodata 106846 106861 +15 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 128/0) Total: 128 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2026-02-041-24/+28
|\|
| * httpd: add a TODO, no code changesDenys Vlasenko2026-01-251-0/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: allow static files in /cgi-bin/, do not search for interpreter twiceDenys Vlasenko2026-01-241-24/+25
| | | | | | | | | | | | | | | | | | | | function old new delta handle_incoming_and_exit 2270 2334 +64 send_cgi_and_exit 790 754 -36 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 64/-36) Total: 28 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2026-02-021-220/+489
|\|
| * httpd: code shrinkDenys Vlasenko2026-01-241-18/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta send_file_and_exit 931 933 +2 get_line 126 120 -6 httpd_main 968 959 -9 send_headers 708 694 -14 handle_incoming_and_exit 2285 2270 -15 cgi_io_loop_and_exit 635 620 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/5 up/down: 2/-59) Total: -57 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: code shrink via "split-globals" trickDenys Vlasenko2026-01-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta httpd_main 957 968 +11 log_and_exit 25 26 +1 send_headers 712 708 -4 handle_incoming_and_exit 2292 2285 -7 sigalrm_handler 102 93 -9 parse_conf 1332 1323 -9 send_cgi_and_exit 803 790 -13 cgi_io_loop_and_exit 656 635 -21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/6 up/down: 12/-63) Total: -51 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: implement POSTDATA read timeout, and -K KILLSECS CGI lifetime controlDenys Vlasenko2026-01-241-59/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta cgi_io_loop_and_exit 496 656 +160 sigalrm_handler 1 102 +101 .rodata 106814 106853 +39 send_cgi_and_exit 770 803 +33 packed_usage 35894 35924 +30 httpd_main 950 957 +7 handle_incoming_and_exit 2297 2292 -5 send_REQUEST_TIMEOUT_and_exit 10 - -10 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 6/1 up/down: 370/-15) Total: 355 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: fix incorrect == comparison in last commit, must be !=Denys Vlasenko2026-01-231-1/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: smarter handling of CGI's "Status: " headerDenys Vlasenko2026-01-231-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Do one less write() function old new delta handle_incoming_and_exit 2290 2297 +7 cgi_io_loop_and_exit 498 500 +2 .rodata 106821 106814 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 9/-7) Total: 2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: simplify CGI headers handling, check "HTTP/1.1" prefix, not just "HTTP"Denys Vlasenko2026-01-231-28/+30
| | | | | | | | | | | | | | | | | | | | function old new delta cgi_io_loop_and_exit 477 498 +21 .rodata 106830 106821 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 21/-9) Total: 12 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: simplify CGI code a bit, add a bunch of TODOs and FIXMEsDenys Vlasenko2026-01-231-27/+35
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta log_and_exit 33 25 -8 handle_incoming_and_exit 2298 2290 -8 send_cgi_and_exit 784 770 -14 cgi_io_loop_and_exit 538 477 -61 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-91) Total: -91 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: do not force clean connection termination on write errors and timeoutsDenys Vlasenko2026-01-221-24/+45
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta send_file_and_exit 891 931 +40 send_EOF_and_exit - 14 +14 cgi_io_loop_and_exit 535 538 +3 log_and_exit 44 33 -11 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/1 up/down: 57/-11) Total: 46 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: make timeout messages less confusingDenys Vlasenko2026-01-221-6/+10
| | | | | | | | | | | | | | function old new delta send_file_and_exit 891 930 +39 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: time out data writes after 60 seconds of no progressDenys Vlasenko2026-01-221-13/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta prepare_write_timeout - 29 +29 static.tv - 16 +16 httpd_main 939 950 +11 send_file_and_exit 887 891 +4 handle_incoming_and_exit 2306 2298 -8 cgi_io_loop_and_exit 552 535 -17 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/2 up/down: 60/-25) Total: 35 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: optimize header reading timeout codeDenys Vlasenko2026-01-221-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set up the signal handler once, outside of main loop. Do not reset the timer if headers are big - they still are expected to arrive quickly. function old new delta httpd_main 913 939 +26 handle_incoming_and_exit 2312 2306 -6 get_line 134 126 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 26/-14) Total: 12 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: when reading headers, abort if they are too longDenys Vlasenko2026-01-221-7/+9
| | | | | | | | | | | | | | function old new delta get_line 130 134 +4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: reject request line and headers with control charsDenys Vlasenko2026-01-221-0/+12
| | | | | | | | | | | | | | | | | | This removes the need to check various corner cases later. function old new delta get_line 108 130 +22 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: allow http2 requests if proxying, tighten METHOD checksDenys Vlasenko2026-01-221-9/+16
| | | | | | | | | | | | | | | | | | | | function old new delta handle_incoming_and_exit 2264 2312 +48 httpd_main 915 913 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 48/-2) Total: 46 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: fix compilation script of httpd_ratelimit_cgi.cDenys Vlasenko2026-01-221-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: add -M MAXCONN - do not accept unlimited number of connectionsDenys Vlasenko2026-01-221-19/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were lacking even basic rate-limiting. function old new delta httpd_main 648 915 +267 handle_incoming_and_exit 2235 2264 +29 packed_usage 35868 35894 +26 cgi_io_loop_and_exit 537 552 +15 send_headers 704 712 +8 get_line 106 108 +2 .rodata 106829 106830 +1 send_file_and_exit 890 887 -3 mini_httpd 161 - -161 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 7/1 up/down: 348/-164) Total: 184 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: stop disabling/enabling SIGHUP in every childDenys Vlasenko2026-01-211-8/+13
| | | | | | | | | | | | | | | | | | | | function old new delta sighup_handler 30 47 +17 httpd_main 710 695 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 17/-15) Total: 2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: remove one close() from main loopDenys Vlasenko2026-01-211-5/+6
| | | | | | | | | | | | | | function old new delta httpd_main 701 710 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: expand logging: now can see what CGIs are startedDenys Vlasenko2026-01-211-26/+45
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta send_cgi_and_exit 711 784 +73 vmstat_main 657 708 +51 .rodata 106746 106778 +32 send_file_and_exit 877 887 +10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 166/0) Total: 166 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2025-08-121-1/+1
|\|
| * libbb: add yescrypt password hashing supportDenys Vlasenko2025-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It seems to work, but not at all optimized for size. The extra copy of sha256 code need to be removed. The yescrypt code in libbb/yescrypt/* is adapted from libxcrypt-4.4.38 with minimal edits, hopefully making it easier to track backports by resetting the tree to this commit, then comparing changes in upstream libxcrypt to the tree. function old new delta blockmix_xor_save - 7050 +7050 static.blockmix_xor - 6475 +6475 blockmix - 3390 +3390 SHA256_Transform - 3083 +3083 yescrypt_kdf_body - 1724 +1724 PBKDF2_SHA256 - 1003 +1003 smix1 - 960 +960 yescrypt_r - 890 +890 salsa20 - 804 +804 smix - 790 +790 smix2 - 659 +659 blockmix_salsa8_xor - 601 +601 yescrypt_kdf - 479 +479 blockmix_salsa8 - 415 +415 Krnd - 256 +256 _HMAC_SHA256_Init - 213 +213 _SHA256_Update - 198 +198 _SHA256_Final - 195 +195 decode64_uint32 - 166 +166 encode64 - 153 +153 decode64 - 136 +136 libcperciva_HMAC_SHA256_Buf - 132 +132 SHA256_Pad_Almost - 131 +131 salsa20_simd_unshuffle - 101 +101 salsa20_simd_shuffle - 101 +101 yes_crypt - 90 +90 libcperciva_SHA256_Buf - 86 +86 crypt_make_rand64encoded - 85 +85 static.atoi64_partial - 77 +77 alloc_region - 72 +72 ascii64 - 65 +65 PAD - 64 +64 _HMAC_SHA256_Final - 55 +55 static.cpu_to_be32_vect - 51 +51 free_region - 47 +47 libcperciva_SHA256_Init - 37 +37 yescrypt_init_local - 34 +34 crypt_make_pw_salt 92 125 +33 initial_state - 32 +32 .rodata 105771 105803 +32 atoi64 - 25 +25 explicit_bzero - 22 +22 pw_encrypt 920 941 +21 yescrypt_free_local - 9 +9 crypt_make_salt 85 - -85 ------------------------------------------------------------------------------ (add/remove: 43/1 grow/shrink: 3/0 up/down: 31042/-85) Total: 30957 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: code shrink system drive handlingRon Yorston2024-07-071-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous commit (e3bfe3695) revised the use of getsysdir() to obtain the system directory, and hence the system drive. See the commit message for the history to that point. Further improvements are possible: - Remove getsysdir() and push the calls to GetSystemDirectory() down into get_system_drive() and get_proc_addr(). - Check the return value of GetSystemDirectory(). It's unlikely to fail, but better safe than sorry. - Instead of making all callers of get_system_drive() check for a NULL return value always return a non-NULL pointer. If the drive can't be found an empty string is returned instead (which is what the callers were using anyway). - The function need_system_drive() was only used in one place (in httpd). Move the code there and remove the function. - Use concat_path_file() where possible. Saves 76-144 bytes.
* | build system: avoid full rebuild when EXTRAVERSION changesRon Yorston2024-02-161-0/+3
| | | | | | | | | | | | | | | | | | | | The last two commits allow EXTRAVERSION to track the current state of a git repository. The build system was unable to determine which files were affected by changes to EXTRAVERSION and caused a full rebuild when it changed. Alter how the version information is passed to the code so only a handful of files need to be rebuilt when it changes.
* | httpd: enable interpreter script featureRon Yorston2024-02-111-10/+30
| | | | | | | | | | | | | | | | | | | | | | | | The web server in BusyBox has an optional feature to allow pages with a given suffix to be processed by a script interpreter: PHP, for example. Enable this in the busybox-w32 build. Costs 256-320 bytes. (GitHub issue #266)
* | httpd: code shrinkRon Yorston2024-02-111-10/+7
| | | | | | | | | | | | | | | | | | | | When setting up the arguments for the CGI handler: - Use '-I0' rather than two separate arguments. - Use memcpy() to copy the server arguments. Saves 32 bytes.
* | httpd: avoid unnecessary process creationRon Yorston2024-02-091-3/+4
| | | | | | | | | | | | | | | | | | | | | | The httpd server made unnecessary calls to detach from the console. Avoiding this saves one process creation when a file is being served and two for a CGI script. Then again, commit ad4bd5bbd (win32: avoid console windows from CGI scripts) results in a console host always being created for a CGI script even if it turns out to be unnecessary. So the net saving is only one process for CGI scripts.
* | httpd: enable support for CGIRon Yorston2023-12-201-7/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The upstream code uses fork/exec when running a CGI process. Emulate this by: - Spawning a child httpd process with the special '-I 0' option, along with the options provided on the server command line. This sets up the proper state then calls the cgi_handler() function. - The cgi_handler() function fixes the pipe file descriptors and starts another child process to run the CGI script. These processes are detached from the console on creation. When spawn() functions are run in P_DETACH mode they don't connect to the standard file descriptors. Normally this doesn't matter but the process which runs the CGI scripts needs to inherit the pipe endpoints. The create_detached_process() function handles this. See: https://github.com/rprichard/win32-console-docs/blob/master/README.md Adds about 2.9Kb to the size of the binary. (GitHub issue #266)
* | httpd: fix return code when run in backgroundRon Yorston2023-12-151-3/+1
| | | | | | | | | | | | | | | | | | | | | | When httpd was run in the background the return code of the parent process was incorrect. It seems when spawn() is run in _P_DETACH mode it returns 0 on success, not a process handle. Fix the test for the return code and alter mingw_spawn_detach() so it doesn't treat the return from spawn() as a handle. Saves 32 bytes.
* | win32: code shrink copying of argvRon Yorston2023-04-281-6/+4
| | | | | | | | | | | | | | There are two places where a copy of an argv array is made with extra space at the start. Move this code into a function. Saves 56-64 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2023-04-091-37/+39
|\|
| * libbb: consolidate NOMMU fix of restoring high bit in argv[0][0]Denys Vlasenko2023-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | function old new delta fork_or_rexec 46 56 +10 bootchartd_main 1087 1079 -8 cpio_main 674 661 -13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-21) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: do not mangle cgi-bin/SCRIPT/params URLsDenys Vlasenko2023-03-281-36/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | If cgi-bin/ prefix is seen, do not test the rest for existence, whether it's a dir, and such. function old new delta handle_incoming_and_exit 2200 2212 +12 Reported here: https://lists.zx2c4.com/pipermail/cgit/2023-March/004825.html Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: add fake HUP and QUIT signalsRon Yorston2023-04-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | It's fairly common for shell scripts to trap this set of signals: EXIT HUP INT QUIT TERM (or the numeric equivalent: 0 1 2 3 15) Add definitions for SIGHUP and SIGQUIT. We don't take any action if traps are defined for them, but at least scripts won't fail. (GitHub issue #303)
* | Merge busybox into mergeRon Yorston2022-02-091-2/+1
|\| | | | | | | | | | | | | | | Fix conflicts in reset and ash. Redefine the new safe_read_key() as a reference to read_key(). Disable SHA256_HWACCEL.
| * libbb: introduce and use chdir_or_warn()Denys Vlasenko2022-01-131-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta chdir_or_warn - 37 +37 send_cgi_and_exit 720 711 -9 xchdir 27 15 -12 setup_environment 233 217 -16 fork_job 449 433 -16 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/4 up/down: 37/-53) Total: -16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge busybox into mergeRon Yorston2022-01-061-1/+1
|\| | | | | | | | | | | Fix merge conflict in miscutils/less.c. Use exit_SUCCESS() where possible.
* | Merge busybox into mergeRon Yorston2021-12-271-1/+6
|\| | | | | | | Fix merge conflict in coreutils/timeout.c.
| * httpd: fix compile failure if !FEATURE_HTTPD_RANGESDenys Vlasenko2021-12-261-0/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: do not send Last-Modified / ETag / Content-Length for error pagesDenys Vlasenko2021-12-171-20/+14
| | | | | | | | | | | | | | | | function old new delta send_headers 713 701 -12 send_headers_and_exit 20 34 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: don't send Content-Length in error pages headerDenys Vlasenko2021-12-171-14/+21
| | | | | | | | | | | | | | function old new delta send_headers 701 713 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-10-131-3/+6
|\|
| * httpd: if range is not specified, correctly fall back to read/write loopDenys Vlasenko2021-10-081-2/+5
| | | | | | | | | | | | | | | | | | | | | | range_start was staying -1, and comparison meant to detect "is it the first sendfile that failed, or not the first?" was making incorrect decision. The result: nothing is sent. function old new delta send_file_and_exit 865 877 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>