aboutsummaryrefslogtreecommitdiff
path: root/miscutils (follow)
Commit message (Collapse)AuthorAgeFilesLines
* win32: export xappendword()Ron Yorston2023-04-232-16/+1
| | | | | | | Export the function xappendword() from make. Use it in drop and watch. Saves 8-80 bytes, an unusually large disparity.
* Merge branch 'busybox' into mergeRon Yorston2023-04-171-2/+22
|\
| * seedrng: fix for glibc <= 2.24 not providing random headerThomas Devoogdt2023-04-111-4/+10
| | | | | | | | | | | | | | | | | | | | - dropped the wrong define (not sure why it was there) - <sys/random.h> not available if glibc <= 2.24 - GRND_NONBLOCK not defined if <sys/random.h> not included - ret < 0 && errno == ENOSYS has to be true to get creditable set Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * seedrng: fix for glibc <= 2.24 not providing getrandom()Denys Vlasenko2023-04-101-0/+14
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Remove "select PLATFORM_LINUX"Denys Vlasenko2022-11-295-9/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Fix non-Linux buildsSamuel Thibault2022-11-295-0/+9
| | | | | | | | | | | | | | | | | | | | | | 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>
* | drop: adjust environment on privilege changeRon Yorston2023-03-271-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some environment variables are subject to special treatment: USER, LOGNAME, HOME and SHELL are initialised when the shell starts if they don't already have a value. Some adjustments are necessary when changing privilege level: - USERNAME is added to the set of variables subject to special treatment. Unlike the others this is normally set on Windows. - The special variables are now also updated on shell start up if the current process is running with elevated privileges. This is necessary so USER, USERNAME and LOGNAME have the correct value. - USER, USERNAME and LOGNAME are set to the name of the unprivileged user when elevated privileges are dropped, though not if they've been changed from the expected value of "root". Costs 160-208 bytes. (GitHub issue #300)
* | drop: cdrop and pdrop don't need shellRon Yorston2023-03-231-8/+18
| | | | | | | | | | | | | | | | | | The cdrop and pdrop variants don't require the binary to include a shell. Removing this dependency makes it possible to build cdrop/pdrop as a much smaller standalone binaries. Update the default configuration to build a standalone make binary to exclude drop/cdrop/pdrop.
* | drop: search PATH for cmd.exe/PowerShellRon Yorston2023-03-231-27/+25
| | | | | | | | | | | | | | | | | | Rather than hardcode the paths of cmd.exe and PowerShell find them by searching PATH. Saves 104-128 bytes. (GitHub issue #240)
* | drop: add cdrop and pdrop aliasesRon Yorston2023-03-191-3/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add cdrop and pdrop applets as aliases for drop. If a command isn't specified these use cmd.exe and PowerShell instead of the BusyBox shell. This makes it possible to choose the default shell used for SSH connections even in older versions of OpenSSH that don't support the DefaultShellArguments registry key. Note that to get cmd.exe to run a command rather than an interactive shell it's necessary to set the DefaultShellCommandOption registry key to '/c'. Costs 248-272 bytes.
* | runuser,drop: drop runuser, tweak dropRon Yorston2023-03-191-0/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the runuser applet, leaving only drop. Move drop from util-linux to miscutils. A command of the form 'drop -c command' causes the BusyBox shell to be used, just like 'drop' without any arguments. A simple OpenSSH configuration with 'drop.exe' as DefaultShell and no DefaultShellArguments now works both for interactive login and to run a command. This is useful for older versions of OpenSSH which don't support DefaultShellArguments. Saves 208-232 bytes.
* | make: code shrinkRon Yorston2023-03-161-2/+2
| | | | | | | | | | | | Use alloc_ext_space() instead of a hand-coded equivalent. Saves 16-32 bytes.
* | win32: add support for virtual terminal inputRon Yorston2023-03-051-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Alter certain applets to support virtual terminal input, if enabled. In many places this is achieved by building previously excluded upstream terminal-handling code. The busybox-w32 implementation of termios(3) functions does nothing if virtual terminal input is disabled, so it can be invoked regardless. Some applet-specific terminal-handling code is also required. This affects less, more, vi and command line editing in the shell. (The `more` applet isn't enabled in the default configuration.) This series of patches adds about 1.7KB to the binaries.
* | make: strip leading whitespace in shell assignmentRon Yorston2023-02-011-11/+28
| | | | | | | | | | | | | | | | | | | | | | | | Assignment of shell output to a macro ('!=') was originally a non-POSIX extension. It later became a POSIX 202X feature. However, the implementation failed to include the additional POSIX requirement that leading whitespace is removed from the shell output. Neither GNU make nor bmake strip leading whitespace. Implement this behaviour as a non-POSIX extension.
* | make: allow building as pdpmake onlyRon Yorston2023-01-241-0/+1
| | | | | | | | | | | | | | | | | | 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.
* | make: add '-x' option to set pragmasRon Yorston2022-11-211-50/+92
| | | | | | | | | | | | Add a command line option to allow pragmas to be set. This is an alternative to the use of the .PRAGMA special target. The same pragmas are supported.
* | make: add .PRAGMA special targetRon Yorston2022-11-181-38/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the special target .PRAGMA. This allows certain features of the POSIX standard to be disabled when POSIX mode is being enforced. This is done by setting prerequisites of .PRAGMA, as follows: - macro names containing '-' are permitted with the 'macro_name' prerequisite; - target names containing '-' or '/' are permitted with the 'target_name' prerequisite; - the '#' character isn't treated as the start of a comment in a command line with the 'command_comment' prerequisite; - an empty suffix is permitted in a macro expansion of the form $(VAR:=.c) with the 'empty_suffix' prerequisite. Additionally the 'posix_202x' prerequisite enforces the future POSIX standard instead of the current one. In this case the 'macro_name' and 'target_name' pragmas aren't required as the future standard will allow the additional characters. .PRAGMA without any prerequisites restores the default behaviour.
* | make: changes to suffix substitution in macro expansionRon Yorston2022-11-161-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The POSIX standard defines suffix substitution in macro expansion as taking the form: $(string1 [: subst1 =[ subst2 ]]) Since 'subst1' isn't bracketed a value must be supplied. Enforce this in POSIX mode. As a non-POSIX extension an empty 'subst1' is permitted with 'subst2' being added to all words unconditionally. If both 'subst1' and 'subst2' are empty the words are returned unchanged.
* | make: show location of errors during buildRon Yorston2022-11-161-15/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Error messages only displayed the location of an error while the makefile was being parsed. Store the location (makefile name and line number) of each command line. This allows location information to be displayed in errors encountered while targets are being built. Take this Makefile, for example: target: @echo $(hello Previously this would display: make: unterminated variable '$(hello' Now it shows: make: (Makefile:2): unterminated variable '$(hello'
* | make: fix typo in help textRon Yorston2022-11-141-2/+2
| |
* | make: use correct test for valid macro nameRon Yorston2022-11-131-1/+1
| | | | | | | | | | The test for valid macro names in POSIX mode was incorrect: it shouldn't have allowed '-'.
* | make: make + sh configurationRon Yorston2022-11-101-1/+8
| | | | | | | | | | | | Add a configuration that just includes make and a shell. Add 'pdpmake' as an alias for 'make'.
* | make: fix typo in inference rule handlingRon Yorston2022-11-041-1/+1
| | | | | | | | | | | | | | A typo in the previous commit caused dyndep() to process inference rules incorrectly. This didn't affect the results of the test suite when extensions were allowed but it caused the test 'Inference rule with explicit rule for prerequisite' to fail in POSIX mode.
* | make: fixes to inference rulesRon Yorston2022-11-031-18/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Austin Group defect report 875 clarifies some aspects of inference rules. The crux of the issue is related to chained inference rules so it doesn't affect POSIX mode. The test makefile looks like this: .SUFFIXES: .a .b .c .a.c: @echo .a.c .b.c: @echo .b.c test.c: test.b test.a: test.b: The correct output is deemed to be '.a.c'. Additional complications are: - whether or not the prerequisite files are present; - the use of the suffixes '.a' and '.c' may result in the builtin inference rule '.c.a' being considered. In favourable circumstances pdpmake managed to give the correct result, in unfavourable it reported circular dependencies or segfaulted. Changes to fix these issues are: - When prerequisites are being recursively built the standard says: 'Upon recursion, each prerequisite shall become a target itself.' Follow this requirement. - At the end of make() the target being built should have its time (as represented by n_tim in struct name) updated when any action has been taken. - When dyndep() is looking for prerequisites it should: * skip candidates that are in the process of being built; * consider whether an explicit candidate is a target, not whether it has any commands associated with it. pdpmake now behaves similarly to GNU make when presented with makefiles like the above. bmake gives the incorrect output '.b.c'.
* | make: comments in macro expansions and command linesRon Yorston2022-11-011-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The POSIX specification says: There are three kinds of comments: blank lines, empty lines, and a <number-sign> ('#') and all following characters up to the first unescaped <newline> character. Most implementations don't treat '#' in a macro expansion or a command line as the start of a comment. POSIX doesn't mention either of these exceptions. Permit the exceptions as a non-POSIX extension.
* | make: different treatment for escaped NL in macro in commandRon Yorston2022-10-301-6/+24
| | | | | | | | | | | | | | Austin Group defect report 1549 has been accepted. It requires that an escaped newline inside a macro expansion in a command is replaced by a space. Other escaped newlines in commands are left in place, as before.
* | make: add a comment, no functional changeRon Yorston2022-10-211-3/+8
| |
* | make: $+ should support D/F modifiersRon Yorston2022-10-201-0/+1
| | | | | | | | | | The code to handle the modifiers for 'directory part' and 'filename part' has been updated to support the $+ internal macro.
* | make: .NOTPARALLEL and .WAIT are special targetsRon Yorston2022-10-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Austin Group defect report 1437 has been accepted. It describes the special targets .NOTPARALLEL and .WAIT which are used to influence the behaviour of parallel builds. Since parallel builds aren't implemented in here they actually don't 't have much effect. - For completeness they're flagged as special targets. - .WAIT should be allowed as a prerequisite.
* | make: shell assignment is a POSIX 202X featureRon Yorston2022-10-181-5/+4
| | | | | | | | | | | | | | | | Austin Group defect report 337 has been accepted, thus making macro assignment from the output of a shell command (!=) a POSIX 202X feature. This was previously implemented as a non-POSIX extension.
* | make: support $+ and $^ as POSIX 202X featuresRon Yorston2022-10-181-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Austin Group defect reports 514 and 1520 have both been accepted. Together these introduce the internal macros $+ and $^: - $+ lists all prerequisites, with duplicates retained; - $^ lists all prerequisites, with duplicates removed. $^ had already been implemented as a non-POSIX extension, it now becomes a POSIX 202X extension. $+ has been added as a POSIX 202X extension. Neither of the above defect reports mentions how $? should handle duplicate prerequisites. In POSIX mode duplicates are retained. Removal of duplicates is implemented as a non-POSIX extension to match existing practice in other versions of make.
* | Merge branch 'busybox' into mergeRon Yorston2022-10-125-40/+193
|\|
| * *: style fixDenys Vlasenko2022-08-303-16/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * devmem: add 128-bit widthAaro Koskinen2022-08-261-24/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add 128-bit width if the compiler provides the needed type. function old new delta devmem_main 405 464 +59 .rodata 109025 109043 +18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 77/0) Total: 77 bytes Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com> Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tree: unicode tweak (use normal space char, 0x20)Denys Vlasenko2022-08-261-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tree: make it unicode-awareDenys Vlasenko2022-08-261-3/+16
| | | | | | | | | | | | | | | | | | | | | | function old new delta tree_print 396 420 +24 .rodata 105251 105266 +15 tree_main 86 91 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 44/0) Total: 44 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * bc: hopefully fix bug 14956 (use-after-free)Denys Vlasenko2022-08-181-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tree: new appletRoger Knecht2022-06-301-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the tree program to list directories and files in a tree structure. function old new delta tree_print - 343 +343 scandir64 - 330 +330 scandir - 330 +330 tree_main - 86 +86 .rodata 105150 105228 +78 packed_usage 34511 34557 +46 alphasort64 - 31 +31 alphasort - 31 +31 strcoll - 5 +5 applet_names 2801 2806 +5 applet_main 1616 1620 +4 applet_suid 101 102 +1 applet_install_loc 202 203 +1 ------------------------------------------------------------------------------ (add/remove: 11/0 grow/shrink: 6/0 up/down: 1291/0) Total: 1291 bytes Signed-off-by: Roger Knecht <rknecht@pm.me> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | make: fix incorrect handling of escaped newlineRon Yorston2022-08-281-5/+4
| | | | | | | | | | | | Fix a bug in process_command() where an escaped newline followed by a character other than tab resulted in premature termination of the command.
* | make: new appletRon Yorston2022-08-011-0/+2621
| | | | | | | | | | | | | | | | | | This is an experimental implementation of make for busybox-w32, based on my public domain POSIX make: https://frippery.org/make/ (GitHub issue #44)
* | jn: new appletRon Yorston2022-05-161-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | Add a Windows-specific applet to create a directory junction. Usage: jn DIR JUNC where DIR must be an existing directory on a local drive and JUNC must not currently exist. There isn't a simple WIN32 API to create directory junctions. The implementation of mklink in ReactOS provided useful inspiration.
* | Merge branch 'busybox' into mergeRon Yorston2022-05-122-7/+258
|\|
| * seedrng: do not hash in a constant string, it's not adding entropyDenys Vlasenko2022-05-031-8/+8
| | | | | | | | | | | | | | | | | | | | function old new delta seedrng_main 906 880 -26 .rodata 104899 104873 -26 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-52) Total: -52 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * seedrng: restore error check on fsyncDenys Vlasenko2022-05-021-9/+12
| | | | | | | | | | | | | | | | | | Or else security people will never stop nagging us. function old new delta seedrng_main 884 906 +22 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * seedrng: it's not a part of util-linux, move to miscutilsDenys Vlasenko2022-05-021-0/+239
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * crond: implement support for setting PATH in crontab filesPaul Fox2022-05-021-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It's very inconvenient for a cron user not to be able to set a "personal" PATH for their cron jobs, as is possible with other crons function old new delta load_crontab 868 942 +74 .rodata 104878 104884 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 80/0) Total: 80 bytes Signed-off-by: Paul Fox <pgf@foxharp.boston.ma.us> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge busybox into mergeRon Yorston2022-02-098-11/+12
|\| | | | | | | | | | | | | | | Fix conflicts in reset and ash. Redefine the new safe_read_key() as a reference to read_key(). Disable SHA256_HWACCEL.
| * *: slap on a few ALIGN_PTR where appropriateDenys Vlasenko2022-02-061-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * *: slap on a few ALIGN* where appropriateDenys Vlasenko2022-02-062-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map" function old new delta .rodata 108586 108460 -126 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126) Total: -126 bytes text data bss dec hex filename 970412 4219 1848 976479 ee65f busybox_old 970286 4219 1848 976353 ee5e1 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * fix "defined but not used" warningsDenys Vlasenko2022-01-171-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>