betterthanbusybox
5 weeks agoFeatures are a strict superset of busybox's features, making this software better... master
Pete [Mon, 5 Apr 2021 03:10:46 +0000 (20:10 -0700)]
Features are a strict superset of busybox's features, making this software better than busybox, because MORE FEATURES ALWAYS GOOD

IT DOES NOT MATTER IF IT IS SOMETHING NOBODY NEEDS

IT IS A FEATURE

KEEP ADDING MORE FEATURES

5 weeks agovi: deal with invalid movements in shift commands
Ron Yorston [Tue, 30 Mar 2021 12:02:32 +0000 (13:02 +0100)]
vi: deal with invalid movements in shift commands

Since commit 25d259264 (vi: make buffer handling more vi-like)
find_range() can return early when an invalid movement is
specified.

The call to find_range() in the code that handles shift commands
('<' and '>') doesn't check for this condition.  Previously this
only resulted in the current line being shifted but it can now
result in a segfault.

Check for an invalid movement and notify the user without taking
any further action.

function                                             old     new   delta
do_cmd                                              4890    4898      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 8/0)                 Total: 8 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: code shrink
Ron Yorston [Sun, 28 Mar 2021 12:23:51 +0000 (13:23 +0100)]
vi: code shrink

- In the '+' and '-' commands the call to dot_skip_over_ws() is
  only needed for the final line processed so it can be moved out
  of the while loop.

- Marking sync_cursor() NOINLINE doesn't seem to offer the same
  advantages it did in 2009 (commit adf922ec2).

function                                             old     new   delta
refresh                                              694     974    +280
do_cmd                                              4900    4887     -13
sync_cursor                                          336       -    -336
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 280/-349)          Total: -69 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: improve operations involving paragraph movement
Ron Yorston [Sun, 28 Mar 2021 12:23:12 +0000 (13:23 +0100)]
vi: improve operations involving paragraph movement

Movement by paragraph doesn't always involve whole lines.  If the
cursor is positioned in the middle of a line deleting to either end
of the paragraph will result in one partial line and zero or more
full lines.

Adjust the end of ranges delimited by paragraph movement to more
closely match what vi does.

function                                             old     new   delta
find_range                                           467     518     +51
at_eof                                                 -      49     +49
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 100/0)             Total: 100 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: improve motion by paragraph
Ron Yorston [Sun, 28 Mar 2021 12:22:43 +0000 (13:22 +0100)]
vi: improve motion by paragraph

When moving by paragraph ('{' and '}'):

- Treat multiple empty lines as a single paragraph separator.

- When no paragraph separator is found move to the start or end of
  the file depending on the direction of motion.

function                                             old     new   delta
do_cmd                                              4821    4900     +79
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 79/0)               Total: 79 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: allow repetition count for paragraph motion
Ron Yorston [Sun, 28 Mar 2021 12:22:11 +0000 (13:22 +0100)]
vi: allow repetition count for paragraph motion

The paragraph motion commands '{' and '}' should accept a count.

function                                             old     new   delta
do_cmd                                              5054    5071     +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 17/0)               Total: 17 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: allow motion count for change/delete/yank/shift
Ron Yorston [Sun, 28 Mar 2021 12:21:34 +0000 (13:21 +0100)]
vi: allow motion count for change/delete/yank/shift

The motion that determines the range of a change, delete, yank
or shift operation can have its own count.  Thus the commands
'5dd' and 'd5d' are equivalent:  both delete 5 lines.

When the command itself also has a count the two values are
multiplied.  Thus the command '2d3w' deletes 6 words and '2D3G'
deletes from the current line to line 6.

(When dealing with structured data it might make sense to think in
units of 3 words so '2d3w' is deleting 2 such units.  It doesn't
seem quite as sensible to express 'delete from current line to line 6'
as '2D3G' but vi permits it.)

function                                             old     new   delta
get_motion_char                                        -      68     +68
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/0 up/down: 68/0)               Total: 68 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: support more commands for range selection
Ron Yorston [Sun, 28 Mar 2021 12:21:08 +0000 (13:21 +0100)]
vi: support more commands for range selection

Add 'F', 'T' and '|' as commands that can be used to specify a
range for change/delete/yank operations.

function                                             old     new   delta
.rodata                                           105129  105135      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 6/0)                 Total: 6 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: improvements to character search within line
Ron Yorston [Sun, 28 Mar 2021 16:15:30 +0000 (17:15 +0100)]
vi: improvements to character search within line

- Use a common routine to handle all commands to search for a
  character in a line.

- When searching for the nth occurrence of a character don't move
  the cursor if fewer than n occurrences are present.

- Add support for the 'T' command, search backwards for character
  after next occurrence of given character.

function                                             old     new   delta
do_cmd                                              4861    4805     -56
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-56)             Total: -56 bytes

v2: Add parentheses to avoid searches continuing past end of line.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: remember cursor column during vertical motion
Ron Yorston [Sun, 28 Mar 2021 12:20:01 +0000 (13:20 +0100)]
vi: remember cursor column during vertical motion

When the 'j'/'k' commands or up/down arrow keys are used to move
the cursor vertically 'vi' remembers the original cursor column
and positions the cursor there if possible.  Also, if the '$'
command has been used to position the cursor at the end of a line
vertical movements keep the cursor at the end of the line.

Make BusyBox 'vi' do the same.

function                                             old     new   delta
refresh                                              674     694     +20
do_cmd                                              4853    4861      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 28/0)               Total: 28 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: 'G'/'M' commands move to first visible character
Ron Yorston [Sun, 28 Mar 2021 12:19:26 +0000 (13:19 +0100)]
vi: 'G'/'M' commands move to first visible character

The 'G' command with no target (meaning 'go to last line') should
position the cursor on the first visible character of the line, as
it already does in other cases.

The 'M' command  should position the cursor on the first visible
character (as 'H' and 'L' already do).

function                                             old     new   delta
do_cmd                                              4842    4853     +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 11/0)               Total: 11 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: don't overwrite existing file
Ron Yorston [Sun, 28 Mar 2021 12:18:40 +0000 (13:18 +0100)]
vi: don't overwrite existing file

If the name of the file being written doesn't match the current
filename and the output file already exists vi should issue a
warning and not overwrite the file.

Because the test only compares the file names it's somewhat over-
protective.  If the current file name is 'my_text' and the user tries
to save to './my_text' they'll be prevented from doing so.

function                                             old     new   delta
colon                                               3092    3151     +59
.rodata                                           105118  105146     +28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 87/0)               Total: 87 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: make buffer handling more vi-like
Ron Yorston [Thu, 25 Mar 2021 14:23:36 +0000 (14:23 +0000)]
vi: make buffer handling more vi-like

Vi places text affected by change/delete/yank operations into a
buffer.  The contents of such buffers can be restored with the put
commands, 'p' or 'P'.  These behave differently depending on whether
the buffer contains whole lines or partial lines.  For whole lines
the text is copied into the file on the line before (P) or after
(p) the current line.  For partial lines the text is copied before
or after the current cursor position.

Whether an operation results in whole or partial lines depends on
the command used.

BusyBox vi treats any buffer with a newline as though it contained
whole lines.  This is incorrect.  Deleting multiple words across
a line boundary results in a buffer with a newline but not having
whole lines.

Rework how buffers are handled to behave more like vi.

function                                             old     new   delta
static.text_yank                                      79      99     +20
colon                                               3092    3097      +5
edit_file                                            885     887      +2
yank_delete                                          127     112     -15
.rodata                                           105139  105101     -38
find_range                                           514     467     -47
do_cmd                                              5088    4842    -246
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/4 up/down: 27/-346)          Total: -319 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: code shrink
Ron Yorston [Thu, 25 Mar 2021 14:21:49 +0000 (14:21 +0000)]
vi: code shrink

I was puzzled by code in find_range() which handles forward word
movement.  It included a test to see if we're at the start of a
word.  Since these are forward word movements surely we'd expect to
be at the start of a word?  In fact, the test was intended to fix a
problem with changes to the last word in a file, as discussed in the
thread starting here:

   http://lists.busybox.net/pipermail/busybox/2004-January/044552.html

The code can be simplified by testing directly for end of file instead
of indirectly for not being at the start of a word.  Since trailing
whitespace is now handled in do_cmd() the code to back up off a newline
is no longer required.

function                                             old     new   delta
find_range                                           619     514    -105
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-105)           Total: -105 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 weeks agovi: fix word operations across line boundaries
Ron Yorston [Thu, 25 Mar 2021 14:20:56 +0000 (14:20 +0000)]
vi: fix word operations across line boundaries

Commit 4b49422a0 (vi: fix changes to word at end of line. Closes
11796) fixed a problem where an operation on a word at the end of
a line followed by a line starting with whitespace incorrectly
joined the lines.  However it also broke the case where operating
on multiple words across a line boundary *should* join the lines.

Fix this by detecting when trailing whitepace in a word operation
includes a newline.  Whitespace beyond the newline is excluded
from consideration.

function                                             old     new   delta
do_cmd                                              5083    5088      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 5/0)                 Total: 5 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 weeks agontpd: code shrink (force not-inlining, stop returning structs)
Denys Vlasenko [Fri, 26 Mar 2021 11:02:08 +0000 (12:02 +0100)]
ntpd: code shrink (force not-inlining, stop returning structs)

function                                             old     new   delta
d_to_sfp                                               -     133    +133
lfp_to_d                                               -      84     +84
sfp_to_d                                               -      78     +78
d_to_lfp                                             141     137      -4
.rodata                                           103182  103174      -8
recv_and_process_peer_pkt                           2380    2173    -207
recv_and_process_client_pkt                          706     493    -213
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 0/4 up/down: 295/-432)         Total: -137 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 weeks agotimeout,top,watch,ping: parse NN.N fractional duration in locales with other separators
Denys Vlasenko [Tue, 23 Mar 2021 12:50:02 +0000 (13:50 +0100)]
timeout,top,watch,ping: parse NN.N fractional duration in locales with other separators

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 weeks agoresume: write offset in /sys/power/resume_offset
Denys Vlasenko [Sat, 20 Mar 2021 13:01:04 +0000 (14:01 +0100)]
resume: write offset in /sys/power/resume_offset

Doing this the kernel will hibernate and resume successfully from a swap file.
Stop writing offset to /sys/power/resume, as this is not a parameter
the kernel takes from this input. (Change added by Sven Mueller)

function                                             old     new   delta
resume_main                                          522     561     +39
.rodata                                           103175  103182      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 46/0)               Total: 46 bytes

Signed-off-by: Jordi Pujol Palomer <jordipujolp@gmail.com>
Signed-off-by: Sven Mueller <sven.mueller72+busybox@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 weeks agologin: implement LOGIN_TIMEOUT
Denys Vlasenko [Thu, 18 Mar 2021 23:27:44 +0000 (00:27 +0100)]
login: implement LOGIN_TIMEOUT

function                                             old     new   delta
packed_usage                                       33559   33598     +39
login_main                                           953     986     +33
.rodata                                           103161  103175     +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 86/0)               Total: 86 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 weeks agoudhcpc: ignore zero-length DHCP options, take 2
Denys Vlasenko [Tue, 16 Mar 2021 10:42:56 +0000 (11:42 +0100)]
udhcpc: ignore zero-length DHCP options, take 2

advance the optionptr by two bytes, not one

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 weeks agoudhcpc: ignore zero-length DHCP options
Russell Senior [Tue, 16 Mar 2021 05:42:43 +0000 (22:42 -0700)]
udhcpc: ignore zero-length DHCP options

Discovered that the DHCP server on a TrendNet router (unknown model)
provides a zero-length option 12 (Host Name) in the DHCP ACK message. This
has the effect of causing udhcpc to drop the rest of the options, including
option 51 (IP Address Lease Time), 3 (Router), and 6 (Domain Name Server),
most importantly leaving the OpenWrt device with no default gateway.

The TrendNet behavior violates RFC 2132, which in Section 3.14 declares that
option 12 has a minimum length of 1 octet. It is perhaps not a cosmic coincidence
that I found this behavior on Pi Day.

This patch allows zero length options without bailing out, by simply skipping them.

function                                             old     new   delta
udhcp_scan_options                                   183     172     -11

Signed-off-by: Russell Senior <russell@personaltelco.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 weeks agoecho: special case "echo --help": it should not show help text
Denys Vlasenko [Mon, 15 Mar 2021 16:42:25 +0000 (17:42 +0100)]
echo: special case "echo --help": it should not show help text

While at it, fix "busybox --help echo" and other special applets to still print
the help text.

function                                             old     new   delta
run_applet_and_exit                                  732     761     +29
show_usage_if_dash_dash_help                          70      78      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 37/0)               Total: 37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
8 weeks agodecompress_gunzip: Fix DoS if gzip is corrupt
Samuel Sapalski [Wed, 3 Mar 2021 15:31:22 +0000 (16:31 +0100)]
decompress_gunzip: Fix DoS if gzip is corrupt

On certain corrupt gzip files, huft_build will set the error bit on
the result pointer. If afterwards abort_unzip is called huft_free
might run into a segmentation fault or an invalid pointer to
free(p).

In order to mitigate this, we check in huft_free if the error bit
is set and clear it before the linked list is freed.

Signed-off-by: Samuel Sapalski <samuel.sapalski@nokia.com>
Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
8 weeks agohush: make LINENO selectable without BASH-COMPAT
Denys Vlasenko [Wed, 10 Mar 2021 15:31:05 +0000 (16:31 +0100)]
hush: make LINENO selectable without BASH-COMPAT

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agowget: new option FEATURE_WGET_FTP to enable/disable FTP
Sergey Ponomarev [Sun, 17 Jan 2021 18:35:08 +0000 (20:35 +0200)]
wget: new option FEATURE_WGET_FTP to enable/disable FTP

Introduce a separate option FTPS_SUPPORTED instead of not obvious ENABLE_FEATURE_WGET_HTTPS.

function                                             old     new   delta
P_FTP                                                  4       -      -4
P_FTPS                                                 5       -      -5
reset_beg_range_to_zero                               41       -     -41
parse_url                                            431     366     -65
parse_pasv_epsv                                      154       -    -154
.rodata                                           115566  115408    -158
ftpcmd                                               204       -    -204
spawn_ssl_client                                     291       -    -291
wget_main                                           2998    2664    -334
------------------------------------------------------------------------------
(add/remove: 0/7 grow/shrink: 0/3 up/down: 0/-1256)         Total: -1256 bytes

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agobloat-o-meter: avoid double counting
Ron Yorston [Mon, 8 Mar 2021 19:30:57 +0000 (19:30 +0000)]
bloat-o-meter: avoid double counting

Disable 'echo' in the default config, run 'make baseline', then
re-enable 'echo' and run 'make bloatcheck':

function                                             old     new   delta
.rodata                                           182521  182622    +101
packed_usage                                       33714   33792     +78
applet_main                                         3168    3176      +8
applet_names                                        2730    2735      +5
applet_suid                                           99     100      +1
applet_install_loc                                   198     199      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 194/0)             Total: 194 bytes
   text    data     bss     dec     hex filename
 955052    4195    1808  961055   eaa1f busybox_old
 955153    4195    1808  961156   eaa84 busybox_unstripped

The Total bytes value doesn't equal the change in the size of the
binary.  The packed_usage and applet_* items are in .rodata and
are counted twice.  With this modified bloat-o-meter the size of
named items is deducted from .rodata:

function                                             old     new   delta
packed_usage                                       33714   33792     +78
applet_main                                         3168    3176      +8
.rodata                                           105105  105113      +8
applet_names                                        2730    2735      +5
applet_suid                                           99     100      +1
applet_install_loc                                   198     199      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 101/0)             Total: 101 bytes
   text    data     bss     dec     hex filename
 955052    4195    1808  961055   eaa1f busybox_old
 955153    4195    1808  961156   eaa84 busybox_unstripped

v2: Sections numbered less than 10 were always being omitted from
    consideration because splitting "[ 1] .interp" leaves "1]" in
    x[1] where the section name is expected.  This wasn't a problem
    for .rodata (numbered 15 in my testing) but let's fix it anyway.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agostart-stop-daemon: explain -x + -a test
Denys Vlasenko [Tue, 9 Mar 2021 00:12:18 +0000 (01:12 +0100)]
start-stop-daemon: explain -x + -a test

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agontpd: tweak comments
Denys Vlasenko [Tue, 2 Mar 2021 18:54:09 +0000 (19:54 +0100)]
ntpd: tweak comments

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agontpd: decrease INITIAL_SAMPLES from 4 to 3
Denys Vlasenko [Tue, 2 Mar 2021 11:07:14 +0000 (12:07 +0100)]
ntpd: decrease INITIAL_SAMPLES from 4 to 3

This reduces initial traffic to NTP servers when a lot of devices boot at once.

Log inspection tells me we agressively burst-poll servers about 5 times
at startup, even though we usually already update clock after second replies.
INITIAL_SAMPLES can probably be even lower, e.g. 2, but let's be conservative
when changing this stuff.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agovi: code shrink
Denys Vlasenko [Mon, 1 Mar 2021 13:41:39 +0000 (14:41 +0100)]
vi: code shrink

function                                             old     new   delta
setops                                                85      73     -12
colon                                               2965    2915     -50
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-62)             Total: -62 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agovi: restore 0 offset after :set noXXX command
Alison Winters [Sat, 27 Feb 2021 23:18:45 +0000 (15:18 -0800)]
vi: restore 0 offset after :set noXXX command

Fixes bug where commands after the first noXXX command are ignored.
    e.g. :set noic tabstop=4

While at it, stop recognizing "notabstop=NNN".

function                                             old     new   delta
colon                                               2990    2965     -25

Signed-off-by: Alison Winters <alisonatwork@outlook.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agobc: typo fix in comment
Denys Vlasenko [Fri, 26 Feb 2021 20:20:18 +0000 (21:20 +0100)]
bc: typo fix in comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agodc: more docs in --help
Denys Vlasenko [Fri, 26 Feb 2021 16:11:55 +0000 (17:11 +0100)]
dc: more docs in --help

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agodc: document what non-GNU commands do
Denys Vlasenko [Fri, 26 Feb 2021 13:48:04 +0000 (14:48 +0100)]
dc: document what non-GNU commands do

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agobc/dc: fix length(0) and length(0.000nnn) result
Denys Vlasenko [Fri, 26 Feb 2021 13:05:28 +0000 (14:05 +0100)]
bc/dc: fix length(0) and length(0.000nnn) result

function                                             old     new   delta
zxc_vm_process                                      6464    6498     +34

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agodc: correct --help text
Denys Vlasenko [Fri, 26 Feb 2021 12:26:48 +0000 (13:26 +0100)]
dc: correct --help text

before:

    Tiny RPN calculator. Operations:
    +, -, *, /, %, ~, ^, |,
    p - print top of the stack without popping
    f - print entire stack
    k - pop the value and set the precision
    i - pop the value and set input radix
    o - pop the value and set output radix

After:

    Tiny RPN calculator. Operations:
    Arithmetic: + - * / % ^
    ~ - divide with remainder
    | - modular exponentiation
    v - square root
    p - print top of the stack without popping
    f - print entire stack
    k - pop the value and set precision
    i - pop the value and set input radix
    o - pop the value and set output radix

function                                             old     new   delta
packed_usage                                       33519   33565     +46

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agotrylink: do not drop libs from CONFIG_EXTRA_LDLIBS
Denys Vlasenko [Tue, 23 Feb 2021 22:09:49 +0000 (23:09 +0100)]
trylink: do not drop libs from CONFIG_EXTRA_LDLIBS

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agoecho: do not assume that free() leaves errno unmodified
Natanael Copa [Fri, 22 Jan 2021 07:35:55 +0000 (08:35 +0100)]
echo: do not assume that free() leaves errno unmodified

musl libc's mallocng free() may modify errno if kernel does not support
MADV_FREE which causes echo to echo with error when it shouldn't.

Future versions of POSIX[1] will require that free() leaves errno
unmodified but til then, do not rely free() implementation.

Should fix downstream issues:
https://github.com/alpinelinux/docker-alpine/issues/134
https://gitlab.alpinelinux.org/alpine/aports/-/issues/12311

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agolineedit: support empty PATH entries in tab completion
Ron Yorston [Thu, 18 Feb 2021 09:50:29 +0000 (09:50 +0000)]
lineedit: support empty PATH entries in tab completion

Zero-length path prefixes can be specified in PATH as a leading or
trailing colon or two adjacent colons.  POSIX says that the use of
zero-length prefixes to refer to the current directory is a legacy
feature.  Nonetheless the shells in BusyBox respect this feature,
as does 'which'.

Tab-completion of executables using PATH should support this too.

function                                             old     new   delta
complete_cmd_dir_file                                934     931      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agodiff: code shrink
Ron Yorston [Tue, 16 Feb 2021 09:09:12 +0000 (09:09 +0000)]
diff: code shrink

function                                             old     new   delta
diff_main                                           1515    1495     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-20)             Total: -20 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agodnsd: check that we don't read past packet
Denys Vlasenko [Mon, 22 Feb 2021 14:36:07 +0000 (15:36 +0100)]
dnsd: check that we don't read past packet

function                                             old     new   delta
dnsd_main                                           1296    1304      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agoudhcp: reuse strings
Denys Vlasenko [Sun, 21 Feb 2021 15:32:07 +0000 (16:32 +0100)]
udhcp: reuse strings

   text    data     bss     dec     hex filename
1019916     559    5020 1025495   fa5d7 busybox_old
1019906     559    5020 1025485   fa5cd busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agontpd: log responses to clients at log level 3
Denys Vlasenko [Sun, 21 Feb 2021 08:47:34 +0000 (09:47 +0100)]
ntpd: log responses to clients at log level 3

function                                             old     new   delta
recv_and_process_client_pkt                          670     706     +36

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agontpd: without INITIAL_FREQ_ESTIMATION code, state variable is not needed too
Denys Vlasenko [Sun, 21 Feb 2021 08:13:05 +0000 (09:13 +0100)]
ntpd: without INITIAL_FREQ_ESTIMATION code, state variable is not needed too

function                                             old     new   delta
update_local_clock                                   917     872     -45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agontpd: remove unused USING_INITIAL_FREQ_ESTIMATION code
Denys Vlasenko [Sun, 21 Feb 2021 08:05:48 +0000 (09:05 +0100)]
ntpd: remove unused USING_INITIAL_FREQ_ESTIMATION code

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agontpd: increase loglevel to 3 for "poll:32s sockets:0 interval:64s" message
Denys Vlasenko [Sun, 21 Feb 2021 07:54:08 +0000 (08:54 +0100)]
ntpd: increase loglevel to 3 for "poll:32s sockets:0 interval:64s" message

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agoudhcpc: clarify bcast/unicast sends in logs, include server ID
Denys Vlasenko [Sat, 20 Feb 2021 17:09:54 +0000 (18:09 +0100)]
udhcpc: clarify bcast/unicast sends in logs, include server ID

Before:
    sending discover
    sending select for 192.168.1.173
    lease of 192.168.1.173 obtained, lease time 43200
    sending renew to 192.168.1.1
    lease of 192.168.1.173 obtained, lease time 43200
After:
    broadcasting discover
    broadcasting select for 192.168.1.173, server 192.168.1.1
    lease of 192.168.1.173 obtained from 192.168.1.1, lease time 43200
    sending renew to server 192.168.1.1
    lease of 192.168.1.173 obtained from 192.168.1.1, lease time 43200

function                                             old     new   delta
udhcpc_main                                         2580    2610     +30
send_select                                          104     130     +26
send_renew                                            82      99     +17
send_discover                                         94      89      -5
send_decline                                          93      88      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 73/-10)             Total: 63 bytes
   text    data     bss     dec     hex filename
1019732     559    5020 1025311   fa51f busybox_old
1019898     559    5020 1025477   fa5c5 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agolibbb: fix '--help' handling in FEATURE_SH_NOFORK=y
Denys Vlasenko [Thu, 18 Feb 2021 22:30:24 +0000 (23:30 +0100)]
libbb: fix '--help' handling in FEATURE_SH_NOFORK=y

Most BusyBox applets respond to the '--help' option by printing
a usage message.  This is normally handled by busybox_main() so
applet main routines don't have support for '--help'.

In standalone shell mode with FEATURE_SH_NOFORK enabled nofork
applets are invoked directly, bypassing busybox_main().  This
results in inconsistent handling of '--help':

- applets which call getopt() report "unrecognized option '--help'"
  and print help anyway;

- realpath says "--help: No such file or directory" and doesn't
  print help;

- usleep says "invalid number '--help'" and doesn't print help.

Avoid inconsistency by checking for '--help' in run_nofork_applet().

Bug found by Ron Yorston.

function                                             old     new   delta
show_usage_if_dash_dash_help                           -      70     +70
run_nofork_applet                                    347     362     +15
run_applet_no_and_exit                               432     365     -67
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 85/-67)             Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agoash: placate -Werror=format-security
Denys Vlasenko [Thu, 18 Feb 2021 12:44:27 +0000 (13:44 +0100)]
ash: placate -Werror=format-security

"In function 'sprint_status48':
 error: format not a string literal and no format arguments"

function                                             old     new   delta
sprint_status48                                      160     158      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2 months agoapplets/usage_pod.c: placate gcc
Denys Vlasenko [Mon, 15 Feb 2021 11:36:44 +0000 (12:36 +0100)]
applets/usage_pod.c: placate gcc

"error: format not a string literal and no format arguments"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agoMakefile.flags: fix the OS detection for libresolv
Martin Kaiser [Fri, 22 Jan 2021 21:24:05 +0000 (22:24 +0100)]
Makefile.flags: fix the OS detection for libresolv

054493350 ("Do not add -lresolv on non-Linux systems") adds a condition
to link with libresolv only on linux systems.

The check requires that CONFIG_UNAME_OSNAME equals Linux. This works only
if the uname applet is enabled. Otherwise, CONFIG_UNAME_OSNAME is empty,
regardless of the platform.

By default, CONFIG_UNAME_OSNAME is the output of uname -o. For most
linux systems, uname -o returns "GNU/Linux" and the check fails. In this
case, linking a static busybox fails because of missing symbols from
libresolv.

networking/lib.a(nslookup.o): In function `add_query':
nslookup.c:789: undefined reference to `__res_mkquery'
networking/lib.a(nslookup.o): In function `parse_reply':
nslookup.c:355: undefined reference to `ns_initparse'
nslookup.c:361: undefined reference to `ns_parserr'
nslookup.c:404: undefined reference to `ns_name_uncompress'
nslookup.c:418: undefined reference to `ns_get16'
nslookup.c:419: undefined reference to `ns_name_uncompress'
..
nslookup.c:456: undefined reference to `ns_get16'
...
nslookup.c:469: undefined reference to `ns_name_uncompress'
...
nslookup.c:489: undefined reference to `ns_get32'
...
collect2: error: ld returned 1 exit status

This patch uses the output of $CC -dumpmachine to detect the target platform
for which we compile. Both gcc and clang support -dumpmachine. Like the
original patch, we link against libresolv only if our target platform is
linux-based.

Fixes: 054493350 ("Do not add -lresolv on non-Linux systems")
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
3 months agolibbb: introduce and use fputs_stdout
Ron Yorston [Wed, 3 Feb 2021 19:47:14 +0000 (20:47 +0100)]
libbb: introduce and use fputs_stdout

function                                             old     new   delta
fputs_stdout                                           -      12     +12
zxc_vm_process                                      7237    7230      -7
yes_main                                              85      78      -7
write_block                                          380     373      -7
wrapf                                                305     298      -7
strings_main                                         437     430      -7
show_bridge                                          353     346      -7
rev_main                                             384     377      -7
put_prompt_custom                                     58      51      -7
put_cur_glyph_and_inc_cursor                         168     161      -7
print_numbered_lines                                 152     145      -7
print_named_ascii                                    130     123      -7
print_name                                           135     128      -7
print_login_issue                                    386     379      -7
print_ascii                                          208     201      -7
powertop_main                                       1249    1242      -7
od_main                                             1789    1782      -7
logread_main                                         518     511      -7
head_main                                            804     797      -7
display_process_list                                1319    1312      -7
cut_main                                            1002     995      -7
bb_dump_dump                                        1550    1543      -7
bb_ask_noecho                                        393     386      -7
baseNUM_main                                         702     695      -7
expand_main                                          755     745     -10
dumpleases_main                                      497     487     -10
write1                                                12       -     -12
putcsi                                                37      23     -14
print_login_prompt                                    55      41     -14
paste_main                                           525     511     -14
cat_main                                             440     426     -14
print_it                                             245     230     -15
print_addrinfo                                      1188    1171     -17
print_rule                                           770     750     -20
print_linkinfo                                       842     822     -20
httpd_main                                           791     771     -20
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341)         Total: -329 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agolibbb: code shrink fgets_str
Ron Yorston [Sat, 23 Jan 2021 13:22:33 +0000 (13:22 +0000)]
libbb: code shrink fgets_str

Use a NULL value of maxsz_p to indicate to xmalloc_fgets_internal()
that the caller doesn't care about the maximum size of the buffer.
This allows the default maximum size to be set once in
xmalloc_fgets_internal() instead of separately in each caller.

function                                             old     new   delta
xmalloc_fgets_internal                               273     287     +14
xmalloc_fgets_str                                     30       9     -21
xmalloc_fgetline_str                                  33      12     -21
xmalloc_fgets_str_len                                 38      10     -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 14/-70)            Total: -56 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agonl: ensure '-b n' option displays file content
Ron Yorston [Thu, 21 Jan 2021 08:40:54 +0000 (08:40 +0000)]
nl: ensure '-b n' option displays file content

The command 'nl -b n' should output no line numbers, just some
spaces as a placeholder followed by the actual file content.

Add tests for line numbering by cat and nl.  The correct results
were obtained from coreutils.

function                                             old     new   delta
print_numbered_lines                                 152     157      +5
.rodata                                           182456  182453      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-3)                Total: 2 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agocryptpw: typo in usage message
Ron Yorston [Tue, 26 Jan 2021 13:02:03 +0000 (13:02 +0000)]
cryptpw: typo in usage message

'[-p N]' should be '[-P N]' in the trivial usage message.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agovi: fix range selection by forward character motion
Ron Yorston [Mon, 1 Feb 2021 11:54:15 +0000 (11:54 +0000)]
vi: fix range selection by forward character motion

Selection of ranges for change/delete/yank by forward character
motion commands (SPACE or 'l') was incorrect.  The range was
always one character whereas vi allows the size of the range to
be specified.

Fix this by executing the motion command the required number of times.
There is a complication when the range is at the end of a line.  We need
to distinguish between a range which excludes the last character and
one which includes it.  This requires comparing the actual range with
that expected from the command count.  (With the additional quirk that
a command count of zero is equivalent to a command count of one.)

function                                             old     new   delta
find_range                                           587     619     +32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 32/0)               Total: 32 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agolibbb: code shrink and speed up index_in_strings()
Ron Yorston [Fri, 29 Jan 2021 13:23:27 +0000 (13:23 +0000)]
libbb: code shrink and speed up index_in_strings()

Rewrite index_in_strings() to replace calls to strcmp()/strlen().
With this change searching for valid names in the applet_names
array (for example) is 40% faster.

The code has to assume the strings aren't sorted, so will always scan
the entire array when presented with an invalid name.

function                                             old     new   delta
index_in_strings                                      63      56      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-7)               Total: -7 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agolibbb: code shrink and speed up find_applet_by_name()
Ron Yorston [Fri, 29 Jan 2021 13:22:48 +0000 (13:22 +0000)]
libbb: code shrink and speed up find_applet_by_name()

find_applet_by_name() determines the appropriate range of applet
indices to check for the given name and performs a linear search in
applet_names[].

Revise the code so the index of the upper bound of the range, 'max',
isn't calculated.  Instead check the value of the first non-matching
character to see if we've reached the end of the range.

This new code speeds up the time to find a valid applet name by 6%
and halves the time to detect that a given name is invalid.  The
average time to detect an invalid name is now the same as for a valid
one.

function                                             old     new   delta
find_applet_by_name                                  155     133     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-22)             Total: -22 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agoawk: allow printf('%c') to output NUL, closes 13486
Ron Yorston [Wed, 27 Jan 2021 11:19:14 +0000 (11:19 +0000)]
awk: allow printf('%c') to output NUL, closes 13486

Treat the output of printf as binary rather than a null-terminated
string so that NUL characters can be output.

This is considered to be a GNU extension, though it's also available
in mawk and FreeBSD's awk.

function                                             old     new   delta
evaluate                                            3487    3504     +17
awk_printf                                           504     519     +15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0)               Total: 32 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agotraceroute: fix option parsing
Denys Vlasenko [Tue, 2 Feb 2021 12:48:21 +0000 (13:48 +0100)]
traceroute: fix option parsing

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agoupdate_passwd: fix context variable
Bernd Kuhls [Sun, 10 Jan 2021 12:20:44 +0000 (13:20 +0100)]
update_passwd: fix context variable

Commit
https://git.busybox.net/busybox/commit/libbb/update_passwd.c?id=2496616b0a8d1c80cd1416b73a4847b59b9f969a

changed the variable used from context to seuser but forgot this
change resulting in build errors detected by buildroot autobuilders:

http://autobuild.buildroot.net/results/b89/b89b7d0f0601bb706e76cea31cf4e43326e5540c//build-end.log

libbb/update_passwd.c:51:11: error: 'context' undeclared (first use in
 this function); did you mean 'ucontext'?
   freecon(context);

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agoash: match bash behavior for ${empty_var/*/repl}
Denys Vlasenko [Sat, 9 Jan 2021 07:46:54 +0000 (08:46 +0100)]
ash: match bash behavior for ${empty_var/*/repl}

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
3 months agoash: fix ${unset_var/pattern/repl}
Denys Vlasenko [Sat, 9 Jan 2021 07:27:37 +0000 (08:27 +0100)]
ash: fix ${unset_var/pattern/repl}

function                                             old     new   delta
subevalvar                                          1349    1353      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agobc: code shrink
Denys Vlasenko [Wed, 6 Jan 2021 13:00:53 +0000 (14:00 +0100)]
bc: code shrink

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agopmap: fix column width, closes 13431
Denys Vlasenko [Tue, 5 Jan 2021 18:39:34 +0000 (19:39 +0100)]
pmap: fix column width, closes 13431

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix for the FEATURE_UTMP on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 18:35:09 +0000 (19:35 +0100)]
Fix for the FEATURE_UTMP on the FreeBSD

FreeBSD is not using <utmp.h> and does not define _PATH_UTMPX.
Tested with busybox applets depending on FEATURE_UTMP (e.g. who, users, etc)

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agobc: ^C on input line exits (unlike ^C during calculations, which does not)
Denys Vlasenko [Mon, 4 Jan 2021 13:41:20 +0000 (14:41 +0100)]
bc: ^C on input line exits (unlike ^C during calculations, which does not)

function                                             old     new   delta
xc_read_line                                         353     344      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix mail compilation on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 00:18:44 +0000 (01:18 +0100)]
Fix mail compilation on the FreeBSD

FreeBSD using procctl instead of Linux prctl

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix traceroute applet on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 00:41:34 +0000 (01:41 +0100)]
Fix traceroute applet on the FreeBSD

This patch addressing 2 issues:

1. Replacing source/dest with uh_sport/uh_dport. It seems that uh_* members are
   defined on both Linux and BSD, so no #ifdef here
2. Use SOL_IPV6 instead of SOL_RAW on the FreeBSD to fix IPV6_CHECKSUM setsockopt

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix ping build on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 00:31:11 +0000 (01:31 +0100)]
Fix ping build on the FreeBSD

- Define iphdr structure to build busybox/ping
- Add missing includes

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix ntpd compilcation on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 00:28:39 +0000 (01:28 +0100)]
Fix ntpd compilcation on the FreeBSD

FreeBSD using different constant names, defining them inline

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix mknod compilation on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 00:25:48 +0000 (01:25 +0100)]
Fix mknod compilation on the FreeBSD

<sys/sysmacros.h> is linux-only
FreeBSD defines makedev in sys/types.h already included in the libbb.h.

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix missing "crypt.h" compilation error on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 00:36:05 +0000 (01:36 +0100)]
Fix missing "crypt.h" compilation error on the FreeBSD

FreeBSD does not use crypt.h, but unistd.h which is already included

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix klogd applet compilation on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 00:11:57 +0000 (01:11 +0100)]
Fix klogd applet compilation on the FreeBSD

FreeBSD also using /dev/klog, see syslogd(8)

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix httpd compilation on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 00:16:28 +0000 (01:16 +0100)]
Fix httpd compilation on the FreeBSD

FreeBSD is not exporting s6_addr32 by default, but has it.

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoFix bb_setpgrp weapper on the FreeBSD
Alex Samorukov [Mon, 4 Jan 2021 00:33:32 +0000 (01:33 +0100)]
Fix bb_setpgrp weapper on the FreeBSD

FreeBSD uses setpgrp(pid_t, pid_t)
This patch makes crond.c and probably others compilable

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoDo not add -lresolv on non-Linux systems
Alex Samorukov [Mon, 4 Jan 2021 00:22:24 +0000 (01:22 +0100)]
Do not add -lresolv on non-Linux systems

On FreeBSD getaddrinfo and friends are part of libc.
Other OS-es will also have own dependencies

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoash: improve --help
Denys Vlasenko [Mon, 4 Jan 2021 02:50:38 +0000 (03:50 +0100)]
ash: improve --help

function                                             old     new   delta
packed_usage                                       33504   33499      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agohush: code shrink
Denys Vlasenko [Mon, 4 Jan 2021 02:05:34 +0000 (03:05 +0100)]
hush: code shrink

function                                             old     new   delta
hush_main                                           1071    1066      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5)               Total: -5 bytes
   text    data     bss     dec     hex filename
1020110     559    5020 1025689   fa699 busybox_old
1020037     559    5020 1025616   fa650 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agonuke: default to N
Denys Vlasenko [Sun, 3 Jan 2021 15:48:53 +0000 (16:48 +0100)]
nuke: default to N

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoash: code shrink
Denys Vlasenko [Sun, 3 Jan 2021 11:14:58 +0000 (12:14 +0100)]
ash: code shrink

function                                             old     new   delta
ash_main                                            1218    1202     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoash: make a strdup copy of $HISTFILE for line editing
Denys Vlasenko [Sun, 3 Jan 2021 09:55:39 +0000 (10:55 +0100)]
ash: make a strdup copy of $HISTFILE for line editing

Otherwise if $HISTFILE is unset or reassigned, bad things can happen.

function                                             old     new   delta
ash_main                                            1210    1218      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoudhcpc: Add support to change default interface name
Andre Kalb [Tue, 5 May 2020 16:24:25 +0000 (18:24 +0200)]
udhcpc: Add support to change default interface name

Signed-off-by: Andre Kalb <Andre.Kalb@sma.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agotls: code shrink
Denys Vlasenko [Fri, 1 Jan 2021 17:48:38 +0000 (18:48 +0100)]
tls: code shrink

function                                             old     new   delta
curve25519                                           881     832     -49

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agotar: add TODO about a bug with non-writable directories on extract
Denys Vlasenko [Fri, 1 Jan 2021 12:34:25 +0000 (13:34 +0100)]
tar: add TODO about a bug with non-writable directories on extract

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agonslookup: do not print "No answer" for NODATA replies, closes 13006
Denys Vlasenko [Thu, 31 Dec 2020 00:39:44 +0000 (01:39 +0100)]
nslookup: do not print "No answer" for NODATA replies, closes 13006

Only print when there was no answer at all.

function                                             old     new   delta
send_queries                                        1834    1813     -21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agolibbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in shells
Denys Vlasenko [Wed, 30 Dec 2020 22:48:01 +0000 (23:48 +0100)]
libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in shells

function                                             old     new   delta
xgettimeofday                                          -      11     +11
get_local_var_value                                  280     281      +1
svlogd_main                                         1323    1322      -1
change_epoch                                          67      66      -1
timestamp_and_log                                    461     458      -3
hwclock_main                                         301     298      -3
fmt_time_bernstein_25                                135     132      -3
step_time                                            331     326      -5
script_main                                         1207    1202      -5
machtime                                              34      28      -6
curtime                                               61      54      -7
ts_main                                              423     415      -8
nmeter_main                                          761     751     -10
gettime1900d                                          67      46     -21
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/12 up/down: 12/-73)           Total: -61 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agolibbb/procps: smaller global data for username/groupname cache
Denys Vlasenko [Wed, 30 Dec 2020 00:04:56 +0000 (01:04 +0100)]
libbb/procps: smaller global data for username/groupname cache

function                                             old     new   delta
get_cached                                           101     133     +32
cache_user_group                                       -       4      +4
get_cached_username                                   17      14      -3
username                                               8       -      -8
groupname                                              8       -      -8
clear_username_cache                                  65      47     -18
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 1/2 up/down: 36/-37)             Total: -1 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months ago*: use fopen helpers where appropriate
Denys Vlasenko [Tue, 29 Dec 2020 23:16:27 +0000 (00:16 +0100)]
*: use fopen helpers where appropriate

function                                             old     new   delta
finalize                                             348     343      -5
parse_resolvconf                                     306     299      -7
list_i2c_busses_and_exit                             495     483     -12
bootchartd_main                                     1091    1076     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-39)             Total: -39 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agohttpd: fix offset for sendfile
Maxim Storchak [Tue, 29 Dec 2020 15:29:05 +0000 (17:29 +0200)]
httpd: fix offset for sendfile

If the Range: header is not present it the request,
the offset passed to sendfile is wrong,
and httpd falls back to the read-write loop.

function                                             old     new   delta
send_file_and_exit                                   857     865      +8
handle_incoming_and_exit                            2239    2230      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 8/-9)               Total: -1 bytes

Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agobc,dc: make BC_LINE_LENGTH/DC_LINE_LENGTH more compatible with GNU
Denys Vlasenko [Tue, 29 Dec 2020 17:50:56 +0000 (18:50 +0100)]
bc,dc: make BC_LINE_LENGTH/DC_LINE_LENGTH more compatible with GNU

function                                             old     new   delta
xc_vm_init                                           640     682     +42

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoStart 1.34.0 development cycle
Denys Vlasenko [Tue, 29 Dec 2020 16:43:40 +0000 (17:43 +0100)]
Start 1.34.0 development cycle

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoBump version to 1.33.0
Denys Vlasenko [Tue, 29 Dec 2020 16:42:59 +0000 (17:42 +0100)]
Bump version to 1.33.0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agolibiproute: band-aid for old uclibc missing IFA_FLAGS
Denys Vlasenko [Tue, 29 Dec 2020 16:33:22 +0000 (17:33 +0100)]
libiproute: band-aid for old uclibc missing IFA_FLAGS

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agomodprobe-small: convert to new recursive_action() API
Denys Vlasenko [Tue, 29 Dec 2020 15:55:59 +0000 (16:55 +0100)]
modprobe-small: convert to new recursive_action() API

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agobc: placate gcc (it thinks 's' can be uninitialized here)
Denys Vlasenko [Tue, 29 Dec 2020 15:54:37 +0000 (16:54 +0100)]
bc: placate gcc (it thinks 's' can be uninitialized here)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agorandomconfig fixes
Denys Vlasenko [Tue, 29 Dec 2020 15:53:11 +0000 (16:53 +0100)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agohush: make comment more clear
Denys Vlasenko [Sun, 27 Dec 2020 15:04:54 +0000 (16:04 +0100)]
hush: make comment more clear

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agoman: implement SECTION parameters
Denys Vlasenko [Sun, 27 Dec 2020 15:02:37 +0000 (16:02 +0100)]
man: implement SECTION parameters

function                                             old     new   delta
man_main                                             807     942    +135
is_section_name                                        -      52     +52
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 187/0)             Total: 187 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
4 months agotypo fix
Denys Vlasenko [Fri, 25 Dec 2020 18:08:16 +0000 (19:08 +0100)]
typo fix

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