oweals/busybox.git
9 years agoAboriginal linux/musl build fixes
Denys Vlasenko [Mon, 5 Oct 2015 09:15:43 +0000 (11:15 +0200)]
Aboriginal linux/musl build fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoAdd qemu_multiarch_testing/
Denys Vlasenko [Mon, 5 Oct 2015 07:04:04 +0000 (09:04 +0200)]
Add qemu_multiarch_testing/

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoawk: support "length" form of "length()". Closes 8371
Denys Vlasenko [Fri, 2 Oct 2015 00:41:39 +0000 (02:41 +0200)]
awk: support "length" form of "length()". Closes 8371

function                                             old     new   delta
parse_expr                                           805     848     +43
tokenlist                                            447     448      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoumount: always use umount2 syscall with specified flags
Denys Vlasenko [Thu, 1 Oct 2015 16:50:06 +0000 (18:50 +0200)]
umount: always use umount2 syscall with specified flags

Make umount -f more compatible with util-linux 2.22.2.

Before:
  * 'umount -f': calls umount syscall,
        if it fails calls umount2 with 'MNT_FORCE'
  * 'mount -f -l': calls umount syscall,
        if it fails calls umount2 with 'MNT_LAZY'. 'MNT_FORCE' dropped
After:
  * 'umount -f': calls umount2 syscall with 'MNT_FORCE'
  * 'mount -f -l': calls umount2 syscall with 'MNT_LAZY' and 'MNT_FORCE'

function                                             old     new   delta
umount                                                45       -     -45
umount_main                                          610     555     -55

Signed-off-by: Anton Bondarenko <anton.bondarenko@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoadduser: fix help text
Denys Vlasenko [Mon, 21 Sep 2015 19:11:12 +0000 (21:11 +0200)]
adduser: fix help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoadduser: Add -k /path/to/skel
Bernhard Reutner-Fischer [Mon, 25 May 2015 21:25:19 +0000 (23:25 +0200)]
adduser: Add -k /path/to/skel

function                                             old     new   delta
.rodata                                           157069  157133     +64
adduser_main                                         921     936     +15
adduser_longopts                                     103     110      +7
packed_usage                                       30230   30236      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 92/0)               Total: 92 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2c-tools: rename remaining defines
Bartosz Golaszewski [Fri, 4 Sep 2015 08:38:48 +0000 (10:38 +0200)]
i2c-tools: rename remaining defines

Rename the defines not present in linux UAPI headers to better reflect
their purpose.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2c-tools: remove duplicate definitions
Bartosz Golaszewski [Fri, 4 Sep 2015 08:35:22 +0000 (10:35 +0200)]
i2c-tools: remove duplicate definitions

Most applets include linux' user API headers instead of duplicating
the definitions. Make it the case for i2c-tools as well.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agosort: fix -kN,M handling (was including last separator into the comparison)
Denys Vlasenko [Sat, 19 Sep 2015 20:06:40 +0000 (22:06 +0200)]
sort: fix -kN,M handling (was including last separator into the comparison)

Testcase:

$ printf '%s\n' a/a:a a:b | sort -t: -k1,1
a:b
a/a:a

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: another unit test for is_suffixed_with
Tito Ragusa [Tue, 15 Sep 2015 21:38:01 +0000 (23:38 +0200)]
libbb: another unit test for is_suffixed_with

Suggested by Bartosz Golaszewski.

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodprobe: handle module arguments containing spaces
Peter Korsgaard [Wed, 9 Sep 2015 12:55:07 +0000 (14:55 +0200)]
modprobe: handle module arguments containing spaces

Modprobe wasn't correctly parsing module arguments containing spaces from
/proc/cmdline - E.G. module.property="some text".

Extend the parsing to correctly handle quoted text.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: fix slash treatment in expmeta
Ron Yorston [Fri, 4 Sep 2015 09:32:41 +0000 (10:32 +0100)]
ash: fix slash treatment in expmeta

Commit 549deab caused this sequence of commands:

   mkdir foo
   cd foo
   touch a b
   echo "./"*

to return './*' instead of the expected './a ./b'.  The problem
was caused by the backport of commit 880d952 from dash.  In dash
the issue was fixed by two further commits by Herbert Xu:

<d6d06ff> [EXPAND] Fixed non-leading slash treatment in expmeta
<36f0fa8> [EXPAND] Fix slash treatment in expmeta

(See git://git.kernel.org/pub/scm/utils/dash/dash.git)

Apply these fixes to BusyBox ash, thus causing the new test
glob3.tests to succeed.

function                                             old     new   delta
expmeta                                              469     528     +59

Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agohush: fix a nommu bug where a part of function body is lost if run in a pipe
Denys Vlasenko [Fri, 4 Sep 2015 04:22:10 +0000 (06:22 +0200)]
hush: fix a nommu bug where a part of function body is lost if run in a pipe

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoMakefile.flags: survive a build system which has no pthread
Denys Vlasenko [Fri, 4 Sep 2015 02:20:51 +0000 (04:20 +0200)]
Makefile.flags: survive a build system which has no pthread

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash,hush: add a test which fails for ash since commit 549deab
Denys Vlasenko [Fri, 4 Sep 2015 01:33:02 +0000 (03:33 +0200)]
ash,hush: add a test which fails for ash since commit 549deab

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: add tests adapted from hush glob tests. glob2.tests currently fails
Denys Vlasenko [Fri, 4 Sep 2015 01:27:08 +0000 (03:27 +0200)]
ash: add tests adapted from hush glob tests. glob2.tests currently fails

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: make is_suffixed_with() return pointer inside string, not key.
Denys Vlasenko [Tue, 25 Aug 2015 19:47:33 +0000 (21:47 +0200)]
libbb: make is_suffixed_with() return pointer inside string, not key.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: add is_suffixed_with() function
Bartosz Golaszewski [Tue, 25 Aug 2015 14:36:43 +0000 (16:36 +0200)]
libbb: add is_suffixed_with() function

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoping: fix recently introduced build breakage for non-optimizing builds
Denys Vlasenko [Tue, 25 Aug 2015 14:26:31 +0000 (16:26 +0200)]
ping: fix recently introduced build breakage for non-optimizing builds

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: add a comment describing the way is_prefixed_with() works
Bartosz Golaszewski [Tue, 25 Aug 2015 11:10:00 +0000 (13:10 +0200)]
libbb: add a comment describing the way is_prefixed_with() works

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: add unit tests for is_prefixed_with()
Bartosz Golaszewski [Tue, 25 Aug 2015 11:09:59 +0000 (13:09 +0200)]
libbb: add unit tests for is_prefixed_with()

Test corner cases too like looking for an empty prefix etc.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agologin: don't print motd if .hushlogin exists in users home
Sören Tempel [Mon, 24 Aug 2015 20:16:48 +0000 (22:16 +0200)]
login: don't print motd if .hushlogin exists in users home

function                                             old     new   delta
login_main                                           978     996     +18

Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodmesg: add -r option to print raw format even when FEATURE_DMESG_PRETTY is enabled
Peter Korsgaard [Mon, 24 Aug 2015 13:54:49 +0000 (15:54 +0200)]
dmesg: add -r option to print raw format even when FEATURE_DMESG_PRETTY is enabled

Similar to the "big" util-linux version. For !DMESG_PRETTY, the option is accepted
(but ignored) as well, for compatibility reasons.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoifupdown: 'prio' should have been 'metric' in static_up and static_up6
Alex Dowad [Fri, 7 Aug 2015 09:53:26 +0000 (11:53 +0200)]
ifupdown: 'prio' should have been 'metric' in static_up and static_up6

When a static interface with explicit gateway and metric in /etc/network/interfaces
is enabled using 'ifup', and further, the BusyBox 'ip' applet is enabled, the
following error message appears at the console (and no default route is added):

ip: either "to" is duplicate, or "prio" is garbage

Tracing ifup reveals that it is attempting to run the following shell command:

ip route add default via <GW> dev <DEVICE> prio <METRIC>

'ip' does not understand the 'prio' argument, causing this error. With 'metric',
it works fine.

Signed-off-by: Alex Dowad <alexinbeijing@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: add setsockopt_foo helpers
Denys Vlasenko [Mon, 24 Aug 2015 17:48:03 +0000 (19:48 +0200)]
libbb: add setsockopt_foo helpers

function                                             old     new   delta
setsockopt_int                                         -      23     +23
do_load                                              918     934     +16
setsockopt_SOL_SOCKET_int                              -      14     +14
setsockopt_keepalive                                   -      10     +10
setsockopt_SOL_SOCKET_1                                -      10     +10
buffer_fill_and_print                                169     178      +9
setsockopt_1                                           -       8      +8
nfsmount                                            3560    3566      +6
redirect                                            1277    1282      +5
tcpudpsvd_main                                      1782    1786      +4
d6_send_kernel_packet                                272     275      +3
i2cget_main                                          380     382      +2
ed_main                                             2544    2545      +1
scan_recursive                                       380     378      -2
nbdclient_main                                       492     490      -2
hash_find                                            235     233      -2
cmdputs                                              334     332      -2
parse_command                                       1443    1440      -3
static.two                                             4       -      -4
ntpd_main                                           1039    1035      -4
const_int_1                                            4       -      -4
const_IPTOS_LOWDELAY                                   4       -      -4
RCVBUF                                                 4       -      -4
ntp_init                                             474     469      -5
change_listen_mode                                   316     310      -6
uevent_main                                          416     409      -7
arping_main                                         1697    1690      -7
telnet_main                                         1612    1603      -9
socket_want_pktinfo                                   42      33      -9
setsockopt_reuseaddr                                  21      10     -11
setsockopt_broadcast                                  21      10     -11
httpd_main                                           772     757     -15
get_remote_transfer_fd                               109      94     -15
make_new_session                                     503     487     -16
ftpd_main                                           2177    2160     -17
read_bunzip                                         1896    1866     -30
common_traceroute_main                              4099    4058     -41
common_ping_main                                    1836    1783     -53
------------------------------------------------------------------------------
(add/remove: 5/4 grow/shrink: 8/21 up/down: 111/-283)        Total: -172 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoMerge setsockopt error messages
Denys Vlasenko [Mon, 24 Aug 2015 17:08:14 +0000 (19:08 +0200)]
Merge setsockopt error messages

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotraceroute: fix help text
Denys Vlasenko [Mon, 24 Aug 2015 16:56:46 +0000 (18:56 +0200)]
traceroute: fix help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoMakefile: add missing libraries to LDLIBS
Bartosz Golaszewski [Fri, 14 Aug 2015 06:50:00 +0000 (08:50 +0200)]
Makefile: add missing libraries to LDLIBS

Static build with CONFIG_PAM fails on Debian Jessie due to undefined
references to libdl and libaudit.

Static build without pam, but with libcrypt required fails as well due
to undefined references to libpthread.

Fix these two cases by adding the missing libraries to LDLIBS when
appropriate.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agounit-tests: remove code depending on WANT_TIMING
Bartosz Golaszewski [Thu, 13 Aug 2015 13:57:22 +0000 (15:57 +0200)]
unit-tests: remove code depending on WANT_TIMING

Since there is no interest in merging a config option for WANT_TIMING,
remove the parts of code depending on it altogether.

While we're at it: add some newlines to improve readability.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agounit-tests: remove unnecesary field from struct bbunit_listelem
Bartosz Golaszewski [Thu, 13 Aug 2015 13:57:21 +0000 (15:57 +0200)]
unit-tests: remove unnecesary field from struct bbunit_listelem

In the initial submission struct bbunit_listelem was manipulated by
custom list functions implemented in bbunit.c. Since the tests are now
added to the list by llist_add_to_end(), which allocates the llist_t
objects behind the scenes, there's no need for the *next field.

function                                             old     new   delta
unit_main                                            142     141      -1
bbunit_strrstr_elem                                   24      16      -8
bbunit_obscure_weak_pass_elem                         24      16      -8
bbunit_obscure_strong_pass_elem                       24      16      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-25)             Total: -25 bytes

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoarping: make help text clearer
Denys Vlasenko [Sun, 16 Aug 2015 17:56:16 +0000 (19:56 +0200)]
arping: make help text clearer

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: fix botched attempt to use last column
Ron Yorston [Tue, 4 Aug 2015 16:10:37 +0000 (17:10 +0100)]
less: fix botched attempt to use last column

Commit 1ecb996 attempted to make read_lines() use the last column of
the terminal (as re_wrap() did).  There were two problems with this:

- The size of the buffer allocated for lines wasn't increased to allow
  for the extra character.

- The test for width overflow was moved after the point where the
  next character was added to the buffer.  This caused a buffer overflow
  in certain circumstances.

  For example, if the line beyond the end of the display was wider than
  the display read_lines() would initially read the partial line into a
  buffer.  When the user moved down read_lines() would be called again
  to ensure the rest of the line was read.  This would place the next
  character in the partial line before checking for overflow.

  This can be fixed by moving the test for overflow back to where it was
  before commit 1ecb996 and changing the comparison to `>` rather than
  `>=`.

There are two other places where buffers are created without allowing
for width+1 characters.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoipcalc: fix trivial usage message
Ron Yorston [Sun, 12 Jul 2015 20:19:28 +0000 (21:19 +0100)]
ipcalc: fix trivial usage message

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agozcip: tweak comments and make unsigned division more obvious
Denys Vlasenko [Tue, 4 Aug 2015 13:06:38 +0000 (15:06 +0200)]
zcip: tweak comments and make unsigned division more obvious

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agozcip: another code shrink
Denys Vlasenko [Tue, 4 Aug 2015 12:30:31 +0000 (14:30 +0200)]
zcip: another code shrink

function                                             old     new   delta
send_arp_request                                       -     185    +185
zcip_main                                           1273    1272      -1
pick_nip                                              40       -     -40
arp                                                  185       -    -185
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 0/1 up/down: 185/-226)          Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agozcip: code shrink
Denys Vlasenko [Tue, 4 Aug 2015 10:28:21 +0000 (12:28 +0200)]
zcip: code shrink

function                                             old     new   delta
zcip_main                                           1263    1230     -33

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agozcip: simplify code
Denys Vlasenko [Tue, 4 Aug 2015 01:27:56 +0000 (03:27 +0200)]
zcip: simplify code

function                                             old     new   delta
zcip_main                                           1411    1263    -148

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agouname: make OS name configurable
Ron Yorston [Sun, 12 Jul 2015 15:06:37 +0000 (16:06 +0100)]
uname: make OS name configurable

A mailing list thread in September 2013 discussed changing the string
returned by the non-POSIX 'uname -o' option.  Nothing ever came of this
because there was no agreement as to what the string should be.

Make the string configurable so that people can decide for themselves.

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: further tweaks to regular file detection
Ron Yorston [Fri, 31 Jul 2015 16:33:24 +0000 (17:33 +0100)]
less: further tweaks to regular file detection

Test explicitly for REOPEN flags:  update_num_lines is called
unconditionally so (num_lines != NOT_REGULAR_FILE) is also true when
num_lines contains a valid number of lines.

The call to fstat doesn't need to be in #if ENABLE_FEATURE_LESS_FLAGS:
the whole function is already in such a test.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodiff.tests: add testcases for -B and single line changes
Aaro Koskinen [Thu, 30 Jul 2015 20:13:26 +0000 (23:13 +0300)]
diff.tests: add testcases for -B and single line changes

Add testcases for -B and single line changes.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodiff: fix -B with single line changes
Aaro Koskinen [Thu, 30 Jul 2015 20:13:25 +0000 (23:13 +0300)]
diff: fix -B with single line changes

Fix -B with single line changes. They were always ignored regardless
if they were blank or not.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: improve regular file detection in line counting code
Denys Vlasenko [Fri, 31 Jul 2015 14:42:20 +0000 (16:42 +0200)]
less: improve regular file detection in line counting code

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: allow use of last column of terminal
Ron Yorston [Fri, 24 Jul 2015 13:29:45 +0000 (14:29 +0100)]
less: allow use of last column of terminal

When read_lines tests whether a character will fit on the current
line it checks the *next* character but in case of overflow doesn't
display the *current* one.  This results in the last column of the
terminal never being used.

The test in re_wrap (used when the terminal width changes or line
numbers are enabled/disabled) is different:  it does allow the use
of the final column.

function                                             old     new   delta
read_lines                                           764     770      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 6/0)                 Total: 6 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: fix line number confusion
Ron Yorston [Fri, 24 Jul 2015 13:29:13 +0000 (14:29 +0100)]
less: fix line number confusion

Much of the code refers to lines using indices into the flines
array (which splits lines into portions that fit on the terminal).
In some cases this is wrong and actual line numbers should be
used:

- when lines are being truncated rather than wrapped (-S flag)
- when line numbers have been entered by the user

Also fix a bug in numeric input and improve the display at EOF.

function                                             old     new   delta
goto_lineno                                            -     111    +111
cap_cur_fline                                          -     101    +101
buffer_to_line                                         -      56     +56
buffer_up                                             35      66     +31
less_main                                           2606    2615      +9
goto_match                                           125     127      +2
buffer_down                                           81      56     -25
buffer_line                                           64       -     -64
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 3/1 up/down: 310/-89)           Total: 221 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: add a function to detect when display is at end of file
Ron Yorston [Fri, 24 Jul 2015 13:28:50 +0000 (14:28 +0100)]
less: add a function to detect when display is at end of file

Add a function to package the test that detects whether enough has
been read from the file to allow a screenful to be displayed.

Also use this to determine when to display '(END)' in the status
line.  The previous code was incomplete and didn't handle truncated
lines (-S flag) properly.

function                                             old     new   delta
at_end                                                 -      63     +63
status_print                                         111     109      -2
read_lines                                           819     764     -55
getch_nowait                                         319     264     -55
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 63/-112)           Total: -49 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: rearrange detection of non-regular files
Ron Yorston [Fri, 24 Jul 2015 13:28:08 +0000 (14:28 +0100)]
less: rearrange detection of non-regular files

Move the code to detect non-regular files to the point where the
file is being opened.  If num_lines == READING_FILE guarantees
that the file is regular.

Detect when a file becomes unreadable between it first being opened
and the call to update_num_lines.  Mark the file as being non-regular
so we don't try that again.

function                                             old     new   delta
reinitialize                                         197     245     +48
update_num_lines                                     159     127     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 48/-32)             Total: 16 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: move code to count lines into a separate function
Ron Yorston [Fri, 24 Jul 2015 13:27:42 +0000 (14:27 +0100)]
less: move code to count lines into a separate function

function                                             old     new   delta
update_num_lines                                       -     159    +159
m_status_print                                       409     266    -143
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 159/-143)           Total: 16 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: fix numeric input
Ron Yorston [Tue, 21 Jul 2015 19:12:31 +0000 (20:12 +0100)]
less: fix numeric input

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoecho: make escape sequences depend on fancy mode
Mike Frysinger [Thu, 30 Jul 2015 03:33:16 +0000 (23:33 -0400)]
echo: make escape sequences depend on fancy mode

Currently when you disable fancy echo, escape sequences are hardcoded
enabled (e.g. as if you used `echo -e` all the time).  The opposite
behavior is more desirable (always disable -e support) because:
* This seems to contradict the spirit of the kconfig help text (where
  it says enable support for -n/-e flags), although you could say that
  we aren't supporting the -e flag directly as `echo -e` will show the
  -e flag.
* POSIX makes escape sequences optional, and even says they are there
  only on XSI-conformant systems.
* It saves space (~100 bytes on x86_64).
* It makes things faster!
* It makes it behave more like bash where you need an explicit -e flag
  in order for escape sequences to be interpreted.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agofbset: fix rgba parsing
Linus Walleij [Mon, 27 Jul 2015 07:59:04 +0000 (09:59 +0200)]
fbset: fix rgba parsing

In commit b5c7220e7b2b6611fe5beca494c67bfe51fcfafb
"fbset: respect rgba configuration lines in fb.modes"
I somehow managed to swap the offset/length markers around.
The man page for fb.modes says it should be offset/length
not length/offset as I was accidentally parsing it.

As my fb.modes file was also reversed I didn't notice
until I tried someone elses fb.modes file. Mea culpa.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoudhcpc: dns labels can actually start with a number
Arthur Gautier [Tue, 28 Jul 2015 05:35:00 +0000 (05:35 +0000)]
udhcpc: dns labels can actually start with a number

While RFC1035 recommends a label not to start with a number, there is
actually no such limitation in dns. One may buy a domain name like
0x1.net and use it.

This commit remove this check and allow a user to use such domains.

Signed-off-by: Arthur Gautier <baloo@gandi.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: improvements to verbose status messages
Ron Yorston [Tue, 21 Jul 2015 20:28:09 +0000 (22:28 +0200)]
less: improvements to verbose status messages

Make verbose status messages (-m/-M flags) behave more like the
real `less` command:

- fix display of line numbers so they're correct whether lines are
  being truncated (-S flag) or wrapped.
- don't display total lines or percentage when lines are read from
  stdin:  we don't have that information until we reach EOF.  When
  we do reach EOF the additional information is displayed.
- when lines are read from a file count the total number of lines
  so that we can display percentages.  Counting lines is avoided
  until the information is actually needed.  If the user pages to
  EOF the separate read pass can be avoided entirely.

Fixes Bug 7586

function                                             old     new   delta
m_status_print                                       195     382    +187
safe_lineno                                            -      35     +35
reinitialize                                         172     182     +10
read_lines                                           675     685     +10
buffer_fill_and_print                                178     169      -9
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 242/-9)            Total: 233 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agosync: add support for -d -f FILE
Denys Vlasenko [Tue, 21 Jul 2015 17:50:48 +0000 (19:50 +0200)]
sync: add support for -d -f FILE

Based on the patch by Ari Sundholm <ari@tuxera.com>

function                                             old     new   delta
sync_main                                             20     163    +143
packed_usage                                       30653   30673     +20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 163/0)             Total: 163 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoRemove old_e2fsprogs/*
Denys Vlasenko [Sun, 19 Jul 2015 21:12:51 +0000 (23:12 +0200)]
Remove old_e2fsprogs/*

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: add a function to make a copy of a region of memory
Ron Yorston [Sun, 19 Jul 2015 21:05:20 +0000 (23:05 +0200)]
libbb: add a function to make a copy of a region of memory

Introduce a library routine to package the idiom:

    p = xmalloc(b, n);
    memcpy(p, b, n);

and use it where possible.  The example in traceroute used xzalloc
but it didn't need to.

function                                             old     new   delta
xmemdup                                                -      32     +32
last_main                                            834     826      -8
make_device                                         2321    2311     -10
common_traceroute_main                              3698    3685     -13
readtoken1                                          3182    3168     -14
procps_scan                                         1222    1206     -16
forkchild                                            655     638     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78)            Total: -46 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: correctly account for tabs when rewrapping lines
Ron Yorston [Sun, 19 Jul 2015 20:41:09 +0000 (21:41 +0100)]
less: correctly account for tabs when rewrapping lines

Lines are rewrapped when the terminal width changes or line numbers
are enabled/disabled.  The current calculation always adds eight to
the line length for a tab whereas it should only add enough to move
to the next tab stop.

This doesn't affect the display of lines, which is handled elsewhere
and gets tab stops right, but it does cause lines to be wrapped at
the wrong position.

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: fix display of line numbers
Ron Yorston [Sat, 18 Jul 2015 15:20:03 +0000 (16:20 +0100)]
less: fix display of line numbers

Line numbers are displayed incorrectly on lines that have a search
pattern highlighted.  The problem can be fixed by moving the call to
lineno_str in print_found above the while loop that alters the value
of the line pointer.  However, a more substantial rewrite results in
savings.

function                                             old     new   delta
buffer_print                                         688     697      +9
.rodata                                           156077  156045     -32
lineno_str                                            85       -     -85
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 9/-117)           Total: -108 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoless: document -S flag and make it independently configurable
Ron Yorston [Sun, 19 Jul 2015 10:12:29 +0000 (11:12 +0100)]
less: document -S flag and make it independently configurable

The -S flag, to cause long lines to be truncated, was enabled by
FEATURE_LESS_DASHCMD.  This is non-obvious and -S is useful even
if the '-' command isn't enabled.

function                                             old     new   delta
.rodata                                           156045  156077     +32
packed_usage                                       30223   30244     +21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 53/0)               Total: 53 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: use alloca to get rid of setjmp
Ron Yorston [Wed, 1 Jul 2015 15:46:18 +0000 (16:46 +0100)]
ash: use alloca to get rid of setjmp

Now that the only thing protected by setjmp/longjmp is the saved string,
we can allocate it on the stack to get rid of the jump.

Based on commit bd35d8e from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu.

function                                             old     new   delta
readtoken1                                          3182    3116     -66
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-66)             Total: -66 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agofix file mode
Denys Vlasenko [Mon, 13 Jul 2015 01:52:32 +0000 (03:52 +0200)]
fix file mode

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: remove parsebackquote flag
Ron Yorston [Wed, 1 Jul 2015 15:45:40 +0000 (16:45 +0100)]
ash: remove parsebackquote flag

Commit 503a0b8 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu says:

  >The parsebackquote flag is only used in a test where it always has the
  >value zero.  So we can remove it altogether.

The first statement is incorrect:  parsebackquote is non-zero when
backquotes (as opposed to $(...)) are used for command substitution.
It is possible for the test to be executed with parsebackquote != 0 in
that case.

The test is question checks whether quotes have been closed, raising
the error "unterminated quoted string" if they haven't.  There seems
to be no good reason to allow unclosed quotes within backquotes.  Bash,
hush and dash (after commit 503a0b8) all treat the following as an error:

   XX=`"pwd`

whereas BusyBox ash doesn't.  It just ignores the unclosed quote and
executes pwd.

So, parsebackquote should be removed but not for the reason stated.

function                                             old     new   delta
parsebackquote                                         1       -      -1
readtoken1                                          3222    3182     -40
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-41)             Total: -41 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoRemoves stray empty line from code
Maninder Singh [Wed, 10 Jun 2015 03:47:27 +0000 (03:47 +0000)]
Removes stray empty line from code

This patch removes stray empty line from busybox code
reported by script find_stray_empty_lines

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoapplets: Add installation of individual binaries
Clayton Shotwell [Thu, 21 May 2015 19:48:35 +0000 (14:48 -0500)]
applets: Add installation of individual binaries

Adding support to install individual binaries if the option is
enabled. This also installs the shared libbusybox.so.* library.

Signed-off-by: Clayton Shotwell <clshotwe@rockwellcollins.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agops: fix SEGV on narrow screens. closes 8176
Denys Vlasenko [Wed, 1 Jul 2015 17:07:24 +0000 (19:07 +0200)]
ps: fix SEGV on narrow screens. closes 8176

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoipaddress: better formatting, no code changes
Denys Vlasenko [Wed, 1 Jul 2015 16:36:06 +0000 (18:36 +0200)]
ipaddress: better formatting, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoip addr: support change and replace commands
Michael Tokarev [Wed, 20 May 2015 13:27:44 +0000 (16:27 +0300)]
ip addr: support change and replace commands

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agofix whitespaces
Maninder Singh [Mon, 1 Jun 2015 10:40:09 +0000 (10:40 +0000)]
fix whitespaces

reported by script :- scripts/fix_ws.sh

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agofix if(p)/free(p) construct
Maninder Singh [Mon, 1 Jun 2015 10:38:07 +0000 (10:38 +0000)]
fix if(p)/free(p) construct

No need of explicit NULL check before free.

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2cdetect: use break instead of goto in list_i2c_busses_and_exit()
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:32 +0000 (10:27 +0200)]
i2cdetect: use break instead of goto in list_i2c_busses_and_exit()

Since there are now more statements in the if block after the while loop
in list_i2c_busses_and_exit(), there's no need for a label.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2cdump: code rework
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:31 +0000 (10:27 +0200)]
i2cdump: code rework

Split i2cdump_main() into shorter functions. Simplify the code a bit.
Make block an array of ints so that we can store negative results of
read functions (fixes a bug found by Denys Vlasenko).

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2cdetect: add a check for (mode == DETECT_MODE_AUTO)
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:30 +0000 (10:27 +0200)]
i2cdetect: add a check for (mode == DETECT_MODE_AUTO)

We should only warn the user about addresses to be skipped if
(mode == DETECT_MODE_AUTO).

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2cdetect: don't scan non-regular addresses without the '-a' option
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:29 +0000 (10:27 +0200)]
i2cdetect: don't scan non-regular addresses without the '-a' option

Addresses 0x00-0x02 shouldn't be scanned by default. This patch makes
'first' default to 0x03 and only enables lower addresses if '-a' option
is passed

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2cdetect: don't die on addresses already in use by drivers
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:28 +0000 (10:27 +0200)]
i2cdetect: don't die on addresses already in use by drivers

We can't use i2c_set_slave_addr() in i2cdetect, as we have to check for
EBUSY after calling ioctl(I2C_SLAVE) and print 'UU' on busy addresses
instead of bailing-out.

While we're at it: reorder definitions of local vars in i2cdetect_main().

function                                             old     new   delta
i2cdetect_main                                       703     744     +41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 41/0)               Total: 41 bytes
   text    data     bss     dec     hex filename
 826097    4164    9584  839845   cd0a5 busybox_old
 826145    4164    9584  839893   cd0d5 busybox_unstripped

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agochown: fix help text
Junling Zheng [Sun, 7 Jun 2015 00:32:23 +0000 (02:32 +0200)]
chown: fix help text

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotruncate: do not die when a file doesn't exist and no-create flag is on
Ari Sundholm [Mon, 25 May 2015 13:16:11 +0000 (15:16 +0200)]
truncate: do not die when a file doesn't exist and no-create flag is on

Additionally, open(2) failures do not make the program die immediately.
This makes the behavior of the program match coreutils more closely.

function                                             old     new   delta
truncate_main                                        161     221     +60

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoPrint one less newline at the end of bb_show_usage()
Denys Vlasenko [Mon, 25 May 2015 12:30:52 +0000 (14:30 +0200)]
Print one less newline at the end of bb_show_usage()

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotypo fixes
Maninder Singh [Mon, 25 May 2015 11:46:36 +0000 (13:46 +0200)]
typo fixes

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodc: fix "dc p" prinitng bogus data
Denys Vlasenko [Mon, 25 May 2015 11:31:25 +0000 (13:31 +0200)]
dc: fix "dc p" prinitng bogus data

function                                             old     new   delta
check_under                                            -      20     +20
print_no_pop                                          27      32      +5
pop                                                   33      24      -9
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 25/-9)              Total: 16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotc: fix print_rate
Denys Vlasenko [Sun, 24 May 2015 16:01:53 +0000 (18:01 +0200)]
tc: fix print_rate

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agohush: add recent ash tests to hush testsuite too (they all pass for hush)
Denys Vlasenko [Mon, 18 May 2015 08:23:16 +0000 (10:23 +0200)]
hush: add recent ash tests to hush testsuite too (they all pass for hush)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotestsuite: add some tests for ash
Ron Yorston [Mon, 18 May 2015 08:13:21 +0000 (10:13 +0200)]
testsuite: add some tests for ash

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: fix breakage of ${v/pat/str}
Ron Yorston [Mon, 18 May 2015 07:59:14 +0000 (09:59 +0200)]
ash: fix breakage of ${v/pat/str}

The commit

   ash: move parse-time quote flag detection to run-time

breaks pattern substitution in parameter expansion.  Fix this and
revise the code so that the different handling of the pattern and
the replacement string takes place in rmescapes rather than the
separate function parse_sub_pattern.

function                                             old     new   delta
rmescapes                                            227     273     +46
static.qchars                                          3       4      +1
subevalvar                                          1177    1157     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 47/-20)             Total: 27 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: move parse-time quote flag detection to run-time
Ron Yorston [Mon, 18 May 2015 07:57:51 +0000 (09:57 +0200)]
ash: move parse-time quote flag detection to run-time

Because the parser does not recursively parse parameter expansion
with respect to quotes, we can't accurately determine quote status at
parse time.  This patch works around this by moving the quote detection
to run-time where we do interpret it recursively.

Test case:
   foo=\\ echo "<${foo#[\\]}>"
Old result:
   <\>
New result:
   <>

Do not quote back slashes in parameter expansions outside quotes.

Test case:
   a=/b/c/*
   b=\\
   echo ${a%$b*}
Old result:
   /b/c/*
New result:
   /b/c/

Based on commits 880d9527cfd8be0d7d660 and a7c21a6 from
git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu

function                                             old     new   delta
argstr                                              1164    1193     +29
memtodest                                            147     174     +27
subevalvar                                          1153    1177     +24
redirect                                            1279    1282      +3
dolatstr                                               5       7      +2
static.spclchars                                      10       9      -1
expandarg                                            962     960      -2
evalcase                                             273     271      -2
evalcommand                                         1204    1197      -7
rmescapes                                            236     227      -9
preglob                                               27       8     -19
evalvar                                              604     582     -22
cmdputs                                              389     334     -55
readtoken1                                          3163    3061    -102
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/9 up/down: 85/-219)          Total: -134 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: remove arithmetic expansion collapsing at parse time
Ron Yorston [Mon, 18 May 2015 07:56:16 +0000 (09:56 +0200)]
ash: remove arithmetic expansion collapsing at parse time

Collapsing arithmetic expansion is incorrect when the inner arithmetic
expansion is a part of a parameter expansion.

Test case:
   unset a
   echo $((3 + ${a:=$((4 + 5))}))
   echo $a
Old result:
   12
   (4 + 5)
New result:
   12
   9

Based on commit bb777a6 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
readtoken1                                          3180    3163     -17

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: remove superfluous code in arithmetic mode
Ron Yorston [Mon, 18 May 2015 07:54:43 +0000 (09:54 +0200)]
ash: remove superfluous code in arithmetic mode

Based on commits 1a74845cfc3d6a and ff13779 from
git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu

function                                             old     new   delta
evalcommand                                         1197    1204      +7
localcmd                                             327     325      -2
readtoken1                                          3200    3180     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 7/-22)             Total: -15 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: do not expand tilde in parameter expansion within quotes
Ron Yorston [Mon, 18 May 2015 07:53:26 +0000 (09:53 +0200)]
ash: do not expand tilde in parameter expansion within quotes

Test case:
   unset a
   echo "${a:-~root}"
Old result:
   /root
New result:
   ~root

Based on commit 170f44d from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
evalvar                                              598     604      +6
parse_command                                       1440    1443      +3
localcmd                                             325     327      +2
readtoken1                                          3199    3200      +1
argstr                                              1180    1164     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 12/-16)             Total: -4 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: perform tilde expansion in all parameter expansion words
Ron Yorston [Mon, 18 May 2015 07:51:35 +0000 (09:51 +0200)]
ash: perform tilde expansion in all parameter expansion words

Previously tilde expansion was not carried out for =?#% expansion words.

Test case:
   a=~root:~root
   echo ${a#~root}
Old result:
   /root:/root
New result:
   :/root

Based on commit dd721f71 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
subevalvar                                          1152    1153      +1

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: code shrink around varvalue
Ron Yorston [Mon, 18 May 2015 07:49:28 +0000 (09:49 +0200)]
ash: code shrink around varvalue

Based on commit c989d72 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
strtodest                                              -      40     +40
memtodest                                            123     147     +24
parse_command                                       1443    1440      -3
readtoken1                                          3205    3199      -6
argstr                                              1203    1180     -23
varvalue                                             788     660    -128
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/4 up/down: 64/-160)           Total: -96 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: explain what "local -" does
Denys Vlasenko [Wed, 13 May 2015 00:20:14 +0000 (02:20 +0200)]
ash: explain what "local -" does

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: consider "local -" case while iterating over local variables in mklocal.
Eugene Rudoy [Sun, 26 Apr 2015 21:32:00 +0000 (23:32 +0200)]
ash: consider "local -" case while iterating over local variables in mklocal.

fixes segfault introduced in 0a0acb55db8d7c4dec445573f1b0528d126b9e1f with functions using "local -".
test-case: f() { local -; local x; }; f

note: with this change applied multiple 'local -'s still cause multiple entries to be added to the localvars list.
this problem will be addressed in a separate commit.

Signed-off-by: Eugene Rudoy <gene.devel@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: Enable support for !CONFIG_MULTIUSER
Daniel Thompson [Tue, 12 May 2015 06:56:04 +0000 (07:56 +0100)]
libbb: Enable support for !CONFIG_MULTIUSER

Linux recently gained a new config option, CONFIG_MULTIUSER, that makes
support for non-root users optional. This results in a number of syscalls
being disabled: setuid, setregid, setgid, setreuid, setresuid, getresuid,
setresgid, getresgid, setgroups, getgroups, setfsuid, setfsgid, capget,
capset.

Currently a number of busybox applets, including login, struggle to run
when CONFIG_MULTIUSER is disabled. Even the root user is unable to login:
  login: can't set groups: Functi

This patch adds code to make change_identity() a nop on single user
systems. It works by recognising the signature errno value (ENOSYS, due
to the system calls being disabled) and, to avoid security risks, only
deploys when the current uid and target uid is the same.

After the patch is applied any attempt to switch to a non-root user will
fail. Thus a badly configured userspace (for example, one that tries to
start a daemon as a non-root user when the kernel cannot support this)
will report errors as one would expect.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2c-tools: only try /dev/i2c/* if opening /dev/i2c-* fails with ENOENT
Bartosz Golaszewski [Mon, 11 May 2015 15:26:27 +0000 (17:26 +0200)]
i2c-tools: only try /dev/i2c/* if opening /dev/i2c-* fails with ENOENT

Trying to access /dev/i2c/* on every error after opening /dev/i2c-* can
mislead users who e.g. don't have root access. Instead of bailing-out
with "permission denied" we currently print "no such file or directory".

Fix it by trying open("/dev/i2c/%d") only if we got ENOENT.

Upstream i2cdetect tries to get any info it can from /sys and /proc even
when invoked by an unprivileged user, but we don't want to add unnecessary
bloat.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2c-tools: fix 'i2cdetect -l'
Bartosz Golaszewski [Mon, 11 May 2015 15:22:10 +0000 (17:22 +0200)]
i2c-tools: fix 'i2cdetect -l'

Calling 'i2cdetect -l' only displays usage and exits. Fix it by
correctly parsing command-line arguments.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agobzcat.tests: Run both .gz and .bz2 tests, and add .Z tests
Thiago Jung Bauermann [Mon, 11 May 2015 15:18:59 +0000 (17:18 +0200)]
bzcat.tests: Run both .gz and .bz2 tests, and add .Z tests

Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotar: do not try to decode GNU extended headers as pax headers
Denys Vlasenko [Mon, 11 May 2015 14:55:16 +0000 (16:55 +0200)]
tar: do not try to decode GNU extended headers as pax headers

function                                             old     new   delta
get_header_tar                                      1736    1692     -44

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoConditionalize Bionic workarounds on __ANDROID_API__
Matt Whitlock [Sun, 3 May 2015 16:59:50 +0000 (18:59 +0200)]
Conditionalize Bionic workarounds on __ANDROID_API__

Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoBionic lacks mempcpy; enable existing workaround
Matt Whitlock [Sun, 3 May 2015 16:57:44 +0000 (18:57 +0200)]
Bionic lacks mempcpy; enable existing workaround

Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibarchive: auto-detect .Z files as well
Thiago Jung Bauermann [Sun, 3 May 2015 16:40:12 +0000 (18:40 +0200)]
libarchive: auto-detect .Z files as well

Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotypo fix
Denys Vlasenko [Sun, 3 May 2015 16:24:33 +0000 (18:24 +0200)]
typo fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agovi: basic undo feature shouldn't depend on yankmark
Andrew Fuller [Sun, 3 May 2015 16:18:25 +0000 (18:18 +0200)]
vi: basic undo feature shouldn't depend on yankmark

Currently basic undo functionality with the 'u' key depends on
FEATURE_VI_YANKMARK. These two features are separate, so we can remove this
dependency.

Signed-off-by: Andrew Fuller <abf@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>