aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-04-01libbb: remove unnecessary variable in xmalloc_fgetsQuentin Rameau
Signed-off-by: Quentin Rameau <quinq@fifth.space> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01hush: add a comment where we differ from bash wrt heredoc EOF mark handlingDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01parser: Fix backquote support in here-document EOF markDenys Vlasenko
Upstream commit: Author: Herbert Xu <herbert@gondor.apana.org.au> Date: Thu Mar 15 18:27:30 2018 +0800 parser: Fix backquote support in here-document EOF mark Currently using backquotes in a here-document EOF mark is broken because dash tries to do command substitution on it. This patch fixes it by checking whether we're looking for an EOF mark during tokenisation. Reported-by: Harald van Dijk <harald@gigawatt.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> With added fix for quoted-ness of the EOF mark. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01ash,hush: handle a few more bkslash-newline casesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31shells: fix var_LINENO1.tests false positive, add it to ash tests tooDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31hush: fix heredoc_bkslash_newline1.tests failureDenys Vlasenko
function old new delta parse_stream 2787 2827 +40 builtin_type 117 115 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31ash: use pgetc_eatbnl() in more placesDenys Vlasenko
Part of upstream commit: Date: Thu Mar 8 08:37:11 2018 +0100 Author: Harald van Dijk <harald@gigawatt.nl> parser: use pgetc_eatbnl() in more places dash has a pgetc_eatbnl function in parser.c which skips any backslash-newline combinations. It's not used everywhere it could be. There is also some duplicated backslash-newline handling elsewhere in parser.c. Replace most of the calls to pgetc() with calls to pgetc_eatbnl() and remove the duplicated backslash-newline handling. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Not adding "readtoken1(pgetc_eatbnl(), DQSYNTAX..." changes, since readtoken1() handles the "starts with backslash + newline" case itself. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31ash: 'nolog' and 'debug' options cause "$-" to wreak havocMartijn Dekker
Upstream commit: Date: Tue Mar 6 17:40:37 2018 +0000 expand: 'nolog' and 'debug' options cause "$-" to wreak havoc Op 29-03-17 om 20:02 schreef Martijn Dekker: > Bug: if either the 'nolog' or the 'debug' option is set, trying to > expand "$-" silently aborts parsing of an entire argument. > > $ dash -o nolog -c 'set -fuC; echo "|$- are the options|"; set +o nolog; echo "|$- are the options|"' > | > |uCf are the options| > $ dash -o debug -c 'set -fuC; echo "|$- are the options|"; set +o debug; echo "|$- are the options|"' > | > |uCf are the options| This turned out to be easy to fix. The routine producing the "$-" expansion failed to skip options for which there is no option letter, but only a long-form name. In dash, 'nolog' and 'debug' are currently the only two such options. Patch below. - Martijn Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> In bbox ash, pipefail is the option which exhibited this. Signed-off-by: Martijn Dekker <martijn@inlv.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31stat: fix a typo: s/romfs/ramfs/, closes 10876Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31hush: fix a signedness bugDenys Vlasenko
Testcase: set -- a ""; space=" "; printf "<%s>\n" "$@"$space Before: <a > After: <a> <> It usually does not bite since bbox forces -funsigned-char build. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30ash,hush: new test dollar_repl_slash_bash2.testsDenys Vlasenko
This fails for ash. hush works. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30ash: fix "char == CTLfoo" comparison signedness bugDenys Vlasenko
It usually does not bite since bbox forces -funsigned-char build. But for some reason void linux people disabled that. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30ash: use F_DUPFD_CLOEXEC and O_CLOEXECDenys Vlasenko
function old new delta setjobctl 371 367 -4 setinputfile 226 220 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-10) Total: -10 bytes Based on patch by Mark Marshall <mark.marshall@omicronenergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30examples/var_service: new example: dnsmasq serviceDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30cpio: extract "unsafe" symlinks the same way tar/unzip doesNatanael Copa
function old new delta cpio_main 588 596 +8 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30svok: new applet (daemontools compat)Denys Vlasenko
function old new delta svok_main - 127 +127 packed_usage 32705 32757 +52 applet_names 2756 2761 +5 applet_main 1588 1592 +4 bb_banner 46 47 +1 sv 1286 1284 -2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/1 up/down: 189/-2) Total: 187 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30ifplugd service example: always run up/down script on startupDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-29ifplugd: if SIOCSIFFLAGS fails with EADDRNOTAVAIL, don't dieStefan Agner
When using ifplugd on a RNDIS interface with monitor mode, using SIOCSIFFLAGS seems to fail with EADDRNOTAVAIL. Treat it the same as if iface disappeared again. This has been observed on a Tegra TK1 using Linux 4.14. There seem to be a race when the kernel is creating the device: ifplugd(usb0): started: BusyBox v1.24.1 (2018-03-27 09:47:48 CEST) ifplugd(usb0): interface doesn't exist, waiting ifplugd(usb0): interface appeared ifplugd(usb0): upping interface ifplugd(usb0): setting interface flags failed: Cannot assign requested address <exit> With this patch ifplugd is successful in upping the device the second time around: ifplugd(usb0): upping interface ifplugd(usb0): using SIOCETHTOOL detection mode ifplugd(usb0): interface appeared ifplugd(usb0): upping interface ifplugd(usb0): setting interface flags failed: Cannot assign requested address ifplugd(usb0): interface appeared ifplugd(usb0): upping interface ifplugd(usb0): using SIOCETHTOOL detection mode ifplugd(usb0): link is up ifplugd(usb0): executing '/etc/ifplugd/ifplugd.usb.action usb0 up' ifplugd up ifplugd(usb0): exit code: 0 function old new delta up_iface 120 127 +7 Signed-off-by: Stefan Agner <stefan@agner.ch> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-29fbsplash: support configurable image positionPeter Korsgaard
For some setups (E.G. for supporting different screen resolutions), positioning the image somewhere else than the top left corner may be interesting. Add support for IMG_LEFT/IMG_TOP settings to specify the image location, similar to how it is done for the progress bar. function old new delta fbsplash_main 994 1038 +44 static.param_names 57 74 +17 packed_usage 32631 32647 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 77/0) Total: 77 bytes Signed-off-by: Peter Korsgaard <peter@korsgaard.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-29grep: fix echo "aa" | busybox grep -F -w "a" (should not match)Denys Vlasenko
function old new delta grep_file 1461 1470 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-29fstrim: do not check that specified file is on a block deviceDenys Vlasenko
Kernel will surely inform us in FITRIM does not make sense on a given file. function old new delta fstrim_main 241 221 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-28hush: add a FIXME commentDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-28ash,hush: fix "saved" redirected fds still visible in childrenDenys Vlasenko
Based on a patch by Mark Marshall <mark.marshall@omicronenergy.com> function old new delta dup_CLOEXEC - 49 +49 fcntl_F_DUPFD 46 - -46 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-28libbb: use BUILD_BUG_ON in utoa_to_buf()Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-28ifupdown: do not fail if interface disappears during ifdownKaarle Ritvanen
Interface may not exist because it got deleted by an ifdown hook script earlier. This may happen when a virtual interface, such as VLAN, has multiple iface blocks defined. function old new delta static_down6 14 40 +26 static_down 54 70 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0) Total: 42 bytes Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-27ioctl(SIOCGIFINDEX) does not require clearing of entire ifrDenys Vlasenko
function old new delta INET6_setroute 492 472 -20 do_iplink 1357 1330 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-47) Total: -47 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-27netstat: produce numeric-ip output for non-resolved namesMark Marshall
If we don't ask for numerical output, and the symbolic look-up failed we used to get "(null)", but the numeric output would be better. function old new delta ip_port_str 109 121 +12 Signed-off-by: Mark Marshall <mark.marshall@omicronenergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-20ssl_client: fix option parsingRon Yorston
The wrong character was used to indicate options taking an integer parameter. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-19top: fix "warning: unused variable new_mask"Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-16tar: add -o and -k to short --help tooDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-16tar: add -k and -o to --helpDenys Vlasenko
-o Don't restore user:group -k Don't replace existing files Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-11tcpsvd: fix fallout from opt_complementary removalDenys Vlasenko
text data bss dec hex filename 933035 473 6836 940344 e5938 busybox_old 933051 473 6836 940360 e5948 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-11readprofile: code shrinkDenys Vlasenko
function old new delta defaultpro 14 - -14 defaultmap 17 - -17 readprofile_main 1762 1719 -43 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-74) Total: -74 bytes text data bss dec hex filename 933081 473 6836 940390 e5966 busybox_old 933035 473 6836 940344 e5938 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-11ntpd: choose initial FREQHOLD_cnt dynamicallyDenys Vlasenko
function old new delta update_local_clock 834 858 +24 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-11udhcpd: clamp down huge auto_times to ~2M seconds, better EINTR poll handlingDenys Vlasenko
EINTR _should_ only happen on two signals we trap, and safe_poll _should_ work here just fine, but there were kernel bugs where spurious EINTRs happen (e.g. on ptrace attach). Be safe. function old new delta udhcpd_main 1437 1468 +31 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-10ntpd: suppress in-kernel frequency correction in first 8 adjtimex callsDenys Vlasenko
In other words: try to correct initially existing clock offset first, before assuming that our clock drifts. function old new delta update_local_clock 826 834 +8 ntp_init 550 557 +7 filter_datapoints 179 173 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 15/-6) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-10udhcpd: fix "not dying on SIGTERM"Denys Vlasenko
Fixes: commit 52a515d18724bbb34e3ccbbb0218efcc4eccc0a8 "udhcp: use poll() instead of select()" Feb 16 2017 udhcp_sp_read() is meant to check whether signal pipe indeed has some data to read. In the above commit, it was changed as follows: - if (!FD_ISSET(signal_pipe.rd, rfds)) + if (!pfds[0].revents) return 0; The problem is, the check was working for select() purely by accident. Caught signal interrupts select()/poll() syscalls, they return with EINTR (regardless of SA_RESTART flag in sigaction). _Then_ signal handler is invoked. IOW: they can't see any changes to fd state caused by signal haldler (in our case, signal handler makes signal pipe ready to be read). For select(), it means that rfds[] bit array is unmodified, bit of signal pipe's read fd is still set, and the above check "works": it thinks select() says there is data to read. This accident does not work for poll(): .revents stays clear, and we do not try reading signal pipe as we should. In udhcpd, we fall through and block in socket read. Further SIGTERM signals simply cause socket read to be interrupted and then restarted (since SIGTERM handler has SA_RESTART=1). Fixing this as follows: remove the check altogether. Set signal pipe read fd to nonblocking mode. Always read it in udhcp_sp_read(). If read fails, assume it's EAGAIN and return 0 ("no signal seen"). udhcpd avoids reading signal pipe on every recvd packet by looping if EINTR (using safe_poll()) - thus ensuring we have correct .revents for all fds - and calling udhcp_sp_read() only if pfds[0].revents!=0. udhcpc performs much fewer reads (typically it sleeps >99.999% of the time), there is no need to optimize it: can call udhcp_sp_read() after each poll unconditionally. To robustify socket reads, unconditionally set pfds[1].revents=0 in udhcp_sp_fd_set() (which is before poll), and check it before reading network socket in udhcpd. TODO: This might still fail: if pfds[1].revents=POLLIN, socket read may still block. There are rare cases when select/poll indicates that data can be read, but then actual read still blocks (one such case is UDP packets with wrong checksum). General advise is, if you use a poll/select loop, keep all your fds nonblocking. Maybe we should also do that to our network sockets? function old new delta udhcp_sp_setup 55 65 +10 udhcp_sp_fd_set 54 60 +6 udhcp_sp_read 46 36 -10 udhcpd_main 1451 1437 -14 udhcpc_main 2723 2708 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/3 up/down: 16/-39) Total: -23 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-08remove stray newline in "iplink --help"Denys Vlasenko
function old new delta packed_usage 32547 32550 +3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-08ip: fix "ip -oneline a"Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-08ipcs: further code shrinkDenys Vlasenko
function old new delta packed_usage 32543 32547 +4 ipcs_main 1014 980 -34 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-34) Total: -30 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-08ipcs: code shrinkDenys Vlasenko
function old new delta packed_usage 32539 32543 +4 format 1 - -1 do_shm 883 880 -3 do_sem 636 633 -3 do_msg 782 779 -3 ipcs_main 1049 1014 -35 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/4 up/down: 4/-45) Total: -41 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-08md5sum: use config help text similar to other "sum" toolsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-07top: much faster cursor key navigation by avoiding process rescanDenys Vlasenko
function old new delta handle_input 549 560 +11 top_main 889 891 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-07top: do unsigned rather than signed division in do_stats()Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-07top: handle much larger VSZ valuesDenys Vlasenko
function old new delta display_process_list 1018 999 -19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-06use gmtime_r() instead of gmtime()Denys Vlasenko
This avoids pulling in gmtime's static buffer: function old new delta svlogd_main 1401 1412 +11 send_headers 668 678 +10 gmtime 21 - -21 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 2/0 up/down: 21/-21) Total: 0 bytes text data bss dec hex filename 920221 555 5804 926580 e2374 busybox_old 920221 555 5740 926516 e2334 busybox_unstripped ^^^^ Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-06hush: code shrinkDenys Vlasenko
function old new delta run_pipe 1589 1591 +2 pseudo_exec_argv 374 375 +1 builtin_type 114 115 +1 find_function 8 - -8 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 3/0 up/down: 4/-8) Total: -4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-05networking/interface.c: get rid of global dataDenys Vlasenko
These were data/bss: static.proc_read 1 - -1 int_list 4 - -4 int_last 4 - -4 We never call display_interfaces() twice, thus code to not scan /proc twice never triggers. function old new delta do_if_print - 1998 +1998 display_interfaces 145 249 +104 static.proc_read 1 - -1 add_interface 104 103 -1 int_list 4 - -4 int_last 4 - -4 if_readlist_proc 560 542 -18 if_readconf 141 - -141 do_if_fetch 643 - -643 ife_print 1296 - -1296 ------------------------------------------------------------------------------ (add/remove: 1/6 grow/shrink: 1/2 up/down: 2102/-2108) Total: -6 bytes text data bss dec hex filename 933084 473 6844 940401 e5971 busybox_old 933087 473 6836 940396 e596c busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-05networking/interface.c: get rid of global "smallint interface_opt_a"Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-05networking/interface.c: code shrinkDenys Vlasenko
function old new delta ife_print 1293 1296 +3 display_interfaces 145 146 +1 if_readconf 162 141 -21 if_readlist_proc 631 560 -71 do_if_fetch 753 643 -110 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/3 up/down: 4/-202) Total: -198 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>