aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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-16ash: ensure variables are fully initialised when unsetRon Yorston
When a variable is unset by calling setvar(name, NULL, 0) the code to initialise the new, empty variable fails to initialise the last character of the string. Attempts to read the contents of the unset variable will result in the uninitialised character at the end of the string being accessed. For example, running BusyBox under Valgrind and unsetting PATH: $ valgrind ./busybox_unstripped sh ==21249== Memcheck, a memory error detector ==21249== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==21249== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info ==21249== Command: ./busybox_unstripped sh ==21249== /data2/git/build_fix_8721 $ unset PATH /data2/git/build_fix_8721 $ 0 ==21249== Conditional jump or move depends on uninitialised value(s) ==21249== at 0x451371: path_advance (ash.c:2555) ==21249== by 0x456E22: find_command (ash.c:13407) ==21249== by 0x458425: evalcommand (ash.c:10139) ==21249== by 0x454CBC: evaltree (ash.c:9131) ==21249== by 0x456C80: cmdloop (ash.c:13164) Closes https://bugs.busybox.net/show_bug.cgi?id=8721 v2: On the dash mailing list Harald van Dijk was kind enough to point out a flaw in my reasoning and provide an alternative patch. Sadly his patch adds 2 bytes of bloat. Using xzalloc to zero the whole string gives a bloat of -3 bytes. function old new delta setvar 172 169 -3 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-14hush: correct description for HUSH_TICK config optionRon Yorston
The HUSH_TICK configuration option enables command substitution, not process substitution. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-14tls: code shrinkDenys Vlasenko
function old new delta spawn_ssl_client 219 218 -1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-13wget: print "TLS certificate validation not implemented" only once on redirectsDenys Vlasenko
function old new delta spawn_ssl_client 209 219 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-13tls: code shrinkDenys Vlasenko
function old new delta tls_get_zeroed_outbuf - 28 +28 static.empty_client_cert 7 - -7 tls_handshake 1930 1890 -40 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/1 up/down: 28/-47) Total: -19 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-13tls: tidy up recently added ECDSA codeDenys Vlasenko
function old new delta tls_handshake 1935 1930 -5 static.OID_ECDSA_KEY_ALG 21 11 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-15) Total: -15 bytes text data bss dec hex filename 950036 477 7296 957809 e9d71 busybox_old 950048 477 7296 957821 e9d7d busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-13tls: code shrinkDenys Vlasenko
function old new delta static.f25519_one 32 - -32 curve25519 835 802 -33 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-65) Total: -65 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-13tls: add support for ECDHE-ECDSA-AES-128-CBC-SHA and x25519 curveDenys Vlasenko
function old new delta curve25519 - 835 +835 tls_handshake 1619 1935 +316 xc_diffadd - 230 +230 fe_mul__distinct - 149 +149 lm_sub - 103 +103 lm_add - 82 +82 fe_mul_c - 74 +74 fe_select - 45 +45 static.f25519_one - 32 +32 static.basepoint9 - 32 +32 static.OID_ECDSA_KEY_ALG - 21 +21 static.OID_RSA_KEY_ALG - 13 +13 static.supported_groups - 8 +8 static.empty_client_cert - 7 +7 der_binary_to_pstm 40 42 +2 static.expected 13 - -13 ------------------------------------------------------------------------------ (add/remove: 14/1 grow/shrink: 2/0 up/down: 1949/-13) Total: 1936 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-06ash: minor fixesRon Yorston
Ensure that login_sh is initialised in procargs even when running an embedded script. The argc argument to ash_main isn't unused when embedded scripts are present. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-05tls: code shrinkDenys Vlasenko
function old new delta tls_handshake 1643 1619 -24 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-04tls: reorder a few more cipher idsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-04tls: move TLS_AES_128_GCM_SHA256 definition upDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-04tls: add more cipher ids, no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-03udhcpc: code shrinkDenys Vlasenko
function old new delta perform_release 112 172 +60 send_release 81 - -81 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 60/-81) Total: -21 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-02remove FAST_FUNC on a static functionDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-02scripts/embedded_scripts: do not add superfluous NUL to script_names[]Denys Vlasenko
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-01svlogd: fix pattern matching when using timestampsDenys Vlasenko
function old new delta svlogd_main 1488 1496 +8 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: fix thinko in last commitDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01ash: in tryexec(), ensure we don't try to run embedded scripts as appletsRon Yorston
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-31vi: remove duplicated codeRon Yorston
At worst show_status_line() might be called needlessly when the user presses ^L/^R, but I don't think we'll get many complaints about that. function old new delta do_cmd 4592 4558 -34 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-34) Total: -34 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-30ntpd: default to FEATURE_NTP_AUTH=yDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30dd: do not have 'ocount' variable if ibs/obs support is not enabledDenys Vlasenko
function old new delta packed_usage 32964 32961 -3 dd_main 1033 1021 -12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-15) Total: -15 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30dd: add 'oflag=seek_bytes'Rostislav Skudnov
Allow specifying position in the output file in bytes instead of obs-sized blocks, improve compatibility with GNU dd. function old new delta dd_main 1632 1693 +61 packed_usage 33130 33150 +20 static.oflag_words - 12 +12 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 93/0) Total: 93 bytes Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30xargs: fix exit code if command exits nonzero, closes 11381Denys Vlasenko
No code size change on x86. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30free: add 'available' memory if provided by the kernelGuillermo Rodriguez
Show estimated available memory if this is provided by the kernel. See [1] for the full story. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773 function old new delta free_main 537 633 +96 parse_cached_kb 85 - -85 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 96/-85) Total: 11 bytes Signed-off-by: Guillermo Rodriguez <guille.rodriguez@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30examples/udhcp/simple.script: add possibility to use modern "ip"Jiří Prchal
Script uses "ifconfig" only, not up-to-date so much. This patch adds "ip" in condition if exists. Signed-off-by: Jiří Prchal <jiri.prchal@aksignal.cz> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30udhcpc: ensure at least one unicast renew attemptDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-27ntpd: add support for MD5/SHA1 message authenticationBrandon P. Enochs
Add support for MD5 message authentication as described in RFC 5905. This patch also supports SHA1 authentication. The key file format is the same file format as used by ntpd. The configuration file format follows standard Unix conventions (# comments) with lines consist of the following fields separated by whitespace: <key identifier, [1,65535]> <SHA1|MD5> <an ASCII string of up to 20 characters|an octet string [a-zA-F0-9] of up to 40 characters>. https://www.ietf.org/rfc/rfc5905.txt function old new delta ntp_init 473 987 +514 hash - 125 +125 recv_and_process_peer_pkt 889 961 +72 packed_usage 33066 33130 +64 ntpd_main 1226 1277 +51 find_key_entry - 29 +29 add_peers 195 207 +12 recv_and_process_client_pkt 509 514 +5 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 6/0 up/down: 872/0) Total: 872 bytes Signed-off-by: Brandon P. Enochs <enochs.brandon@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-24nbd-client: support newstyle protocol, -b, -d, -p, -NDenys Vlasenko
Recognize the "newstyle" protocol and switch to it automatically. Add options for setting blocksize (-b) and for disconnecting a nbd device (-d). function old new delta nbdclient_main 492 1179 +687 static.long_options - 80 +80 print_direc 438 457 +19 brctl_main 1169 1183 +14 bb_strtoll 84 89 +5 packed_usage 33082 33066 -16 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/1 up/down: 805/-16) Total: 789 bytes Signed-off-by: Elvira Khabirova <lineprinter@altlinux.org> 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-10-01brctl: use a single buffer for brname and ifnameBernhard Reutner-Fischer
function old new delta brctl_main 1681 1675 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-6) Total: -6 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-30ifupdown: support "source-directory" stanzaBrandon Maier
Support the "source-directory" stanza from ifupdown[1]. source-directory will include all files in the named directory. Similar to the Busybox version of the "source" stanza, this version of source-directory does not currently support shell wildcards. We only check that the stanza starts with "source-dir" as ifupdown does[2]. [1] https://manpages.debian.org/stretch/ifupdown/interfaces.5.en.html#INCLUDING_OTHER_FILES [2] https://salsa.debian.org/debian/ifupdown/blob/0.8.33/config.c#L498 function old new delta read_interfaces 1150 1241 +91 Signed-off-by: Brandon Maier <brandon.maier@rockwellcollins.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-28move storage helpers to libbb.hDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-28udhcpc: give SIGUSR1-induced renew one chance of unicast renewDenys Vlasenko
The caps were inconsistent: timeout to renew was capped at 20 seconds, and any renews with timeout <= 60 seconds were forced to broadcast. function old new delta udhcpc_main 2683 2680 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-26.gitignore: add ctags output filesMartin Kaiser
Exuberant ctags creates an output file called "tags" by default or "TAGS" when it's run in emacs mode. Add those two files to .gitignore so they won't be removed by git clean -df. Signed-off-by: Martin Kaiser <martin@kaiser.cx> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-25mdev.txt: explain the meaning of a leading "-"Martin Kaiser
If a line in mdev.conf starts with "-", parsing will continue even if a match is found in that line. Signed-off-by: Martin Kaiser <martin@kaiser.cx> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-25sed: fix double-free in FEATURE_CLEAN_UP codeDenys Vlasenko
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-22head: convert existing tests to new-styleThomas De Schampheleire
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>