Commit graph

18146 commits

Author SHA1 Message Date
Denys Vlasenko
56143ea63f ash: code shrink: eliminate pstrcmp1()
function                                             old     new   delta
find_command                                         961     963      +2
evalcommand                                         1631    1633      +2
hashcmd                                              299     300      +1
describe_command                                     320     321      +1
clearcmdentry                                         93      94      +1
cdcmd                                                695     696      +1
pstrcmp1                                              16       -     -16
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 6/0 up/down: 8/-16)              Total: -8 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 09:23:54 +01:00
Denys Vlasenko
758c948a63 ash: remove non-standard chdir builtin
function                                             old     new   delta
.rodata                                           106853  106846      -7
builtintab                                           352     344      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-15)             Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 01:34:13 +01:00
Denys Vlasenko
77d242d7ac ash: get rid of a static in cmdlookup()/delete_cmd_entry()
function                                             old     new   delta
cmdlookup_pp                                           -     120    +120
find_command                                         953     961      +8
unsetcmd                                              74      76      +2
hashcmd                                              297     299      +2
lastcmdentry                                           4       -      -4
delete_cmd_entry                                      47      43      -4
cmdlookup                                            132       -    -132
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 3/1 up/down: 132/-140)           Total: -8 bytes
   text	   data	    bss	    dec	    hex	filename
  47470	      8	    149	  47627	   ba0b	shell/ash.o.orig
  47466	      8	    145	  47619	   ba03	shell/ash.o

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 01:01:15 +01:00
Denys Vlasenko
2051c69358 ash: group command hashing/searching code together, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 00:34:22 +01:00
Denys Vlasenko
e05b922c89 ash: move casematch() directly to its only caller, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 23:44:06 +01:00
Denys Vlasenko
c9af9073b8 ash: reorder functions to reduce forward declarations, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 17:08:12 +01:00
Denys Vlasenko
b715e82e1f ash: JOBSTOPPED can only be set if job control is compiled in - conditionalize code which depends on it
With !ASH_JOB_CONTROL:

function                                             old     new   delta
cmdloop                                              363     351     -12
exitcmd                                               47      31     -16
.rodata                                           106422  106398     -24
stoppedjobs                                           58       -     -58
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/3 up/down: 0/-110)           Total: -110 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 13:15:14 +01:00
Denys Vlasenko
dee0168219 ash: reorder functions to reduce forward declarations, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 13:15:13 +01:00
Denys Vlasenko
97a7813971 ash: move applet handling out of tryexec() - making it similar to dash
function                                             old     new   delta
tryexec                                                -      60     +60
shellexec                                            476     349    -127
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 60/-127)           Total: -67 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 11:17:38 +01:00
Denys Vlasenko
e4f4bf95ac doc: update docs/nofork_noexec.txt
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 08:13:42 +01:00
Denys Vlasenko
22b96c0ddf ash: unset traps before entering NOEXEC programs after [v]fork
If we don't do that, if INT trap was set, ^C will set a flag
"run trap later" and _return_, which is not expected by the NOFORK!

function                                             old     new   delta
clear_traps                                            -     107    +107
evalcommand                                         1617    1631     +14
shellexec                                            471     476      +5
setsignal                                            333     327      -6
forkchild                                            620     480    -140
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 126/-146)          Total: -20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 08:03:15 +01:00
Denys Vlasenko
28e4d2b854 httpd: optimize example CGIs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-26 07:21:11 +01:00
Wouter Franken
4e82d99460 libbb/loop: fix existence check for LOOP_CONFIGURE ioctl
The LOOP_CONFIGURE ioctl is supported in 5.8 kernels and up. To have
backwards compatibility there is a config option CONFIG_TRY_LOOP_CONFIGURE
that will check if the ioctl exists and if not fall back to old way of
configuring loop devices.

Normally errno will be set to EINVAL when this ioctl does not exist.
However, when kernel config CONFIG_COMPAT is enabled, then compat_ioctl
is called. In that case -ENOIOCTLCMD is returned by loop device driver
and generic ioctl wrapper will set errno to ENOTTY. Because busybox
does not expect this it will fail to mount loop devices in this case.

This patch fixes the check for the existence of the ioctl LOOP_CONFIGURE
by checking if errno is one of both: EINVAL or ENOTTY.

function                                             old     new   delta
set_loop                                             809     821     +12

Signed-off-by: Wouter Franken <wouter.franken_ext@softathome.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-26 05:43:17 +01:00
Denys Vlasenko
4da1badf13 networking/httpd_indexcgi.c: non-mallocing version
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-26 04:48:28 +01:00
Denys Vlasenko
052b253696 httpd: add a TODO, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-25 08:17:23 +01:00
Denys Vlasenko
1db8aa2b59 ash: code shrink
function                                             old     new   delta
fg_bgcmd                                             294     296      +2
killpg                                                43       -     -43
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/0 up/down: 2/-43)             Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-24 23:14:33 +01:00
Denys Vlasenko
ea7d310ad6 httpd: allow static files in /cgi-bin/, do not search for interpreter twice
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>
2026-01-24 17:11:39 +01:00
Denys Vlasenko
898cffe5f9 ash,hush: allow 0x in arith (bash supports it for 0x$v case when v='')
function                                             old     new   delta
parse_with_base                                      174     196     +22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-24 14:37:22 +01:00
Denys Vlasenko
a2f8c89aec httpd: code shrink
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>
2026-01-24 13:29:50 +01:00
Denys Vlasenko
5cba59e9ce awk: use more understandable form of "split-globals" trick
function                                             old     new   delta
parse_expr                                           986     998     +12
chain_group                                          633     640      +7
next_token                                           930     934      +4
getvar_s                                             102     101      -1
awk_main                                             891     888      -3
evaluate                                            3379    3355     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/3 up/down: 23/-28)             Total: -5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-24 05:43:45 +01:00
Denys Vlasenko
43982ed499 httpd: code shrink via "split-globals" trick
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>
2026-01-24 05:22:33 +01:00
Denys Vlasenko
1a64fe3594 httpd: implement POSTDATA read timeout, and -K KILLSECS CGI lifetime control
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>
2026-01-24 02:01:42 +01:00
Denys Vlasenko
927ff335c5 httpd: fix incorrect == comparison in last commit, must be !=
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-23 11:32:32 +01:00
Denys Vlasenko
5d33dbb67c httpd: smarter handling of CGI's "Status: " header
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>
2026-01-23 11:04:28 +01:00
Denys Vlasenko
a5f120b620 httpd: simplify CGI headers handling, check "HTTP/1.1" prefix, not just "HTTP"
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>
2026-01-23 10:14:04 +01:00
Denys Vlasenko
01ea35e81d httpd: simplify CGI code a bit, add a bunch of TODOs and FIXMEs
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>
2026-01-23 02:18:30 +01:00
Denys Vlasenko
2d78809b74 httpd: do not force clean connection termination on write errors and timeouts
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>
2026-01-22 22:35:58 +01:00
Denys Vlasenko
04d8729adb httpd: make timeout messages less confusing
function                                             old     new   delta
send_file_and_exit                                   891     930     +39

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 21:21:16 +01:00
Denys Vlasenko
d8059bd827 httpd: time out data writes after 60 seconds of no progress
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>
2026-01-22 17:22:06 +01:00
Denys Vlasenko
c1ed0c4049 httpd: optimize header reading timeout code
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>
2026-01-22 15:49:58 +01:00
Denys Vlasenko
52a88341d6 httpd: when reading headers, abort if they are too long
function                                             old     new   delta
get_line                                             130     134      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 15:33:42 +01:00
Denys Vlasenko
f0a63eefae httpd: reject request line and headers with control chars
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>
2026-01-22 14:33:22 +01:00
Denys Vlasenko
851992f070 httpd: allow http2 requests if proxying, tighten METHOD checks
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>
2026-01-22 13:58:28 +01:00
Denys Vlasenko
649da41ca4 httpd: fix compilation script of httpd_ratelimit_cgi.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 10:42:20 +01:00
Denys Vlasenko
3f36fe9c2f httpd: add -M MAXCONN - do not accept unlimited number of connections
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>
2026-01-22 01:58:46 +01:00
Denys Vlasenko
5ac9d0a865 httpd: stop disabling/enabling SIGHUP in every child
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>
2026-01-21 19:16:29 +01:00
Denys Vlasenko
71c703c26b httpd: remove one close() from main loop
function                                             old     new   delta
httpd_main                                           701     710      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-21 19:01:42 +01:00
Denys Vlasenko
58b46b7d67 networking/httpd_ratelimit_cgi.c: new example CGI handler
text	   data	    bss	    dec	    hex	filename
   4003	     40	    352	   4395	   112b	httpd_ratelimit_cgi

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-21 18:47:56 +01:00
Denys Vlasenko
38721685af httpd: expand logging: now can see what CGIs are started
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>
2026-01-21 17:49:40 +01:00
Denys Vlasenko
b96342799f vmstat: fix I/O, int and ctxt rates: need to be divided by seconds
function                                             old     new   delta
vmstat_main                                          657     708     +51

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-20 01:34:08 +01:00
Denys Vlasenko
3a8d2db1ce vmstat: fixes for >4TB memory and long sampling intervals
function                                             old     new   delta
load_row                                             661    1061    +400
vmstat_main                                          561     657     +96
.rodata                                           106716  106746     +30
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 526/0)             Total: 526 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-20 00:41:47 +01:00
Denys Vlasenko
1ef0c69db4 vmstat: fix "vmstat N 0" to act compatibly (do not print infinitely)
function                                             old     new   delta
vmstat_main                                          559     561      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-19 02:52:06 +01:00
Denys Vlasenko
afb92adf47 vmstat: smarter handling of header re-printing
function                                             old     new   delta
vmstat_main                                          230     559    +329
print_row                                            340       -    -340
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 329/-340)          Total: -11 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-19 02:16:10 +01:00
Denys Vlasenko
fd2ce3fa27 vmstat: show shorter, human-readable accumulating counts if they grow large
function                                             old     new   delta
print_row                                            247     340     +93
.rodata                                           106717  106716      -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 93/-1)              Total: 92 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-18 18:57:37 +01:00
Denys Vlasenko
6ba6f5f6ab vmstat: reduce the chances of misaligned columns
function                                             old     new   delta
print_row                                            215     247     +32

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-18 18:09:12 +01:00
Denys Vlasenko
c21d8ff8c5 vmstat: code shrink
function                                             old     new   delta
load_row                                             667     661      -6
next_col                                             105      59     -46
coldescs                                             239     146     -93
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-145)           Total: -145 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-18 16:51:35 +01:00
David Leonard
c385dac31c procps: new applet: vmstat
Adds a compact vmstat applet that matches the default behaviour
of procps's vmstat.

function                                             old     new   delta
load_row                                               -     667    +667
.rodata                                           106441  106717    +276
coldescs                                               -     239    +239
vmstat_main                                            -     230    +230
print_row                                              -     215    +215
next_col                                               -     105    +105
find_col                                               -      78     +78
packed_usage                                       35828   35868     +40
applet_names                                        2849    2856      +7
applet_main                                         1640    1644      +4
applet_install_loc                                   205     206      +1
------------------------------------------------------------------------------
(add/remove: 7/0 grow/shrink: 5/0 up/down: 1862/0)           Total: 1862 bytes

Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-18 10:58:46 +01:00
Achill Gilgenast
6f43f948bc adduser: remove preconfigured GECOS full name field
Pre-configuring "Linux User" as Full Name is confusing a lot of users
downstream.[1] For example, in geary e-mails were sent out as "Linux
User"[2] and I also saw a couple of git commits with this name. This name
does not bring any more improvements than just leaving this field
empty, and let applications most likely fallback to the username.

Alternative would be to set the field to `&` (Capitalized username,
according to passwd(5)) or that we just set the GECOS field downstream.

[1] https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2214
[2] https://gitlab.gnome.org/GNOME/geary/-/issues/1486

function                                             old     new   delta
.rodata                                           106455  106441     -14

Signed-off-by: Achill Gilgenast <achill@achill.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-18 03:17:00 +01:00
Martin Storsjö
993d416d02 md5/sha1sum: Honor the -b flag in the output
The output of md5sum/sha1sum contains a character to indicate
what mode was used to read the file - '*' for binary, and ' '
for text or where binary is insignificant.

This flag character makes a difference for the ffmpeg testsuite.
This testsuite contains a number of reference files (e.g. [1]),
containing the expected md5sum output for those files, which is
checked verbatim.

By making busybox's md5sum honor this flag in the output,
ffmpeg's testsuite can run successfully on top of busybox.

The flag is only partially implemented; in coreutils md5sum,
a later "-t" option overrides an earlier "-b" option. Here,
just check if a "-b" option was specified or not. Neither
flag affects how the files actually are read.

[1] 894da5ca7d/tests/ref/acodec/flac

Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-18 03:09:52 +01:00
Denys Vlasenko
fc9d352b4c cmp: fix -n causing all diffs to be output, implement size suffixes for SKIP
function                                             old     new   delta
packed_usage                                       35802   35828     +26
cmp_main                                             616     595     -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 26/-21)              Total: 5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-18 02:41:20 +01:00