Commit Graph

16709 Commits

Author SHA1 Message Date
Sergey Ponomarev
b414cdf5b4 httpd: Update to HTTP/1.1
HTTP v1.1 was released in 1999 year and it's time to update BB HTTPD.
Browsers may behave badly with HTTP/1.0
E.g. Chrome does not send the If-None-Match header with ETag.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-15 22:51:14 +02:00
Eddie James
1a5d6fcbb5 hwclock: Fix settimeofday for glibc v2.31+
The glibc implementation changed for settimeofday, resulting in "invalid
argument" error when attempting to set both timezone and time with a single
call. Fix this by calling settimeofday twice

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-15 22:29:00 +02:00
Denys Vlasenko
a77f3ecf68 grep: for -L, exitcode 0 means files *without* matches were found, closes 13151
This is a recent change in GNU grep as well (after 3.1)

function                                             old     new   delta
grep_file                                           1215    1228     +13

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-15 00:39:30 +02:00
Ron Yorston
5c69ad0ecd build system: drop PLATFORM_LINUX
PLATFORM_LINUX is a hidden configuration option which is disabled by
default and enabled at over a hundred locations for features that are
deemed to be Linux specific.

The only effect of PLATFORM_LINUX is to control compilation of
libbb/match_fstype.c.  This file is only needed by mount and umount.

Remove all references to PLATFORM_LINUX and compile match_fstype.c
if mount or umount is enabled.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-13 17:12:56 +02:00
Martin Lewis
9914d8b861 udhcpc: add support for long options
Duplicate options are currently overridden (only the last option is kept).
This leads to unexpected behavior when using long options.

The patch adds support for long options in compliance with RFC 3396.

Fixes #13136.

function                                             old     new   delta
udhcp_run_script                                     601     725    +124
optitem_unset_env_and_free                             -      38     +38
putenvp                                               46      59     +13
static.xmalloc_optname_optval                        718     717      -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 175/-1)            Total: 174 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-13 16:48:07 +02:00
Christian Eggers
8a485b0a36 ip address: Add support for "valid_lft" and "preferred_lft" options
Signed-off-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-31 18:48:50 +02:00
Christian Eggers
31d34f3bd8 ip: Add support for "noprefixroute" option
The "noprefixroute" option suppresses automatic generation of a routing
table entry based on the interface's ip address.

The ifa_flags field has only 8 bit. If higher bits are set,
rta_tb[IFA_FLAGS] has to be used instead.

Signed-off-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-31 18:45:36 +02:00
Christian Eggers
39925026f6 shell: Fix "read -d ''" behavior
With bash's read builtin it is possible to read from a file (e.g.
device-tree) until the first '\0' character:

IFS= read -r -d '' VARIABLE < file

In busybox ash the -d extension is also implemented, but checking the
read character for '\0' has to be performed after comparing with the
delimiter.

Signed-off-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-31 18:42:30 +02:00
Sergey Ponomarev
a088da4476 httpd_indexcgi.c: use CSS for odd/even rows
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-31 18:14:54 +02:00
Sergey Ponomarev
197ae0f9ae httpd_indexcgi.c: minimize style CSS
Remove new lines \n and some semicolons ;. This minimize page style size from 655 to 604

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-31 17:53:48 +02:00
Denys Vlasenko
2dd82f465e lsscsi: code shrink
function                                             old     new   delta
lsscsi_main                                          298     302      +4
get_line                                              56      45     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-11)              Total: -7 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-20 02:03:02 +02:00
Denys Vlasenko
9a2d899273 ntpd: fix refid reported in server mode, closes 13056
function                                             old     new   delta
resolve_peer_hostname                                129     196     +67
recv_and_process_peer_pkt                           2475    2476      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 68/0)               Total: 68 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-20 00:04:33 +02:00
Denys Vlasenko
06a407c628 networking: support ftp PASV responses not ending with ')'
Patch by Baruch Burstein <bmburstein@gmail.com>

function                                             old     new   delta
parse_pasv_epsv                                      153     181     +28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-19 20:59:35 +02:00
Denys Vlasenko
79a4032eef libbb: shrink last_char_is(), no longer allow NULL string argument
function                                             old     new   delta
last_char_is                                          40      28     -12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-19 20:49:22 +02:00
Martin Lewis
4468c569f7 domain_codec: optimize dname_dec and convert_dname
dname_dec: now iterates over the packet only once.
convert_dname: remove redundant checks and code shrink.

While testing I've noticed that some of the tests didn't compile
properly, so I fixed them.

function                                             old     new   delta
dname_dec                                            286     267     -19
dname_enc                                            166     143     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-42)             Total: -42 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-12 21:19:13 +02:00
Gray Wolf
051665ef69 crontab: Fix -e with editors saving using renaming strategy
Some editors (like vim) use renaming strategy to save file. That means
they save a file to some random name and then rename it to final
location. The advantage is that such save is atomic.

However, crontab -e holds open fd to the temporary file, meaning it
never sees the changes. The temporary file needs to be re-opened after
the editor terminates for the changes to properly save.

Fixes #12491

Signed-off-by: Gray Wolf <wolf@wolfsden.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-11 17:02:37 +02:00
Denys Vlasenko
d21a63f9fc libbb: code shrink in last_char_is()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-30 08:33:02 +02:00
Martin Lewis
c9fc15359e compare_string_array: code shrink
Code shrink and prevention of possible out of bounds access.

function                                             old     new   delta
nth_string                                            36      26     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-10)             Total: -10 bytes
   text	   data	    bss	    dec	    hex	filename
 981342	  16915	   1872	1000129	  f42c1	busybox_old
 981332	  16915	   1872	1000119	  f42b7	busybox_unstripped

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 16:09:46 +02:00
Martin Lewis
ac79db6a3b procps: code shrink
function                                             old     new   delta
skip_whitespace_if_prefixed_with                       -      17     +17
procps_read_smaps                                    911     854     -57
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 17/-57)            Total: -40 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 16:07:20 +02:00
Martin Lewis
1f86ecb729 udhcpc: fix a TODO in fill_envp using option scanner
fill_envp now iterates over the packet only once instead of a few hundred times
using the new option scanner.

function                                             old     new   delta
udhcp_scan_options                                     -     189    +189
putenvp                                                -      46     +46
init_scan_state                                        -      22     +22
udhcp_get_option                                     227     104    -123
udhcp_run_script                                     835     601    -234
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 0/2 up/down: 257/-357)         Total: -100 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 15:26:09 +02:00
Martin Lewis
acdc8eed89 udhcp: add option scanner
Added an option scanner to udhcp to enable iteration over packet options.

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:57:02 +02:00
Scott Court
fc2ce04a38 wget: fix openssl options for cert verification
function                                             old     new   delta
is_ip_address                                          -      54     +54
spawn_https_helper_openssl                           461     486     +25
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 79/0)               Total: 79 bytes

Signed-off-by: Scott Court <z5t1@z5t1.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:32:09 +02:00
Norbert Lange
79bd7c3f7b acpid: only display -p if supported in usage
Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:11:03 +02:00
Norbert Lange
05faa6103b dhcpd: remove hardcoded pidfile path
Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:07:57 +02:00
Norbert Lange
86a633ef9a dpkg: prevent important directories from being removed
busybox will remove directory symlinks, which is at
odds with common layouts that have some of
bin/lib/lib32/lib64 symlinked.

this adds a exludelist for critcal and often symlinked
directories.

Fixes: Bug 12551

function                                             old     new   delta
remove_file_array                                    139     231     +92

Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:06:40 +02:00
Norbert Lange
a16c8ef212 nc_bloaty: support udp broadcast ports
Add a -b option, identical to debians "traditional" netcat.
This allows sending (subnet) UDP Broadcasts.

function                                             old     new   delta
packed_usage                                       33420   33441     +21
nc_main                                             1041    1057     +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 37/0)               Total: 37 bytes

Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 13:53:17 +02:00
Denys Vlasenko
c918ea1673 Start 1.33.0 development cycle
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-26 21:30:50 +02:00
Denys Vlasenko
fb957125d8 Bump version to 1.32.0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-26 21:22:50 +02:00
Denys Vlasenko
24c212b9ac gzip -d with zcat enabled but gunzip disabled was misbehaving
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-25 02:01:29 +02:00
Denys Vlasenko
b02f8ca909 make_single_applets.sh: switch off nologin deps option
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 16:36:44 +02:00
Denys Vlasenko
5663a17dab bc: placate a "defined but not used" warning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 15:05:29 +02:00
Denys Vlasenko
67e1529b92 nologin: make it possible to build it as single applet
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 15:05:22 +02:00
Denys Vlasenko
d5314e7129 suppress a few compile warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 09:31:30 +02:00
Denys Vlasenko
7c443d110d randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 00:27:37 +02:00
Denys Vlasenko
5fa5c4bde8 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-23 21:28:19 +02:00
Denys Vlasenko
d206b1651a randomconfig fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-23 09:38:53 +02:00
Denys Vlasenko
03ab212bff randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-23 03:43:39 +02:00
Denys Vlasenko
df1f479fc5 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-23 03:13:55 +02:00
Denys Vlasenko
6eb38fded2 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-23 02:46:53 +02:00
Stefan Agner
62744efa47 examples/udhcp/simple.script: fix IPv6 support when using udhcpc
The udhcpc script calls ip addr flush .. which flushes addresses
of any address family, including IPv6. However, busybox udhcpc is
IPv4 only and should not influence IPv6 addressing. Hence use ip
addr flush with family constraint.

The script particularly broke IPv6 SLAAC: Typically when udhcpc
calls the script the kernel already assigned the IPv6 link-local
address. The flush removes the link-local IPv6 address again and
prohibits proper IPv6 operation such as SLAAC since neighbor
discovery protocol relies on IPv6 link-local addressing.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
[Taken from https://git.openembedded.org/openembedded-core/commit/meta/recipes-core/busybox/files/simple.script?id=b77541dbb2f442e51842f9d24c8745a6df2d1478]
Signed-off-by: Quentin Schulz <quentin.schulz@streamunlimited.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-21 03:02:02 +02:00
Uwe Glaeser
faab906d28 udhcpc6: use correct multicast MAC
function                                             old     new   delta
static.MAC_DHCP6MCAST_ADDR                             -       6      +6

Signed-off-by: Uwe Glaeser <uwe.glaeser@dormakaba.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-21 02:56:12 +02:00
Denys Vlasenko
4789c7cd81 nmeter: add %T (zero-based timestamp) format
function                                             old     new   delta
collect_tv                                             -     132    +132
collect_monotonic                                      -      61     +61
nmeter_main                                          754     778     +24
gmtime                                                 -      21     +21
init_monotonic                                         -      18     +18
init_functions                                        44      48      +4
packed_usage                                       33432   33420     -12
collect_time                                         125      19    -106
------------------------------------------------------------------------------
(add/remove: 5/0 grow/shrink: 2/2 up/down: 260/-118)          Total: 142 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-10 15:37:39 +02:00
Biswapriyo Nath
505eeae402 Makefile.flags: restrict Wno-constant-logical-operand and Wno-string-plus-int options for clang
these options were added in b4ef2e3467 commit
gcc shows unrecognized command-line option warnings

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-10 14:33:19 +02:00
Sören Tempel
0356607264 deluser: check if specified home is a directory before removing it
On Alpine, some users use /dev/null as a home directory. When removing
such a user with `deluser --remove-home` this causes the /dev/null
device file to be removed which is undesirable. To prevent this pitfall,
check if the home directory specified for the user is an actual
directory (or a symlink to a directory).

Implementations of similar tools for other operating systems also
implement such checks. For instance, the OpenBSD rmuser(1)
implementation [0].

[0]: b69faa6c70/usr.sbin/adduser/rmuser.perl (L143-L151)

function                                             old     new   delta
deluser_main                                         337     380     +43

Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 18:04:31 +02:00
Martin Lewis
d30d1ebc11 dhcpc: refactor xmalloc_optname_optval to shrink binary size
function                                             old     new   delta
len_of_option_as_string                               14      13      -1
dhcp_option_lengths                                   14      13      -1
udhcp_str2optset                                     641     637      -4
static.xmalloc_optname_optval                        777     718     -59
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-65)             Total: -65 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 17:59:56 +02:00
Ron Yorston
17764603f2 httpd: allow '-h' to work when daemonized with NOMMU enabled
Commit d1b75e184 (httpd: permit non-default home directory with NOMMU
enabled) only works when used with the '-f' (foreground) option.

When '-f' isn't specified and NOMMU is enabled bb_daemonize_or_rexec()
is called to daemonize the server.  Since the server process has been
re-execed the previous patch results in the xchdir() not being called.

Fix this by resetting the re_execed variable in this case.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 17:38:21 +02:00
Denys Vlasenko
0cad5f9b6d udhcp: comment out unused domain compression code
function                                             old     new   delta
attach_option                                        411     406      -5
dname_enc                                            381     167    -214
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-219)           Total: -219 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 17:22:06 +02:00
Denys Vlasenko
002be6e821 sysctl: do report EACCES errors on write
function                                             old     new   delta
sysctl_act_recursive                                 165     179     +14
sysctl_act_on_setting                                467     471      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 18/0)               Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 15:58:32 +02:00
Mark Edgar
b2ab920716 unexpand: correct behavior for --first-only --tabs=4
Prior to the patch, both -f and --first-only are in all cases either
no-op or ignored.
Without --tabs, --first-only is the default so specifying it is a no-op.
With --tabs, --all is implied, and --first-only is intended to reset this.

function                                             old     new   delta
expand_main                                          690     694      +4

Signed-off-by: Mark Edgar <medgar123@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 15:40:49 +02:00
Martin Lewis
9b4a9d96b8 xstrndup: Use strndup instead of implementing it.
Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 01:55:59 +02:00