oweals/busybox.git
6 years agochrt: add support for SCHED_BATCH
Povilas Kanapickas [Sat, 13 Jan 2018 21:26:39 +0000 (23:26 +0200)]
chrt: add support for SCHED_BATCH

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agood_bloaty: fix debug code
Denys Vlasenko [Tue, 23 Jan 2018 13:49:12 +0000 (14:49 +0100)]
od_bloaty: fix debug code

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoless: optional support of -R
Denys Vlasenko [Mon, 22 Jan 2018 13:38:51 +0000 (14:38 +0100)]
less: optional support of -R

Based on patches by Lubomir Rintel <lkundrak@v3.sk>

function                                             old     new   delta
read_lines                                           653     722     +69
less_main                                           2464    2531     +67
packed_usage                                       32202   32239     +37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 173/0)             Total: 173 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agovolume_id: add LittleFS detection
Sven-Göran Bergh [Fri, 19 Jan 2018 19:36:15 +0000 (20:36 +0100)]
volume_id: add LittleFS detection

Add support for LittleFS to blkid. Not included if FEATURE_BLKID_TYPE
is not selected (neither UUID nor label).

LittleFS is a small fail-safe filesystem designed for embedded
systems. It has strong copy-on-write guarantees and storage on disk
is always kept in a valid state. It also provides a form of dynamic
wear levelling for systems that can not fit a full flash translation
layer. (https://github.com/geky/littlefs)

ARM has introduced it in its Mbed OS 5.7, so it starts to gain focus.
(https://os.mbed.com/blog/entry/littlefs-high-integrity-embedded-fs/)

function                                             old     new   delta
volume_id_probe_lfs                                    -      62     +62
fs1                                                   20      24      +4

Signed-off-by: Sven-Göran Bergh <sgb@systemaxion.se>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: fix for ppp interface type
Denys Vlasenko [Fri, 19 Jan 2018 17:44:19 +0000 (18:44 +0100)]
udhcpc6: fix for ppp interface type

function                                             old     new   delta
d6_read_interface                                    454     600    +146

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix a case where EXIT trap may modify its code mid-flight
Denys Vlasenko [Fri, 19 Jan 2018 15:58:44 +0000 (16:58 +0100)]
hush: fix a case where EXIT trap may modify its code mid-flight

function                                             old     new   delta
hush_exit                                             93      99      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix build if !BASH_LINENO_VAR
Denys Vlasenko [Fri, 19 Jan 2018 15:00:57 +0000 (16:00 +0100)]
hush: fix build if !BASH_LINENO_VAR

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: implement $LINENO bashism
Denys Vlasenko [Fri, 19 Jan 2018 14:37:04 +0000 (15:37 +0100)]
hush: implement $LINENO bashism

function                                             old     new   delta
run_pipe                                            1697    1774     +77
unset_local_var_len                                  258     301     +43
hush_main                                           1009    1051     +42
set_local_var                                        516     554     +38
parse_and_run_file                                    42      75     +33
i_getch                                               96     116     +20
.rodata                                            18858   18876     +18
done_command                                         106     122     +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/0 up/down: 287/0)             Total: 287 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc[6]: remove overzealous timeout clamping code
Denys Vlasenko [Wed, 17 Jan 2018 12:55:51 +0000 (13:55 +0100)]
udhcpc[6]: remove overzealous timeout clamping code

function                                             old     new   delta
udhcpc_main                                         2840    2826     -14
udhcpc6_main                                        2699    2670     -29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: --help fixes
Denys Vlasenko [Tue, 16 Jan 2018 21:23:38 +0000 (22:23 +0100)]
udhcpc6: --help fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: show only short opts in --help text
Denys Vlasenko [Tue, 16 Jan 2018 21:10:12 +0000 (22:10 +0100)]
udhcpc6: show only short opts in --help text

function                                             old     new   delta
packed_usage                                       26028   25966     -62

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: fix lease time staying very small because -d was not specified
Denys Vlasenko [Tue, 16 Jan 2018 20:52:23 +0000 (21:52 +0100)]
udhcpc6: fix lease time staying very small because -d was not specified

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: code shrink
Denys Vlasenko [Tue, 16 Jan 2018 20:47:10 +0000 (21:47 +0100)]
udhcpc6: code shrink

function                                             old     new   delta
udhcpc6_main                                        2723    2727      +4
.rodata                                           128695  128561    -134

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: add support of prefix delegation
Denys Vlasenko [Tue, 16 Jan 2018 20:39:14 +0000 (21:39 +0100)]
udhcpc6: add support of prefix delegation

Based on patch by DannyAAM <danny@saru.moe>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: preparatory patch, no code changes
Denys Vlasenko [Tue, 16 Jan 2018 20:35:39 +0000 (21:35 +0100)]
udhcpc6: preparatory patch, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: fix ipv6prefix[_lease] envvar value in script invocation
Denys Vlasenko [Tue, 16 Jan 2018 15:00:13 +0000 (16:00 +0100)]
udhcpc6: fix ipv6prefix[_lease] envvar value in script invocation

Based on a patch by DannyAAM <danny@saru.moe>.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: a bit of NOFORK code should only be active if FEATURE_SH_STANDALONE=y
Denys Vlasenko [Sun, 14 Jan 2018 23:41:04 +0000 (00:41 +0100)]
ash: a bit of NOFORK code should only be active if FEATURE_SH_STANDALONE=y

function                                             old     new   delta
evalcommand                                         1546    1420    -126

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agopopmaildir: tweak help text
Denys Vlasenko [Sun, 14 Jan 2018 19:48:14 +0000 (20:48 +0100)]
popmaildir: tweak help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agorenice: add comment about getpwnam/NOFORK interaction
Denys Vlasenko [Sun, 14 Jan 2018 18:40:00 +0000 (19:40 +0100)]
renice: add comment about getpwnam/NOFORK interaction

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agorenice: use BUILD_BUG_ON()
Denys Vlasenko [Sun, 14 Jan 2018 18:05:02 +0000 (19:05 +0100)]
renice: use BUILD_BUG_ON()

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoNOFORK_NOEXEC.sh: a script to find "interesting" applets
Denys Vlasenko [Sun, 14 Jan 2018 13:44:30 +0000 (14:44 +0100)]
NOFORK_NOEXEC.sh: a script to find "interesting" applets

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agomv: make it NOEXEC
Denys Vlasenko [Sun, 14 Jan 2018 13:41:52 +0000 (14:41 +0100)]
mv: make it NOEXEC

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agocal: make it NOEXEC
Denys Vlasenko [Sun, 14 Jan 2018 13:32:11 +0000 (14:32 +0100)]
cal: make it NOEXEC

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonandwrite: cope with old headers which have no MTD_FILE_MODE_RAW
Denys Vlasenko [Sun, 14 Jan 2018 12:43:31 +0000 (13:43 +0100)]
nandwrite: cope with old headers which have no MTD_FILE_MODE_RAW

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agosize_single_applets.sh: fix a bug which mishandles e.g. "udhcpc6" name
Denys Vlasenko [Sun, 14 Jan 2018 11:13:16 +0000 (12:13 +0100)]
size_single_applets.sh: fix a bug which mishandles e.g. "udhcpc6" name

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoconfig: add size estimations for a few applets
Denys Vlasenko [Sun, 14 Jan 2018 11:03:33 +0000 (12:03 +0100)]
config: add size estimations for a few applets

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotc: fix single-applet build
Denys Vlasenko [Sat, 13 Jan 2018 20:37:20 +0000 (21:37 +0100)]
tc: fix single-applet build

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoshell: echo ${?:0} was fixed sometime ago, enable it in tests
Denys Vlasenko [Sat, 13 Jan 2018 18:28:19 +0000 (19:28 +0100)]
shell: echo ${?:0} was fixed sometime ago, enable it in tests

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix raw ^C handlisg in single-quoted strings
Denys Vlasenko [Sat, 13 Jan 2018 18:14:27 +0000 (19:14 +0100)]
hush: fix raw ^C handlisg in single-quoted strings

function                                             old     new   delta
parse_stream                                        2719    2754     +35

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: add command2.tests from ash tests
Denys Vlasenko [Fri, 12 Jan 2018 16:58:20 +0000 (17:58 +0100)]
hush: add command2.tests from ash tests

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: tweak command -vV printing code, no logic changes
Denys Vlasenko [Fri, 12 Jan 2018 15:17:59 +0000 (16:17 +0100)]
hush: tweak command -vV printing code, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: implement "command -v -V"
Denys Vlasenko [Fri, 12 Jan 2018 13:41:45 +0000 (14:41 +0100)]
hush: implement "command -v -V"

function                                             old     new   delta
pseudo_exec_argv                                     231     374    +143
if_command_vV_print_and_exit                           -     127    +127
builtin_set                                          267     273      +6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 276/0)             Total: 276 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowhich: fix TODO with NOFORK+malloc_failure misbehaving
Denys Vlasenko [Fri, 12 Jan 2018 12:21:33 +0000 (13:21 +0100)]
which: fix TODO with NOFORK+malloc_failure misbehaving

function                                             old     new   delta
find_executable                                       86     104     +18
which_main                                           202     194      -8
executable_exists                                     66      51     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 18/-23)             Total: -5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: implement "command" builtin (no options are supported yet)
Denys Vlasenko [Thu, 11 Jan 2018 17:05:05 +0000 (18:05 +0100)]
hush: implement "command" builtin (no options are supported yet)

function                                             old     new   delta
pseudo_exec_argv                                     194     231     +37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix handling of ^C in eval
Denys Vlasenko [Thu, 11 Jan 2018 12:17:30 +0000 (13:17 +0100)]
hush: fix handling of ^C in eval

function                                             old     new   delta
run_list                                            1044    1259    +215
builtin_eval                                          45     126     +81
expand_strvec_to_string                               91       -     -91
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/0 up/down: 296/-91)           Total: 205 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix handling of raw ^C in scripts: "echo ^C"
Denys Vlasenko [Thu, 11 Jan 2018 11:39:48 +0000 (12:39 +0100)]
hush: fix handling of raw ^C in scripts: "echo ^C"

function                                             old     new   delta
expand_vars_to_list                                 1133    1187     +54
parse_stream                                        2690    2719     +29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: remove dead code
Denys Vlasenko [Thu, 11 Jan 2018 10:19:00 +0000 (11:19 +0100)]
hush: remove dead code

function                                             old     new   delta
done_word                                            761     711     -50

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: ALWAYS_INLINE grabstackblock()
Denys Vlasenko [Wed, 10 Jan 2018 14:18:35 +0000 (15:18 +0100)]
ash: ALWAYS_INLINE grabstackblock()

function                                             old     new   delta
grabstackblock                                         5       -      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoinit: stop using static data
Denys Vlasenko [Wed, 10 Jan 2018 12:32:20 +0000 (13:32 +0100)]
init: stop using static data

function                                             old     new   delta
init_action_list                                       4       -      -4
new_init_action                                      148     142      -6
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-10)             Total: -10 bytes
   text    data     bss     dec     hex filename
 927839     481    6832  935152   e44f0 busybox_old
 927833     481    6824  935138   e44e2 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: make ${v:N:M} more robust for very large M by clamping to MIN/MAX_INT
Denys Vlasenko [Wed, 10 Jan 2018 12:22:25 +0000 (13:22 +0100)]
ash: make ${v:N:M} more robust for very large M by clamping to MIN/MAX_INT

Before this patch, "${v:2:0x100000001}" = "${v:2:1}",
and similarly, constructs like "${v:2:9999999999}" may give wrong result
due to int overflows.

function                                             old     new   delta
substr_atoi                                            -      43     +43

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agodd: fixed partial count logic
Denys Vlasenko [Wed, 10 Jan 2018 10:04:09 +0000 (11:04 +0100)]
dd: fixed partial count logic

$ busybox dd if=/dev/zero of=/dev/loop0 bs=100M count=8; echo $?
8+0 records in
7+0 records out  <=========== FIXED, was 7+1
805220352 bytes (767.9MB) copied, 0.464010 seconds, 1.6GB/s
1

function                                             old     new   delta
write_and_stats                                       97      99      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agodd: exit with 1 if last write was incomplete
Denys Vlasenko [Wed, 10 Jan 2018 09:58:55 +0000 (10:58 +0100)]
dd: exit with 1 if last write was incomplete

$ busybox dd if=/dev/zero of=/dev/loop0 bs=100M count=8; echo $?
8+0 records in
7+1 records out
805220352 bytes (767.9MB) copied, 0.464010 seconds, 1.6GB/s
1  <=========== FIXED

function                                             old     new   delta
write_and_stats                                       96      97      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: add comment explaining last change
Denys Vlasenko [Tue, 9 Jan 2018 16:25:58 +0000 (17:25 +0100)]
ash: add comment explaining last change

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: fix var_bash5.tests - ${VAR/pattern/repl} construct
Denys Vlasenko [Tue, 9 Jan 2018 16:01:00 +0000 (17:01 +0100)]
ash: fix var_bash5.tests - ${VAR/pattern/repl} construct

function                                             old     new   delta
subevalvar                                          1198    1279     +81
rmescapes                                            308     330     +22
preglob                                                8      10      +2
parsefname                                           152     154      +2
expandarg                                            973     975      +2
argstr                                              1144    1146      +2
mklocal                                              290     288      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/1 up/down: 111/-2)            Total: 109 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoumount: ignore -c
Shawn Landden [Mon, 8 Jan 2018 12:31:58 +0000 (13:31 +0100)]
umount: ignore -c

"-c, --no-canonicalize: Do not canonicalize paths."

As busybox doesn't canonicalize paths in the first place it is safe to ignore
this option.

See https://github.com/systemd/systemd/issues/7786

Signed-off-by: Shawn Landden <slandden@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agomknod: better --help, much clearer code
Denys Vlasenko [Mon, 8 Jan 2018 10:22:37 +0000 (11:22 +0100)]
mknod: better --help, much clearer code

function                                             old     new   delta
packed_usage                                       32066   32091     +25
mknod_main                                           173     174      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoless: code shrink
Denys Vlasenko [Mon, 8 Jan 2018 09:27:23 +0000 (10:27 +0100)]
less: code shrink

function                                             old     new   delta
less_main                                           2471    2464      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agodhcprelay: code shrink
Denys Vlasenko [Mon, 8 Jan 2018 09:14:17 +0000 (10:14 +0100)]
dhcprelay: code shrink

function                                             old     new   delta
dhcprelay_main                                       961     958      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonice: code shrink
Denys Vlasenko [Mon, 8 Jan 2018 09:13:11 +0000 (10:13 +0100)]
nice: code shrink

function                                             old     new   delta
nice_main                                            157     152      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years ago*: make "argc UNUSED_PARAM" consistent
Denys Vlasenko [Mon, 8 Jan 2018 08:43:51 +0000 (09:43 +0100)]
*: make "argc UNUSED_PARAM" consistent

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoawk: code shrink
Denys Vlasenko [Sun, 7 Jan 2018 13:39:34 +0000 (14:39 +0100)]
awk: code shrink

function                                             old     new   delta
awk_main                                             955     948      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: fail if 'shift' operand is out of range
Ingo van Lil [Fri, 5 Jan 2018 14:04:23 +0000 (15:04 +0100)]
ash: fail if 'shift' operand is out of range

If the numeric argument passed to ash's 'shift' built-in is greater than
'$#' the command performs no operation and exits successfully. It should
return a non-zero exit code instead:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#shift

This is consistent with bash and hush.

function                                             old     new   delta
shiftcmd                                             122     120      -2

Signed-off-by: Ingo van Lil <inguin@gmx.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoawk: fix 'delete array[var--]' decrementing var twice
Denys Vlasenko [Sun, 7 Jan 2018 00:19:08 +0000 (01:19 +0100)]
awk: fix 'delete array[var--]' decrementing var twice

function                                             old     new   delta
evaluate                                            3395    3390      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolibbb: compile obscure() only if FEATURE_PASSWD_WEAK_CHECK=y
Denys Vlasenko [Thu, 4 Jan 2018 14:21:25 +0000 (15:21 +0100)]
libbb: compile obscure() only if FEATURE_PASSWD_WEAK_CHECK=y

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agobuild system: add rule to install without cloberring existing utilities
Yann E. MORIN [Thu, 28 Dec 2017 22:49:49 +0000 (23:49 +0100)]
build system: add rule to install without cloberring existing utilities

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoapplets/install: accept more than one install option
Yann E. MORIN [Thu, 28 Dec 2017 22:49:48 +0000 (23:49 +0100)]
applets/install: accept more than one install option

Currently, it is impossible to pass more than one option to the isntall
script, so it totally prevents using --noclobber.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoapplets/install: respect noclobber for script wrappers too
Yann E. MORIN [Thu, 28 Dec 2017 22:49:47 +0000 (23:49 +0100)]
applets/install: respect noclobber for script wrappers too

Simplify the handling of --noclobber so that it applies to all types of
installation types, even to script wrappers.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotc: enables this applet
Denys Vlasenko [Thu, 4 Jan 2018 09:27:51 +0000 (10:27 +0100)]
tc: enables this applet

function                                             old     new   delta
tc_main                                                -     946    +946
cbq_print_opt                                          -     517    +517
print_qdisc                                            -     475    +475
print_class                                            -     359    +359
llproto_names                                          -     264    +264
packed_usage                                       31853   32066    +213
ll_proto_a2n                                           -     112    +112
llproto_ids                                            -      86     +86
print_tc_classid                                       -      82     +82
static.objects                                         -      20     +20
static._q_                                             -      16     +16
applet_main                                         1564    1568      +4
print_filter                                           -       3      +3
applet_names                                        2708    2711      +3
------------------------------------------------------------------------------
(add/remove: 13/0 grow/shrink: 3/0 up/down: 3100/0)          Total: 3100 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoStart 1.29.0 development cycle
Denys Vlasenko [Tue, 2 Jan 2018 05:11:19 +0000 (06:11 +0100)]
Start 1.29.0 development cycle

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoBump version to 1.28.0 1_28_0
Denys Vlasenko [Tue, 2 Jan 2018 05:07:28 +0000 (06:07 +0100)]
Bump version to 1.28.0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoscripts/randomtest: do not try building static libbysubox
Denys Vlasenko [Sun, 31 Dec 2017 19:31:05 +0000 (20:31 +0100)]
scripts/randomtest: do not try building static libbysubox

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agochown: fix a mistake in opt_complementary change
Denys Vlasenko [Sun, 31 Dec 2017 16:59:16 +0000 (17:59 +0100)]
chown: fix a mistake in opt_complementary change

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agorandomconfig fixes
Denys Vlasenko [Sun, 31 Dec 2017 16:30:02 +0000 (17:30 +0100)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agontpd: do run the script at leat once in 11 minutes
Denys Vlasenko [Tue, 26 Dec 2017 19:19:37 +0000 (20:19 +0100)]
ntpd: do run the script at leat once in 11 minutes

function                                             old     new   delta
ntpd_main                                           1197    1226     +29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoenv: -u option fails due to typo
Ron Yorston [Mon, 25 Dec 2017 20:36:05 +0000 (21:36 +0100)]
env: -u option fails due to typo

The -u option is supposed to be allowed to appear multiple times; the
option string supplied to getopt32long requires it to be followed by a
nonnegative integer.

Reported-by: Keith Maxwell <keith.maxwell@gmail.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotar: code shrink
Denys Vlasenko [Mon, 13 Nov 2017 00:56:51 +0000 (01:56 +0100)]
tar: code shrink

function                                             old     new   delta
packed_usage                                       31863   31853     -10
tar_main                                            1013    1002     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-21)             Total: -21 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotar: code shrink, better help text
Denys Vlasenko [Mon, 13 Nov 2017 00:40:28 +0000 (01:40 +0100)]
tar: code shrink, better help text

function                                             old     new   delta
tar_main                                             994    1013     +19
packed_usage                                       31893   31863     -30
writeTarFile                                         250     207     -43
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 19/-73)            Total: -54 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotar: improve help text
Denys Vlasenko [Fri, 10 Nov 2017 21:14:22 +0000 (22:14 +0100)]
tar: improve help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoinetd: fix for running by non-root
Denys Vlasenko [Thu, 9 Nov 2017 15:19:42 +0000 (16:19 +0100)]
inetd: fix for running by non-root

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounshare: -r should map root to user, not the other way around
Denys Vlasenko [Thu, 9 Nov 2017 15:06:33 +0000 (16:06 +0100)]
unshare: -r should map root to user, not the other way around

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounshare: -r implies -U, not -u
Denys Vlasenko [Thu, 9 Nov 2017 14:59:22 +0000 (15:59 +0100)]
unshare: -r implies -U, not -u

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounzip: add missing -j to trivial usage
Eugene Rudoy [Tue, 7 Nov 2017 07:03:37 +0000 (08:03 +0100)]
unzip: add missing -j to trivial usage

Signed-off-by: Eugene Rudoy <gene.devel@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounzip: fix content listing and filtering when -j is used
Eugene Rudoy [Tue, 7 Nov 2017 07:03:36 +0000 (08:03 +0100)]
unzip: fix content listing and filtering when -j is used

Original Info-ZIP's unzip uses unstripped filenames
while doing content listing and filtering, i.e.
 - in content listing mode -j is ignored completely
 - filtering is applied to non-stripped names, -j
   takes effect first while extracting the files

997ad2c64abbe931dffa3598b015c5de04e515cf strips path
components a little bit too early resulting in behavior
deviations.

Fix it by doing stripping after listing/filtering.

p.s. Info-ZIP's unzip behavior is the same as
     that of tar in --strip-components=NUM mode

Signed-off-by: Eugene Rudoy <gene.devel@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolineedit: get terminal width before printing prompt
Denys Vlasenko [Wed, 8 Nov 2017 12:38:12 +0000 (13:38 +0100)]
lineedit: get terminal width before printing prompt

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolineedit: do not tab-complete any strings which have control characters
Denys Vlasenko [Tue, 7 Nov 2017 17:09:29 +0000 (18:09 +0100)]
lineedit: do not tab-complete any strings which have control characters

function                                             old     new   delta
add_match                                             41      68     +27

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: fix nofork bug where environment is not properly passed to a command
Denys Vlasenko [Fri, 3 Nov 2017 13:16:25 +0000 (14:16 +0100)]
ash: fix nofork bug where environment is not properly passed to a command

function                                             old     new   delta
listvars                                             144     252    +108
evalcommand                                         1500    1546     +46
showvars                                             142     147      +5
shellexec                                            242     245      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 162/0)             Total: 162 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoinit: reduce the window when init can lose reboot/poweroff signals
Denys Vlasenko [Thu, 2 Nov 2017 14:25:28 +0000 (15:25 +0100)]
init: reduce the window when init can lose reboot/poweroff signals

function                                             old     new   delta
init_main                                            695     712     +17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: retain envvars with bad names in initial environment. Closes 10231
Denys Vlasenko [Thu, 2 Nov 2017 11:56:24 +0000 (12:56 +0100)]
ash: retain envvars with bad names in initial environment. Closes 10231

Reworks "ash: [VAR] Sanitise environment variable names on entry"
commit.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agontpd: skip over setting next DNS resolution attempt if it is not needed
Denys Vlasenko [Tue, 31 Oct 2017 15:53:23 +0000 (16:53 +0100)]
ntpd: skip over setting next DNS resolution attempt if it is not needed

function                                             old     new   delta
ntpd_main                                           1177    1197     +20
resolve_peer_hostname                                127     129      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoFix build failures if MAXHOSTNAMELEN or MAXPATHLEN is not defined
Denys Vlasenko [Tue, 31 Oct 2017 14:59:19 +0000 (15:59 +0100)]
Fix build failures if MAXHOSTNAMELEN or MAXPATHLEN is not defined

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agogrep: skip grepping symlinks to directories
James Clarke [Sat, 7 Oct 2017 17:53:24 +0000 (18:53 +0100)]
grep: skip grepping symlinks to directories

When grep is passed -r, recursive_action will treat any symlinks to
directories not in the root as normal files, since it lstat's them and
is therefore told they are not directories. However, file_action_grep
will still try to fopen and read from them to see whether they match,
which varies in behaviour across platforms. Linux will give EISDIR and
thus grep will not find any matching lines, but FreeBSD will give the
raw contents of the directory itself, which may match the given pattern.
Also, if grep is passed -c, it will even print a count for these
symlinks, even on Linux.

Since this recursive_action behaviour is required for the correct
functioning of other applets, such as tar, grep should handle this
special case and skip any such symlinks.

function                                             old     new   delta
file_action_grep                                      80     161     +81

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agontpd: mention in help text that -d can be repeated
Denys Vlasenko [Tue, 31 Oct 2017 11:47:07 +0000 (12:47 +0100)]
ntpd: mention in help text that -d can be repeated

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agontpd: improve treatment of DNS resolution failures
Denys Vlasenko [Tue, 31 Oct 2017 11:44:37 +0000 (12:44 +0100)]
ntpd: improve treatment of DNS resolution failures

function                                             old     new   delta
ntpd_main                                           1106    1177     +71
resolve_peer_hostname                                122     127      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 76/0)               Total: 76 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudp_io, traceroute: Standardise IPv6 PKTINFO handling to be portable
James Clarke [Sat, 7 Oct 2017 17:53:23 +0000 (18:53 +0100)]
udp_io, traceroute: Standardise IPv6 PKTINFO handling to be portable

The current standard (RFC 3542) is for IPV6_RECVPKTINFO to be given to
setsockopt, and IPV6_PKTINFO to be used as the packet type. Previously,
RFC 2292 required IPV6_PKTINFO to be used for both, but RFC 3542
re-purposed IPV6_PKTINFO when given to setsockopt. The special
Linux-specific IPV6_2292PKTINFO has the same semantics as IPV6_PKTINFO
in RFC 2292, but was introduced at the same time as IPV6_RECVPKTINFO.

Therefore, if we have IPV6_RECVPKTINFO available, we can use the RFC
3542 style, and if not, we assume that only the RFC 2292 API is
available, using IPV6_PKTINFO for both.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agodf: Use statvfs instead of non-standard statfs
James Clarke [Sat, 7 Oct 2017 17:53:20 +0000 (18:53 +0100)]
df: Use statvfs instead of non-standard statfs

Platforms differ on what their implementations of statfs include.
Importantly, FreeBSD's does not include a f_frsize member inside struct
statfs. However, statvfs is specified by POSIX and includes everything
we need, so we can just use that instead.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoxfuncs: Handle missing non-POSIX termios constants
James Clarke [Mon, 30 Oct 2017 14:18:32 +0000 (15:18 +0100)]
xfuncs: Handle missing non-POSIX termios constants

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoblkdiscard: Only build on Linux
James Clarke [Sat, 7 Oct 2017 17:53:19 +0000 (18:53 +0100)]
blkdiscard: Only build on Linux

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonetworking: Fall back on IPPROTO_RAW when SOL_RAW is not defined
James Clarke [Sat, 7 Oct 2017 17:53:21 +0000 (18:53 +0100)]
networking: Fall back on IPPROTO_RAW when SOL_RAW is not defined

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agontpd: perform DNS resolution out of send/receive loop - closes 10466
Denys Vlasenko [Sat, 28 Oct 2017 15:54:24 +0000 (17:54 +0200)]
ntpd: perform DNS resolution out of send/receive loop - closes 10466

Bad case: send request to server1good.com; then try to resolve server2bad.com -
this fails, and failure takes ~5 secs; then receive server1's
response 5 seconds later. We'll never sync up in this case...

function                                             old     new   delta
ntpd_main                                           1079    1106     +27

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoiproute/iprule: support toolchains without RTA_TABLE routing attribute
Eugene Rudoy [Wed, 18 Oct 2017 22:05:11 +0000 (00:05 +0200)]
iproute/iprule: support toolchains without RTA_TABLE routing attribute

 iproute.c: In function 'print_route':
 iproute.c:85:9: error: 'RTA_TABLE' undeclared (first use in this function)
 iproute.c:85:9: note: each undeclared identifier is reported only once for each function it appears in
 iproute.c: In function 'iproute_modify':
 iproute.c:467:36: error: 'RTA_TABLE' undeclared (first use in this function)

Fix it by partially #ifdef'ing the code added in b42107f21538e39d9a344376372f8261aed589b2

Signed-off-by: Eugene Rudoy <gene.devel@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotime: fix build for toolchains without O_CLOEXEC
Denys Vlasenko [Fri, 27 Oct 2017 17:05:00 +0000 (19:05 +0200)]
time: fix build for toolchains without O_CLOEXEC

Based on patch by Eugene Rudoy <gene.devel@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounlzma: fix SEGV, closes 10436
Denys Vlasenko [Fri, 27 Oct 2017 13:37:03 +0000 (15:37 +0200)]
unlzma: fix SEGV, closes 10436

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agobunzip2: fix runCnt overflow from bug 10431
Denys Vlasenko [Sun, 22 Oct 2017 16:23:23 +0000 (18:23 +0200)]
bunzip2: fix runCnt overflow from bug 10431

This particular corrupted file can be dealth with by using "unsigned".
If there will be cases where it genuinely overflows, there is a disabled
code to deal with that too.

function                                             old     new   delta
get_next_block                                      1678    1667     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix comment parsing in `cmd`, closes 10421
Denys Vlasenko [Sun, 22 Oct 2017 13:55:48 +0000 (15:55 +0200)]
hush: fix comment parsing in `cmd`, closes 10421

function                                             old     new   delta
parse_stream                                        2692    2690      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolsscsi: fix xchdir("..") from symlink in /sys/bus/scsi/devices
Markus Gothe [Sat, 21 Oct 2017 19:34:22 +0000 (21:34 +0200)]
lsscsi: fix xchdir("..") from symlink in /sys/bus/scsi/devices

Signed-off-by: Markus Gothe <nietzsche@lysator.liu.se>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowhitespace fixes
Denys Vlasenko [Thu, 12 Oct 2017 17:40:47 +0000 (19:40 +0200)]
whitespace fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotypo fix
Denys Vlasenko [Thu, 12 Oct 2017 17:35:42 +0000 (19:35 +0200)]
typo fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: survive failures in $PS1 expansion. Closes 10371
Denys Vlasenko [Thu, 12 Oct 2017 17:20:13 +0000 (19:20 +0200)]
ash: survive failures in $PS1 expansion. Closes 10371

function                                             old     new   delta
expandstr                                            120     209     +89

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolineedit: improve multiline PS1 - redraw using last PS1 line. Closes 10381
Avi Halachmi [Thu, 12 Oct 2017 14:38:35 +0000 (16:38 +0200)]
lineedit: improve multiline PS1 - redraw using last PS1 line. Closes 10381

This patch only affects prompts with newlines.

We redraw the prompt [+ input] occasionally, e.g. during tab completion,
history browsing or search, etc, and we expect it to align with prior
redraws, such that the visible effect is that only the input changes.

With multi-line PS1, redraw always printed the prompt some lines below
the old one, which resulted in terminal scroll during every redraw.

Now we only redraw the last PS1 line, so vertical alignment is easier to
manage (we already calculated it using only the last line, but re-drew
all lines - that was the culprit), which fixes those extra scrolls.

Notes:
- We now use the full prompt for the initial draw, after clear-screen (^L),
  and after tab-completion choices are displayed. Everything else now
  redraws using the last/sole prompt line.

- During terminal resize we now only redraw the last[/sole] prompt line,
  which is arguably better because it's hard to do right (and we never did).

- Good side effect for reverse-i-search: its prompt now replaces only the
  last line of the original prompt - like other shells do.

function                                             old     new   delta
put_prompt_custom                                      -      66     +66
draw_custom                                            -      66     +66
parse_and_put_prompt                                 766     806     +40
read_line_input                                     3867    3884     +17
input_tab                                           1069    1076      +7
cmdedit_setwidth                                      61      63      +2
redraw                                                59      47     -12
put_prompt                                            46       -     -46
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 4/1 up/down: 198/-58)           Total: 140 bytes

Signed-off-by: Avi Halachmi <avihpit@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agosendmail allow "=" symbol in recipient, closes 10241
Denys Vlasenko [Thu, 5 Oct 2017 15:18:23 +0000 (17:18 +0200)]
sendmail allow "=" symbol in recipient, closes 10241

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