oweals/busybox.git
7 years agobusybox: stop depending on FEATURE_AUTOWIDTH for applet list
Denys Vlasenko [Wed, 11 Jan 2017 09:52:24 +0000 (10:52 +0100)]
busybox: stop depending on FEATURE_AUTOWIDTH for applet list

Many other appletw don't - they unconditionally use get_terminal_wodth(),
and here the amount of code saved by FEATURE_AUTOWIDTH=n is tiny.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotop: FEATURE_USE_TERMIOS shouldn't control reading of screen size
Denys Vlasenko [Wed, 11 Jan 2017 09:50:08 +0000 (10:50 +0100)]
top: FEATURE_USE_TERMIOS shouldn't control reading of screen size

It controls whether we take input.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomore: hardcode FEATURE_USE_TERMIOS=y in this applet; code shrink
Denys Vlasenko [Wed, 11 Jan 2017 09:38:52 +0000 (10:38 +0100)]
more: hardcode FEATURE_USE_TERMIOS=y in this applet; code shrink

function                                             old     new   delta
get_wh                                                 -      27     +27
tcsetattr_tty_TCSANOW                                  -      18     +18
gotsig                                                35      27      -8
more_main                                            835     759     -76
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/2 up/down: 45/-84)            Total: -39 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: shorten output of "help" builtin
Denys Vlasenko [Tue, 10 Jan 2017 15:51:10 +0000 (16:51 +0100)]
hush: shorten output of "help" builtin

   text    data     bss     dec     hex filename
 891272     485    6856  898613   db635 busybox_old
 891232     485    6856  898573   db60d busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: reorder builtins (cd and pwd ought to be close, etc), no code changes
Denys Vlasenko [Tue, 10 Jan 2017 14:58:02 +0000 (15:58 +0100)]
hush: reorder builtins (cd and pwd ought to be close, etc), no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoinit: rename FEATURE_EXTRA_QUIET -> FEATURE_INIT_QUIET
Denys Vlasenko [Tue, 10 Jan 2017 14:24:13 +0000 (15:24 +0100)]
init: rename FEATURE_EXTRA_QUIET -> FEATURE_INIT_QUIET

The former name had no INIT anywhere in its name, sounded generic

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: revert "make dot command search current directory first"
Denys Vlasenko [Tue, 10 Jan 2017 14:18:38 +0000 (15:18 +0100)]
ash: revert "make dot command search current directory first"

Reverts this:
    commit 8ad78e1ec7b2e873953f9f476fb63b5893526c39
    Author: Denis Vlasenko <vda.linux@googlemail.com>
    Date:   Sun Feb 15 12:40:30 2009 +0000
    ash: make dot command search current directory first, as bash does.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoshells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_foo
Denys Vlasenko [Tue, 10 Jan 2017 14:13:30 +0000 (15:13 +0100)]
shells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_foo

This makes hash and ash more symmetrical wrt config menu and config
options.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoBig cleanup in config help and description
Denys Vlasenko [Tue, 10 Jan 2017 13:58:54 +0000 (14:58 +0100)]
Big cleanup in config help and description

Redundant help texts (one which only repeats the description)
are deleted.

Descriptions and help texts are trimmed.

Some config options are moved, even across menus.

No config option _names_ are changed.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoAllow FAST_FUNC to be overridden at build time
Kang-Che Sung [Thu, 5 Jan 2017 01:25:03 +0000 (09:25 +0800)]
Allow FAST_FUNC to be overridden at build time

Busybox uses FAST_FUNC macro to tweak with IA-32 calling conventions in
order to make the function call slightly smaller or slightly faster.
However, when I experiment with GCC's LTO (Link Time Optimization), I
discovered that FAST_FUNC could hinder LTO's optimization so that the
resulting executable become a few bytes larger (than what is compiled
without FAST_FUNC).

This change allows to specify e.g.
CONFIG_EXTRA_CFLAGS="-DFAST_FUNC= -flto"
and compile with LTO without a source code hack.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agokill: optimizations for single-applet build
Kang-Che Sung [Mon, 9 Jan 2017 17:46:58 +0000 (18:46 +0100)]
kill: optimizations for single-applet build

* Fix a bug with a configuration in which the shell's kill builtin
  would be mistreated as a killall command (i.e. '-q' works, and
  'kill process_name' succeeds when it shouldn't):

    CONFIG_ASH_JOB_CONTROL=y
    CONFIG_HUSH_KILL=y
    # CONFIG_KILL is not set
    CONFIG_KILLALL=y
    # CONFIG_KILLALL5 is not set

* Optimize out unneeded code when the relevant applets are not
  selected.

* Move kbuild lines about shells' kill builtins from Kbuild.src to
  kill.c, to accompany the new HAVE_SH_KILL macro. I hope this would
  make maintanence a little bit easier.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: make echo builtin optional
Denys Vlasenko [Mon, 9 Jan 2017 16:10:04 +0000 (17:10 +0100)]
hush: make echo builtin optional

It's a bit overkill (who would want it off?) but ash already has it
configurable. Let's be symmetric.

Also tweak kbuild logic to use ASH_BUILTIN_ECHO to select echo.o,
not ASH.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agokill: need not build kill.c when ash's job control is off
Kang-Che Sung [Mon, 9 Jan 2017 16:02:51 +0000 (17:02 +0100)]
kill: need not build kill.c when ash's job control is off

ash kill builtin depends on the job control config option.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomake_single_applets.sh: show errors and warnings
Denys Vlasenko [Mon, 9 Jan 2017 15:31:21 +0000 (16:31 +0100)]
make_single_applets.sh: show errors and warnings

While at it, fix one warning in modprobe-small.c

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounlzma: expand comments, no code changes
Denys Vlasenko [Mon, 9 Jan 2017 13:28:25 +0000 (14:28 +0100)]
unlzma: expand comments, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounlzma: fix erroneous "while" instead of "if". Closes 4682
Denys Vlasenko [Mon, 9 Jan 2017 12:55:11 +0000 (13:55 +0100)]
unlzma: fix erroneous "while" instead of "if". Closes 4682

These parts of the code essentially check whether
stepping back by rep0 goes negative or not.

LZMA SDK from lzma1604.7z has the following in the corresponding places:

... = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]

Clearly, not loop here.

Technically, "while" here works: if condition is false (because pos
underflowed), it iterates once, adds header.dict_size (a.k.a. dicBufSize),
this makes pos positive but smaller than header.dict_size, and loop exits.

Now we'll just check for negative result of subtraction, which is less code:

function                                             old     new   delta
unpack_lzma_stream                                  2659    2641     -18

(I hope 2 Gbyte+ dictionaries won't be in use soon).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: match "Defl:?" display with info-zip; cosmetic code shuffling
Denys Vlasenko [Mon, 9 Jan 2017 12:10:10 +0000 (13:10 +0100)]
unzip: match "Defl:?" display with info-zip; cosmetic code shuffling

Large nested indented code blocks made more sane with a few gotos.

function                                             old     new   delta
unzip_main                                          2491    2519     +28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: optional support for xz
Denys Vlasenko [Mon, 9 Jan 2017 10:12:01 +0000 (11:12 +0100)]
unzip: optional support for xz

function                                             old     new   delta
unzip_main                                          2476    2491     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: optional support for bzip2 and lzma
Denys Vlasenko [Mon, 9 Jan 2017 09:58:37 +0000 (10:58 +0100)]
unzip: optional support for bzip2 and lzma

function                                             old     new   delta
unzip_main                                          2376    2476    +100
bbunpack                                             750     745      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodprobe-small: build fixes
Denys Vlasenko [Mon, 9 Jan 2017 08:48:58 +0000 (09:48 +0100)]
modprobe-small: build fixes

Was throwing some build errors:

CONFIG_MODPROBE_SMALL=y
CONFIG_DEPMOD=y
CONFIG_LSMOD=y
CONFIG_MODINFO=y
CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y

error: unused variable 'exitcode'

modutils/modprobe-small.c: In function 'modprobe_main':
modutils/modprobe-small.c:1060: error: control reaches end of non-void function

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodprobe-small: optimizations for single applet build
Explorer09 [Mon, 9 Jan 2017 07:04:43 +0000 (15:04 +0800)]
modprobe-small: optimizations for single applet build

(I'm requesting for a review first because I fear such an aggressive
change could lead to bugs. While I observe the sizes have reduced, I
haven't test the functionality of each applet after that. So please
test before merging.)

Aggressively cut off unneeded code when the relevant applets are not
built.

Correct dependencies of FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE and
FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED.

Don't bother with the '-r' option check if only rmmod is built (assume
true then), or when neither rmmod or mobprobe is built (assume false
then).

Size comparison before and after the change (single applet
configuration):

     text    data     bss     dec     hex filename
    34778     946     112   35836    8bfc old/busybox_DEPMOD
    34151     946     112   35209    8989 new/busybox_DEPMOD

    34903     946     112   35961    8c79 old/busybox_INSMOD
    28316     778     112   29206    7216 new/busybox_INSMOD

    35228     962     112   36302    8dce old/busybox_LSMOD
     5011     706      40    5757    167d new/busybox_LSMOD

    34830     946     112   35888    8c30 old/busybox_MODPROBE
    34795     946     112   35853    8c0d new/busybox_MODPROBE

    34718     946     112   35776    8bc0 old/busybox_RMMOD
     7502     714     104    8320    2080 new/busybox_RMMOD

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoAllow 'gzip -d' and 'bzip2 -d' without gunzip or bunzip2
Kang-Che Sung [Sun, 8 Jan 2017 06:28:34 +0000 (14:28 +0800)]
Allow 'gzip -d' and 'bzip2 -d' without gunzip or bunzip2

Idea copied from the "ip" applet.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: fix a bug in argv restoration after sourcing a file
Denys Vlasenko [Mon, 9 Jan 2017 07:22:06 +0000 (08:22 +0100)]
ash: fix a bug in argv restoration after sourcing a file

if sourced file "shift"ed argvs so that $1 is NULL, restore wasn't done.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: fix a bug in argv restoration after sourcing a file
Denys Vlasenko [Mon, 9 Jan 2017 07:13:21 +0000 (08:13 +0100)]
hush: fix a bug in argv restoration after sourcing a file

if sourced file "shift"ed argvs so that $1 is NULL, restore wasn't done.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: global_args_malloced is used only if set builtin is enabled
Denys Vlasenko [Mon, 9 Jan 2017 06:57:38 +0000 (07:57 +0100)]
hush: global_args_malloced is used only if set builtin is enabled

function                                             old     new   delta
run_pipe                                            1623    1635     +12
builtin_source                                       210     222     +12
save_and_replace_G_args                               70      60     -10
builtin_shift                                        132      94     -38
restore_G_args                                        98       -     -98
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/2 up/down: 24/-146)          Total: -122 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: fix 'defined but not used' warning
Denys Vlasenko [Mon, 9 Jan 2017 05:19:55 +0000 (06:19 +0100)]
hush: fix 'defined but not used' warning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: remove redundand test for ENABLE_HUSH_JOB
Denys Vlasenko [Mon, 9 Jan 2017 04:57:13 +0000 (05:57 +0100)]
hush: remove redundand test for ENABLE_HUSH_JOB

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: fix kill builtin without jobs support
Denys Vlasenko [Mon, 9 Jan 2017 04:47:57 +0000 (05:47 +0100)]
hush: fix kill builtin without jobs support

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotypo fix
Denys Vlasenko [Mon, 9 Jan 2017 04:11:09 +0000 (05:11 +0100)]
typo fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: conditionalize print_escaped() on EXPORT || TRAP
Denys Vlasenko [Sun, 8 Jan 2017 17:56:24 +0000 (18:56 +0100)]
hush: conditionalize print_escaped() on EXPORT || TRAP

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: make memleak builtin optional
Denys Vlasenko [Sun, 8 Jan 2017 17:44:41 +0000 (18:44 +0100)]
hush: make memleak builtin optional

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: make export builtin optional
Denys Vlasenko [Sun, 8 Jan 2017 17:40:41 +0000 (18:40 +0100)]
hush: make export builtin optional

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: make umask builtin optional
Denys Vlasenko [Sun, 8 Jan 2017 17:31:39 +0000 (18:31 +0100)]
hush: make umask builtin optional

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: make set/unset builtins optional
Denys Vlasenko [Sun, 8 Jan 2017 17:28:43 +0000 (18:28 +0100)]
hush: make set/unset builtins optional

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: make read and trap builtins optional
Denys Vlasenko [Sun, 8 Jan 2017 16:40:18 +0000 (17:40 +0100)]
hush: make read and trap builtins optional

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: kill builtin and kill %jobspec support
Denys Vlasenko [Sun, 8 Jan 2017 16:19:38 +0000 (17:19 +0100)]
hush: kill builtin and kill %jobspec support

Also made it and printf, type and wait builtins optional.

function                                             old     new   delta
builtin_kill                                           -     323    +323
bltins1                                              336     348     +12
builtin_type                                         114     116      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 337/0)             Total: 337 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: support %%, %+ and % jobspec (meaning "current job")
Denys Vlasenko [Sun, 8 Jan 2017 14:46:04 +0000 (15:46 +0100)]
hush: support %%, %+ and % jobspec (meaning "current job")

function                                             old     new   delta
parse_jobspec                                         83     133     +50
builtin_wait                                         278     283      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohttpd: fix address family for reverse proxy client socket
Laurent Bercot [Fri, 6 Jan 2017 21:03:08 +0000 (22:03 +0100)]
httpd: fix address family for reverse proxy client socket

When httpd proxies a request to another server, it first creates
an AF_INET socket, then resolves the server name to a sockaddr,
then connects to it. This fails if the server name resolves to
an IPv6 address.

This patch ensures that the socket is created with the correct
address family (AF_INET6 if the server resolves to an IPv6 address
and AF_INET otherwise).

Signed-off-by: Laurent Bercot <ska-dietlibc@skarnet.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agobuild system: no longer prompt for PLATFORM_LINUX option
Kang-Che Sung [Sat, 7 Jan 2017 07:16:46 +0000 (15:16 +0800)]
build system: no longer prompt for PLATFORM_LINUX option

With the new "select PLATFORM_LINUX" mechanism
(commit e3b1a1fd28558f7a1b3c0ec33313bedb675be8a1), the PLATFORM_LINUX
option alone no longer has any purpose of changing program behavior or
affecting compiled code. So there is no longer need to prompt user of
this config question.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agobunzip2: fix code bloat caused by zcat's seamless magic
Kang-Che Sung [Sun, 8 Jan 2017 13:31:06 +0000 (14:31 +0100)]
bunzip2: fix code bloat caused by zcat's seamless magic

This example single-applet configuration would trigger the bloat:

    CONFIG_FEATURE_SEAMLESS_XZ=y
    CONFIG_FEATURE_SEAMLESS_LZMA=y
    CONFIG_FEATURE_SEAMLESS_BZ2=y
    CONFIG_FEATURE_SEAMLESS_GZ=y
    CONFIG_BUNZIP2=y
    # CONFIG_ZCAT is not set
    # All other applets disabled

Here, the resulting "busybox-bunzip2" binary would contain
unpack_gz_stream, unpack_lzma_stream and unpack_xz_stream functions
code. In other words, the gzip, lzma and xz decompressors' code are
linked into the binary unnecessarily.

This happens because SEAMLESS_MAGIC != 0 and compiler is unable
to figure out that SEAMLESS_MAGIC bit is never set.

Fix this by disabling SEAMLESS_MAGIC option flag (setting its value
to 0) when zcat is disabled. This will help the compiler optimize out
bbunpack() and no longer generate open_zipped() function call.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: fix "kill %1" not working if CONFIG_ASH is disabled
Kang-Che Sung [Sun, 8 Jan 2017 13:27:34 +0000 (14:27 +0100)]
ash: fix "kill %1" not working if CONFIG_ASH is disabled

ix ash "kill %1" not working if CONFIG_ASH is disabled but
ash is launched by 'sh' or 'bash' name

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: do not use CDF.extra_len, read local file header. Closes 9536
Denys Vlasenko [Sun, 8 Jan 2017 13:14:19 +0000 (14:14 +0100)]
unzip: do not use CDF.extra_len, read local file header. Closes 9536

While at it, shorten many field and variable names.

function                                             old     new   delta
unzip_main                                          2334    2376     +42

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: fix open fds leaking in redirects. Closes 9561
Denys Vlasenko [Sat, 7 Jan 2017 09:15:01 +0000 (10:15 +0100)]
ash: fix open fds leaking in redirects. Closes 9561

commit e19923f6652a638ac39c84012e97f52cf5a7568e deleted clearredir()
call in shellexec():

ash: [REDIR] Remove redundant CLOEXEC calls
Upstream commit:

Now that we're marking file descriptors as CLOEXEC in savefd, we no longer
need to close them on exec or in setinputfd.

but it missed one place where we don't set CLOEXEC. Fixing this.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoAutomatically disable FEATURE_COMPRESS_USAGE for small builds.
Denys Vlasenko [Fri, 6 Jan 2017 18:16:36 +0000 (19:16 +0100)]
Automatically disable FEATURE_COMPRESS_USAGE for small builds.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: explicltly group ash options
Kang-Che Sung [Fri, 6 Jan 2017 16:02:03 +0000 (17:02 +0100)]
ash: explicltly group ash options

This would makes all ash options indented inside "ash" in menuconfig.
It appears that menuconfig has a limit at tracking multiple dependency
lines like this (it looks like a "diamond problem" but I'm not sure if
it is):

               ---ASH <----------
              /                  \       ASH_OPTIMIZE_FOR_SIZE
    !NOMMU <-*----SH_IS_ASH <----[OR] <--ASH_INTERNAL_GLOB
              \                  /       ASH_RANDOM_SUPPORT
               ---BASH_IS_ASH <--        [...]

The kconfig-language document [1] states that:

> If a menu entry somehow depends on the previous entry, it can be
> made a submenu of it. First, the previous (parent) symbol must be
> part of the dependency list and then one of these two conditions
> must be true:
> - the child entry must become invisible, if the parent is set to 'n'

    [BusyBox ash used to satisfy this, but no longer does]

> - the child entry must only be visible, if the parent is visible

    [BusyBox ash configs actually satisfy this, but because of
     "diamond" above this might not be easily detected]

So I found out a direct workaround: by making ash options explicitly
depend on !NOMMU, we can tell menuconfig that rule 2 above is satisfied
without any more tracking.

               ---------------------
              /                     \
    !NOMMU <-*-----ASH <--------     \
              \                 \     \        ASH_OPTIMIZE_FOR_SIZE
               *---SH_IS_ASH <---[OR]-[AND] <--ASH_INTERNAL_GLOB
                \                /             ASH_RANDOM_SUPPORT
                 --BASH_IS_ASH <-              [...]

So all ash options would now be indented under "ash".

[1] "Documentation/kbuild/kconfig-language.txt" in Linux kernel source

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agontpd: improve postponed hostname resolution
Natanael Copa [Fri, 6 Jan 2017 15:18:45 +0000 (16:18 +0100)]
ntpd: improve postponed hostname resolution

Run the namelookup from the main loop so a misspelled first ntp server
name does not block everything forever.

This fixes the following situation which would block forever:
  $ sudo ./busybox ntpd -dn -p foobar  -p pool.ntp.org
  ntpd: bad address 'foobar'
  ntpd: bad address 'foobar'
  ntpd: bad address 'foobar'
  ...

New behavior:
  ntpd: bad address 'foobar'
  ntpd: sending query to 137.190.2.4
  ntpd: reply from 137.190.2.4: offset:-1.009775 delay:0.175550 status:0x24 strat:1 refid:0x00535047 rootdelay:0.000000 reach:0x01
  ntpd: sending query to 137.190.2.4
  ntpd: reply from 137.190.2.4: offset:-1.009605 delay:0.175461 status:0x24 strat:1 refid:0x00535047 rootdelay:0.000000 reach:0x03
  ntpd: sending query to 137.190.2.4
  ntpd: reply from 137.190.2.4: offset:-1.005327 delay:0.167027 status:0x24 strat:1 refid:0x00535047 rootdelay:0.000000 reach:0x07
  ntpd: sending query to 137.190.2.4
  ntpd: bad address 'foobar'
  ntpd: reply from 137.190.2.4: offset:-1.046349 delay:0.248705 status:0x24 strat:1 refid:0x00535047 rootdelay:0.000000 reach:0x0f

This patch is based on Kaarle Ritvanens work.
http://lists.busybox.net/pipermail/busybox/2016-May/084197.html

function                                             old     new   delta
ntpd_main                                           1061    1079     +18
ntp_init                                             556     560      +4
resolve_peer_hostname                                 81      75      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 22/-6)              Total: 16 bytes

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: remove now-pointless lseek which returns current position
Cristian Ionescu-Idbohrn [Thu, 5 Jan 2017 18:07:54 +0000 (19:07 +0100)]
unzip: remove now-pointless lseek which returns current position

archival/unzip.c: In function 'read_next_cdf':
archival/unzip.c:271:8: warning: variable 'org' set but
                                 not used [-Wunused-but-set-variable]
  off_t org;
        ^~~

Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotypo fix in config help text
Denys Vlasenko [Thu, 5 Jan 2017 10:47:28 +0000 (11:47 +0100)]
typo fix in config help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: properly use CDF to find compressed files. Closes 9536
Denys Vlasenko [Thu, 5 Jan 2017 10:43:53 +0000 (11:43 +0100)]
unzip: properly use CDF to find compressed files. Closes 9536

function                                             old     new   delta
unzip_main                                          2437    2350     -87

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodutils: remove special handling of uClibc
Waldemar Brodkorb [Mon, 26 Dec 2016 19:07:59 +0000 (20:07 +0100)]
modutils: remove special handling of uClibc

Commit 3a45b87ac36f (modutils: support finit_module syscall) introduced
macro finit_module. But it is not defined for uClibc.

The compilation for busybox fails for MIPS with:
With uClibc, we get following build errors:

  modutils/lib.a(modutils.o): In function `bb_init_module':
  modutils.c:(.text.bb_init_module+0x94): undefined reference to `finit_module'
  modutils.c:(.text.bb_init_module+0xa0): undefined reference to `finit_module'

We can just use syscall() without any need for the
uClibc wrappers.

Newer versions of uClibc-ng (>1.0.20) will remove the
module syscall wrappers.

Found via Buildroot autobuilders:
http://autobuild.buildroot.net/results/556/55655daef23788fb3967f801ec8b79e9bed7122b/build-end.log

function                                             old     new   delta
bb_delete_module                                      26      32      +6
bb_init_module                                        90      95      +5
delete_module                                         37       -     -37
init_module                                           53       -     -53
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 2/0 up/down: 11/-90)            Total: -79 bytes

Reported-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoshell: clarify help text of CONFIG_{SH,BASH}_IS_* options
Kang-Che Sung [Wed, 4 Jan 2017 11:29:04 +0000 (12:29 +0100)]
shell: clarify help text of CONFIG_{SH,BASH}_IS_* options

Mention the behavior if user selects CONFIG_SH_IS_ASH but not
CONFIG_ASH. We will be explicit that invocations like "busybox ash"
will not work for such configuration.

Also clarify help text of CONFIG_BASH_IS_* that bash compatibility in
ash is not complete. (It shouldn't be anyway - ash can't support every
bash quirk out there.)

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcp: tweak config order and menu item names
Denys Vlasenko [Wed, 4 Jan 2017 11:13:38 +0000 (12:13 +0100)]
udhcp: tweak config order and menu item names

All other applets are listed simply by their name, no reason why
dumpleases doesn't do that.

Group all udhcpd feature options directly after it.

Put "NOT READY" into udhcpc6 item (some users actually tried to use it,
and complained).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoFix dependency for IFUPDOWN_UDHCPC_CMD_OPTIONS
Jörg Krause [Tue, 3 Jan 2017 11:29:52 +0000 (12:29 +0100)]
Fix dependency for IFUPDOWN_UDHCPC_CMD_OPTIONS

Commit a8c696bf09d8151323f6e99348c4bc8989f829c8 makes ifup and ifdown
individually selectable, but forgets to update the dependency to
IFUPDOWN_UDHCPC_CMD_OPTIONS, so it is not selectable anymore.

This patch fixes the dependency by checking for IFUP or IFDOWN, instead
of the obsolete IFUPDOWN.

Also, it drops dependency on UDHCPC: udhcpc on the target system
does not have to come from the _same_ binary.

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoREADME_distro_proposal.txt: typo fixes
Tito Ragusa [Tue, 3 Jan 2017 11:25:18 +0000 (12:25 +0100)]
README_distro_proposal.txt: typo fixes

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoappletlib: avoid warning on unused function ingroup
Cristian Ionescu-Idbohrn [Mon, 2 Jan 2017 10:17:09 +0000 (11:17 +0100)]
appletlib: avoid warning on unused function ingroup

libbb/appletlib.c:558:12: warning: 'ingroup' defined but
                                   not used [-Wunused-function]
 static int ingroup(uid_t u, gid_t g)
            ^~~~~~~

That function is used only if FEATURE_SUID_CONFIG is also enabled.

Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: correct exitcode for unterminated ')' - exitcode2.tests testcase
Denys Vlasenko [Tue, 3 Jan 2017 10:47:50 +0000 (11:47 +0100)]
hush: correct exitcode for unterminated ')' - exitcode2.tests testcase

function                                             old     new   delta
parse_stream                                        2595    2609     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: fix error code regression
Ron Yorston [Tue, 3 Jan 2017 10:18:23 +0000 (11:18 +0100)]
ash: fix error code regression

The commit 'ash,hush: set exit code 127 in "sh /does/not/exist" case'
only partly implemented the dash commit '[ERROR] Allow the originator
of EXERROR to set the exit status'.  This resulted in incorrect error
codes for a syntax error:

   $ )
   $ echo $?
   0

or a redirection error for a special builtin:

   $ rm -f xxx
   $ eval cat <xxx
   $ echo $?
   0

Signed-off-by: Ron Yorston <rmy@pobox.com>
Reported-by: Martijn Dekker <martijn@inlv.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoqemu_multiarch_testing: small improvements
Denys Vlasenko [Mon, 2 Jan 2017 12:48:06 +0000 (13:48 +0100)]
qemu_multiarch_testing: small improvements

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotcpudp: define SO_ORIGINAL_DST directly, not via include
Denys Vlasenko [Mon, 2 Jan 2017 09:46:08 +0000 (10:46 +0100)]
tcpudp: define SO_ORIGINAL_DST directly, not via include

musl does not like including linux/netfilter_ipv4.h
(enum / #define collision in two headers, resulting in "3 = 3"
type situation in enum definition).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agodepmod: don't build it if MODPROBE_SMALL=y
Denys Vlasenko [Sun, 1 Jan 2017 12:12:48 +0000 (13:12 +0100)]
depmod: don't build it if MODPROBE_SMALL=y

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoUpdate to examples/var_service/README_distro_proposal.txt
Denys Vlasenko [Sun, 25 Dec 2016 19:41:00 +0000 (20:41 +0100)]
Update to examples/var_service/README_distro_proposal.txt

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomake_single_applets.sh: SH_IS_HUSH needs special handling too
Denys Vlasenko [Fri, 23 Dec 2016 18:42:53 +0000 (19:42 +0100)]
make_single_applets.sh: SH_IS_HUSH needs special handling too

Well, in fact it works (make oldconfig throws only a warning when it sees
both SH_IS_HUSH=y and SH_IS_NONE=y), but let's be nice.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoMake it possible to select "sh" and "bash" aliases without selecting ash or hush
Denys Vlasenko [Fri, 23 Dec 2016 15:49:07 +0000 (16:49 +0100)]
Make it possible to select "sh" and "bash" aliases without selecting ash or hush

The same can be done for msh, but we are probably better off just deleting it
in a next versio or two.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoMake RMMOD=y by default
Denys Vlasenko [Fri, 23 Dec 2016 14:57:26 +0000 (15:57 +0100)]
Make RMMOD=y by default

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoMake INSMOD=y by default
Denys Vlasenko [Fri, 23 Dec 2016 14:22:44 +0000 (15:22 +0100)]
Make INSMOD=y by default

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoRemove FEATURE_IFUPDOWN_IP_BUILTIN and FEATURE_IFUPDOWN_IFCONFIG_BUILTIN
Denys Vlasenko [Fri, 23 Dec 2016 14:18:31 +0000 (15:18 +0100)]
Remove FEATURE_IFUPDOWN_IP_BUILTIN and FEATURE_IFUPDOWN_IFCONFIG_BUILTIN

They merely enable ip or ifconfig/route. There is already a way to do this
on the same menuconfig page.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodprobe-small: make applets individually selectable
Denys Vlasenko [Fri, 23 Dec 2016 14:12:27 +0000 (15:12 +0100)]
modprobe-small: make applets individually selectable

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoMake DPKG=y and DPKG_DEB=y by default
Denys Vlasenko [Fri, 23 Dec 2016 12:52:53 +0000 (13:52 +0100)]
Make DPKG=y and DPKG_DEB=y by default

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoSelinux complains about deprecated selinux/flask.h, stop including it
Denys Vlasenko [Fri, 23 Dec 2016 12:52:13 +0000 (13:52 +0100)]
Selinux complains about deprecated selinux/flask.h, stop including it

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoMake FEATURE_USERNAME_COMPLETION=y by default
Denys Vlasenko [Fri, 23 Dec 2016 12:40:24 +0000 (13:40 +0100)]
Make FEATURE_USERNAME_COMPLETION=y by default

This matches bash behavior on Fedora

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomake_single_applets.sh: a tool to check single-applet builds
Denys Vlasenko [Fri, 23 Dec 2016 12:39:22 +0000 (13:39 +0100)]
make_single_applets.sh: a tool to check single-applet builds

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agofix breakage found by mass one-applet builds
Denys Vlasenko [Fri, 23 Dec 2016 01:42:26 +0000 (02:42 +0100)]
fix breakage found by mass one-applet builds

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoip: make ip aliases individually selectable
Denys Vlasenko [Thu, 22 Dec 2016 21:30:13 +0000 (22:30 +0100)]
ip: make ip aliases individually selectable

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoMake POST upload example script easier to use
Denys Vlasenko [Thu, 22 Dec 2016 14:33:11 +0000 (15:33 +0100)]
Make POST upload example script easier to use

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoshell: move "config" blocks above their use in coditional includes
Denys Vlasenko [Thu, 22 Dec 2016 14:21:58 +0000 (15:21 +0100)]
shell: move "config" blocks above their use in coditional includes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoUpdate information on building httpd and wget helpers
Denys Vlasenko [Thu, 22 Dec 2016 14:13:37 +0000 (15:13 +0100)]
Update information on building httpd and wget helpers

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoTweak some config defaults; fix MODPROBE_SMALL ordering in "make config"
Denys Vlasenko [Thu, 22 Dec 2016 13:36:49 +0000 (14:36 +0100)]
Tweak some config defaults; fix MODPROBE_SMALL ordering in "make config"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: clarify uclibc glob() bug in comment
Denys Vlasenko [Wed, 21 Dec 2016 20:04:16 +0000 (21:04 +0100)]
ash: clarify uclibc glob() bug in comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: error out if ASH_INTERNAL_GLOB is not selected on uClibc
Denys Vlasenko [Wed, 21 Dec 2016 03:13:23 +0000 (04:13 +0100)]
ash: error out if ASH_INTERNAL_GLOB is not selected on uClibc

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoStart 1.27.0 development cycle
Denys Vlasenko [Wed, 21 Dec 2016 02:33:42 +0000 (03:33 +0100)]
Start 1.27.0 development cycle

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoBump version to 1.26.0 1_26_0
Denys Vlasenko [Tue, 20 Dec 2016 02:00:43 +0000 (03:00 +0100)]
Bump version to 1.26.0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibiproute: handle table ids larger than 255
Lukasz Nowak [Tue, 13 Dec 2016 12:58:31 +0000 (12:58 +0000)]
libiproute: handle table ids larger than 255

Linux kernel, starting from 2.6.19 allows ip table ids to have 32-bit values.
In order to preserve compatibility, the old 8-bit field: rtm_table is still
in use when table id is lower than 256.

Add support for the 32-bit table id (RTA_TABLE attribute) in:
- ip route print
- ip route modify
- ip rule print
- ip rule modify

Add printing of table ids to ip route.

Changes are compatible with the mainline iproute2 utilities.

These changes are required for compatibility with ConnMan, which by default
uses table ids greater than 255.

function                                             old     new   delta
print_route                                         1588    1637     +49
do_iproute                                          2187    2222     +35
do_iprule                                            955     987     +32
print_rule                                           617     630     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 129/0)             Total: 129 bytes

Signed-off-by: Lukasz Nowak <lnowak@tycoint.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agodf: implement -B n<suff> and -B <suff> formats of -B option
Denys Vlasenko [Mon, 12 Dec 2016 18:56:31 +0000 (19:56 +0100)]
df: implement -B n<suff> and -B <suff> formats of -B option

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agorandomconfig fixes
Denys Vlasenko [Mon, 12 Dec 2016 18:17:12 +0000 (19:17 +0100)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: fix signed char expansion bug
Denys Vlasenko [Mon, 12 Dec 2016 16:39:12 +0000 (17:39 +0100)]
ash: fix signed char expansion bug

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoshell: suppress "unused var/func" warnings on some configs
Denys Vlasenko [Mon, 12 Dec 2016 15:30:20 +0000 (16:30 +0100)]
shell: suppress "unused var/func" warnings on some configs

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agosuppress glibc "use sysmacros.h for major" warning
Denys Vlasenko [Mon, 12 Dec 2016 15:29:32 +0000 (16:29 +0100)]
suppress glibc "use sysmacros.h for major" warning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agorandomconfig fixes
Denys Vlasenko [Mon, 12 Dec 2016 13:33:53 +0000 (14:33 +0100)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agorandomconfig fixes
Denys Vlasenko [Mon, 12 Dec 2016 10:08:51 +0000 (11:08 +0100)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agorandomconfig fixes
Denys Vlasenko [Mon, 12 Dec 2016 08:26:16 +0000 (09:26 +0100)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agorandomconfig fixes
Denys Vlasenko [Sat, 10 Dec 2016 19:57:00 +0000 (20:57 +0100)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoselinux: drop deprecated headers
Mike Frysinger [Fri, 9 Dec 2016 23:30:30 +0000 (18:30 -0500)]
selinux: drop deprecated headers

The selinux guys want you to get class values at runtime by converting
textual names into constants.  Drop the deprecated headers and switch
to the new format.

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

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
7 years agosetfiles: fix build failure after common_bufsiz change
Mike Frysinger [Fri, 9 Dec 2016 23:14:12 +0000 (18:14 -0500)]
setfiles: fix build failure after common_bufsiz change

Commit 47cfbf32fd66563f8c4e09ad6cced6abfbe2fad5 ("*: add most of the
required setup_common_bufsiz() calls") switched this tool over to use
the common_bufsiz logic but missed including the header leading to a
build failure when enabled:
selinux/setfiles.c:80:30: error: 'bb_common_bufsiz1' undeclared (first use in this function)

URL: https://bugs.gentoo.org/600106
Reported-by: Jonas Jelten <jj@stusta.net>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
7 years agomdev.conf: rename hw_random to hwrng
Mike Frysinger [Fri, 9 Dec 2016 21:12:15 +0000 (16:12 -0500)]
mdev.conf: rename hw_random to hwrng

The kernel broke the name years ago, but didn't notice until it was much
too late.  Rename the node to match expectations of userland software,
and what the kernel itself documents in its Kconfig help:
This provides a device that's usually called /dev/hwrng, ...

URL: https://marc.info/?l=linux-crypto-vger&m=144249767024990&w=2
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
7 years agorandomconfig fixes
Denys Vlasenko [Thu, 8 Dec 2016 11:24:48 +0000 (12:24 +0100)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agosvc: new applet (daemontools-compatible version of "sv")
Denys Vlasenko [Mon, 5 Dec 2016 12:56:40 +0000 (13:56 +0100)]
svc: new applet (daemontools-compatible version of "sv")

function                                             old     new   delta
sv                                                     -    1199   +1199
svc_main                                               -     145    +145
packed_usage                                       30255   30364    +109
applet_names                                        2437    2441      +4
applet_main                                         1420    1424      +4
find_applet_by_name                                  125     126      +1
sv_main                                             1201       9   -1192
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 4/1 up/down: 1462/-1192)        Total: 270 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agofix musl problem with dirname, now for all users of bb_make_directory()
Denys Vlasenko [Sun, 4 Dec 2016 09:42:07 +0000 (10:42 +0100)]
fix musl problem with dirname, now for all users of bb_make_directory()

function                                             old     new   delta
bb_make_directory                                    412     419      +7
install_main                                         793     769     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-24)             Total: -17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoREADME_distro_proposal.txt: writeup about runit adoption
Denys Vlasenko [Sat, 3 Dec 2016 13:06:55 +0000 (14:06 +0100)]
README_distro_proposal.txt: writeup about runit adoption

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotop: fix help text: with !TERMIOS, no keys are affected top output
Denys Vlasenko [Sat, 3 Dec 2016 11:09:50 +0000 (12:09 +0100)]
top: fix help text: with !TERMIOS, no keys are affected top output

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoinstall: fix musl problem with dirname
Denys Vlasenko [Sat, 3 Dec 2016 10:49:23 +0000 (11:49 +0100)]
install: fix musl problem with dirname

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