aboutsummaryrefslogtreecommitdiff
path: root/miscutils (follow)
Commit message (Collapse)AuthorAgeFilesLines
* rpm: respect BB_SYSTEMROOTHEADmasterRon Yorston2026-07-021-1/+1
| | | | | | | | | | | | | | Update the 'rpm' applet so it also respects the BB_SYSTEMROOT environment variable. Replace chdir_system_drive() with xchdir_system_drive(), which exits on failure to change directory. Saves 32-36 bytes. (GitHub PR #603) Signed-off-by: Ron Yorston <rmy@pobox.com>
* crond: fix reboot special timeRon Yorston2026-05-191-0/+31
| | | | | | | | | | | | | | | The 'reboot' special time didn't work because the file to check for a reboot couldn't be created. And in any case, the mechanism used on Linux wouldn't work: Windows has no /var/run directory which is cleared on reboot. The crond.reboot file is now placed in the cron directory. If it doesn't exist when crond starts, it's created but the reboot job (if any) isn't run. If the file exists its modification time is compared with the time of the current boot. If it's older update its time and run the reboot job. Adds 144-224 bytes.
* crond: drop '-S' optionRon Yorston2026-05-191-5/+22
| | | | | | | Since we don't use syslog on Windows there's no point in having an option to set it. Log to stderr by default instead. Saves 88-96 bytes.
* crond,crontab: executable-relative cron directoriesRon Yorston2026-05-192-4/+40
| | | | | | | | | | | | | | | | | Some users want a 'portable' busybox-w32 installation on removable media. To help with this, certain files can be positioned relative to the location of the executable. crond and crontab now look for var/spool/cron/crontabs relative to the binary, and use that as their working directory if it exists. If it doesn't, fall back to the hardcoded absolute path. The '-c' command line option can still be used to override the automatic choice. The '-c' option in crond now updates the cron directory variable as well as that for crontabs. Adds 128-144 bytes.
* crond: build tweaksRon Yorston2026-05-031-2/+2
| | | | | | | | | | | | | | | Using 'depends on FEATURE_SYSLOG' is unreliable because FEATURE_SYSLOG can't be set directly. A POSIX build with all applets that need syslog disabled *except* crond may fail. Revert to using 'select FEATURE_SYSLOG' in crond and exclude the unused syslog code on Windows. If crond is unable to run sendmail report this in the error message. Update all default Windows configurations. (GitHub PR #561)
* Add crond and crontab (#561)mbartlett212026-05-032-8/+204
| | | | | | | | | | | | | | | | | | | | | * Enable crontab * Enable crond * Allow sendmail to be used in crond This also adds another option to the mingw_popen_fd function to capture stderr as well. And also added the options to support WNOHANG as well as an unused status in mingw_wait3 * Check current uid when running crond * Only show tail for mailto jobs * Use system drive for cron * crond: add missing feature check * crond: use spawn_detach for background operation
* Merge branch 'busybox' into mergeRon Yorston2026-03-112-60/+87
|\
| * less: unbreak EAGAIN propagationDenys Vlasenko2026-02-271-6/+12
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * less: make read error reporting actually visibleDenys Vlasenko2026-02-271-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta m_status_print 252 275 +23 status_print 111 122 +11 read_lines 783 775 -8 .rodata 107141 107131 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 34/-18) Total: 16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * less: improve O_NONBLOCK manipulations on stdinDenys Vlasenko2026-02-271-32/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | "less FILE" case needs it to be set just once. In other cases, manipulate it less often. function old new delta read_lines 702 783 +81 reinitialize 198 199 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 82/0) Total: 82 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * less: do not retry reads of stdin if got EAGAINDenys Vlasenko2026-02-271-35/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also: fewer syscalls to set/clear O_NONBLOCK, skip trying to read keyboard if poll() told us it's not ready. function old new delta reinitialize 184 198 +14 getch_nowait 251 258 +7 sched_yield 25 - -25 read_lines 815 702 -113 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 2/1 up/down: 21/-138) Total: -117 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * *: 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-123-24/+35
|\|
| * *: whitespace cleanupDenys Vlasenko2026-02-081-1/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * *: use xasprintf_inplace() in more placesDenys Vlasenko2026-02-061-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta .rodata 107009 107018 +9 parse_stream 3075 3069 -6 buffer_print 612 603 -9 expand_args 159 144 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 9/-30) Total: -21 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * man: fix following links if run inside manpage dirDenys Vlasenko2026-02-051-16/+28
| | | | | | | | | | | | | | function old new delta run_man_pipe 369 420 +51 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2026-02-102-8/+10
|\|
| * fdisk: several fixes for 4K sector sizeDenys Vlasenko2026-02-041-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta bb_getsize_in_512sect - 187 +187 list_disk_name_and_sizes - 80 +80 get_geometry 511 535 +24 .rodata 107066 107088 +22 msg_building_new_label 143 142 -1 fdisk_main 4781 4775 -6 list_table 1423 1366 -57 list_disk_geometry 143 68 -75 bb_BLKGETSIZE_sectors 191 - -191 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 2/4 up/down: 313/-330) Total: -17 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * devfsd: constify, code shrinkDenys Vlasenko2026-02-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta static.copy_inode 613 608 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5) Total: -5 bytes text data bss dec hex filename 1087619 827 5088 1093534 10af9e busybox_old 1087654 787 5088 1093529 10af99 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | make: bring into alignment with pdpmakeRon Yorston2026-01-261-2/+3
| | | | | | | | | | | | | | | | | | | | The make applet is based on code from pdpmake. Make a few minor adjustments to bring the two into line. The only one of any significance is setting 'target' to NULL in docmds(). Adds 16 bytes.
* | make: fix expansion of immediate-mode macrosRon Yorston2025-11-281-1/+5
| | | | | | | | | | | | | | | | | | Immediate-mode macros shouldn't be recursively expanded, but are subject to suffix and pattern substitution. Adds 16 bytes to the 32-bit build. (pdpmake GitHub issue 77)
* | make: override commands for single-colon target ruleRon Yorston2025-09-031-7/+30
| | | | | | | | | | | | | | | | | | | | If more than one single-colon target rule has commands only the last set of commands should be used. Previously the presence of more than one single-colon target rule with commands was treated as an error. Adds 88-112 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2025-08-151-1/+9
|\|
| * *: use safe_waitpid() or wait_any_nohang() where approppriateDenys Vlasenko2025-07-301-3/+7
| | | | | | | | | | | | | | | | | | | | | | function old new delta crond_main 1227 1237 +10 init_main 804 794 -10 wait_one 263 252 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-21) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * crond: reap orphaned grandchildren to prevent zombie buildupValentin Lab2025-07-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a cron job launches a background task, e.g. `sh -c "sleep 5 &"`, the shell exits immediately and the `sleep` process is re-parented to PID 1. When BusyBox `crond` itself happens to be PID 1 (common in a minimal container), those orphans become direct children of `crond`. Because `crond` only calls waitpid() for the PIDs it explicitly tracks, these processes remain forever in Z state and the container slowly fills with zombies. Add a small `while (waitpid(-1, NULL, WNOHANG) > 0)` sweep at the end of check_completions() so any stray children are reaped. When `crond` is not PID 1 the loop returns -ECHILD immediately, so behaviour and overhead on a normal system are unchanged. Size impact: +12 bytes on x86-64 (gcc 13.3.0 -Os, static) Signed-off-by: Valentin Lab <valentin.lab@kalysto.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2025-08-121-1/+1
|\|
| * libbb: crypt_make_pw_salt(): fix yescrypt's random salt last charDenys Vlasenko2025-07-191-1/+1
| | | | | | | | | | | | | | function old new delta crypt_make_pw_salt 128 146 +18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2025-08-101-1/+1
|\|
| * shell: fix race between signal handlers setting bb_got_signal and poll()Denys Vlasenko2025-07-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta __ppoll_time64 - 211 +211 check_got_signal_and_poll - 164 +164 read_key 607 601 -6 shell_builtin_read 1328 1318 -10 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 0/2 up/down: 375/-16) Total: 359 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2025-05-192-2/+2
|\|
| * libbb/archival: make setup_unzip_on_fd() return bytes read if not compressedDenys Vlasenko2025-04-202-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | setup_unzip_on_fd() does not return the transformer structure, so the user does not know how much to seek back (or alternatively what the signature was) when compressor signature is not detected. Currently not needed (the only user is tar which dies anyway). However, rpm2cpio may need this if we extend it to extract the internal .cpio even if cpio's compressions algo is not known. function old new delta setup_unzip_on_fd 53 59 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | make: fix detection of target rule with inline commandRon Yorston2025-01-221-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit f9d10b2b6 (make: fix detection of target rules (take 2)) added code to handle the case where a target rule had an inline command with a ';' separator in a macro. This required all macros on the line to be expanded, including those in the inline command. The ';' should first be searched for in the original line (without any macro expansion) and only if that fails should macros be expanded. This matches the behaviour of GNU and Unix V7 make. BSD and Schily make don't handle the case where the ';' is in a macro. (pdpmake GitHub issue 73)
* | make: fix single-suffix inference rule regressionRon Yorston2025-01-211-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | Commit 85bbce87d (make: support GNU/BSD suffixes and inference rules) added code to handle inference rules with arbitrary suffixes. Unfortunately it failed to check for a single-suffix rule in the case where no known suffix was found. Add the necessary code and a test which would have caught the problem. Adds 48 bytes. (pdpmake GitHub issue 72)
* | make: phony targets and double colon rulesRon Yorston2025-01-161-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 770bad1fe (make: disallow inference rules for phony targets) added the GNU/BSD make feature that inference rules aren't used for phony targets. Normally a double-colon rule without associated commands causes an inference rule search. If the target of the double-colon rule was phony no search was carried out and the rule failed. As a result of this perl failed to build (on Linux, I didn't try on Windows). When a double-colon rule has no commands and a phony target the prerequisites should be built and the rule should succeed. Adds 32 bytes. (pdpmake GitHub issue #70)
* | make: minor tweaksRon Yorston2025-01-161-32/+37
| | | | | | | | | | | | | | | | | | | | | | Move the code to remove the suffix from a target into a separate function. There's no need to test for non-NULL 'makefile' in newcmd(). Cosmetic changes. Saves 0-16 bytes.
* | make: support GNU/BSD suffixes and inference rulesRon Yorston2025-01-141-70/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The specification of inference rules in POSIX implies that only suffixes starting with a period and containing no other periods are to be considered. In contrast, both GNU and BSD make allow suffixes to contain an arbitrary number of periods, or none at all. Allow this as an extension. Adds 640-816 bytes. (pdpmake GitHub issue 70)
* | 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.
* | 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-201-7/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | make: fix error reporting for included filesFRP-5467-g9376eebd8Ron Yorston2024-09-151-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | The global variables 'makefile' and 'lineno' weren't properly reset after a recursive call to input(). As a result error messages for included files could refer to the wrong file or line number. Restore 'makefile' and 'lineno' immediately after a rescursive call to input(). This also requires a different fix for commit b21546ddb (make: fix test for include with no pathnames). Adds 16 bytes in the 32-bit build.
* | make: fix test for include with no pathnamesRon Yorston2024-09-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In POSIX 2024 the behaviour of an include line with no pathnames is unspecified. The test for this condition was incorrect in certain circumstances. Files containing dependencies may be generated by the compiler and included in the makefile. On an initial build no dependency files will be present and the include line is made to ignore errors. In this case the test for no pathnames returned true, even though many pathnames may have been present. Fix the problem by always setting 'makefile' even if the named file can't be opened.
* | make: handling of leading whitespace in makefilesRon Yorston2024-09-101-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Try to match how different makes handle leading whitespace in makefiles. (Tested with GNU, BSD, Schily and UNIX Version 7 make.) - Commands in rules must start with a tab. It's the law. - BSD make doesn't allow any whitespace at the start of an include line. Enforce this restriction in POSIX mode: 'the word include ... appears at the beginning of a line'. As an extension allow arbitrary tabs or spaces. - All implementations allow a space as the first character of a macro definition or rule. Permit this in all cases. - Only GNU make allows a tab as the first character of a macro definition, but POSIX 2024 seems to permit it too: 'string1 is defined as all characters from the first non-<blank> character to the last non-<blank> character, inclusive'. Allow this in POSIX 2024 mode and as an extension. - No implementation allows a tab as the first character of a rule. Disallow this in all cases. Adds 32-64 bytes. (pdpmake GitHub issue 63)
* | make: reinstate conditional skipping of command linesRon Yorston2024-09-101-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit e90345c10 (make: allow empty commands) rearranged readline() in a way that broke the use of conditionals within the definition of a rule. Add a test case to detect this. Adjust readline() so that conditionals are processed before returning command lines or checking for empty lines and comments. Remove the test for a leading tab in skip_lines(). This allows conditionals in the definition of a rule to be indented with a leading tab.
* | make: duplicate makefile name recorded with commandRon Yorston2024-08-221-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit f3f72ac1d (make: show location of errors during build) stored a pointer to the name of the makefile with each command, for use in diagnostic messages. While this is fine for makefiles defined on the command line, the names of included files will have been freed before they can be used. Always take a copy of the makefile name stored with commands. Adds 32-48 bytes. (GitHub issue #449)
* | win32: use 64-bit time on 32-bit platformsRon Yorston2024-08-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid problems with dates in 2038 and beyond use 64-bit time values on 32-bit platforms. - Mostly this just requires a few preprocessor macros to choose the appropriate functions, structs and typedefs. - We have our own implementations of nanosleep(), clock_gettime() and clock_settime(). Omit the Windows include file that declares them. - Apply the hack for struct timeval in the 'ts' applet on 32-bit. Adds 1624 bytes on 32-bit, none on 64-bit. (GitHub issue #446)
* | make: disallow inference rules for phony targetsRon Yorston2024-08-101-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | GNU make doesn't allow inference rules or the .DEFAULT target to be used for phony targets. POSIX is unclear on the matter but there doesn't seem to be an explicit prohibition of inference rules or .DEFAULT. Follow the GNU make behaviour as a non-POSIX extension. Adds 48-80 bytes. (pdpmake GitHub issue 56)