summaryrefslogtreecommitdiff
path: root/libbb
AgeCommit message (Collapse)Author
2018-12-08lineedit: fix "defined but not used" sigaction2 warningDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-08inetd: suppress aliasing warningDenys Vlasenko
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>
2018-12-08suppress gcc 8 aliasing warningsDenys Vlasenko
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>
2018-12-06bc: unbreak FEATURE_CLEAN_UP buildDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-29libbb: do not misinterpret 0x10-0x19 chars in "\xNNN" tooDenys Vlasenko
function old new delta bb_process_escape_sequence 141 151 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-29libbb: @ in "\x3@" is not a valid hex digitDenys Vlasenko
function old new delta bb_process_escape_sequence 134 141 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-29cat,nl: fix handling of open errorsDenys Vlasenko
$ 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>
2018-11-27hush: allow hush to run embedded scriptsRon Yorston
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>
2018-11-26libbb: add comment on sha384Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-23wget: print the final newline only for non-tty outputDenys Vlasenko
$ 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>
2018-11-18busybox: add '--show SCRIPT' option to display scriptsRon Yorston
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>
2018-11-17Treat custom and applet scripts as appletsRon Yorston
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>
2018-11-02libarchive: add a function to unpack embedded dataRon Yorston
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>
2018-11-01busybox: show embedded scripts in applet listDenys Vlasenko
function old new delta busybox_main 624 642 +18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01lineedit: autocompletion for embedded scriptsRon Yorston
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>
2018-11-01ash: recognize embedded scripts in SH_STANDALONE modeRon Yorston
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>
2018-11-01claenups for previous commitDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01ash: allow shell scripts to be embedded in the binaryDenys Vlasenko
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>
2018-10-31libbb/u_signal_names.c: don't check errno after bb_strtouRasmus Villemoes
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>
2018-10-31libbb: optionally honour libc provided SIGRTMIN/SIGRTMAX in get_signum()Rasmus Villemoes
When an application documents that it responds such and such to SIGRTMIN+n, that almost always means with respect to the libc-provided SIGRTMIN. Hence I disagree with the "more correct" in commit 7b276fc17594. In any case, this is rather unfortunate: 36 34 (the first shell is bash). We probably can't change default behaviour after 7 years, but at least we can provide a config option. We avoid a little code generation (repeated calls to __libc_current_sigrtmin) by stashing SIGRTMIN/SIGRTMAX in local variables, but it does cost ~50 bytes. The next patch serves as penance for that. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30printf: fix printf "%u\n" +18446744073709551614Denys Vlasenko
function old new delta conv_strtoll 19 32 +13 conv_strtoull 49 61 +12 bb_strtoll 89 84 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 25/-5) Total: 20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-19printf: fix printing +-prefixed numbersBernhard Reutner-Fischer
Thanks to Cristian Ionescu-Idbohrn for noticing. Also fix "%d" ' 42' to skip leading whitespace. function old new delta print_direc 435 454 +19 bb_strtoll 99 103 +4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 23/0) Total: 23 bytes Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2018-09-30unzip: use printable_string() for printing filenamesDenys Vlasenko
function old new delta unzip_main 2726 2792 +66 printable_string2 - 57 +57 identify 4329 4336 +7 expmeta 659 663 +4 add_interface 99 103 +4 beep_main 286 289 +3 changepath 192 194 +2 builtin_type 115 117 +2 devmem_main 469 470 +1 input_tab 1076 1074 -2 create_J 1821 1819 -2 poplocalvars 314 311 -3 doCommands 2222 2214 -8 do_load 918 902 -16 printable_string 57 9 -48 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 8/6 up/down: 146/-79) Total: 67 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-23date: do not allow "month #20" and such, closes 11356Denys Vlasenko
function old new delta parse_datestr 906 961 +55 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-09remove_file: don't call rmdir if remove_file return failureChen Yu
When deleting a directory, the directory should not be removed if the file in the subdirectory fails to be deleted. Background information: When I tested the kernel using LTP (linux-test-project).I found the mv command have some issue. The LTP test case use the mv command to move the directory t1 in the cgroup file system to the /tmp directory. becase files in the cgroup file system are not allowed to be removed. so the mv reported "Permission denied", but I used the ls command to view the results and found that the directory t1 had been removed from the cgroup file system. For the same test case, I used the mv tool in the GNU coreutils, and the directory t1 will not be removed. the following testcase use busybox mv: / # mount -t cgroup -o cpu cgroup /cpu / # cd /cpu /cpu # mkdir -p t1 /cpu # ls cgroup.clone_children cpu.cfs_period_us cpu.stat t1 cgroup.procs cpu.cfs_quota_us notify_on_release tasks cgroup.sane_behavior cpu.shares release_agent /cpu # mv t1 /tmp mv: can't remove 't1/cgroup.procs': Operation not permitted mv: can't remove 't1/cpu.cfs_period_us': Operation not permitted mv: can't remove 't1/cpu.stat': Operation not permitted mv: can't remove 't1/cpu.shares': Operation not permitted mv: can't remove 't1/cpu.cfs_quota_us': Operation not permitted mv: can't remove 't1/tasks': Operation not permitted mv: can't remove 't1/notify_on_release': Operation not permitted mv: can't remove 't1/cgroup.clone_children': Operation not permitted /cpu # ls cgroup.clone_children cpu.cfs_period_us cpu.stat cgroup.procs cpu.cfs_quota_us notify_on_release tasks cgroup.sane_behavior cpu.shares release_agent /cpu # This patch fixed it, don't call rmdir if remove_file return failure, and under certain file systems, the mv could work normally. Signed-off-by: Chen Yu <yu.chen3@zte.com.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-03libbb: fix potential NULL pointer useDenys Vlasenko
function old new delta unicode_conv_to_printable2 193 216 +23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-03libbb: fix use-after-free in copy_fileDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-02libbb: in xmalloc_fgets(), use size_t for bb_get_chunk_from_file()Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-02Revert "libbb: remove unnecessary variable in xmalloc_fgets"Denys Vlasenko
The variable is in fact necessary. commit 2da9724b56169f00bd7fb6b9a11c9409a7620981 Author: Quentin Rameau <quinq@fifth.space> Date: Sun Apr 1 17:05:35 2018 +0200 libbb: remove unnecessary variable in xmalloc_fgets Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-26fix !CONFIG_FLOAT_DURATION buildDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-03Complie libbb/duration.c if ping[6] is selectedDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-03extend fractional duration support to "top -d N.N" and "timeout"Denys Vlasenko
function old new delta parse_duration_str - 168 +168 sleep_for_duration - 157 +157 top_main 885 928 +43 timeout_main 269 312 +43 handle_input 571 614 +43 duration_suffixes - 40 +40 sfx 40 - -40 sleep_main 364 79 -285 ------------------------------------------------------------------------------ (add/remove: 4/1 grow/shrink: 3/1 up/down: 494/-325) Total: 169 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-24hush: fix nested redirects colliding with script fdsDenys Vlasenko
This necessitates switch from libc FILE api to a simple homegrown replacement. The change which fixes the bug here is the deleting of restore_redirected_FILEs(); line. It was prematurely moving (restoring) script fd#3. The fix is: we don't even _want_ to restore scrit fds, we are perfectly fine with them being moved. The only reason we tried to restore them is that FILE api did not allow moving of FILE->fd. function old new delta refill_HFILE_and_getc - 93 +93 hfopen - 90 +90 hfclose - 66 +66 pseudo_exec_argv 591 597 +6 hush_main 1089 1095 +6 builtin_source 209 214 +5 save_fd_on_redirect 197 200 +3 setup_redirects 320 321 +1 fgetc_interactive 235 236 +1 i_peek_and_eat_bkslash_nl 99 97 -2 expand_vars_to_list 1103 1100 -3 restore_redirects 99 52 -47 fclose_and_forget 57 - -57 remember_FILE 63 - -63 ------------------------------------------------------------------------------ (add/remove: 3/2 grow/shrink: 6/3 up/down: 271/-172) Total: 99 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-17whitespace fixesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-13cp: optional --reflink supportDenys Vlasenko
function old new delta cp_main 428 512 +84 copy_file 1676 1742 +66 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-09usage: do not print trailing space for commands which have no argumentsDenys Vlasenko
function old new delta bb_show_usage 120 130 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-03hexdump: fix short file of zero butes treated as dupDenys Vlasenko
function old new delta bb_dump_dump 1466 1491 +25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-28testsuite/mount.tests: fix false positiveDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-27libbb: crypt() in newer glibc requires include <crypt.h>Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-06restore documentation on the build config languageKartik Agaram
Kconfig-language.txt was deleted in commit 4fa499a17b52b back in 2006. Move to docs/ as suggested by Xabier Oneca: http://lists.busybox.net/pipermail/busybox/2014-May/080914.html Also update references to it everywhere. Signed-off-by: Kartik Agaram <akkartik@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-26whitespace fixDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-24realpath,readlink -f: coreutils compat, closes 11021Denys Vlasenko
function old new delta xmalloc_realpath_coreutils - 121 +121 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-17libbb: new option FEATURE_ETC_SERVICES: if off, /etc/services reads often ↵Denys Vlasenko
avoided In practice, "wget http://host.com/" always uses port 80. People explicitly set non-standard ports via options or parameters ("telnet 1.2.3.4 567" or "telnet 1.2.3.4 ftp") instead of modifying /etc/services. function old new delta telnet_main 1466 1464 -2 rdate_main 215 198 -17 fakeidentd_main 269 252 -17 parse_url 459 392 -67 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-103) Total: -103 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-16less: fix fallout from "use common routine to set raw termios"Denys Vlasenko
Testcase: (sleep 10; ls) | busybox less [...] ~ LICENSE ~ Makefile ~ Makefile.custom ~ Makefile.flags [...] less did not want this part: + /* dont convert NL to CR+NL on output */ + newterm->c_oflag &= ~(ONLCR); function old new delta get_termios_and_make_raw 108 115 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08bzip2: fix two crashes on corrupted archivesDenys Vlasenko
As it turns out, longjmp'ing into freed stack is not healthy... function old new delta unpack_usage_messages - 97 +97 unpack_bz2_stream 369 409 +40 get_next_block 1667 1677 +10 get_bits 156 155 -1 start_bunzip 212 183 -29 bb_show_usage 181 120 -61 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/3 up/down: 147/-91) Total: 56 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07libbb: switch bb_ask_noecho() to "mallocing" string return APIDenys Vlasenko
function old new delta bb_ask_noecho 313 330 +17 get_cred_or_die 125 115 -10 passwd_main 995 958 -37 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 17/-47) Total: -30 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07xargs: use bb_ask_y_confirmation_FILE() instead of homegrown copyDenys Vlasenko
function old new delta bb_ask_y_confirmation_FILE - 83 +83 inetd_main 2033 2043 +10 udhcp_send_kernel_packet 295 301 +6 rmescapes 306 310 +4 send_tree 353 355 +2 i2cdetect_main 674 672 -2 confirm_or_abort 43 38 -5 get_terminal_width_height 242 234 -8 bb_ask_y_confirmation 76 10 -66 xargs_main 823 755 -68 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/5 up/down: 105/-149) Total: -44 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07libbb: rename bb_ask -> bb_ask_noecho, bb_ask_confirmation -> ↵Denys Vlasenko
bb_ask_y_confirmation Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07telnet: move winsize detection closer to I/O loop, delete non-functioning ↵Denys Vlasenko
debug code Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06placate gcc-8.0.1 warningsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>