oweals/busybox.git
9 years agomdev: improve logging
Denys Vlasenko [Sun, 19 Apr 2015 16:54:49 +0000 (18:54 +0200)]
mdev: improve logging

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agohush: document buggy handling of duplicate "local"
Denys Vlasenko [Sat, 18 Apr 2015 17:38:13 +0000 (19:38 +0200)]
hush: document buggy handling of duplicate "local"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: fix handling of duplicate "local"
Denys Vlasenko [Sat, 18 Apr 2015 17:36:38 +0000 (19:36 +0200)]
ash: fix handling of duplicate "local"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agosed: implement ",+N" range end
Denys Vlasenko [Fri, 17 Apr 2015 12:24:55 +0000 (14:24 +0200)]
sed: implement ",+N" range end

function                                             old     new   delta
add_cmd                                             1115    1173     +58
process_files                                       2226    2253     +27
sed_main                                             696     702      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 91/0)               Total: 91 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agouevent: new applet
Denys Vlasenko [Thu, 16 Apr 2015 10:44:02 +0000 (12:44 +0200)]
uevent: new applet

This applet listens on netlink socket with kernel's uevent messages.
Run-tested.

function                                             old     new   delta
uevent_main                                            -     416    +416
packed_usage                                       30671   30713     +42
applet_names                                        2531    2538      +7
applet_main                                         1468    1472      +4
RCVBUF                                                 -       4      +4
applet_nameofs                                       734     736      +2
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 4/0 up/down: 475/0)             Total: 475 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agofind: fix regression in status processing for path arguments
Felix Fietkau [Thu, 9 Apr 2015 08:20:16 +0000 (10:20 +0200)]
find: fix regression in status processing for path arguments

Regression added in commit 14158b4127dba30466c50147b868a6a89702960b
"find: add optional support for '-exec ... {} +'"

This commit causes find to exit on the first path argument that was not
found, which breaks existing scripts and is incompatible to other
implementations.

Instead of exiting on the first failure, return EXIT_FAILURE at the end
if any error occurred.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agovolume_id: fix a buglet introduced by is_prefixed_with() conversion
Alfonso Ranieri [Tue, 14 Apr 2015 12:32:39 +0000 (14:32 +0200)]
volume_id: fix a buglet introduced by is_prefixed_with() conversion

Signed-off-by: Alfonso Ranieri <alforan@tin.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agobuild system: make CONFIG_EXTRA_LDFLAGS go to LDFLAGS, not EXTRA_LDFLAGS
Denys Vlasenko [Tue, 14 Apr 2015 12:15:15 +0000 (14:15 +0200)]
build system: make CONFIG_EXTRA_LDFLAGS go to LDFLAGS, not EXTRA_LDFLAGS

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoupdate copyright years
Aaro Koskinen [Wed, 1 Apr 2015 21:55:17 +0000 (00:55 +0300)]
update copyright years

Copyright years seem to be out of date, e.g. coreutils/truncate.c
has Copyright (C) 2015.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
9 years ago*: Switch to POSIX utmpx API
Bernhard Reutner-Fischer [Thu, 2 Apr 2015 21:03:46 +0000 (23:03 +0200)]
*: Switch to POSIX utmpx API

UTMP is SVID legacy, UTMPX is mandated by POSIX.

Glibc and uClibc have identical layout of UTMP and UTMPX, both of these
libc treat _PATH_UTMPX as _PATH_UTMP so from a user-perspective nothing
changes except the names of the API entrypoints.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
9 years agoupdate example ntp.script
Denys Vlasenko [Tue, 31 Mar 2015 20:00:55 +0000 (22:00 +0200)]
update example ntp.script

Handle an interesting corner case when NTP server is reachable...
but on a different IP now.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoftpd: change_identity() must be after chroot()
Denys Vlasenko [Tue, 31 Mar 2015 19:46:26 +0000 (21:46 +0200)]
ftpd: change_identity() must be after chroot()

Otherwise chroot() doesn't work for non-root

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotypo fix
Denys Vlasenko [Thu, 26 Mar 2015 09:49:02 +0000 (10:49 +0100)]
typo fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotruncate: new applet
Denys Vlasenko [Sun, 22 Mar 2015 17:00:32 +0000 (18:00 +0100)]
truncate: new applet

Add the actual new source file :(

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agozcip: fix wrong comparison of source IP with our IP
Vladislav Grishenko [Thu, 19 Mar 2015 11:19:35 +0000 (16:19 +0500)]
zcip: fix wrong comparison of source IP with our IP

Commit "zcip: fix link-local IP conflict detection" has introduced
wrong comparsion of source IP with our IP. This leads to a new IP
being picked unnecessarily on every incoming ARP packet.

Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotruncate: new applet
Ari Sundholm [Sun, 22 Mar 2015 16:55:38 +0000 (17:55 +0100)]
truncate: new applet

function                                             old     new   delta
truncate_main                                          -     161    +161
cwbkMG_suffixes                                        -     128    +128
packed_usage                                       30443   30459     +16
applet_names                                        2512    2521      +9
applet_main                                         1456    1460      +4
parse_command                                       1460    1463      +3
applet_nameofs                                       728     730      +2
applet_install_loc                                   182     183      +1
dd_suffixes                                          112       -    -112
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 10/3 up/down: 337/-133)         Total: 204 bytes

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodd: move suffix struct to xatonum.c
Ari Sundholm [Wed, 4 Mar 2015 16:46:48 +0000 (18:46 +0200)]
dd: move suffix struct to xatonum.c

This way it can be used by other applets without duplication.

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agologread: implement dumpfollow mode of operation
Phil Sutter [Sun, 22 Mar 2015 16:36:20 +0000 (17:36 +0100)]
logread: implement dumpfollow mode of operation

This is basically a combination of the default (dump mode) and -f
(follow mode). Specifying -F makes logread first dump the log buffer and
then immediately start following it.

function                                             old     new   delta
packed_usage                                       30412   30443     +31
logread_main                                         491     497      +6

Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoifupdown: shrink a message
Denys Vlasenko [Sun, 22 Mar 2015 16:08:51 +0000 (17:08 +0100)]
ifupdown: shrink a message

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoifupdown: correct ifstate update during 'ifup -a'. Closes 6212
Frank Bergmann [Fri, 13 Mar 2015 09:05:08 +0000 (10:05 +0100)]
ifupdown: correct ifstate update during 'ifup -a'. Closes 6212

When 'if -a' runs into an failure on an interface all further
interfaces won't be correctly updated in ifstate. This patch
inserts a new variable that only tracks the current interfaces
failure so that the write to ifstate can rely on this and not
the one for the functions return value.

Fixes https://bugs.busybox.net/show_bug.cgi?id=6212

Signed-off-by: Frank Bergmann <frank.frajasalo@googlemail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: do not split the result of tilde expansion
Ron Yorston [Mon, 16 Mar 2015 14:14:11 +0000 (14:14 +0000)]
ash: do not split the result of tilde expansion

A tilde expansion generates a valid pathname. Splitting it using IFS
either leaves it unchanged or changes it to something unintended.

Example:
   IFS=m HOME=/tmp; printf "%s\n" ~

Based on this commit authored by Jilles Tjoelker:

   http://git.kernel.org/cgit/utils/dash/dash.git/commit/?id=834629283f6c629a4da05ef60bae9445c954a19a

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotrylink: respect compiler settings when probing features
Mike Frysinger [Mon, 16 Mar 2015 21:47:01 +0000 (17:47 -0400)]
trylink: respect compiler settings when probing features

The CPPFLAGS/CFLAGS settings might have features that matter, so make
sure we utilize them when testing the compiler.

URL: https://bugs.gentoo.org/471118
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
9 years agotrylink: use mktemp instead of hardcoding paths
Mike Frysinger [Mon, 16 Mar 2015 21:46:17 +0000 (17:46 -0400)]
trylink: use mktemp instead of hardcoding paths

This way we respect standard tempdir env vars and are guaranteed to
be unique.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
9 years agovi: make BACKSPACE and DELETE join lines at start/end of line
Denys Vlasenko [Thu, 12 Mar 2015 20:15:34 +0000 (21:15 +0100)]
vi: make BACKSPACE and DELETE join lines at start/end of line

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoUse chomp to remove newlines
Ron Yorston [Thu, 12 Mar 2015 19:18:51 +0000 (20:18 +0100)]
Use chomp to remove newlines

function                                             old     new   delta
unix_do_one                                          548     540      -8
process_timer_stats                                  508     500      -8
process_irq_counts                                   532     524      -8
lpd_main                                             839     831      -8
hwclock_main                                         502     494      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-50)             Total: -40 bytes

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agood: fix printing of high-bit chars
Ron Yorston [Thu, 12 Mar 2015 19:10:40 +0000 (20:10 +0100)]
od: fix printing of high-bit chars

Example: echo £ | od -c

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: introduce and use is_prefixed_with()
Denys Vlasenko [Thu, 12 Mar 2015 16:48:34 +0000 (17:48 +0100)]
libbb: introduce and use is_prefixed_with()

function                                             old     new   delta
is_prefixed_with                                       -      18     +18
complete_username                                     78      77      -1
man_main                                             737     735      -2
fsck_device                                          429     427      -2
unpack_ar_archive                                     80      76      -4
strip_unsafe_prefix                                  105     101      -4
singlemount                                         1054    1050      -4
rtc_adjtime_is_utc                                    90      86      -4
resolve_mount_spec                                    88      84      -4
parse_one_line                                      1029    1025      -4
parse_conf                                          1460    1456      -4
may_wakeup                                            83      79      -4
loadkmap_main                                        219     215      -4
get_irqs_from_stat                                   103      99      -4
get_header_cpio                                      913     909      -4
findfs_main                                           79      75      -4
fbsplash_main                                       1230    1226      -4
load_crontab                                         776     771      -5
expand_vars_to_list                                 1151    1146      -5
date_main                                            881     876      -5
skip_dev_pfx                                          30      24      -6
make_device                                         2199    2193      -6
complete_cmd_dir_file                                773     767      -6
run_applet_and_exit                                  715     708      -7
uudecode_main                                        321     313      -8
pwdx_main                                            197     189      -8
execute                                              568     560      -8
i2cdetect_main                                      1186    1176     -10
procps_scan                                         1242    1230     -12
procps_read_smaps                                   1017    1005     -12
process_module                                       746     734     -12
patch_main                                          1903    1891     -12
nfsmount                                            3572    3560     -12
stack_machine                                        126     112     -14
process_timer_stats                                  449     435     -14
match_fstype                                         111      97     -14
do_ipaddr                                           1344    1330     -14
open_list_and_close                                  359     343     -16
get_header_tar                                      1795    1779     -16
prepend_new_eth_table                                340     323     -17
fsck_main                                           1811    1794     -17
find_iface_state                                      56      38     -18
dnsd_main                                           1321    1303     -18
base_device                                          179     158     -21
find_keyword                                         104      82     -22
handle_incoming_and_exit                            2785    2762     -23
parse_and_put_prompt                                 774     746     -28
modinfo                                              347     317     -30
find_action                                          204     171     -33
update_passwd                                       1470    1436     -34
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/49 up/down: 18/-540)         Total: -522 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodeluser: also remove user from /etc/group
Denys Vlasenko [Thu, 12 Mar 2015 14:30:46 +0000 (15:30 +0100)]
deluser: also remove user from /etc/group

function                                             old     new   delta
update_passwd                                       1270    1470    +200
deluser_main                                         310     332     +22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoarping: fix iface name in error messages
Alexander Korolkov [Thu, 12 Mar 2015 12:05:33 +0000 (13:05 +0100)]
arping: fix iface name in error messages

arping: interface eth0 not found: No such device
                  ^^^^

This is because error template is formed before parsing command line arguments,
so it always uses default interface name "eth0".

Signed-off-by: Alexander Korolkov <alexander.korolkov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agopatch: segfault fix. Closes 7916
Denys Vlasenko [Wed, 11 Mar 2015 17:01:34 +0000 (18:01 +0100)]
patch: segfault fix. Closes 7916

Fix segfault on this case (malformed --- line):

    -- dwarves.orig 2015-02-25 01:45:27.753000000 +0000
    +++ dwarves     2015-02-25 01:46:08.199000000 +0000
    @@ -1,7 +1,7 @@
     Bashful
     Doc
     Dopey
    -Grouchy
    +Grumpy
     Happy
     Sleepy
     Sneezy

function                                             old     new   delta
patch_main                                          1903    1957     +54

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomount: -T OTHERTAB support
Isaac Dunham [Wed, 11 Mar 2015 15:07:24 +0000 (16:07 +0100)]
mount: -T OTHERTAB support

function                                             old     new   delta
mount_main                                          1221    1241     +20
packed_usage                                       30616   30610      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Isaac Dunham <ibid.ag@gmail.com>
9 years agontpd: tweak help text
Denys Vlasenko [Thu, 5 Mar 2015 13:04:44 +0000 (14:04 +0100)]
ntpd: tweak help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoinetd: fix order of array index check and array access
Denys Vlasenko [Tue, 3 Mar 2015 12:10:30 +0000 (13:10 +0100)]
inetd: fix order of array index check and array access

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agontpd: chnage help text about -l to say that it doesn't disable client code
Denys Vlasenko [Mon, 2 Mar 2015 19:59:13 +0000 (20:59 +0100)]
ntpd: chnage help text about -l to say that it doesn't disable client code

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agorunsvdir: if pid==1, also intercept SIGINT for -s SCRIPT
Denys Vlasenko [Mon, 2 Mar 2015 16:39:13 +0000 (17:39 +0100)]
runsvdir: if pid==1, also intercept SIGINT for -s SCRIPT

function                                             old     new   delta
runsvdir_main                                       1057    1064      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agorunsvdir: do not block SIGCHLD around poll/sleep
Denys Vlasenko [Mon, 2 Mar 2015 16:38:18 +0000 (17:38 +0100)]
runsvdir: do not block SIGCHLD around poll/sleep

There is no reason to do so. We do not even have SIGCHLD handler.

function                                             old     new   delta
runsvdir_main                                       1077    1057     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agorunsvdir: (almost) close a signal race
Denys Vlasenko [Mon, 2 Mar 2015 16:37:31 +0000 (17:37 +0100)]
runsvdir: (almost) close a signal race

We could lose a signal while processing previous one

function                                             old     new   delta
runsvdir_main                                       1088    1077     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoacpid: fix logging
Serj Kalichev [Mon, 23 Feb 2015 14:26:47 +0000 (15:26 +0100)]
acpid: fix logging

Without this patch acpid can't log the events at all. Moreover it tries
to truncate log file every time.

Signed-off-by: Serj Kalichev <serj.kalichev@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agols: heed compiler warning
Denys Vlasenko [Mon, 23 Feb 2015 14:25:58 +0000 (15:25 +0100)]
ls: heed compiler warning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodinfo: fix fallout from basename removal
Denys Vlasenko [Sat, 21 Feb 2015 16:08:35 +0000 (17:08 +0100)]
modinfo: fix fallout from basename removal

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: fix thinko in getpwnam
Tito Ragusa [Thu, 19 Feb 2015 21:02:59 +0000 (22:02 +0100)]
libpwdgrp: fix thinko in getpwnam

function                                             old     new   delta
parse_file                                             -      64     +64
getXXnam_r                                           162     138     -24
getXXnam                                              90      50     -40
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 64/-64)              Total: 0 bytes

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agowget: fix --header to not append duplicate headers
Bernhard Reutner-Fischer [Wed, 18 Feb 2015 19:41:02 +0000 (20:41 +0100)]
wget: fix --header to not append duplicate headers

function                                             old     new   delta
wget_main                                           2551    2715    +164
wget_user_headers                                      -      62     +62
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 226/0)             Total: 226 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotrivial code shrink
Denys Vlasenko [Wed, 18 Feb 2015 12:47:27 +0000 (13:47 +0100)]
trivial code shrink

function                                             old     new   delta
rdate_main                                           246     251      +5
show_entry                                           291     287      -4
daytime_stream                                        44      39      -5
packed_usage                                       30176   30168      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 5/-17)             Total: -12 bytes
   text    data     bss     dec     hex filename
 929453     932   17684  948069   e7765 busybox_old
 929411     932   17684  948027   e773b busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agols: trivial code shrink
Denys Vlasenko [Wed, 18 Feb 2015 10:29:07 +0000 (11:29 +0100)]
ls: trivial code shrink

function                                             old     new   delta
display_single                                       914     893     -21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodc: tweak parsing
Bernhard Reutner-Fischer [Mon, 16 Feb 2015 16:12:04 +0000 (17:12 +0100)]
dc: tweak parsing

https://bugs.debian.org/538685
dc requires whitespace between language elements.

We were requiring
1 2 + p
instead of the abbreviated
1 2+p
(for example).

function                                             old     new   delta
stack_machine                                         97     126     +29
dc_main                                              117      79     -38
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 29/-38)             Total: -9 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agols: fix year 9999 bug :)
Denys Vlasenko [Mon, 16 Feb 2015 14:36:25 +0000 (15:36 +0100)]
ls: fix year 9999 bug :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodprobe-small: fix thinko in previous commit
Denys Vlasenko [Fri, 13 Feb 2015 10:53:33 +0000 (11:53 +0100)]
modprobe-small: fix thinko in previous commit

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodprobe-small: if concurrent module load did not succeed, wait
Denys Vlasenko [Thu, 12 Feb 2015 15:18:39 +0000 (16:18 +0100)]
modprobe-small: if concurrent module load did not succeed, wait

usecase:
two sd cards are being mounted in parallel at same time on dual core. example
modules which are getting loaded is  nls_cp437. While one module is being
loaded , it makes state in /proc/modules as 'coming' and then starts doing its
module init function (in our case - registering nls). meanwhile on other core,
if modprobe returns that is has already been loaded, then it will continue
and search for the nls list which is not yet finished from first module init.
This fails resulting in not mounting sd card.

function                                             old     new   delta
process_module                                       667     746     +79

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoi2cget, i2cset, i2cdetect, i2cdump: new applets
Bartosz Golaszewski [Tue, 10 Feb 2015 02:16:25 +0000 (03:16 +0100)]
i2cget, i2cset, i2cdetect, i2cdump: new applets

Add a minimal implementation of i2cget, i2cset, i2cdump and i2cdetect
tools. Supports most features of upstream i2c-tools.

function                                             old     new   delta
i2cdump_main                                           -    1444   +1444
i2cset_main                                            -    1239   +1239
i2cdetect_main                                         -     611    +611
list_i2c_busses_and_exit                               -     532    +532
packed_usage                                       29975   30438    +463
i2cget_main                                            -     380    +380
check_read_funcs                                       -     140    +140
i2c_funcs_tab                                          -     128    +128
confirm_action                                         -     100    +100
i2c_dev_open                                           -      57     +57
i2c_smbus_access                                       -      44     +44
confirm_or_abort                                       -      43     +43
check_funcs_test_end                                   -      39     +39
i2c_smbus_read_word_data                               -      38     +38
i2c_smbus_read_byte_data                               -      38     +38
i2c_smbus_read_byte                                    -      37     +37
i2c_set_slave_addr                                     -      32     +32
applet_names                                        2480    2512     +32
adap_descs                                             -      32     +32
i2c_set_pec                                            -      29     +29
get_funcs_matrix                                       -      21     +21
i2c_parse_data_addr                                    -      18     +18
i2c_parse_bus_addr                                     -      18     +18
i2c_bus_lookup                                         -      18     +18
i2c_smbus_write_byte                                   -      17     +17
applet_main                                         1440    1456     +16
will_skip                                              -      14     +14
no_support                                             -      11     +11
applet_nameofs                                       720     728      +8
applet_install_loc                                   180     182      +2
------------------------------------------------------------------------------
(add/remove: 26/0 grow/shrink: 5/0 up/down: 5601/0)          Total: 5601 bytes

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agounzip: prevent attacks via malicious filenames
Denys Vlasenko [Tue, 10 Feb 2015 00:30:43 +0000 (01:30 +0100)]
unzip: prevent attacks via malicious filenames

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: use getpwent() instead of getpwent_r()
Denys Vlasenko [Sat, 7 Feb 2015 20:21:02 +0000 (21:21 +0100)]
libpwdgrp: use getpwent() instead of getpwent_r()

function                                             old     new   delta
massage_data_for_non_r_func                            -      90     +90
bb_internal_getpwent                                   -      69     +69
getXXnam_r                                            94     162     +68
fill_bounds                                          131     128      -3
deluser_main                                         355     310     -45
complete_username                                    123      78     -45
getXXnam                                             163      90     -73
massage_data_for_r_func                              103       -    -103
bb_internal_getpwent_r                               121       -    -121
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/5 up/down: 227/-407)         Total: -163 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodprobe-small: fix and simplify rmmod
Denys Vlasenko [Sat, 7 Feb 2015 19:44:46 +0000 (20:44 +0100)]
modprobe-small: fix and simplify rmmod

"rmmod OUT_OF_TREE_MODULE" was not working, because module is not in depmod file.

In general, rmmod doesn't need scanning, it simply unloads every argv[i].

function                                             old     new   delta
rmmod                                                  -      63     +63
modprobe_main                                        449     465     +16
process_module                                       705     667     -38
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 79/-38)             Total: 41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb/loop: don't try to re-use existing loop device
Kevin Wallace [Wed, 4 Feb 2015 00:17:29 +0000 (16:17 -0800)]
libbb/loop: don't try to re-use existing loop device

loopinfo.lo_file_name is not enough to uniquely identify a file on a system with
multiple mount namespaces.  We could conceivably change this to dedup on
(lo_rdevice, lo_inode), but, as the comment above the deleted code notes, this
whole approach of reusing devices is racy anyway, so it seems better to stop
doing it entirely.

Signed-off-by: Kevin Wallace <k@igneous.io>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoexamples/mdev_fat.conf: document that newer mdev exposes path
Denys Vlasenko [Sat, 7 Feb 2015 17:14:39 +0000 (18:14 +0100)]
examples/mdev_fat.conf: document that newer mdev exposes path

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodd: add optional support for status=noxfer/none
Ari Sundholm [Sat, 7 Feb 2015 00:41:22 +0000 (01:41 +0100)]
dd: add optional support for status=noxfer/none

While at it, added 'B' number suffixes, upstream compat

function                                             old     new   delta
dd_main                                             1469    1543     +74
dd_suffixes                                           88     112     +24
packed_usage                                       30156   30176     +20
dd_output_status                                     372     388     +16
static.status_words                                    -      13     +13
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 147/0)             Total: 147 bytes

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoash: fix a SEGV case in an invalid heredoc
Denys Vlasenko [Thu, 5 Feb 2015 20:00:17 +0000 (21:00 +0100)]
ash: fix a SEGV case in an invalid heredoc

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodeluser: implement --remove-home
Denys Vlasenko [Thu, 5 Feb 2015 17:35:52 +0000 (18:35 +0100)]
deluser: implement --remove-home

function                                             old     new   delta
deluser_main                                         308     355     +47
packed_usage                                       30149   30156      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 54/0)               Total: 54 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agofstrim: fix help text
Denys Vlasenko [Wed, 4 Feb 2015 14:19:38 +0000 (15:19 +0100)]
fstrim: fix help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoroute: fix bogus read error when route table is empty
Denys Vlasenko [Tue, 3 Feb 2015 18:42:28 +0000 (19:42 +0100)]
route: fix bogus read error when route table is empty

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoroute: improve -A inet6
Denys Vlasenko [Tue, 3 Feb 2015 18:32:44 +0000 (19:32 +0100)]
route: improve -A inet6

Upstream route command shows non-up routes, it shows reject and nonexthop flags.
And we had "ref" and "use" values mixed up...

function                                             old     new   delta
flagvals                                              32      44     +12
flagchars                                              9      12      +3
INET_setroute                                        767     768      +1
INET6_setroute                                       495     496      +1
set_flags                                             43      39      -4
flags_ipvx                                            16       8      -8
route_main                                           632     623      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/3 up/down: 17/-21)             Total: -4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agogzip: trivial code shrink -5 bytes
Denys Vlasenko [Tue, 3 Feb 2015 14:25:17 +0000 (15:25 +0100)]
gzip: trivial code shrink -5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoifconfig: fix double free fatal error in INET_sprint
Denys Vlasenko [Tue, 3 Feb 2015 11:11:30 +0000 (12:11 +0100)]
ifconfig: fix double free fatal error in INET_sprint

Based on the patch by Zheng Junling <zhengjunling@huawei.com>
and Chen Gang <cg.chen@huawei.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: make INET[6]_rresolve use sockaddr2{host,dotted}_noport
Denys Vlasenko [Tue, 3 Feb 2015 11:07:40 +0000 (12:07 +0100)]
libbb: make INET[6]_rresolve use sockaddr2{host,dotted}_noport

function                                             old     new   delta
INET_rresolve                                        274     214     -60
INET6_rresolve                                       168      85     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agogzip: speed up and shrink put_16bit()
Denys Vlasenko [Mon, 2 Feb 2015 15:07:07 +0000 (16:07 +0100)]
gzip: speed up and shrink put_16bit()

function                                             old     new   delta
put_16bit                                            104      98      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agogzip: do not store timestamp in gzip header
Rich Felker [Mon, 2 Feb 2015 15:01:16 +0000 (16:01 +0100)]
gzip: do not store timestamp in gzip header

Storing the original file's modification time in the output file is
harmful (precludes deterministic results) and unlike official gzip,
the busybox version provides no way to suppress this behavior; the -n
option is silently ignored. Rather than trying to make -n work, this
patch just removes the timestamp-storing functionality. It should be
considered deprecated anyway; it's not Y2038-safe and gunzip ignores
it by default.

Per RFC 1952, 0 is the correct value to store to indicate that there
is no timestamp.

Signed-off-by: Rich Felker <dalias@libc.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoplatform.h: enable mempcpy for FreeBSD
Denys Vlasenko [Mon, 2 Feb 2015 02:51:47 +0000 (03:51 +0100)]
platform.h: enable mempcpy for FreeBSD

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoubiattach: add option -O
Micke Prag [Sun, 2 Nov 2014 10:08:24 +0000 (11:08 +0100)]
ubiattach: add option -O

Some images do not have the default VID offset. The option -O must
be used to attach such images.

Signed-off-by: Micke Prag <micke.prag@telldus.se>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotelnetd: we only need CONFIG_UNIX98_PTYS from the Linux kernel
Martin Kaiser [Sun, 2 Nov 2014 22:23:16 +0000 (23:23 +0100)]
telnetd: we only need CONFIG_UNIX98_PTYS from the Linux kernel

(re-sending this as it got ignored completey and the format of the
previous mail was probably not correct - please let me know if there's
anything else I can do to get this trivial fix applied)

for telnetd to work, we only need CONFIG_UNIX98_PTYS to be enabled
in the Linux kernel - DEVPTS_FS has been obsolete for some time

Signed-off-by: Martin Kaiser <lists@kaiser.cx>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodpkg: update supported compression methods
Denys Vlasenko [Fri, 30 Jan 2015 14:15:38 +0000 (15:15 +0100)]
dpkg: update supported compression methods

Based on a patch by Ron Yorston <rmy@tigress.co.uk>

function                                             old     new   delta
get_header_tar_xz                                      -      60     +60
filter_accept_list_reassign                          128     188     +60
unpack_package                                       585     621     +36
init_archive_deb_control                              52      76     +24
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/0 up/down: 180/0)             Total: 180 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoplatform.h: mempcpy needs <string.h>
Denys Vlasenko [Thu, 29 Jan 2015 15:41:48 +0000 (16:41 +0100)]
platform.h: mempcpy needs <string.h>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agontpd: get rid of G.initial_poll_complete
Denys Vlasenko [Thu, 29 Jan 2015 15:31:36 +0000 (16:31 +0100)]
ntpd: get rid of G.initial_poll_complete

This speeds up syncing - now happens only just
two replies from a peer. Especially useful for "ntpd -q".
Shouldn't have ill effects: if we chose a bad peer,
we will discover it later and switch to another one.

The code is even smaller this way.

Suggested by Miroslav Lichvar <mlichvar@redhat.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodhcpd: fix an improper widening conversion
Denys Vlasenko [Tue, 27 Jan 2015 20:59:40 +0000 (21:59 +0100)]
dhcpd: fix an improper widening conversion

We wanted to detect when tv_sec = unsigned1 - unsigned2
underflows by looking at tv_sec's sign. But if tv_sec
is long and it is wider than unsigned, we get unsigned -> long
conversion which is in this case never negative.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoftpd: prevent zombies. closes 7832
Denys Vlasenko [Mon, 26 Jan 2015 14:45:48 +0000 (15:45 +0100)]
ftpd: prevent zombies. closes 7832

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoplatform.h: add compat mempcpy
Denys Vlasenko [Sun, 25 Jan 2015 21:08:46 +0000 (22:08 +0100)]
platform.h: add compat mempcpy

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodepmod: simple memory optimization
Denys Vlasenko [Sat, 24 Jan 2015 21:30:30 +0000 (22:30 +0100)]
depmod: simple memory optimization

function                                             old     new   delta
filename2modname                                      67      86     +19
parse_module                                         374     351     -23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agotrim extra newlines in help texts
Denys Vlasenko [Sat, 24 Jan 2015 18:46:45 +0000 (19:46 +0100)]
trim extra newlines in help texts

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodprobe: fix modprobe -r and parsing of /etc/modprobe.d
Natanael Copa [Fri, 16 Jan 2015 12:53:05 +0000 (13:53 +0100)]
modprobe: fix modprobe -r and parsing of /etc/modprobe.d

This fixes a regression introduced with commit 78854520 (modprobe:
revert checking for /, stop doing basename() on modprobe args,
2015-01-01) that broke modprobe options stored in /etc/modprobe.conf and
/etc/modprobe.d/*.conf.

This also fixes modprobe -r

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodprobe: fix "modprobe devname:snd/timer" case (alias with a slash)
Denys Vlasenko [Thu, 15 Jan 2015 02:04:23 +0000 (03:04 +0100)]
modprobe: fix "modprobe devname:snd/timer" case (alias with a slash)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodprobe: fix recent breakage: modules.dep reading code needs to strip dirname
Denys Vlasenko [Thu, 15 Jan 2015 01:48:36 +0000 (02:48 +0100)]
modprobe: fix recent breakage: modules.dep reading code needs to strip dirname

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodprobe-small: code shrink
Denys Vlasenko [Sun, 11 Jan 2015 16:46:56 +0000 (17:46 +0100)]
modprobe-small: code shrink

function                                             old     new   delta
pathname_matches_modname                              80      42     -38

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agomodprobe-small: fix recent breakage: modprobe -r was using full path
Denys Vlasenko [Sun, 11 Jan 2015 16:40:30 +0000 (17:40 +0100)]
modprobe-small: fix recent breakage: modprobe -r was using full path

"modprobe -r MODNAME", after it found the full module pathname,
should strip dirpath before trying to remove the module.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodiff: fix a bug in diffing against stdin. Closes 7784
Denys Vlasenko [Sun, 11 Jan 2015 15:41:54 +0000 (16:41 +0100)]
diff: fix a bug in diffing against stdin. Closes 7784

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agovi: fix reading of file after last line
Ron Yorston [Sun, 30 Nov 2014 20:39:53 +0000 (20:39 +0000)]
vi: fix reading of file after last line

If the :r command is used to read a file after the last line of the
buffer the last line of the buffer and the first line of the file
are joined.  An extra blank line appears at the end of the buffer.

   file 1
   file 1
   file 1file 2
   file 2
   file 2

~
~

The insertion point is normally at the start of the line following the
specified line.  When the specified line is the last one the next_line
function baulks at moving to the non-existent following line.

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agovi: failure to open file is not an error when initialising buffer
Ron Yorston [Sun, 30 Nov 2014 20:39:25 +0000 (20:39 +0000)]
vi: failure to open file is not an error when initialising buffer

Commit 32afd3a introduced these regressions on the master branch:

Starting vi with no filename on the command line gives the status message
"'(null)' Bad address" instead of "- No file 1/1 100%".

Starting vi with a non-existent file on the command line gives the status
message "'new.txt' No such file or directory" instead of "- new.txt 1/1 100%"

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodepmod: fix recent breakage in modules.dep generation
Denys Vlasenko [Wed, 7 Jan 2015 13:39:01 +0000 (14:39 +0100)]
depmod: fix recent breakage in modules.dep generation

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: line counting in error meesages is broken, remove it
Tito Ragusa [Tue, 6 Jan 2015 00:22:36 +0000 (01:22 +0100)]
libpwdgrp: line counting in error meesages is broken, remove it

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agoswaponoff: add support for -e
René Rhéaume [Mon, 5 Jan 2015 19:35:00 +0000 (20:35 +0100)]
swaponoff: add support for -e

Signed-off-by: René Rhéaume <rene.rheaume@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agompstat: code shrink
Denys Vlasenko [Mon, 5 Jan 2015 17:39:23 +0000 (18:39 +0100)]
mpstat: code shrink

function                                             old     new   delta
get_uptime                                           134     129      -5
get_irqs_from_stat                                   110     103      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agofree: handle "cached" value too
Guillermo Rodriguez [Mon, 5 Jan 2015 17:34:53 +0000 (18:34 +0100)]
free: handle "cached" value too

function                                             old     new   delta
free_main                                            356     481    +125

Signed-off-by: Guillermo Rodriguez <guille.rodriguez@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibbb: code shrink by factoring out common update_utmp_DEAD_PROCESS
Denys Vlasenko [Mon, 5 Jan 2015 14:37:58 +0000 (15:37 +0100)]
libbb: code shrink by factoring out common update_utmp_DEAD_PROCESS

function                                             old     new   delta
update_utmp_DEAD_PROCESS                               -      17     +17
telnetd_main                                        1685    1674     -11
mark_terminated                                       56      45     -11
handle_sigchld                                        74      63     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agodeleting unused ntpd_simple.c
Denys Vlasenko [Mon, 5 Jan 2015 14:12:37 +0000 (15:12 +0100)]
deleting unused ntpd_simple.c

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: fixes suggested by Tito, comment tweaks
Denys Vlasenko [Mon, 5 Jan 2015 14:09:04 +0000 (15:09 +0100)]
libpwdgrp: fixes suggested by Tito, comment tweaks

function                                             old     new   delta
bb_internal_getpwent_r                               100     121     +21
parse_common                                         202     203      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agontpd: relicense ntpd applet to ISC-style license
Adam Tkac [Sun, 4 Jan 2015 16:46:08 +0000 (17:46 +0100)]
ntpd: relicense ntpd applet to ISC-style license

OpenNTPd is licensed under ISC-style license so it's good idea to keep
ntpd applet under same license to avoid mess, instead of having
our changes to be under GPL.

Names of original code's authors are added.

Signed-off-by: Adam Tkac <vonsch@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: another code shrink
Denys Vlasenko [Sun, 4 Jan 2015 01:34:52 +0000 (02:34 +0100)]
libpwdgrp: another code shrink

function                                             old     new   delta
massage_data_for_r_func                                -     110    +110
bb_internal_getpwent_r                               173     100     -73
getXXnam_r                                           176      95     -81
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 110/-154)          Total: -44 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: code shrink
Denys Vlasenko [Sun, 4 Jan 2015 01:02:39 +0000 (02:02 +0100)]
libpwdgrp: code shrink

function                                             old     new   delta
parse_common                                         206     205      -1
getgrouplist_internal                                229     225      -4
bb_internal_getpwent_r                               182     173      -9
getXXnam                                             232     222     -10
getXXnam_r                                           216     176     -40
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-64)             Total: -64 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: getgrXXX: empty string is not a member name, do not store it
Denys Vlasenko [Sat, 3 Jan 2015 20:16:18 +0000 (21:16 +0100)]
libpwdgrp: getgrXXX: empty string is not a member name, do not store it

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agofix a SEGV in previous commit
Denys Vlasenko [Sat, 3 Jan 2015 20:11:27 +0000 (21:11 +0100)]
fix a SEGV in previous commit

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: fix counting of commas in group list
Denys Vlasenko [Sat, 3 Jan 2015 20:03:39 +0000 (21:03 +0100)]
libpwdgrp: fix counting of commas in group list

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: store getXXnam result in a single malloc block
Denys Vlasenko [Sat, 3 Jan 2015 19:47:47 +0000 (20:47 +0100)]
libpwdgrp: store getXXnam result in a single malloc block

This saves a bit of memory but more importantly, allows to create
xmalloc_getpwnam() API where result can be deleted simply using free().

function                                             old     new   delta
getXXnam                                             134     173     +39
parse_common                                         188     212     +24
convert_to_struct                                    277     290     +13
get_S                                                 90      88      -2
tokenize                                             129     126      -3
bb_internal_getpwent_r                               175     172      -3
getXXnam_r                                           208     198     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/4 up/down: 76/-18)             Total: 58 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 years agolibpwdgrp: make db->def[] one byte shorter
Denys Vlasenko [Sat, 3 Jan 2015 18:12:49 +0000 (19:12 +0100)]
libpwdgrp: make db->def[] one byte shorter

In the future I will need another uint8_t, want to fit it
w/o using another word on 32 bits.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>