aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* win32: provide a default value for HOMERon Yorston2023-01-292-9/+19
| | | | | | | | | | | | | | | | The busybox-w32 shell initialises HOME when it starts. However, if applets are run outside the environment provided by the shell they may find HOME is unset. This caused a problem for 'vi' as it was unable to locate its .exrc. If HOME isn't available in the environment make getenv(3) provide a sensible default value. The shell must use the *real* getenv(3) when determining if HOME is already set. Also, unrelated to the above, the shell shouldn't treat failure of getpwuid(3) as a fatal error. Costs 72-80 bytes.
* diff: implement --binary flagRon Yorston2023-01-271-0/+25
| | | | | | | | | | | On Windows GNU diff uses text mode for input and output. It also has the '--binary' flag to use binary mode instead. On Unix binary mode is the default and the flag does nothing. Alter diff to use text mode by default for input (though not output, let's not go overboard). Add the '--binary' flag to override this. Costs 96-160 bytes.
* win32: another stat(2) + access time fixRon Yorston2023-01-261-1/+1
| | | | | | | | Use FILE_SHARE_READ when opening a file to check if it's an executable. Without that other processes running in parallel might be unable to access the file. (GitHub issue #284)
* make: enable pdpmake alias in default configurationRon Yorston2023-01-242-2/+2
| | | | | This allows additional flexibility when another 'make' program is present.
* make: allow building as pdpmake onlyRon Yorston2023-01-242-0/+2
| | | | | | | | | Commit f261d2d27 (make: make + sh configuration) added 'pdpmake' as an alias for 'make'. It should have been possible to include 'pdpmake' in a build without also including 'make'. Adjust the build configuration so this works as intended.
* win32: only count subdirectories if necessaryRon Yorston2023-01-234-3/+26
| | | | | | | | | | | | | | | | | Commit 7fb95a2a5 (win32: try to get link count for directories) allowed stat(2) to report accurate values of st_nlink for directories. There are only a couple of places in busybox-w32 where these values are required. Disable counting of subdirectories by default and only enable it when necessary. Microsoft kindly provide directories to test edge cases like this: C:/Windows/WinSxS (contains many subdirectories) C:/Windows/WinSxS/Manifests (contains many files) Adds 84-112 bytes.
* win32: limit setting of errno when lazy loading failsRon Yorston2023-01-221-3/+3
| | | | | | | | | | | | The function get_proc_addr() facilitates dynamic loading of functions from DLLs. In the event of failure it set errno to ENOSYS. This is sometimes useful, such as in the implementations of link(2), symlink(2) and realpath(3). However, many other uses of lazy loading can recover from failure or simply don't care. In these cases setting errno is unnecessary and may be counterproductive. (GitHub issue #283)
* win32: reset errno in read_key()Ron Yorston2023-01-221-0/+1
| | | | | | | | | | | | | The WIN32 implementation of read_key() didn't reset errno to zero, unlike the upstream version. This could result in invalid non-zero errno values after calls to lineedit_read_key(). For example, after an attempt to run a non-existent command in the shell errno is set to ENOENT. If the shell had vi line edit mode enabled any command that reads an additional character (e.g. 'c' or 'd') would see the non-zero errno and report EOF. (GitHub issue #283)
* win32: more minor improvements to stat(2)Ron Yorston2023-01-181-29/+26
| | | | | | | | | | | | | | | | The previous commit incorrectly stated that preventing the access time of a file from being updated only required it to be opened with GENERIC_READ access. In fact, even though we don't want to update the access time, SetFileTime() also requires the file to have been opened with FILE_WRITE_ATTRIBUTES access. There's no need to explicitly avoid device files when checking for execute mode: since device files are now 'character special' they are excluded by the test that the file is 'regular'. Device files should be excluded when trying to obtain extra file data using GetFileInformationByHandle(). It shouldn't be possible for CreateFile() to open then, so there's no point in trying.
* win32: minor improvements to stat(2)Ron Yorston2023-01-171-9/+9
| | | | | | | | | | | Commit b11352dcb (win32: prevent stat(2) from updating access times) requested GENERIC_ALL access when opening files. It appears that GENERIC_READ is sufficient and also faster. The code to find the actual size of compressed or sparse files only needs to be invoked for regular files. Avoiding unnecessary calls to GetCompressedFileSize() makes stat(2) slightly faster and gives a more accurate number of blocks for symbolic links.
* win32: use ACL check to clarify write permissionRon Yorston2023-01-161-27/+30
| | | | | | | | | | | | | | | | | On Microsoft Windows a user's home directory doesn't belong to them: it actually belongs to the 'system' user. stat(2) was only using ownership to determine write permissions, so it seemed that the user was unable to write to their own home directory. Use a call to AccessCheck() to determine if files can be accessed due to an entry in their ACL. User home directories and a few other files (e.g. C:/Users/Public) now have the correct write permission. This feature is enabled by FEATURE_EXTRA_FILE_DATA. Costs 220-256 bytes. (GitHub issue #280)
* win32: fix permissions of read-only directoryRon Yorston2023-01-111-1/+1
| | | | | | | | | | | | Commit 15fcbd19c8 (win32: special case for devices files in stat(2)) caused write permissions on directories to respect the read-only attribute. This is incorrect: the read-only attribute doesn't apply to directories in the same way as to normal files. Give directories write permission unconditionally, as before, though respecting umask. (GitHub issue #280)
* win32: improve seeding of PRNGsRon Yorston2023-01-112-60/+10
| | | | | | | | | | | | | | | | | busybox-w32 provides two PRNG implementations which are used in the emulation of /dev/urandom. The ad hoc method of seeding them has been replaced by calls to RtlGenRandom. The documentation for RtlGenRandom indicates it has been deprecated in favour of CryptGenRandom. The documentation for the latter indicates it has been deprecated in favour of the 'Cryptography Next Generation APIs'. Nonetheless, RtlGenRandom remains available in every version of Windows since XP. In the unlikely event that RtlGenRandom fails simply use the current time as the seed. Saves 192 bytes in the default configuration.
* awk: further improvements to randomnessRon Yorston2023-01-111-0/+15
| | | | | | | | | | | | | | | | | | | | POSIX requires that the awk srand() function uses the time of day to seed the PRNG. The obvious implementation used in BusyBox does exactly that, passing time(NULL) to srand(3). When processes are started within a few seconds of one another their seeds are very similar. Given the realtively poor quality of rand(3) in some C runtimes this results in random number sequences that are somewhat correlated. Improve matters by using an integer hash on the seed, as recommended here: https://nullprogram.com/blog/2019/04/30/#the-wrong-places Costs 48 bytes. (GitHub issue #279)
* awk: make random values more randomRon Yorston2023-01-061-2/+2
| | | | | | | | | | | | | When srand(3) is called to seed the random number generator with the current time the first value returned by rand(3) changes slowly with time. This is a property of the implementation in the C runtime. Change the order in which values from rand(3) are consumed to generate the value returned by the awk rand() function. This puts the value returned by the first call to rand(3) in the least significant bits, not the most significant. (GitHub issue #279)
* Annual update of copyright messageRon Yorston2023-01-051-1/+1
|
* xargs: omit support for -oRon Yorston2023-01-051-3/+14
| | | | | Upstream added the -o option to reopen stdin as /dev/tty. Since /dev/tty isn't available in Microsoft Windows -o isn't applicable.
* Merge branch 'busybox' into mergeRon Yorston2023-01-0527-182/+397
|\
| * Start 1.37.0 development cycleDenys Vlasenko2023-01-031-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Bump version to 1.36.01_36_0Denys Vlasenko2023-01-031-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: code shrinkDenys Vlasenko2023-01-031-4/+9
| | | | | | | | | | | | | | function old new delta run_list 1032 1012 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: trivial code shrinkDenys Vlasenko2023-01-031-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * xxd: use bb_simple_perror_msg... where appropriateDenys Vlasenko2023-01-031-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: fix compile failures in some configsDenys Vlasenko2023-01-034-15/+31
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Makefile.flags: add resolv to LDLIBS for linux compilers too (not only gnu ones)Denys Vlasenko2023-01-021-0/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sed: fix double-free in FEATURE_CLEAN_UP=y configsDenys Vlasenko2023-01-021-4/+13
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * mv: fix error in !VERBOSE configsDenys Vlasenko2023-01-021-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/loop: fix compile failure (name collision)Denys Vlasenko2023-01-021-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * testsuite/sha1sum.tests: fix false positive failureDenys Vlasenko2023-01-021-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * testsuite/tree.tests: fix false positive failureDenys Vlasenko2023-01-021-18/+20
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * xxd: fix use of non-initialized dataDenys Vlasenko2023-01-021-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * xargs: implement -o, closes 15146Denys Vlasenko2022-12-221-34/+51
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta .rodata 105225 105259 +34 d6_listen_socket 150 180 +30 packed_usage 34512 34532 +20 d6_read_interface 595 581 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 84/-14) Total: 70 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcpc6: fix binding to network aliasesDenys Vlasenko2022-12-151-4/+9
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcp: add a few comments, no code changesDenys Vlasenko2022-12-152-0/+11
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcpc6: use a different default config scriptDenys Vlasenko2022-12-152-3/+8
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcpc6: align FF02__1_2[]Denys Vlasenko2022-12-153-5/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * more: accept and ignore -eNatanael Copa2022-12-141-1/+2
| | | | | | | | | | | | | | | | Accept and ignore -e which is specified in POSIX. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/more.html Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcpc6: add some commentsDenys Vlasenko2022-12-142-12/+39
| | | | | | | | | | | | RFCs for DHCPv6 are written rather badly... Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcpc6: remove stray commentDenys Vlasenko2022-12-131-1/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: shrink del_loop()Denys Vlasenko2022-12-131-1/+1
| | | | | | | | | | | | | | function old new delta del_loop 52 49 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * loop: restore the correct return vaule of set_loop()Denys Vlasenko2022-12-131-4/+8
| | | | | | | | | | | | It is only used by mount's error path, though... Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * loop: optionally use ioctl(LOOP_CONFIGURE) to set up loopdevsDenys Vlasenko2022-12-132-9/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LOOP_CONFIGURE is added to Linux 5.8 function old new delta NO_LOOP_CONFIGURE (old code): set_loop 784 782 -2 LOOP_CONFIGURE: set_loop 784 653 -131 TRY_LOOP_CONFIGURE: set_loop 784 811 +27 Based on a patch by Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * testsuite/mount.tests: accomodate umount failure seen on 5.18.0Denys Vlasenko2022-12-131-1/+13
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * loop: refactor: extract subfunction set_loopdev_params()Xiaoming Ni2022-12-131-39/+51
| | | | | | | | | | | | | | | | | | | | Extract subfunction set_loop_info() from set_loop() function old new delta set_loop 760 784 +24 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * loop: simplify code of LOOP_SET_FD failureXiaoming Ni2022-12-121-7/+3
| | | | | | | | | | | | | | | | function old new delta set_loop 790 760 -30 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * loop: refactor: extract subfunction get_next_free_loop()Xiaoming Ni2022-12-121-30/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | Extract subfunction get_next_free_loop() from set_loop() Also fix miss free(try) when stat(try) and mknod fail function old new delta set_loop 807 790 -17 Fixes: 3448914e8cc5 ("mount,losetup: use /dev/loop-control is it exists") Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * xxd: fix typo in trivial usageBrandon Maier2022-12-081-1/+1
| | | | | | | | | | Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * unzip -l: add missed big-endian conversions date and timePeter Kaestle2022-11-291-0/+2
| | | | | | | | | | | | | | | | When calling unzip -l the date and time output was missing big-endian conversions. Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Remove "select PLATFORM_LINUX"Denys Vlasenko2022-11-2954-70/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Fix non-Linux buildsSamuel Thibault2022-11-2956-3/+89
| | | | | | | | | | | | | | | | | | | | | | Various tools are Linuxish and should thus only attempted to build on Linux only. Some features are also Linux-only. Also, libresolv is used on all GNU platforms, notably GNU/Hurd and GNU/kfreeBSD. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>