oweals/busybox.git
6 years agohush: tidy up code after previous commits
Denys Vlasenko [Fri, 20 Jul 2018 17:11:09 +0000 (19:11 +0200)]
hush: tidy up code after previous commits

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: better names for o_free_unsafe() / o_free(), no logic changes
Denys Vlasenko [Fri, 20 Jul 2018 15:51:31 +0000 (17:51 +0200)]
hush: better names for o_free_unsafe() / o_free(), no logic changes

o_free() made o_string NULL-initialized,
o_free_unsafe() did not bother reinitializing (expected caller to not need it).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix handling of '' in ${var:+ARG}
Denys Vlasenko [Fri, 20 Jul 2018 15:36:06 +0000 (17:36 +0200)]
hush: fix handling of '' in ${var:+ARG}

This wasn't an ash bug in dollar_altvalue9, it was hush bug (and bash!)

function                                             old     new   delta
expand_one_var                                      2236    2254     +18
expand_vars_to_list                                 1097    1103      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 24/0)               Total: 24 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix word splitting in ${v:+ARG} - dollar_altvalue1 test
Denys Vlasenko [Fri, 20 Jul 2018 14:18:59 +0000 (16:18 +0200)]
hush: fix word splitting in ${v:+ARG} - dollar_altvalue1 test

ash might be a bit buggy, need to investigate dollar_altvalue9 test

function                                             old     new   delta
expand_one_var                                      1639    2236    +597
expand_variables                                     112     128     +16
expand_vars_to_list                                 1117    1097     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 613/-20)           Total: 593 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: expand_vars_to_list() should not assume it starts new word
Denys Vlasenko [Fri, 20 Jul 2018 12:45:12 +0000 (14:45 +0200)]
hush: expand_vars_to_list() should not assume it starts new word

function                                             old     new   delta
expand_variables                                     112     115      +3
expand_vars_to_list                                 1117    1108      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 3/-9)               Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: remove pointless "next" var, simplify expand_vars_to_list()
Denys Vlasenko [Fri, 20 Jul 2018 12:24:56 +0000 (14:24 +0200)]
hush: remove pointless "next" var, simplify expand_vars_to_list()

function                                             old     new   delta
o_addstr                                               -      26     +26
expand_vars_to_list                                 1112    1117      +5
encode_then_expand_vararg                            398     382     -16
parse_dollar                                         779     762     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 31/-33)             Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: store "ended_in_ifs" flag in o_string
Denys Vlasenko [Thu, 19 Jul 2018 11:45:54 +0000 (13:45 +0200)]
hush: store "ended_in_ifs" flag in o_string

This simplifies function parameter passing.

function                                             old     new   delta
expand_one_var                                      1643    1639      -4
append_str_maybe_ifs_split                            64      52     -12
expand_vars_to_list                                 1125    1112     -13
expand_on_ifs                                        361     345     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-45)             Total: -45 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: propagate (output,n) parameters into expand_one_var()
Denys Vlasenko [Thu, 19 Jul 2018 10:14:47 +0000 (12:14 +0200)]
hush: propagate (output,n) parameters into expand_one_var()

This is necessary since expand_one_var() for ${var:+ARG} must create more than one
output word, and thus can't simply return a char*.

function                                             old     new   delta
expand_one_var                                      1610    1643     +33
expand_vars_to_list                                 1139    1125     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 33/-14)             Total: 19 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: make expand_vars_to_list() a bit more sane
Denys Vlasenko [Thu, 19 Jul 2018 09:16:53 +0000 (11:16 +0200)]
hush: make expand_vars_to_list() a bit more sane

function                                             old     new   delta
append_str_maybe_ifs_split                             -      64     +64
expand_vars_to_list                                 1167    1139     -28
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 64/-28)             Total: 36 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: reduce indentation, no code changes
Denys Vlasenko [Wed, 18 Jul 2018 14:12:23 +0000 (16:12 +0200)]
hush: reduce indentation, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix 'x=; echo ${x:-"$@"}' producing 'BUG in varexp2' message
Denys Vlasenko [Wed, 18 Jul 2018 14:02:25 +0000 (16:02 +0200)]
hush: fix 'x=; echo ${x:-"$@"}' producing 'BUG in varexp2' message

function                                             old     new   delta
expand_string_to_string                              126     128      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: smaller code to set o_string to ""
Denys Vlasenko [Wed, 18 Jul 2018 13:48:53 +0000 (15:48 +0200)]
hush: smaller code to set o_string to ""

function                                             old     new   delta
encode_then_expand_vararg                            399     398      -1
parse_stream                                        2753    2748      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowhitespace fixes
Denys Vlasenko [Tue, 17 Jul 2018 13:04:17 +0000 (15:04 +0200)]
whitespace fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: faster/smaller code to check for presense of multiple chars in string
Denys Vlasenko [Tue, 17 Jul 2018 12:33:19 +0000 (14:33 +0200)]
hush: faster/smaller code to check for presense of multiple chars in string

Go over the string only once.

function                                             old     new   delta
encode_then_expand_string                            126     105     -21
encode_then_expand_vararg                            443     399     -44
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-65)             Total: -65 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: improve ${var#...}, ${var:+...} and ${var/.../...} - handle quoting
Denys Vlasenko [Tue, 17 Jul 2018 12:21:38 +0000 (14:21 +0200)]
hush: improve ${var#...}, ${var:+...} and ${var/.../...} - handle quoting

dollar_altvalue1 test partially fails: word splitting of unquoted ${var:+...}
is not correct

function                                             old     new   delta
encode_then_expand_vararg                              -     443    +443
expand_one_var                                      1599    1610     +11
parse_stream                                        2756    2753      -3
encode_string                                        250     242      -8
setup_heredoc                                        308     298     -10
expand_and_evaluate_arith                            106      96     -10
encode_then_expand_string                            142     126     -16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/5 up/down: 454/-47)           Total: 407 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agocp: add missing quote in config snippet
Denys Vlasenko [Mon, 16 Jul 2018 22:16:16 +0000 (00:16 +0200)]
cp: add missing quote in config snippet

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: shrink code in builtin_eval
Denys Vlasenko [Sun, 15 Jul 2018 16:03:56 +0000 (18:03 +0200)]
hush: shrink code in builtin_eval

function                                             old     new   delta
builtin_eval                                         126     119      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agogrep: accept and ignore --color[=anything]
Denys Vlasenko [Fri, 13 Jul 2018 18:40:40 +0000 (20:40 +0200)]
grep: accept and ignore --color[=anything]

function                                             old     new   delta
grep_main                                            827     834      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agocp: optional --reflink support
Denys Vlasenko [Fri, 13 Jul 2018 18:30:02 +0000 (20:30 +0200)]
cp: optional --reflink support

function                                             old     new   delta
cp_main                                              428     512     +84
copy_file                                           1676    1742     +66

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agousage: do not print trailing space for commands which have no arguments
Denys Vlasenko [Mon, 9 Jul 2018 16:23:33 +0000 (18:23 +0200)]
usage: do not print trailing space for commands which have no arguments

function                                             old     new   delta
bb_show_usage                                        120     130     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agosort: add -V "sort version"
Denys Vlasenko [Sat, 7 Jul 2018 23:37:54 +0000 (01:37 +0200)]
sort: add -V "sort version"

function                                             old     new   delta
packed_usage                                       32855   32858      +3
get_key                                              500     503      +3
sort_opt_str                                          36      37      +1
sort_main                                           1037    1036      -1
compare_keys                                         795     783     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 7/-13)              Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofind: implement -executable
Denys Vlasenko [Fri, 6 Jul 2018 19:04:41 +0000 (21:04 +0200)]
find: implement -executable

function                                             old     new   delta
func_executable                                        -      19     +19
parse_params                                        1505    1519     +14
static.params                                        216     228     +12
packed_usage                                       32847   32855      +8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 53/0)               Total: 53 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agocpio: if longopts are enabled, accept --null (synonym for -0)
Denys Vlasenko [Fri, 6 Jul 2018 18:50:30 +0000 (20:50 +0200)]
cpio: if longopts are enabled, accept --null (synonym for -0)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotweak help texts
Denys Vlasenko [Fri, 6 Jul 2018 18:49:08 +0000 (20:49 +0200)]
tweak help texts

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofind: implement -quit
Denys Vlasenko [Fri, 6 Jul 2018 18:35:35 +0000 (20:35 +0200)]
find: implement -quit

function                                             old     new   delta
packed_usage                                       32816   32846     +30
find_main                                            446     464     +18
func_quit                                              -      13     +13
parse_params                                        1495    1505     +10
static.params                                        210     216      +6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 77/0)               Total: 77 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonproc: implement --all --ignore=N
haroon maqsood [Fri, 6 Jul 2018 14:17:57 +0000 (16:17 +0200)]
nproc: implement --all --ignore=N

function                                             old     new   delta
nproc_main                                            98     242    +144
packed_usage                                       32799   32816     +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 161/0)             Total: 161 bytes

Signed-off-by: haroon maqsood <maqsood3525@live.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agosendmail: fix parsing of addresses in angle brackets
Raffaello D. Di Napoli [Tue, 26 Jun 2018 23:18:02 +0000 (19:18 -0400)]
sendmail: fix parsing of addresses in angle brackets

Pointer e needs to be wound back in order to overwrite '>' with '\0'.
Regression introduced in 20077c1429

Signed-off-by: Raffaello D. Di Napoli <rafdev@dinapo.li>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcp: add decimal option values in comments, no code changes
Denys Vlasenko [Wed, 4 Jul 2018 14:05:48 +0000 (16:05 +0200)]
udhcp: add decimal option values in comments, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcp: tweak comment indentation, no code changes
Denys Vlasenko [Wed, 4 Jul 2018 13:44:22 +0000 (15:44 +0200)]
udhcp: tweak comment indentation, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcp: add option 211, "reboot time"
Jeremy Kerr [Tue, 3 Jul 2018 06:36:13 +0000 (16:36 +1000)]
udhcp: add option 211, "reboot time"

As defined in RFC 5071.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoexamples/var_service/: use standard logger script, viewer and pager scripts
Denys Vlasenko [Tue, 3 Jul 2018 21:23:09 +0000 (23:23 +0200)]
examples/var_service/: use standard logger script, viewer and pager scripts

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoexamples/var_service/: use "svc" for service commands, other tweaks
Denys Vlasenko [Tue, 3 Jul 2018 15:02:50 +0000 (17:02 +0200)]
examples/var_service/: use "svc" for service commands, other tweaks

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohexdump: fix short file of zero butes treated as dup
Denys Vlasenko [Tue, 3 Jul 2018 14:27:54 +0000 (16:27 +0200)]
hexdump: fix short file of zero butes treated as dup

function                                             old     new   delta
bb_dump_dump                                        1466    1491     +25

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowget: fix fetching of https URLs without http proxy
Denys Vlasenko [Mon, 2 Jul 2018 16:31:02 +0000 (18:31 +0200)]
wget: fix fetching of https URLs without http proxy

The "fix fetching of https URLs with http proxy" commit
broke the usual http-to-https redirect:

$ wget http://busybox.net/downloads/busybox-1.29.0.tar.bz2
Connecting to busybox.net (140.211.167.122:80)
Connecting to busybox.net (140.211.167.122:443)
wget: server returned error: HTTP/1.1 400 Bad Request

Fixing...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agontpd: increase minimum G.FREQHOLD_cnt from 8 to 10
Denys Vlasenko [Mon, 2 Jul 2018 14:17:07 +0000 (16:17 +0200)]
ntpd: increase minimum G.FREQHOLD_cnt from 8 to 10

With ~0.9 initiall offsets, using 8 results in a bit too eager
frequency correction.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoStart 1.30.0 development cycle
Denys Vlasenko [Sun, 1 Jul 2018 15:18:47 +0000 (17:18 +0200)]
Start 1.30.0 development cycle

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoBump version to 1.29.0 1_29_0
Denys Vlasenko [Sun, 1 Jul 2018 14:38:52 +0000 (16:38 +0200)]
Bump version to 1.29.0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite/mount.tests: fix false positive
Denys Vlasenko [Thu, 28 Jun 2018 12:10:00 +0000 (14:10 +0200)]
testsuite/mount.tests: fix false positive

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agovi: placate "warning: variable orig_buf set but not used"
Denys Vlasenko [Wed, 27 Jun 2018 13:11:36 +0000 (15:11 +0200)]
vi: placate "warning: variable orig_buf set but not used"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite/pidof.tests: fix false positive take 2
Denys Vlasenko [Wed, 27 Jun 2018 12:50:00 +0000 (14:50 +0200)]
testsuite/pidof.tests: fix false positive take 2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agovi: placate "warning: statement with no effect"
Denys Vlasenko [Wed, 27 Jun 2018 12:46:08 +0000 (14:46 +0200)]
vi: placate "warning: statement with no effect"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: placate "warning: unused variable i"
Denys Vlasenko [Wed, 27 Jun 2018 12:44:35 +0000 (14:44 +0200)]
nslookup: placate "warning: unused variable i"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite/tar.tests: fix false positive
Denys Vlasenko [Wed, 27 Jun 2018 12:35:56 +0000 (14:35 +0200)]
testsuite/tar.tests: fix false positive

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite/pidof.tests: fix false positive
Denys Vlasenko [Wed, 27 Jun 2018 12:26:21 +0000 (14:26 +0200)]
testsuite/pidof.tests: fix false positive

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite/bzcat.tests: fix false positive take 2
Denys Vlasenko [Wed, 27 Jun 2018 11:15:10 +0000 (13:15 +0200)]
testsuite/bzcat.tests: fix false positive take 2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite/unexpand/unexpand-works-like-GNU: fix false positive
Denys Vlasenko [Wed, 27 Jun 2018 10:54:57 +0000 (12:54 +0200)]
testsuite/unexpand/unexpand-works-like-GNU: fix false positive

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite/bzcat.tests: fix false positive
Denys Vlasenko [Wed, 27 Jun 2018 08:35:45 +0000 (10:35 +0200)]
testsuite/bzcat.tests: fix false positive

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite/tar.tests: fix false positive
Denys Vlasenko [Wed, 27 Jun 2018 08:01:49 +0000 (10:01 +0200)]
testsuite/tar.tests: fix false positive

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite/cat.tests: fix false positive
Denys Vlasenko [Wed, 27 Jun 2018 07:57:30 +0000 (09:57 +0200)]
testsuite/cat.tests: fix false positive

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolibbb: crypt() in newer glibc requires include <crypt.h>
Denys Vlasenko [Wed, 27 Jun 2018 07:43:38 +0000 (09:43 +0200)]
libbb: crypt() in newer glibc requires include <crypt.h>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: unset_local_var_len is only used by unset_local_var
Denys Vlasenko [Tue, 26 Jun 2018 16:27:54 +0000 (18:27 +0200)]
hush: unset_local_var_len is only used by unset_local_var

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix compile problem found by randomconfig
Denys Vlasenko [Tue, 26 Jun 2018 16:09:22 +0000 (18:09 +0200)]
hush: fix compile problem found by randomconfig

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoscripts/randomtest: disable CONFIG_NSLOOKUP for uclibc
Denys Vlasenko [Tue, 26 Jun 2018 15:22:35 +0000 (17:22 +0200)]
scripts/randomtest: disable CONFIG_NSLOOKUP for uclibc

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoscripts/randomtest: disable CONFIG_FEATURE_INETD_RPC for glibc
Denys Vlasenko [Tue, 26 Jun 2018 14:08:22 +0000 (16:08 +0200)]
scripts/randomtest: disable CONFIG_FEATURE_INETD_RPC for glibc

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoscripts/randomtest: disable CONFIG_FEATURE_MOUNT_NFS for glibc
Denys Vlasenko [Tue, 26 Jun 2018 14:01:05 +0000 (16:01 +0200)]
scripts/randomtest: disable CONFIG_FEATURE_MOUNT_NFS for glibc

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix dup_CLOEXEC() call without "avoid_fd" parameter
Denys Vlasenko [Tue, 26 Jun 2018 13:50:33 +0000 (15:50 +0200)]
hush: fix dup_CLOEXEC() call without "avoid_fd" parameter

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofdisk: placate warning of strncpy not copying NUL byte
Denys Vlasenko [Tue, 26 Jun 2018 13:44:58 +0000 (15:44 +0200)]
fdisk: placate warning of strncpy not copying NUL byte

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix for !ENABLE_HUSH_MODE_X configuration
Denys Vlasenko [Tue, 26 Jun 2018 13:43:56 +0000 (15:43 +0200)]
hush: fix for !ENABLE_HUSH_MODE_X configuration

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: variable nesting code is used also if HUSH_FUNCTIONS is not enabled
Denys Vlasenko [Tue, 26 Jun 2018 13:36:58 +0000 (15:36 +0200)]
hush: variable nesting code is used also if HUSH_FUNCTIONS is not enabled

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agorandomconfig fixes
Denys Vlasenko [Tue, 26 Jun 2018 13:35:17 +0000 (15:35 +0200)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotls: fix to handle X.509 v1 certificates correctly
Ivan Abrea [Sun, 24 Jun 2018 18:04:57 +0000 (20:04 +0200)]
tls: fix to handle X.509 v1 certificates correctly

The syntax of public key certificates can be found in RFC 5280 section
4.1. The relevant part of the syntax is the following:

  TBSCertificate  ::=  SEQUENCE  {
    version         [0]  EXPLICIT Version DEFAULT v1,
    serialNumber         CertificateSerialNumber,
    ... remaining fields omitted ...
  }

The version field has a default value of v1. RFC 5280 section 4.1.2.1
says the following:

  If only basic fields are present, the version SHOULD be 1 (the value
  is omitted from the certificate as the default value); however, the
  version MAY be 2 or 3.

To help detect if the version field is present or not, the type of the
version field has an explicit tag of [0]. Due to this tag, if the
version field is present, its encoding will have an identifier octet
that is distinct from that of the serialNumber field.

ITU-T X.690 specifies how a value of such a type should be encoded with
DER. There is a PDF of X.690 freely available from ITU-T. X.690 section
8.1.2 specifies the format of identifier octets which is the first
component of every encoded value. Identifier octets encode the tag of a
type. Bits 8 and 7 encode the tag class. Bit 6 will be 0 if the encoding
is primitive and 1 if the encoding is constructed. Bits 5 to 1 encode
the tag number.

X.690 section 8.14 specifies what the identifier octet should be for
explicitly tagged types. Section 8.14.3 says if implicit tagging is not
used, then the encoding shall be constructed. The version field uses
explicit tagging and not implicit tagging, so its encoding will be
constructed. This means bit 6 of the identifier octet should be 1.

X.690 section 8.14 and Annex A provide examples. Note from their
examples that the notation for tags could look like [APPLICATION 2]
where both the tag class and tag number are given. For this example, the
tag class is 1 (application) and the tag number is 2. For notation like
[0] where the tag class is omitted and only the tag number is given, the
tag class will be context-specific.

Putting this all together, the identifier octet for the DER encoding of
the version field should have a tag class of 2 (context-specific), bit 6
as 1 (constructed), and a tag number of 0.

Signed-off-by: Ivan Abrea <ivan@algosolutions.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agontpd: deprecate IPTOS_LOWDELAY in favor of IPTOS_DSCP_AF21
Codarren Velvindron [Sun, 15 Apr 2018 16:37:50 +0000 (20:37 +0400)]
ntpd: deprecate IPTOS_LOWDELAY in favor of IPTOS_DSCP_AF21

Update QoS markers.
Use DSCP AF21 for interactive traffic. DSCP is defined in RFC2474.
Many modern equipment no longer support IPTOS.

Signed-off-by: Codarren Velvindron <codarren@hackers.mu>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoexamples: update /var/service/getty for Unicode ttys
Denys Vlasenko [Sat, 23 Jun 2018 11:55:13 +0000 (13:55 +0200)]
examples: update /var/service/getty for Unicode ttys

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoinstall: fix "-D -t DIR1/DIR2/DIR3" creating only DIR1/DIR2, closes 11106
Denys Vlasenko [Fri, 22 Jun 2018 16:59:10 +0000 (18:59 +0200)]
install: fix "-D -t DIR1/DIR2/DIR3" creating only DIR1/DIR2, closes 11106

function                                             old     new   delta
install_main                                         758     767      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc: remove code which requires server ID to be on local network
Denys Vlasenko [Thu, 21 Jun 2018 15:36:22 +0000 (17:36 +0200)]
udhcpc: remove code which requires server ID to be on local network

This reverts "udhcpc: paranoia when using kernel UDP mode
for sending renew: server ID may be bogus".

Users complain that they do have servers behind routers
(with DHCP relays).

function                                             old     new   delta
send_packet                                          168     166      -2
bcast_or_ucast                                        25      23      -2
udhcp_send_kernel_packet                             301     295      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-10)             Total: -10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoUpdate release script to generate detached signatures and checksum files
Eli Schwartz [Tue, 5 Jun 2018 16:48:53 +0000 (12:48 -0400)]
Update release script to generate detached signatures and checksum files

This is more usable for programmatically checking the validity of a
release.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agorestore documentation on the build config language
Kartik Agaram [Fri, 1 Jun 2018 05:15:55 +0000 (22:15 -0700)]
restore documentation on the build config language

Kconfig-language.txt was deleted in commit 4fa499a17b52b back in 2006.
Move to docs/ as suggested by Xabier Oneca:
  http://lists.busybox.net/pipermail/busybox/2014-May/080914.html
Also update references to it everywhere.

Signed-off-by: Kartik Agaram <akkartik@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowget: emit a message that certificate verification is not implemented
Denys Vlasenko [Mon, 28 May 2018 12:36:26 +0000 (14:36 +0200)]
wget: emit a message that certificate verification is not implemented

function                                             old     new   delta
spawn_ssl_client                                     185     209     +24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofdisk: remove "Partition N does not end on cylinder boundary" message
Denys Vlasenko [Sat, 26 May 2018 16:51:18 +0000 (18:51 +0200)]
fdisk: remove "Partition N does not end on cylinder boundary" message

fdisk from util-linux 2.31 (maybe earlier) does not print this.

function                                             old     new   delta
check_consistency                                    449     399     -50

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowhitespace fix
Denys Vlasenko [Sat, 26 May 2018 15:42:00 +0000 (17:42 +0200)]
whitespace fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounlzma: close another SEGV possibility
Denys Vlasenko [Fri, 25 May 2018 15:03:46 +0000 (17:03 +0200)]
unlzma: close another SEGV possibility

function                                             old     new   delta
unpack_lzma_stream                                  2669    2686     +17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: carry along length of packet when parsing it.
David Decotigny [Thu, 24 May 2018 15:30:15 +0000 (08:30 -0700)]
udhcpc6: carry along length of packet when parsing it.

This is to avoid parsing garbage past packet's actual end.

Also const-ize params to a few functions.

function                                             old     new   delta
d6_run_script_no_option                                -      12     +12
option_to_env                                        791     798      +7
d6_run_script                                        253     255      +2
perform_d6_release                                    95      93      -2
udhcpc6_main                                        2596    2592      -4
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 21/-6)              Total: 15 bytes

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: ignore invalid OPTION_IAADDR
David Decotigny [Thu, 24 May 2018 15:30:16 +0000 (08:30 -0700)]
udhcpc6: ignore invalid OPTION_IAADDR

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agorealpath,readlink -f: coreutils compat, closes 11021
Denys Vlasenko [Thu, 24 May 2018 15:29:14 +0000 (17:29 +0200)]
realpath,readlink -f: coreutils compat, closes 11021

function                                             old     new   delta
xmalloc_realpath_coreutils                             -     121    +121

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonc: fix the !NC_SERVER configuration
Denys Vlasenko [Thu, 24 May 2018 14:38:40 +0000 (16:38 +0200)]
nc: fix the !NC_SERVER configuration

The symptom is the "nc: NO OPT l!" message.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofsck: fix incorrect handling of child exit
Denys Vlasenko [Thu, 24 May 2018 13:26:28 +0000 (15:26 +0200)]
fsck: fix incorrect handling of child exit

In commit

  c4fb8c6a - fsck: do not use statics

not only statics were changed but also a couple of
statics-unrelated changes were made.

This included the handling of the child termination status
as follows:

    - if (WIFEXITED(status))
    -   status = WEXITSTATUS(status);
    - else if (WIFSIGNALED(status)) {
    + status = WEXITSTATUS(status);
    + if (WIFSIGNALED(status)) {

This is wrong, should have used a different variable to hold exit code.

Reported by Niklas Hambüchen <mail@nh2.me>.

function                                             old     new   delta
wait_one                                             294     282     -12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotar: fix interaction of delayed symlink and hardlink creation
Harald van Dijk [Tue, 22 May 2018 15:34:31 +0000 (17:34 +0200)]
tar: fix interaction of delayed symlink and hardlink creation

function                                             old     new   delta
create_or_remember_link                                -     106    +106
create_links_from_list                                 -      93     +93
find_applet_by_name                                  124     128      +4
unzip_main                                          2724    2726      +2
data_extract_all                                     891     873     -18
create_symlinks_from_list                             64       -     -64
create_or_remember_symlink                            94       -     -94
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 2/1 up/down: 205/-176)           Total: 29 bytes

Signed-off-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotweak /var/service example
Denys Vlasenko [Sun, 20 May 2018 20:43:42 +0000 (22:43 +0200)]
tweak /var/service example

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agopopmaildir: placate gcc8 "warning: 'strncpy' output truncated"
Denys Vlasenko [Mon, 14 May 2018 09:14:58 +0000 (11:14 +0200)]
popmaildir: placate gcc8 "warning: 'strncpy' output truncated"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: set -x options in request
Denys Vlasenko [Mon, 14 May 2018 09:06:35 +0000 (11:06 +0200)]
udhcpc6: set -x options in request

Last foru commits:

function                                             old     new   delta
option_to_env                                        621     791    +170
.rodata                                           168351  168505    +154
attach_option                                        431     506     +75
add_d6_client_options                                112     167     +55
d6_option_strings                                     30      84     +54
udhcp_str2optset                                     644     660     +16
d6_optflags                                           12      20      +8
udhcpc6_main                                        2590    2596      +6
udhcpc_main                                         2648    2651      +3
read_optset                                           15      18      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 10/0 up/down: 544/0)            Total: 544 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: add PXELINUX options
Samuel Mendoza-Jonas [Mon, 14 May 2018 04:29:13 +0000 (14:29 +1000)]
udhcpc6: add PXELINUX options

Add support for the PXELINUX options 209 ("ConfigFile") and 210
("PathPrefix") in the DHCPv6 client.

See also: RFC5071, "Dynamic Host Configuration Protocol Options Used by
PXELINUX".

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: add DHCPv6 boot options
Samuel Mendoza-Jonas [Mon, 14 May 2018 04:29:12 +0000 (14:29 +1000)]
udhcpc6: add DHCPv6 boot options

Add support for 'bootfile-url' and 'bootfile-params' as defined by
RFC5970 "DHCPv6 Options for Network Boot".

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: add DHCPv6 env helper
Samuel Mendoza-Jonas [Mon, 14 May 2018 04:29:11 +0000 (14:29 +1000)]
udhcpc6: add DHCPv6 env helper

Add string_option_to_env() to easily generate environment variables for
known simple options.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcp: fix use of trim() in udhcp_str2optset()
Samuel Mendoza-Jonas [Mon, 14 May 2018 04:29:15 +0000 (14:29 +1000)]
udhcp: fix use of trim() in udhcp_str2optset()

trim() modifies the string in place if needed and returns a pointer to
the end of the resulting string. Update udhcp_str2optset() so it no
longer sets the value of 'val' to the return value of trim().

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonsenter: fix parsing of -t, -S and -G options
Euan Harris [Fri, 4 May 2018 15:18:47 +0000 (16:18 +0100)]
nsenter: fix parsing of -t, -S and -G options

-t, -S and -G each take mandatory integer arguments.   getopt32long()'s
option string syntax for this type of argument is 'c:+', however nsenter's
opt_str uses 'c+', which specifies two options 'c' and '+' which do not
take arguments.   This means that giving a target PID causes nsenter to
exit and print the usage string:

  # nsenter -t1 sh
  nsenter: unrecognized option: 1
  BusyBox v1.27.2 (2017-12-12 10:41:50 GMT) multi-call binary.
  ...

The long form options are also broken:

  # nsenter --setuid=1000 --setgid=1000 sh
  BusyBox v1.29.0.git (2018-05-04 13:56:49 UTC) multi-call binary.
  ...

`nsenter --target=<pid> sh` parses correctly and appears to work, but
<pid> is ignored and set to 0.   This doesn't raise an error unless one
of the namespace arguments is also given:

  # ./busybox_unstripped nsenter --target=42 sh
  # exit

  # ./busybox_unstripped nsenter -n --target=42 sh
  BusyBox v1.29.0.git (2018-05-04 13:56:49 UTC) multi-call binary.
  ...

This has caused problems in a couple of places:

  https://github.com/linuxkit/linuxkit/issues/567
  https://github.com/gliderlabs/docker-alpine/issues/359
  https://github.com/kontena/pharos-cluster/pull/81

Signed-off-by: Euan Harris <euan.harris@docker.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonsenter: Rename --network option to --net
Euan Harris [Thu, 3 May 2018 12:34:46 +0000 (13:34 +0100)]
nsenter: Rename --network option to --net

In nsenter from util-linux, the long version of the -n option is
--net=<path>.   BusyBox's version expects --network=<path>, so scripts
and examples written for util-linux's version cause BusyBox's version
to exit with the usage message.

Confusingly, until commit 036585a911a5f, the usage message erroneously
claimed that the long option was indeed called --net; after that commit
long options are not listed at all.

Signed-off-by: Euan Harris <euan.harris@docker.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agocat: fix cat -e and cat -v erroneously numbering 1st line
Denys Vlasenko [Sun, 29 Apr 2018 12:05:43 +0000 (14:05 +0200)]
cat: fix cat -e and cat -v erroneously numbering 1st line

function                                             old     new   delta
cat_main                                             418     421      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoifplugd: close signal race
Denys Vlasenko [Sun, 29 Apr 2018 11:46:49 +0000 (13:46 +0200)]
ifplugd: close signal race

function                                             old     new   delta
ifplugd_main                                        1109    1117      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounlzma: do emit the error message on bad input, when we exit with 1
Denys Vlasenko [Tue, 24 Apr 2018 11:49:12 +0000 (13:49 +0200)]
unlzma: do emit the error message on bad input, when we exit with 1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowget: handle URLs with @ or hash differently
Denys Vlasenko [Tue, 24 Apr 2018 11:35:32 +0000 (13:35 +0200)]
wget: handle URLs with @ or hash differently

If server replied with 302 and

Location: ?foo

we used to underflow the allocated space while trying to form the "@foo"
filename. Switch to forming "foo" filename.

function                                             old     new   delta
packed_usage                                       32795   32799      +4
parse_url                                            387     352     -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-35)             Total: -31 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofree: improve --help for type option
Denys Vlasenko [Tue, 24 Apr 2018 08:13:45 +0000 (10:13 +0200)]
free: improve --help for type option

Patch by Fred Friedrich.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoawk: do not allow $(-1)
Denys Vlasenko [Mon, 23 Apr 2018 08:53:18 +0000 (10:53 +0200)]
awk: do not allow $(-1)

function                                             old     new   delta
EMSG_NEGATIVE_FIELD                                    -      25     +25
evaluate                                            3390    3403     +13
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 38/0)               Total: 38 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoexamples/shutdown-1.0: an example of reboot which does not signal init
Denys Vlasenko [Fri, 20 Apr 2018 13:12:52 +0000 (15:12 +0200)]
examples/shutdown-1.0: an example of reboot which does not signal init

For one, my inits know nothing about the concept of "shutting down the system".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounlzma: fix another SEGV case
Denys Vlasenko [Thu, 19 Apr 2018 17:29:49 +0000 (19:29 +0200)]
unlzma: fix another SEGV case

function                                             old     new   delta
unpack_lzma_stream                                  1705    1717     +12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolibbb: new option FEATURE_ETC_SERVICES: if off, /etc/services reads often avoided
Denys Vlasenko [Tue, 17 Apr 2018 10:43:54 +0000 (12:43 +0200)]
libbb: new option FEATURE_ETC_SERVICES: if off, /etc/services reads often avoided

In practice, "wget http://host.com/" always uses port 80.
People explicitly set non-standard ports via options or parameters
("telnet 1.2.3.4 567" or "telnet 1.2.3.4 ftp") instead of modifying
/etc/services.

function                                             old     new   delta
telnet_main                                         1466    1464      -2
rdate_main                                           215     198     -17
fakeidentd_main                                      269     252     -17
parse_url                                            459     392     -67
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-103)           Total: -103 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agosetlogcons: open /dev/ttyN for "setlogcons N", not /dev/tty1
Denys Vlasenko [Mon, 16 Apr 2018 19:48:32 +0000 (21:48 +0200)]
setlogcons: open /dev/ttyN for "setlogcons N", not /dev/tty1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agobuild system: FEATURE_NSLOOKUP_BIG needs -lresolv
Denys Vlasenko [Mon, 16 Apr 2018 09:04:03 +0000 (11:04 +0200)]
build system: FEATURE_NSLOOKUP_BIG needs -lresolv

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoless: fix fallout from "use common routine to set raw termios"
Denys Vlasenko [Mon, 16 Apr 2018 08:24:48 +0000 (10:24 +0200)]
less: fix fallout from "use common routine to set raw termios"

Testcase: (sleep 10; ls) | busybox less

[...]
~           LICENSE
~                  Makefile
~                          Makefile.custom
~                                         Makefile.flags
[...]

less did not want this part:
+ /* dont convert NL to CR+NL on output */
+ newterm->c_oflag &= ~(ONLCR);

function                                             old     new   delta
get_termios_and_make_raw                             108     115      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: simplify make_ptr
Denys Vlasenko [Sun, 15 Apr 2018 18:04:57 +0000 (20:04 +0200)]
nslookup: simplify make_ptr

function                                             old     new   delta
nslookup_main                                       2644    2611     -33

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: get rid of query::rlen field
Denys Vlasenko [Sun, 15 Apr 2018 17:51:42 +0000 (19:51 +0200)]
nslookup: get rid of query::rlen field

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