summaryrefslogtreecommitdiff
path: root/libbb (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* | win32: add a function to detect running with elevated privilegesRon Yorston2019-03-091-0/+3
| | | | | | | | | | Add is_admin() and use it to alter the command prompt in the line editor when running with admin privileges.
* | libbb: copy entire match during tab-completionRon Yorston2019-03-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Because tab-completion is case-insensitive the matching text might differ from what the user typed. Insert the whole of the matching text, not just the tail. Thus: $ cd doc<TAB> now expands to: $ cd Documents/
* | win32: stat(2) succeeds if fetching extra metadata failsRon Yorston2019-02-192-2/+8
| | | | | | | | | | | | | | | | | | Some files can't be opened to fetch additional metadata. When that happens allow stat(2) to successfully return what data it has. In a few cases where the inode number is used to determine if files are identical ignore invalid inode numbers.
* | win32: fix POSIX buildRon Yorston2019-02-171-0/+8
| | | | | | | | | | | | There were a few places where changes intended for the WIN32 build also affected the POSIX build. Fix these so the result of 'make defconfig; make' for busybox-w32 is identical to upstream BusyBox.
* | win32: make stat(2) fetch additional metadataRon Yorston2019-02-162-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modify the WIN32 implementation of stat(2) to fetch inode number, device id and number of hardlinks. This requires opening a handle to the target file so it will be slower. A number of features can be enabled or start to work: - tar can detect if an archive is being stored in itself; - find can support the -inum and -links options; - ls can display inode numbers; - diff can detect attempts to compare a file with itself; - du has better support for hardlinked files; - cp can detect attempts to copy a file over itself.
* | Merge branch 'busybox' into mergeRon Yorston2019-02-123-13/+14
|\|
| * lineedit: fix SEGV in isk, hexedit, ed, closes 11661Denys Vlasenko2019-02-041-4/+5
| | | | | | | | | | | | | | | | | | | | | | fdisk, hexedit and ed calls read_line_edit in libbb/lineedit.c with NULL as first argument. On line 2373 of lineedit.c of busybox version 1.29.3, state->hist_file is referenced without checking the state->flag. This causes segmentation fault on fdisk, hexedit and ed on ARM Cortex-A9. It somehow works on x86_64. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * capability: fix string comparison in cap_name_to_numberMark Marshall2019-01-211-1/+1
| | | | | | | | | | | | | | | | The result of strcasecmp was being used incorrectly. This function returns 0 if the strings match. Signed-off-by: Mark Marshall <mark.marshall@omicronenergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * start-stop-daemon: create pidfile before parent exits, closes 8596Denys Vlasenko2019-01-141-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes DAEMON_DOUBLE_FORK flag from bb_daemonize_or_rexec(), as SSD was the only user. Also includes fix for -S: now works without -a and -x, does not print pids (compat with "start-stop-daemon (OpenRC) 0.34.11 (Gentoo Linux)"). function old new delta start_stop_daemon_main 1018 1084 +66 add_interface 99 103 +4 fail_hunk 139 136 -3 bb_daemonize_or_rexec 205 183 -22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 70/-25) Total: 45 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: skip fake path componentsRon Yorston2019-02-071-4/+5
| | | | | | | | | | | | | | | | Commit 3476fb9f4 added a fake prefix to the applet pathname to identify the argument containing the name of an interpreted script. Skip over the prefix to prevent it appearing in error messages.
* | win32: add support for the euro currency symbolRon Yorston2019-02-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The euro currency symbol was added to some OEM code pages. See: https://www.aivosto.com/articles/charsets-codepages-dos.html Add a configuration option (enabled by default) to support this. When enabled: - The read_key() function requests wide character key events. This allows the euro symbol to be entered regardless of the console OEM code page, though it needs to be available in the ANSI code page. - Conversions between OEM and ANSI code pages in winansi.c are modified to work around a bug in the Microsoft routines. - If the OEM code page is 850 when BusyBox starts it's changed to 858. This is the only currently supported OEM code page. Also, the shell read builtin is modified to use read_key() whenever input is being taken from the console.
* | Merge branch 'busybox' into mergeRon Yorston2019-01-104-17/+41
|\|
| * single-applet build --help had extra \n, removeDenys Vlasenko2019-01-011-5/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * pmap: make 32-bit version work better on 64-bit kernelsDenys Vlasenko2018-12-311-4/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * randomconfig fixesDenys Vlasenko2018-12-271-8/+10
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * lineedit: fix "defined but not used" sigaction2 warningDenys Vlasenko2018-12-081-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * inetd: suppress aliasing warningDenys Vlasenko2018-12-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta sigprocmask2 - 8 +8 wait_for_child_or_signal 213 218 +5 dowait 424 429 +5 block_CHLD_HUP_ALRM 62 59 -3 sigprocmask_SIG_SETMASK 16 - -16 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 2/1 up/down: 18/-19) Total: -1 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * suppress gcc 8 aliasing warningsDenys Vlasenko2018-12-082-1/+21
| | | | | | | | | | | | | | | | | | function old new delta sigprocmask_SIG_SETMASK - 16 +16 wait_for_child_or_signal 221 213 -8 dowait 432 424 -8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * bc: unbreak FEATURE_CLEAN_UP buildDenys Vlasenko2018-12-061-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ps: display interpreted script name in comm columnRon Yorston2019-01-081-1/+17
| | | | | | | | | | | | | | | | | | | | | | When an interpreted script is being run the comm column in ps should display the name of the script not the name of the interpreter. Use a fake applet pathname to indicate which argument contains the script. This also allows pidof to obtain the pid of a script.
* | ps: add support for the args columnRon Yorston2019-01-081-11/+18
| | | | | | | | | | | | | | | | | | Implement read_cmdline() for WIN32 by storing the command line in the same way as the applet name. The applet name is actually used for the comm column which is truncated to COMM_LEN. Using this as the size of the bb_comm array avoids the need to calculate MAX_APPLET_NAME_LEN.
* | win32: implement umask(2)Ron Yorston2019-01-071-0/+9
| | | | | | | | | | | | | | | | | | umask() in the Microsoft C runtime takes different arguments to umask(2). Implement a fake umask(2) that remembers the mask and calls the Microsoft umask() with an appropriate value. Since the mask won't be inherited by children use an environment variable to pass any value set by the shell built-in umask.
* | iconv: import from win-iconvRon Yorston2019-01-061-1/+1
| | | | | | | | | | Source imported from https://github.com/win-iconv/win-iconv and modified to build in busybox-w32.
* | busybox: add --uninstall optionRon Yorston2019-01-051-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an option to allow hard links to be removed. busybox --uninstall file removes all hard links to the given file (including the file itself.) Since Microsoft Windows refuses to delete a running executable a BusyBox binary is unable to remove links to itself. busybox --uninstall -n file displays the names of all hard links to the given file. Although this feature is couched in terms of uninstalling BusyBox it's actually quite general: it can be used to delete or display hard links to any file.
* | busybox: identify scripts in output of 'busybox --list-full'Ron Yorston2019-01-051-0/+4
| |
* | lineedit: allow non-ASCII characters when tab-completing filenamesRon Yorston2019-01-051-0/+4
| |
* | win32: special treatment for PATHRon Yorston2018-12-142-21/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The PATH shell variable is a special case. It can be exported to the environment where it might be interpreted by native applications which assume the separator is ';'. Hence: - require that the separator used in PATH is ';' - enforce this by intercepting calls to setvareq() that set PATH and adjusting its value if necessary. As a result of this the code to parse PATH can be simplified by replacing the hardcoded Unix ':' path separator by the platform- dependent macro PATH_SEP. The MANPATH variable is also required to use ';' as its separator but since it's less likely to be used this isn't enforced.
* | ash: move code from setup_environment()Ron Yorston2018-12-142-12/+1
| | | | | | | | | | | | | | ash calls setup_environment() but only uses a small amount of its functionality. Moving the code into ash itself means we don't need to customise setup_environment() for WIN32 and can remove it from the build.
* | win32: emulate SIGPIPERon Yorston2018-12-111-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code to check whether a write error is due to a broken pipe can now either: - return with error EPIPE; - cause the process to exit with code 128+SIGPIPE. The default is the latter but the behaviour can be changed by issuing signal(SIGPIPE, SIG_IGN) and signal(SIGPIPE, SIG_DFL) calls. No actual signal is involved so kill can't send SIGPIPE and handlers other than SIG_IGN and SIG_DFL aren't supported. This does, however, avoid unsightly 'broken pipe' errors from commands like the example in GitHub issue #99: dd if=/dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
* | win32: add a case-insensitive version of is_suffixed_with()Ron Yorston2018-12-091-0/+28
| |
* | lineedit: more case-insensitive comparisons in tab completionRon Yorston2018-12-082-0/+26
| |
* | lineedit: improvements to tab completionRon Yorston2018-12-082-10/+22
| | | | | | | | | | | | | | | | | | | | Since getpwent isn't implemented for WIN32 there's no point in enabling FEATURE_USERNAME_COMPLETION. Use case-insensitive comparisons when matching filenames. The code to exclude non-executables when tab completing executables is WIN32-specific and shouldn't omit directories.
* | win32: rework adding of extensions to filenamesRon Yorston2018-12-061-21/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously there was one function to handle adding extensions to executable filenames, add_win32_extension(). Refactor this into three functions: add_win32_extension() appends the suffix to the argument string in-place. The argument must be long enough to cope with this, as is the case in ash where path_advance() adds 4 bytes to each filename for just this reason. alloc_win32_extension() is equivalent to the old add_win32_extension(). It allocates a string to hold the new filename then calls the new add_win32_extension() function. The caller is responsible for managing the returned string. auto_win32_extension() calls alloc_win32_extension() and saves the resulting string using auto_string(). It's used where the new filename is consumed immediately or the actual value isn't needed. Rewrite code to use the most appropriate function. Also reorder some code in find_executable() and find_command().
* | Merge branch 'busybox' into mergeRon Yorston2018-12-052-7/+19
|\|
| * libbb: do not misinterpret 0x10-0x19 chars in "\xNNN" tooDenys Vlasenko2018-11-291-6/+4
| | | | | | | | | | | | | | function old new delta bb_process_escape_sequence 141 151 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: @ in "\x3@" is not a valid hex digitDenys Vlasenko2018-11-291-2/+10
| | | | | | | | | | | | | | function old new delta bb_process_escape_sequence 134 141 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cat,nl: fix handling of open errorsDenys Vlasenko2018-11-291-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ cat -n does_not_exist; echo $? cat: does_not_exist: No such file or directory 1 function old new delta print_numbered_lines 118 129 +11 nl_main 196 201 +5 cat_main 421 425 +4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 20/0) Total: 20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2018-11-284-65/+152
|\|
| * hush: allow hush to run embedded scriptsRon Yorston2018-11-271-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Embedded scripts require a shell to be present in the BusyBox binary. Allow either ash or hush to be used for this purpose. If both are enabled ash takes precedence. The size of the binary is unchanged in the default configuration: both ash and hush are present but support for embedded scripts isn't compiled into hush. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: add comment on sha384Denys Vlasenko2018-11-261-0/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * wget: print the final newline only for non-tty outputDenys Vlasenko2018-11-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ busybox wget URL 2>&1 | cat Connecting to .... install.iso 0% | | 2629k 0:02:05 ETA install.iso 7% |** | 25.7M 0:00:23 ETA install.iso 16% |***** | 54.1M 0:00:14 ETA install.iso 20% |****** | 67.4M 0:00:15 ETA install.iso 25% |******** | 81.0M 0:00:14 ETA install.iso 30% |********* | 97.3M 0:00:13 ETA install.iso 36% |*********** | 117M 0:00:12 ETA install.iso 41% |************* | 134M 0:00:11 ETA install.iso 47% |*************** | 152M 0:00:10 ETA install.iso 54% |***************** | 176M 0:00:08 ETA install.iso 61% |******************* | 200M 0:00:06 ETA install.iso 66% |********************* | 215M 0:00:06 ETA install.iso 71% |********************** | 231M 0:00:05 ETA install.iso 75% |************************ | 244M 0:00:04 ETA install.iso 79% |************************* | 257M 0:00:03 ETA install.iso 84% |*************************** | 275M 0:00:02 ETA install.iso 91% |***************************** | 297M 0:00:01 ETA install.iso 99% |******************************* | 321M 0:00:00 ETA install.iso 100% |********************************| 323M 0:00:00 ETA <-- no empty line here $ function old new delta bb_progress_update 622 632 +10 progress_meter 152 158 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 16/0) Total: 16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * busybox: add '--show SCRIPT' option to display scriptsRon Yorston2018-11-181-38/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an option to allow the content of embedded scripts to be displayed. This includes applet scripts, custom scripts and the .profile script. function old new delta busybox_main 624 701 +77 find_script_by_name - 24 +24 scripted_main 41 35 -6 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 101/-6) Total: 95 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Treat custom and applet scripts as appletsRon Yorston2018-11-172-56/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BusyBox has support for embedded shell scripts. Two types can be distinguished: custom scripts and scripts implementing applets. Custom scripts should be placed in the 'embed' directory at build time. They are given a default applet configuration and appear as applets to the user but no further configuration is possible. Applet scripts are integrated with the BusyBox build system and are intended to be used to ship standard applets that just happen to be implemented as scripts. They can be configured at build time and appear just like native applets. Such scripts should be placed in the 'applets_sh' directory. A stub C program should be written to provide the usual applet configuration details and placed in a suitable subsystem directory. It may be helpful to have a configuration option to enable any dependencies the script requires: see the 'nologin' applet for an example. function old new delta scripted_main - 41 +41 applet_names 2773 2781 +8 applet_main 1600 1604 +4 i2cdetect_main 672 674 +2 applet_suid 100 101 +1 applet_install_loc 200 201 +1 applet_flags 100 101 +1 packed_usage 33180 33179 -1 tryexec 159 152 -7 evalcommand 1661 1653 -8 script_names 9 - -9 packed_scripts 123 114 -9 complete_cmd_dir_file 826 811 -15 shellexec 271 254 -17 find_command 1007 990 -17 busybox_main 642 624 -18 run_applet_and_exit 100 78 -22 find_script_by_name 51 - -51 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 6/9 up/down: 58/-174) Total: -116 bytes text data bss dec hex filename 950034 477 7296 957807 e9d6f busybox_old 949918 477 7296 957691 e9cfb busybox_unstripped Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libarchive: add a function to unpack embedded dataRon Yorston2018-11-021-66/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar code to unpack embedded data is used to decompress usage messages, embedded scripts and the config file (in the non-default bbconfig applet). Moving this code to a common function reduces the size of the default build and hides more of the internals of libarchive. function old new delta unpack_bz2_data - 135 +135 bb_show_usage 137 157 +20 get_script_content 32 47 +15 unpack_scripts 119 - -119 unpack_usage_messages 124 - -124 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 2/0 up/down: 170/-243) Total: -73 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * busybox: show embedded scripts in applet listDenys Vlasenko2018-11-011-15/+21
| | | | | | | | | | | | | | function old new delta busybox_main 624 642 +18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * lineedit: autocompletion for embedded scriptsRon Yorston2018-11-011-4/+10
| | | | | | | | | | | | | | | | function old new delta complete_cmd_dir_file 811 826 +15 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: recognize embedded scripts in SH_STANDALONE modeRon Yorston2018-11-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta find_script_by_name - 51 +51 shellexec 254 271 +17 find_command 990 1007 +17 evalcommand 1653 1661 +8 doCommands 2233 2222 -11 run_applet_and_exit 128 100 -28 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 6/4 up/down: 104/-52) Total: 52 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * claenups for previous commitDenys Vlasenko2018-11-011-20/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: allow shell scripts to be embedded in the binaryDenys Vlasenko2018-11-012-1/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To assist in the deployment of shell scripts it may be convenient to embed them in the BusyBox binary. 'Embed scripts in the binary' takes any files in the directory 'embed', concatenates them with null separators, compresses them and embeds them in the binary. When scripts are embedded in the binary, scripts can be run as 'busybox SCRIPT [ARGS]' or by usual (sym)link mechanism. embed/nologin is provided as an example. function old new delta packed_scripts - 123 +123 unpack_scripts - 87 +87 ash_main 1103 1171 +68 run_applet_and_exit 78 128 +50 get_script_content - 32 +32 script_names - 10 +10 expmeta 663 659 -4 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 2/1 up/down: 370/-4) Total: 366 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/u_signal_names.c: don't check errno after bb_strtouRasmus Villemoes2018-10-311-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we're comparing the return value to a smallish integer anyway, we might as well use that bb_strtou() returns UINT_MAX for malformed input. Referencing errno is kinda bloaty on glibc. While NSIG is not in POSIX, we do already rely on it being defined, compile-time const and smallish, since arrays in struct globals_misc are defined in terms of it. function old new delta get_signum 312 286 -26 Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>