Commit Graph

13663 Commits

Author SHA1 Message Date
Ron Yorston
7e4ed267b6 ash: remove superfluous code in arithmetic mode
Based on commits 1a74845, cfc3d6a 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>
2015-05-18 09:54:43 +02:00
Ron Yorston
3df47f9cbb 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>
2015-05-18 09:53:26 +02:00
Ron Yorston
eb6b48ba74 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>
2015-05-18 09:51:35 +02:00
Ron Yorston
d68d1fbd6c 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>
2015-05-18 09:49:28 +02:00
Denys Vlasenko
e0a4e107aa ash: explain what "local -" does
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-13 02:20:14 +02:00
Eugene Rudoy
1285aa62f9 ash: consider "local -" case while iterating over local variables in mklocal.
fixes segfault introduced in 0a0acb55db 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>
2015-05-13 02:09:53 +02:00
Daniel Thompson
a818777d42 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>
2015-05-12 23:59:57 +02:00
Bartosz Golaszewski
7ca5c51cc8 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>
2015-05-11 17:26:27 +02:00
Bartosz Golaszewski
b2cca32a37 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>
2015-05-11 17:24:03 +02:00
Thiago Jung Bauermann
17b16223f3 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>
2015-05-11 17:19:22 +02:00
Denys Vlasenko
bdb540e04f 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>
2015-05-11 16:55:16 +02:00
Matt Whitlock
778efe37ee Conditionalize Bionic workarounds on __ANDROID_API__
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-03 19:33:32 +02:00
Matt Whitlock
f23e3ec529 Bionic lacks mempcpy; enable existing workaround
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-03 18:57:44 +02:00
Thiago Jung Bauermann
b4059f6309 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>
2015-05-03 18:40:12 +02:00
Denys Vlasenko
c77a58fb2d typo fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-03 18:24:33 +02:00
Andrew Fuller
4d8ddb810d 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>
2015-05-03 18:18:25 +02:00
Aaro Koskinen
bbd53216f8 gzip: add support for compression levels 4-9
function                                             old     new   delta
gzip_main                                            192     282     +90
static.gzip_level_config                               -      24     +24
packed_usage                                       30439   30459     +20
fill_window                                          216     220      +4
pack_gzip                                           1789    1729     -60
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 138/-60)            Total: 78 bytes

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-26 14:22:37 +02:00
Matt Whitlock
93b98ff572 Bionic lacks tcdrain; provide a workaround
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-26 13:14:50 +02:00
Matt Whitlock
cee59053dc Bionic lacks ttyname_r; provide a workaround
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-25 21:32:48 +02:00
Denys Vlasenko
de5edadee2 special-case {true,false,test} --help
This also removes their help texts.

function                                             old     new   delta
run_applet_no_and_exit                               442     452     +10
packed_usage                                       30713   30625     -88

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-21 16:00:41 +02:00
Bernhard Reutner-Fischer
7d86384b24 include: Fallback to UTMP unless there is UTMPX support
Fixes compilation against uClibc-0.9.30 for instance

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-04-20 15:24:30 +02:00
Ron Yorston
61d6ae244a libbb: remove unnecessary argument to nonblock_immune_read
The loop_on_EINTR argument to nonblock_immune_read is always set to 1.

function                                             old     new   delta
xmalloc_reads                                        200     195      -5
pgetc                                                488     483      -5
argstr                                              1313    1308      -5
nonblock_immune_read                                 123      86     -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-52)             Total: -52 bytes

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-20 13:41:32 +02:00
Denys Vlasenko
ad795510d9 mdev: if a "future" mdev.seq is seen, do not overwrite it with ours
This was seen to happen if two mdevs are run in parallel,
mdev.seq is empty, and the "newer" one manages to write it first.

function                                             old     new   delta
mdev_main                                           1366    1388     +22
atoll                                                  -      20     +20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-19 18:55:12 +02:00
Denys Vlasenko
bd77e9d609 mdev: improve logging
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-19 18:54:49 +02:00
Denys Vlasenko
73327a048b hush: document buggy handling of duplicate "local"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-18 19:38:13 +02:00
Denys Vlasenko
0a0acb55db ash: fix handling of duplicate "local"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-18 19:36:38 +02:00
Denys Vlasenko
63f4d32c98 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>
2015-04-17 14:24:55 +02:00
Denys Vlasenko
71a5b67ba0 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>
2015-04-16 12:44:02 +02:00
Felix Fietkau
f7466e4776 find: fix regression in status processing for path arguments
Regression added in commit 14158b4127
"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>
2015-04-14 16:45:23 +02:00
Alfonso Ranieri
a90490fb69 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>
2015-04-14 14:32:39 +02:00
Denys Vlasenko
e0ddb65cb2 build system: make CONFIG_EXTRA_LDFLAGS go to LDFLAGS, not EXTRA_LDFLAGS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-14 14:15:15 +02:00
Aaro Koskinen
7b729edd33 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>
2015-04-02 23:03:56 +02:00
Bernhard Reutner-Fischer
86a7f18f21 *: 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>
2015-04-02 23:03:46 +02:00
Denys Vlasenko
1186894f77 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>
2015-03-31 22:00:55 +02:00
Denys Vlasenko
9472e8a86f ftpd: change_identity() must be after chroot()
Otherwise chroot() doesn't work for non-root

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-31 21:46:26 +02:00
Denys Vlasenko
379e8e81af typo fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-26 10:49:02 +01:00
Denys Vlasenko
1850d5ec0e truncate: new applet
Add the actual new source file :(

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-22 18:00:32 +01:00
Vladislav Grishenko
4d15068d83 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>
2015-03-22 17:59:34 +01:00
Ari Sundholm
911db16229 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>
2015-03-22 17:56:38 +01:00
Ari Sundholm
8893023ba2 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>
2015-03-22 17:41:04 +01:00
Phil Sutter
92edab1aa6 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>
2015-03-22 17:37:20 +01:00
Denys Vlasenko
6d8ea1d50e ifupdown: shrink a message
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-22 17:08:51 +01:00
Frank Bergmann
6ca03f2dd8 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>
2015-03-22 17:04:27 +01:00
Ron Yorston
75a76269ba 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>
2015-03-22 16:55:44 +01:00
Mike Frysinger
6798564b9e 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>
2015-03-16 17:47:01 -04:00
Mike Frysinger
4a08e82d44 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>
2015-03-16 17:46:17 -04:00
Denys Vlasenko
49acc1a761 vi: make BACKSPACE and DELETE join lines at start/end of line
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12 21:15:34 +01:00
Ron Yorston
8ec1ff350c 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>
2015-03-12 20:18:51 +01:00
Ron Yorston
53e9c51ade 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>
2015-03-12 20:11:48 +01:00
Denys Vlasenko
8dff01d06a 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>
2015-03-12 17:48:34 +01:00