Commit Graph

2047 Commits

Author SHA1 Message Date
Denys Vlasenko
048c043ae6 Make FEATURE_USERNAME_COMPLETION=y by default
This matches bash behavior on Fedora

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko
c2f3655842 fix breakage found by mass one-applet builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko
e184a88356 df: implement -B n<suff> and -B <suff> formats of -B option
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-12 19:56:31 +01:00
Denys Vlasenko
ac5d324540 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-10 20:57:00 +01:00
Mike Frysinger
c6f35241b3 selinux: drop deprecated headers
The selinux guys want you to get class values at runtime by converting
textual names into constants.  Drop the deprecated headers and switch
to the new format.

This API has been around for years, so there shouldn't be an issue
with backwards compatibility.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-12-09 18:30:30 -05:00
Denys Vlasenko
548620c18b randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-08 12:24:48 +01:00
Denys Vlasenko
4bd0c2ab38 fix musl problem with dirname, now for all users of bb_make_directory()
function                                             old     new   delta
bb_make_directory                                    412     419      +7
install_main                                         793     769     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-24)             Total: -17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-04 10:42:07 +01:00
Denys Vlasenko
7d877fc931 Do not print useless empty line after list of applets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-28 01:29:28 +01:00
Denys Vlasenko
038a977d47 lineedit: simplify code a bit
function                                             old     new   delta
lineedit_read_key                                    155     162      +7
put_prompt                                            51      46      -5
read_line_input                                     3722    3715      -7
cmdedit_setwidth                                      81      50     -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 7/-43)             Total: -36 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-28 01:10:16 +01:00
Denys Vlasenko
bff71d3b9d lineedit: fix two bugs in SIGWINCH signal handling
(1) restore entire sigaction, not only signal handler function
(2) do not use stdio when not sure WINCH did not interrupt a printf() or such.

function                                             old     new   delta
cmdedit_setwidth                                       -      81     +81
read_line_input                                     3682    3722     +40
lineedit_read_key                                    138     155     +17
put_prompt                                            55      51      -4
win_changed                                           93      47     -46
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 138/-50)            Total: 88 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-27 22:25:07 +01:00
Denys Vlasenko
4b89d512b1 ash,hush: make ^C in interactive mode visually much closer to bash behavior
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-25 03:41:03 +01:00
Denys Vlasenko
24860fa09c Move FEATURE_BUFFERS_USE_foo options to library tuning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-24 22:30:52 +01:00
Denys Vlasenko
1255925a61 Move locale, unicode, and "use sendfile?" options to library tuning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-24 22:18:55 +01:00
Rostislav Skudnov
2e4ef38743 lineedit: fix handling of repeating Alt-b, Alt-f, Alt-d, Alt-Backspace
These key combinations should repeat correctly when the keys are
pressed and held.

Before this change, they do this erratically - many repeats are "eaten"
because they are treated as unrecognized ESC seqs:
ESC 0x7f is treated by Alt+baskspace, but ESC 0x7f ESC 0x7f ESC 0x7f
is unrecognized.

Escape sequences corresponding to these key combinations are moved from
read_line_input to lineedit_read_key.

Also, these key sequences are now enabled regardless of whether
FEATURE_EDITING_VI is set, since Vim does not actually support these key
combinations, but they are present in readline library.

function                                             old     new   delta
static.esccmds                                        93     103     +10
read_line_input                                     3737    3687     -50

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-24 15:04:00 +01:00
Denys Vlasenko
7e8218f9b2 Fix allnoconfig warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-18 21:42:44 +01:00
Denys Vlasenko
834aba3b72 comment and readme updates
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-04 14:13:58 +01:00
Denys Vlasenko
79e2598c48 su: expand help; simplify passing of -c CMD to run_shell()
Also, added a comment about bug 9401 (TIOCSTI input injection).

function                                             old     new   delta
packed_usage                                       30909   30932     +23
su_main                                              470     487     +17
sulogin_main                                         260     258      -2
run_applet_and_exit                                  681     678      -3
run_shell                                            166     126     -40

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-03 22:13:08 +01:00
Denys Vlasenko
7c3c92c533 man: make width selection more thorough; explain how to override it
Fedora's "man CMD >file" still uses terminal width, not 80 (but disables formatting),
this change mimics that.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-31 01:52:18 +01:00
Denys Vlasenko
1336052a49 lineedit: fix completion with applet names. closes 9361
Patch by Ron Yorston <rmy@pobox.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-24 01:25:05 +02:00
Denys Vlasenko
7f0ebbc69e hush: add commented-out debug printouts in "memleak" built-in
Allocation addresses of malloc() are jittery,
thought I had a mem leak in hush, but it was malloc variability.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 17:42:53 +02:00
Denys Vlasenko
3c18e3051d libbb: make xmalloc_sockaddr2dotted use NI_NUMERICSCOPE
Gives "mount -t cifs //fe80::6a05:caff:fe3e:dbf5%eth0/test test"
a chance to work: mount must pass "ip=numeric_IPv6%numeric_iface_id"
in the omunt option string. Currently, it does not.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-26 19:53:04 +02:00
Denys Vlasenko
525209ac94 libbb/speed_table.c: expand comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-26 14:37:12 +02:00
Denys Vlasenko
4537f83d52 typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-26 08:52:52 +02:00
Denys Vlasenko
65ba7113e3 libbb: handle \S in /etc/issue
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-24 23:50:43 +02:00
Denys Vlasenko
7cef4817d6 libbb:/send_to_from: do not require that "to" should have the same AF. Closes 9146
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-15 13:20:51 +02:00
Denys Vlasenko
9fd61be191 libbb/xwrite: print errno on "short write" errors
Lauri Kasanen:
:: Over at TinyCore, we receive a huge number of questions of the type "I
:: got "short write", what does it mean?". Mostly for the rpi port and when
:: using bb wget.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-05 15:20:10 +02:00
Denys Vlasenko
76787a7e02 libbb/speed_table.c: survive B115200 and B230400 not fitting into 16 bits
Seen on OSX.
While at it, expand baud table with B500000..B4000000

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-01 11:44:13 +02:00
Denys Vlasenko
71a090f187 sha3: fix to conform to final SHA3 padding standard, add -a BITS option
function                                             old     new   delta
hash_file                                            331     396     +65
md5_sha1_sum_main                                    485     538     +53
packed_usage                                       30423   30464     +41
sha3_begin                                            17      31     +14
sha3_hash                                            101     110      +9
sha3_end                                              41      49      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-29 14:05:25 +02:00
Denys Vlasenko
d3d7f085eb hexdump: fix numerous bugs in handling of backslashes
Was:
	t=48\\	t=45\\	t=4c\\	t=4c\\	t=4f\\	t=0a\\
Now:
	=48=\n	=45=\n	=4c=\n	=4c=\n	=4f=\n	=0a=\n

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-26 20:14:31 +02:00
Denys Vlasenko
215b0ca6e4 hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186
Run this in a "sh SCRIPT":

sha256sum /dev/null
echo END

sha256sum is a NOEXEC applet. It runs in a forked child. Then child exit()s.
By this time, entire script is read, and buffered in a FILE object
from fopen("SCRIPT"). But fgetc() did not consume entire input.
exit() lseeks back by -9 bytes, from <eof> to 'e' in 'echo'.
(this may be libc-specific).
This change of fd position *is shared with the parent*!

Now parent can read more, and it thinks there is another "echo END".
End result: two "echo END"s are run.

Fix this by _exit()ing instead.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-19 18:43:06 +02:00
Natanael Copa
7e6f9316a8 lineedit: trivial codeshrink for vi-mode
Introduce and use BB_isalnum_or_underscore().

function                                             old     new   delta
BB_isalnum_or_underscore                               -      43     +43
vi_word_motion                                       162     150     -12
vi_end_motion                                        163     145     -18
vi_back_motion                                       198     179     -19
BB_isalnum                                            39       -     -39
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/3 up/down: 43/-88)            Total: -45 bytes

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-14 23:30:29 +02:00
Denys Vlasenko
98c50f93fe cp: fix -i for POSIX mode. Closes 9106
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-13 23:23:48 +02:00
Denys Vlasenko
0fb0045aa9 config: disentangle PREFER_APPLETS from SH_STANDALONE and SH_NOFORK
On user request.
I thought enabling/disabling them all together is more consistent.
Evidently, some people do want them to be separately selectable.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-22 18:48:38 +02:00
Denys Vlasenko
ca003385f1 cp: make verbose cp show symlink copies too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-14 20:58:39 +02:00
Denys Vlasenko
237bedd499 getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST
In many cases, this aqllows to drop use of opt_complementary.
Approximately -400 bytes:

function                                             old     new   delta
getopt32                                            1423    1502     +79
opt_string                                            17      18      +1
OPT_STR                                               24      25      +1
uniq_main                                            416     406     -10
timeout_main                                         279     269     -10
sulogin_main                                         270     260     -10
readprofile_main                                    1825    1815     -10
ps_main                                              543     533     -10
pidof_main                                           245     235     -10
pgrep_main                                           611     601     -10
od_main                                             2600    2590     -10
mkfs_minix_main                                     2684    2674     -10
mkfs_ext2_main                                      2603    2593     -10
microcom_main                                        712     702     -10
makemime_main                                        315     305     -10
ionice_main                                          282     272     -10
inetd_main                                          2074    2064     -10
ifplugd_main                                        1144    1134     -10
halt_main                                            353     343     -10
getopt_main                                          636     626     -10
fdisk_main                                          2854    2844     -10
env_main                                             206     196     -10
dmesg_main                                           319     309     -10
conspy_main                                         1214    1204     -10
awk_main                                             981     971     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/22 up/down: 81/-220)         Total: -139 bytes
   text	   data	    bss	    dec	    hex	filename
 919373	    906	  14060	 934339	  e41c3	busybox_old
 918969	    906	  14060	 933935	  e402f	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-06 21:58:02 +02:00
Denys Vlasenko
f4f8fe841c build system: fix a few warnings for allnoconfig build
Not that allnoconfig build is useful in any way...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-05 21:43:28 +02:00
Ron Yorston
1b0dcc02dd libbb: suppress warning about run_applet_and_exit
When busybox is configured to contain a single applet an unnecessary
declaration of run_applet_and_exit results in a warning.  Move the
declaration to avoid this.

Reported-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-05 21:21:36 +02:00
Denys Vlasenko
bb0bf287d8 randomconfig fixes 2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-19 21:54:04 +02:00
Ron Yorston
ce824aecf2 libbb: move common code into run_applet_and_exit
Both calls to run_applet_and_exit are followed by the same code
to print an error message and return status 127.  Remove this
duplication and make run_applet_and_exit static.

function                                             old     new   delta
run_applet_and_exit                                  675     667      -8
main                                                 119      92     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-35)             Total: -35 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-19 15:16:27 +02:00
Ron Yorston
ba12081a9e Allow "busybox <applet>" to work when busybox is disabled
A recent commit made it possible to disable BusyBox's --install
and --list options.  However it also stopped "busybox <applet>
<params>" from working.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-18 19:15:20 +02:00
Natanael Copa
b684d1b186 libbb: fix time parsing of [[CC]YY]MMDDhhmm[.SS]. Closes 8951
If SS is not given a value, it is assumed to be zero.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-05-31 02:50:54 +02:00
Denys Vlasenko
8e95068c7f Make busybox an optional applet
If it's disabled, code shrinks by about 900 bytes:

function                                             old     new   delta
usr_bin                                               10       -     -10
usr_sbin                                              11       -     -11
install_dir                                           20       -     -20
applet_install_loc                                   184       -    -184
run_applet_and_exit                                  686      21    -665
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 0/1 up/down: 0/-890)           Total: -890 bytes
   text    data     bss     dec     hex filename
 911327     493    7336  919156   e0674 busybox_old
 909848     493    7336  917677   e00ad busybox_unstripped

but busybox executable by itself does not say anything useful:

$ busybox
busybox: applet not found

Based on the patch by Ron Yorston <rmy@pobox.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-05-31 02:44:34 +02:00
Denys Vlasenko
877dedb825 cp: add -u/--update and --remove-destination
Based on the patch by wdlkmpx@gmail.com

function                                             old     new   delta
copy_file                                           1546    1644     +98
add_partition                                       1270    1362     +92
ask_and_unlink                                        95     133     +38
do_iproute                                           132     157     +25
decode_one_format                                    710     715      +5
cp_main                                              369     374      +5
ubirename_main                                       198     202      +4
read_package_field                                   232     230      -2
bb_make_directory                                    421     412      -9
packed_usage                                       30505   30476     -29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/3 up/down: 267/-40)           Total: 227 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-05-27 00:46:38 +02:00
Denys Vlasenko
3e134ebf6a *: slap on a few ALIGN1/2s where appropriate
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

   text	   data	    bss	    dec	    hex	filename
 829901	   4086	   1904	 835891	  cc133	busybox_before
 829665	   4086	   1904	 835655	  cc047	busybox

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-22 18:09:21 +02:00
Denys Vlasenko
93e1aaa1c7 libbb: constify *bb_common_bufsiz1 (if it is compiled to be a pointer)
This lets gcc optimize much better:

   text	   data	    bss	    dec	    hex	filename
 922846	    910	  13056	 936812	  e4b6c	busybox_unstripped.nonconst
 920255	    910	  13056	 934221	  e414d	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 21:47:45 +02:00
Denys Vlasenko
f56fb5eb11 libbb: make "COMMON_BUFSIZE = 1024 bytes, the buffer will be malloced" work
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 21:03:51 +02:00
Denys Vlasenko
e6a2f4cc5a libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default):

function                                             old     new   delta
read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
push                                                  46      44      -2
inetd_main                                          2136    2134      -2
uevent_main                                          421     418      -3
addLines                                              97      92      -5
bb_common_bufsiz1                                   8193    1024   -7169
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181)        Total: -7119 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829901	   4086	   1904	 835891	  cc133	busybox_unstripped

FEATURE_USE_BSS_TAIL=y:

read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
inetd_main                                          2136    2134      -2
bb_common_bufsiz1                                   8193       -   -8193
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195)        Total: -8133 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829911	   4086	    880	 834877	  cbd3d	busybox_unstripped

FIXME: setup_common_bufsiz() calls are missing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 17:39:11 +02:00
Ron Yorston
2b91958dff Rewrite iteration through applet names to save a few bytes
function                                             old     new   delta
run_applet_and_exit                                  758     755      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes

In standalone shell mode the saving increases to 17 bytes.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-15 22:13:51 +02:00
Ron Yorston
b22061718d find_applet_by_name: loop index should be signed
The loop

   for (j = ARRAY_SIZE(applet_nameofs)-1; j >= 0; j--) {

was intended to terminate when j goes negative, so j needs to be signed.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-03 22:29:35 +02:00
Denys Vlasenko
6aab9928de whitespace and namespace cleanups
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-03 22:24:51 +02:00