aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* | libarchive: pdpmake requires some ar functionsRon Yorston2024-11-061-0/+1
| | | | | | | | | | | | | | pdpmake, like make, requires get_header_ar.o and unpack_ar_archive.o from libarchive. This dependency wasn't made explicit in Kbuild.src so building pdpmake failed unless other applets requiring those files were enabled (ar, dpkg, dpkg-deb or make).
* | win32: drop stream i/o workaroundRon Yorston2024-10-301-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | It seems that one of the workarounds for problems with stream i/o in MSVCRT was unnecessary. It also caused display glitches when the 32-bit binary was run on 64-bit systems. Remove it. Saves 112 bytes in the 32-bit build. (GitHub issue #472)
* | win32: try harder to prevent output to stdoutRon Yorston2024-10-291-1/+0
| | | | | | | | | | | | | | | | | | The previous commit failed to stop 'uname 1>&-' from writing to standard output with 32-bit MSVCRT. Close the stream _and_ the file descriptor. (Github issue #472)
* | win32: more problems with stream i/o and MSVCRTRon Yorston2024-10-291-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These commands: cut --wrong-opt 2>&1 echo $(cut --wrong-opt 2>&1) resulted in different output. In the first case the message about the invalid option appeared before the usage message; in the second after. The command uname --wrong-opt 1>&- 2>&- displayed the error message even though both output streams were closed. These issues appear to be related to those previously fixed by commits 4be93f32f and f192e6539: - They involve the interaction between shell redirection and stream input/output. - UCRT builds aren't affected. Apply two workarounds: - When the file descriptor associated with stderr is redirected remind stderr it should be unbuffered. (32- and 64-bit MSVCRT) - When the file descriptor associated with any of the standard i/o streams is to be closed do it by closing the stream instead. (32-bit MSVCRT) Adds 48-176 bytes. (GitHub commit #472)
* | ash: fix waiting for status of background jobRon Yorston2024-10-281-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following has never worked properly in busybox-w32: $ my_func() { return 5; } $ my_func & sleep 1; wait $!; echo $? The expected result is that 'echo' should display '5'. Actual results used to be '0' and more recently have been '127'. The culprit was commit fa6f44ea72 (win32: ash: reimplement waitpid(-1)). When the status of a job changed its pid was set to -1, which flagged processes of interest to the implementation of waitpid(). This is no longer necessary as waitpid() now uses the process handle instead. There's therefore no need to overwrite the pid. (GitHub issue #470)
* | ash: correctly identify nofork applets in error messageRon Yorston2024-10-281-0/+8
| | | | | | | | | | | | | | | | | | | | Commit 633e3a5eae (ash: correctly identify applet in getopt() error messages) made getopt() display the correct name for noexec applets in case of error. Do the same for nofork applets. Adds 32-48 bytes.
* | cut: improve detection of invalid rangesRon Yorston2024-10-281-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 0068ce2fa (cut: add toybox-compatible options -O OUTSEP, -D, -F LIST) added detection of reversed ranges. Further improvements are possible. - The test for reversed ranges compared the start after it had been decremented with the end before decrement. It thus missed ranges of the form 2-1. - Zero isn't a valid start value for a range. (Nor is it a valid end value, but that's caught by the test for a reversed range.) - The code if (!*ltok) e = INT_MAX; duplicates a check that's already been made. - Display the actual range in the error message to make it easier to find which range was at fault. Adds 0-48 bytes. (GitHub issue #467)
* | win32: update poll(2) to match latest gnulib versionRon Yorston2024-10-251-5/+6
| |
* | win32: workaround for pipe writability in poll(2)Ron Yorston2024-10-251-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A CGI script was found to hang when a large amount of data was posted: #!/bin/sh echo "Content-type: text/plain;" echo if [ "$REQUEST_METHOD" = "POST" ]; then dd of=my.dat bs=1 count=${CONTENT_LENGTH} echo -n "success." else echo -n "error!" fi This appears to be due to problems determining whether a pipe is writable on Windows. The Git for Windows project has a workaround in their copy of GNUlib's poll(2) implementation. The details are in the commit message: https://github.com/git-for-windows/git/commit/94f4d01932279c419844aa708bec31a26056bc6b Apply the same workaround here. Saves 220-272 bytes. (GitHub issue #468)
* | make: .WAIT shoudn't have prerequisitesRon Yorston2024-10-231-1/+1
| | | | | | | | | | | | Commit f0dea6674 (make: enforce restrictions on prerequisites/ commands) set the flags for .WAIT incorrectly: in POSIX mode it shouldn't have prerequisites.
* | cut: detect error when bounds are reversedRon Yorston2024-10-222-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | The command 'cut -b 3-2' failed to detect that the bounds were incorrectly ordered, though the check worked when the difference between the bounds was larger. The comparison was made after the lower bound has been decremented but before the upper bound had. Adds 0-16 bytes. (GitHub issue #467)
* | make: enforce restrictions on prerequisites/commandsRon Yorston2024-10-201-9/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX mentions some restrictions on whether rules may or may not have prerequisites or commands: - most special targets shouldn't have commnds; - inference/.DEFAULT rules shouldn't have prerequisites. Enforce these restrictions in POSIX mode. Generally, implementations are happy to accept prerequisites or commands even if they're subsequently ignored. Allow this as an extension. Adds 216-256 bytes.
* | make: changes to .DEFAULT/inference rulesRon Yorston2024-10-202-19/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The POSIX standard allows inference rules to be redefined but not the .DEFAULT rule. There is no explicit exception for .DEFAULT to: Only one target rule for any given target can contain commands. Treat redefinition of a .DEFAULT rule as an error in POSIX mode but allow it as an extension. Also, the code didn't allow an inference rule with dependencies to redefine an existing inference rule. This is no longer the case. Adds 64-96 bytes.
* | make: fix test for empty command in inference ruleRon Yorston2024-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Commit e90345c10 (make: allow empty commands) changed how empty commands are handled. This broke the POSIX mode test for inference rules of the form: rule: ; Adjust the setting of 'semicolon_cmd' to the new reality. Adds 16-32 bytes.
* | make: relax definition of comment lineRon Yorston2024-10-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | According to POSIX: Blank lines, empty lines, and lines with <number-sign> ('#') as the first character on the line are also known as comment lines. Most implementations also include lines where the first non-blank character is '#'. Allow this as an extension. Adds 0-16 bytes.
* | make: improve chaining of implicit rulesRon Yorston2024-10-171-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running 'make thing.z' with the following makefile: .SUFFIXES: .x .y .z .x.y: cp $< $@ .y.x: cp $< $@ .y.z: cp $< $@ resulted in infinite recursion and a segfault. Follow GNU make and don't allow any implicit rule to appear more than once in a chain. Adds 16-32 bytes.
* | make: look for PDPmakefileRon Yorston2024-10-171-10/+9
| | | | | | | | | | | | | | | | As an extension have pdpmake look for the file 'PDPmakefile' before 'makefile' and 'Makefile'. This is similar to how GNU make first checks for 'GNUmakefile'. Adds 32-40 bytes.
* | ash: update commentRon Yorston2024-10-131-1/+0
| | | | | | | | PPID is no longer fake.
* | win32: close exec'ing process if possibleRon Yorston2024-10-131-0/+3
| | | | | | | | | | | | | | | | | | If a process performing an exec is an orphan there's no reason for it to wait for its child's exit code. Let it exit immediately. Adds 16 bytes. (GitHub issue #461)
* | kill: fix regression in 'kill -9'Ron Yorston2024-10-121-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 'kill -9' was found to fail with an 'Invalid argument' error. This is a regression introduced by commit 569de936a (kill: killing a zombie process should fail). Use the correct argument to OpenProcess() for SIGKILL so it can query the exit code of the target process. Adds 16 bytes. (GitHub issue #465)
* | win32: fix problem interrupting shell loopRon Yorston2024-10-111-11/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It proved to be almost impossible to interrupt a loop like: while true; do sleep 1; done where 'sleep' was an external program, not an applet. The issue was introduced by commit 0475b7a64 (win32: convert exit codes). This passed a POSIX error code to the exit() in wait_for_child() so a parent was unable to detect when its child was interrupted. Pass the Windows exit code to exit() instead. Work around the changes introduced by commit 790e377273 (win32: revert 'don't set error mode'). Adds 16-32 bytes.
* | win32: fix regression in chdir(2)Ron Yorston2024-10-101-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | When mingw_chdir() was introduced it canonicalised its argument (585d17d26). This had the side effect of making its case match that of the directory as stored on disk. Subsequent changes retained that behaviour for symlinks but not otherwise (69d328022, b99032390). This was noted to affect the appearance of the directory specified by the (undocumented) 'sh -d' option. Fix the case of non-symlink directories too. Adds 16-32 bytes.
* | id: code shrinkRon Yorston2024-10-093-1/+23
| | | | | | | | | | | | | | | | The bogus user/group ids we use on Windows are very limited. Make these limitations explicit in the 'id' applet. Saves 464 bytes.
* | test: code shrink supplementary groupsRon Yorston2024-10-092-0/+8
| | | | | | | | | | | | | | | | Since we don't use is_in_supplementary_groups() there's no need for the cached_groupinfo structure to include the members required for its support or for them to be initialised. Saves 32 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2024-10-087-66/+102
|\|
| * hexdump: accept hex numbers in -n, closes 16195Denys Vlasenko2024-10-081-3/+8
| | | | | | | | | | | | | | function old new delta hexdump_main 366 383 +17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: modify find_executable() to not temporarily write to PATHDenys Vlasenko2024-10-084-54/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | This allows to simplify "which" applet code function old new delta find_executable 93 111 +18 which_main 191 177 -14 builtin_source 316 294 -22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 18/-36) Total: -18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix "type ./cat" and "command -v ./cat" to not scan PATHDenys Vlasenko2024-10-071-13/+33
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta find_executable_in_PATH - 67 +67 if_command_vV_print_and_exit 114 116 +2 .rodata 105712 105710 -2 builtin_type 137 128 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/2 up/down: 69/-11) Total: 58 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: make "test -x" use cached groupinfoDenys Vlasenko2024-10-071-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While at it, correct "type" to skip non-executable files in PATH function old new delta builtin_source 211 316 +105 builtin_test 10 32 +22 hush_main 1150 1170 +20 builtin_type 122 137 +15 if_command_vV_print_and_exit 120 114 -6 find_in_path 131 - -131 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 4/1 up/down: 162/-137) Total: 25 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: code shrink supplementary group testRon Yorston2024-10-082-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | Recent upstream changes to file permission tests added a function to check and cache values in the supplementary group list. The implementation of getgroups() in the Windows port adds no useful information beyond what can be obtained by checking the current effective gid, which all callers of the new function already do. The function can be replaced with a simple 'FALSE'. Saves 232-288 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2024-10-086-49/+169
|\|
| * test: -x can return 0/1 early if all X bits are the sameDenys Vlasenko2024-10-071-10/+10
| | | | | | | | | | | | | | function old new delta nexpr 702 725 +23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: cache more of uid/gid syscallsDenys Vlasenko2024-10-074-10/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Testcase: setuidgid 1:1 strace ash -c 'test -x TODO; test -x TODO; echo $?' should show that second "test -x" does not query ids again. function old new delta ash_main 1236 1256 +20 get_cached_euid - 19 +19 get_cached_egid - 19 +19 test_main 56 72 +16 test_exec 119 135 +16 is_in_supplementary_groups 52 57 +5 nexpr 718 702 -16 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 4/1 up/down: 95/-16) Total: 79 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: make "test -x" use cached groupinfoDenys Vlasenko2024-10-073-6/+19
| | | | | | | | | | | | | | | | | | | | | | function old new delta test_main2 - 407 +407 testcmd 10 23 +13 test_main 418 56 -362 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 420/-362) Total: 58 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: simplify parameter passing in is_in_supplementary_groups()Denys Vlasenko2024-10-074-20/+34
| | | | | | | | | | | | | | | | | | | | | | function old new delta is_in_supplementary_groups 54 52 -2 nexpr 721 718 -3 test_exec 125 119 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-11) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: command -v CMD must skip (go to next path) when CMD exists, but is not ↵Denys Vlasenko2024-10-071-3/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | executable Upstream commit: Date: Fri, 5 Apr 2024 17:55:46 +0800 exec: Check executable bit when searching path Andrej Shadura <andrew.shadura@collabora.co.uk> wrote: ... > https://bugs.debian.org/874264 > -------- Forwarded Message -------- > Subject: dash: 'command -v' mistakenly returns a shell script whose > executable is not set > Date: Mon, 04 Sep 2017 10:45:48 -0400 > From: Norman Ramsey <nr@cs.tufts.edu> > To: Debian Bug Tracking System <submit@bugs.debian.org> ... > I tracked a build bug in s-nail to a problem with dash. Symptom: > building s-nail tries to run /home/nr/bin/clang, a script whose > executable bit is not set. We tracked the problem to the result of > running `command -v clang` with /bin/sh: ... This is inherited from NetBSD. There is even a commented-out block of code that tried to fix this. Anyway, we now have faccessat so we can simply use it. function old new delta test_exec - 125 +125 find_command 911 918 +7 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 132/0) Total: 132 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: move is_in_supplementary_groups() from test to libbbDenys Vlasenko2024-10-073-19/+26
| | | | | | | | | | | | | | | | | | | | function old new delta is_in_supplementary_groups - 54 +54 nexpr 766 721 -45 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 54/-45) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * test: Invert return value of test_eaccess and rename it to test_st_modeDenys Vlasenko2024-10-061-16/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | From dash: From: herbert <herbert@gondor.apana.org.au> Date: Wed, 2 Mar 2005 22:14:54 +1100 Invert return value of test_eaccess and rename it to test_st_mode. function old new delta nexpr 800 766 -34 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * test: code shrinkDenys Vlasenko2024-10-061-1/+1
| | | | | | | | | | | | | | function old new delta nexpr 813 800 -13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * networking/libiproute/iplink.c: fix support for older kernelsThomas Devoogdt2024-10-061-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The CAN netlink interface has been added in Linux v2.6.31 with only 3 options [1]: CAN_CTRLMODE_LOOPBACK 0x1 /* Loopback mode */ CAN_CTRLMODE_LISTENONLY 0x2 /* Listen-only mode */ CAN_CTRLMODE_3_SAMPLES 0x4 /* Triple sampling mode */ So define the other options. - IFLA_CAN_TERMINATION has been added in Linux 4.11 [2], define it for older kernels. [1] https://github.com/torvalds/linux/blob/v2.6.31/include/linux/can/netlink.h#L80-L82 [2] https://github.com/torvalds/linux/commit/12a6075cabc0d9ffbc0366b44daa22f278606312 Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: fix sha1 on !x86 if CONFIG_SHA1_HWACCEL=yRudi Heitbaum2024-10-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | fixes non i386 and x86 builds libbb/hash_md5_sha.c: In function 'sha1_end': libbb/hash_md5_sha.c:1316:35: error: 'sha1_process_block64_shaNI' undeclared 1316 | || ctx->process_block == sha1_process_block64_shaNI Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: more changes to noexec appletsRon Yorston2024-10-071-30/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Change the 'flags' argument to shellexec()/tryexec() so it only indicates that it's permissible to run ash_main() directly. The flag is only set TRUE in forkshell_shellexec(). - The check for a script with an interpreter which is an applet is now performed for all calls to tryexec(), not just those that originate from evalcommand(). Saves 64-80 bytes. GitHub issue #461.
* | ash: fix regression with 'exec sh -s'Ron Yorston2024-10-061-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was noted this command didn't work properly: su -t -c 'exec sh -s -c "echo 123"' The child shell performed the 'echo' but then exited, despite the '-s' flag. This is a regression introduced by commit 074ebfca21 (ash: code shrink). This simpler command also failed the same way: sh -c "exec sh -s" This regression dates back even further, to commit da7c8cdf63 (ash: run ash_main() directly from a FS_SHELLEXEC shell). The issue can be avoided if shells invoked by the 'exec' builtin aren't run by calling ash_main() directly. Adds 80-96 bytes. GitHub issue #461.
* | win32: adjust usage for timeout and pipe_progressRon Yorston2024-10-022-3/+3
| | | | | | | | | | | | | | | | Reduce the divergence from upstream in the usage messages for timeout and pipe_progress. This only affects the source; there are no visible of functional changes.
* | win32: work around problem with stderr in MSVCRTRon Yorston2024-09-302-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Try to run a non-existent command with standard error closed: xyz 2>&- In recent versions of busybox-w32 this resulted in problems with moving through history (either using up/down keys or ctrl-r) and tab completion. In all cases the order of the prompt and the command were reversed. Bisection showed the problem was first seen in PRE-5396 which merged some commits from upstream, including fd47f0567 (lineedit: print prompt and editing operations to stderr). This (eventually) called to mind a previous problem with stderr in xargs which was fixed by commit f192e6539 (xargs: fix 'xargs -sNUM' tests). In both cases it seemed that mixing calls to bb_putchar_stderr() and fprintf(stderr, ...) was at fault. The former uses a file descriptor while the latter uses a stream. It was almost as if the stream was buffered. - The problem with xargs affected 32-bit and 64-bit builds with MSVCRT. - The problem with '2>&-' only affected 32-bit builds with MSVCRT. - Neither problem was present with UCRT builds. As a workaround change bb_putchar_stderr() to use the stderr stream in builds for MSVCRT. Saves 16 bytes in the 32-bit build. (GitHub issue #460)
* | Merge branch 'busybox' into mergeRon Yorston2024-09-2810-102/+87
|\|
| * hush: whitespace and comment fixesDenys Vlasenko2024-09-281-43/+27
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: reject unknown long optionsRon Yorston2024-09-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 64f70cc755 (Add --login support) added code in options() to handle the bash-compatible '--login' option. In doing so it committed BusyBox ash to silently accepting all other long options. Restore compatibility with other ash variants by rejecting unknown long options. function old new delta options 589 624 +35 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * lineedit: use stdout for shell history builtinRon Yorston2024-09-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit fd47f0567 (lineedit: print prompt and editing operations to stderr) changed various print statements to output to stderr. The change in show_history() caused the shell history builtin to send its output to stderr. Revert that part of the commit. function old new delta show_history 47 42 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5) Total: -5 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ed: fix line insertion before current line. Closes 15081Ron Yorston2024-09-272-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When text is inserted by insertLine() the lines following the insertion are moved down and the insertion point is made the new current line. To avoid too much scanning of the linked list of lines setCurNum() may use the position of the old current line to determine the location of the new current line. If the insertion point is before the old current line in the file the latter will have been moved down, so its line pointer needs to be adjusted. function old new delta insertLine 162 180 +18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 18/0) Total: 18 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>