Commit Graph

2276 Commits

Author SHA1 Message Date
Martin Lewis
7011eca83a replace: count_strstr - Handle an edge case where sub is empty
If sub is empty, avoids an infinite loop.

function                                             old     new   delta
count_strstr                                          45      63     +18

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-09 14:39:41 +02:00
Martin Lewis
dd46861282 libbb: Converted safe_read to safe_write format
Changed safe_read to be symmetrical to safe_write, it shall
never return EINTR because it calls read multiple times,
the error is considered transient.

function                                             old     new   delta
safe_read                                             44      57     +13

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-09 14:35:55 +02:00
Alistair Francis
902d399292 time: Use 64 prefix syscall if we have to
Some 32-bit architectures no longer have the 32-bit time_t syscalls.
Instead they have suffixed syscalls that returns a 64-bit time_t. If
the architecture doesn't have the non-suffixed syscall and is using a
64-bit time_t let's use the suffixed syscall instead.

This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
headers.

If an architecture only supports the suffixed syscalls, but is still
using a 32-bit time_t report a compilation error. This avoids us have to
deal with converting between 64-bit and 32-bit values. There are
currently no architectures where this is the case.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-08 16:31:54 +02:00
Denys Vlasenko
dac0a7d234 unicode: code shrink in character width determination
function                                             old     new   delta
bb_wcwidth                                           267     238     -29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-23 11:26:54 +02:00
Denys Vlasenko
4767a5375e libbb: include <crypt.h> only if necessary
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-16 15:09:06 +02:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
25a871fb40 libbb: deal with "declaration of 'link' shadows a global declaration" warning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-25 18:51:00 +02:00
Denys Vlasenko
3a0eea0887 pidof: support "pidof /path/to/binary" case
function                                             old     new   delta
find_pid_by_name                                     230     227      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-15 18:35:39 +02:00
Denys Vlasenko
070aa61747 readlink,realpath: fix a case with a symplink, closes 11021
function                                             old     new   delta
xmalloc_realpath_coreutils                           125     201     +76

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-13 17:09:05 +02:00
Denys Vlasenko
3b69ba799f mount,losetup: use /dev/loop-control is it exists
function                                             old     new   delta
get_free_loop                                          -      58     +58
set_loop                                             597     649     +52
losetup_main                                         482     476      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 110/-6)            Total: 104 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-09 23:20:49 +02:00
Denys Vlasenko
3b8025f132 tftp: optional tftp-hpa compat
function                                             old     new   delta
tftp_main                                            276     394    +118

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-09 11:12:02 +02:00
Denys Vlasenko
a5c5dc6f0b passwd: do not set 0 as date of last password change, closes 11951
function                                             old     new   delta
update_passwd                                       1491    1505     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-07 12:30:23 +02:00
Denys Vlasenko
45e3967c20 libbb: move netlink socket binding to the utility function
function                                             old     new   delta
create_and_bind_to_netlink                             -     134    +134
ifplugd_main                                        1117    1052     -65
uevent_main                                          399     306     -93
mdev_main                                            314     215     -99
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 134/-257)         Total: -123 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-03 14:16:52 +02:00
Denys Vlasenko
dff2bd733f libarchive: treat one "FIXME: avoid seek"
function                                             old     new   delta
xmalloc_read_with_initial_buf                          -     205    +205
setup_transformer_on_fd                              154     150      -4
xmalloc_open_zipped_read_close                       143     135      -8
xmalloc_read                                         201      10    -191
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 205/-203)            Total: 2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-24 17:03:28 +02:00
Denys Vlasenko
875ce094cf dd: fix handling of short result of full_write(), closes 11711
$ dd bs=1G <sda1 of=/dev/sda1
dd: error writing '/dev/sda1': No space left on device
1+0 records in
0+0 records out
999292928 bytes (953.0MB) copied, 0.784617 seconds, 1.2GB/s

function                                             old     new   delta
write_and_stats                                       99     102      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-14 17:49:14 +02:00
Denys Vlasenko
8c317f03f6 style fix, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-14 17:26:47 +02:00
James Byrne
253c4e787a Optionally re-introduce bb_info_msg()
Between Busybox 1.24.2 and 1.25.0 the bb_info_msg() function was
eliminated and calls to it changed to be bb_error_msg(). The downside of
this is that daemons now log all messages to syslog at the LOG_ERR level
which makes it hard to filter errors from informational messages.

This change optionally re-introduces bb_info_msg(), controlled by a new
option FEATURE_SYSLOG_INFO, restores all the calls to bb_info_msg() that
were removed (only in applets that set logmode to LOGMODE_SYSLOG or
LOGMODE_BOTH), and also changes informational messages in ifplugd and
ntpd.

The code size change of this is as follows (using 'defconfig' on x86_64
with gcc 7.3.0-27ubuntu1~18.04)

function                                             old     new   delta
bb_info_msg                                            -     182    +182
bb_vinfo_msg                                           -      27     +27
static.log7                                          194     198      +4
log8                                                 190     191      +1
log5                                                 190     191      +1
crondlog                                              45       -     -45
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/0 up/down: 215/-45)           Total: 170 bytes

If you don't care about everything being logged at LOG_ERR level
then when FEATURE_SYSLOG_INFO is disabled Busybox actually gets smaller:

function                                             old     new   delta
static.log7                                          194     200      +6
log8                                                 190     193      +3
log5                                                 190     193      +3
syslog_level                                           1       -      -1
bb_verror_msg                                        583     581      -2
crondlog                                              45       -     -45
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 3/1 up/down: 12/-48)            Total: -36 bytes

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-30 10:51:27 +02:00
Denys Vlasenko
f3a064f495 libbbb: find_mount_point() too eager to stat mounted devices
None of the below "devices" (first word on the line) are real.

sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,nosuid,size=7917900k,nr_inodes=1979475,mode=755 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
tmpfs /tmp tmpfs rw,relatime 0 0

function                                             old     new   delta
find_mount_point                                     297     302      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-29 17:59:08 +02:00
Denys Vlasenko
fa8878bf1f start-stop-daemon: do try to close fds > 2
sh -c 'exec 3>&1; exec start-stop-daemon -S -b -x /bin/sleep -- 123'

now closes fd 3.

function                                             old     new   delta
bb_daemonize_or_rexec                                183     192      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 9/0)                 Total: 9 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-29 14:24:07 +02:00
Ron Yorston
3193cb56d6 libbb: mark scripted_main() as externally visible
Building with individual binaries enabled fails when embedded
script applets are included:

   /tmp/ccIvMFZg.o: In function `main':
   applet.c:(.text.main+0x20): undefined reference to `scripted_main'

Mark scripted_main() as externally visible.

Reported-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-03-30 16:46:27 +01:00
Denys Vlasenko
5059653882 do not duplicate CONFIG_PID_FILE_PATH and ".pid" strings
text	   data	    bss	    dec	    hex	filename
 981737	    485	   7296	 989518	  f194e	busybox_old
 981704	    485	   7296	 989485	  f192d	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-03-17 19:48:39 +01:00
Ron Yorston
e563f9e851 du: don't count duplicate arguments. Closes 5288
Since coreutils 8.6 (2010-10-15) du no longer counts duplicate arguments.

Revert the relevant part of commit 618a3027ed (du: fix "du /dir /dir"
case).

function                                             old     new   delta
du_main                                              302     297      -5
reset_ino_dev_hashtable                               78       -     -78
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-83)             Total: -83 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-19 17:08:39 +01:00
Denys Vlasenko
779f96a24c lineedit: fix SEGV in isk, hexedit, ed, closes 11661
fdisk, hexedit and ed calls read_line_edit in libbb/lineedit.c with NULL
as first argument. On line 2373 of lineedit.c of busybox version 1.29.3,
state->hist_file is referenced without checking the state->flag.

This causes segmentation fault on fdisk, hexedit and ed on ARM Cortex-A9.
It somehow works on x86_64.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-04 16:16:30 +01:00
Mark Marshall
11cb9eeffe capability: fix string comparison in cap_name_to_number
The result of strcasecmp was being used incorrectly.  This function
returns 0 if the strings match.

Signed-off-by: Mark Marshall <mark.marshall@omicronenergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-21 12:50:37 +01:00
Denys Vlasenko
088fec36fe start-stop-daemon: create pidfile before parent exits, closes 8596
This removes DAEMON_DOUBLE_FORK flag from bb_daemonize_or_rexec(),
as SSD was the only user.

Also includes fix for -S: now works without -a and -x,
does not print pids
(compat with "start-stop-daemon (OpenRC) 0.34.11 (Gentoo Linux)").

function                                             old     new   delta
start_stop_daemon_main                              1018    1084     +66
add_interface                                         99     103      +4
fail_hunk                                            139     136      -3
bb_daemonize_or_rexec                                205     183     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 70/-25)             Total: 45 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-14 14:47:21 +01:00
Denys Vlasenko
ff65355b8a single-applet build --help had extra \n, remove
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-01 16:54:30 +01:00
Denys Vlasenko
aad76968cd pmap: make 32-bit version work better on 64-bit kernels
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-31 15:18:45 +01:00
Denys Vlasenko
3d27d435db randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-27 18:03:20 +01:00
Denys Vlasenko
23427a63fc lineedit: fix "defined but not used" sigaction2 warning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-08 15:45:46 +01:00
Denys Vlasenko
b437df1157 inetd: suppress aliasing warning
function                                             old     new   delta
sigprocmask2                                           -       8      +8
wait_for_child_or_signal                             213     218      +5
dowait                                               424     429      +5
block_CHLD_HUP_ALRM                                   62      59      -3
sigprocmask_SIG_SETMASK                               16       -     -16
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/1 up/down: 18/-19)             Total: -1 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-08 15:35:24 +01:00
Denys Vlasenko
136fe9bede suppress gcc 8 aliasing warnings
function                                             old     new   delta
sigprocmask_SIG_SETMASK                                -      16     +16
wait_for_child_or_signal                             221     213      -8
dowait                                               432     424      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-08 13:49:15 +01:00
Denys Vlasenko
a68a87cd60 bc: unbreak FEATURE_CLEAN_UP build
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-06 11:12:38 +01:00
Denys Vlasenko
9a2b6dcc2d libbb: do not misinterpret 0x10-0x19 chars in "\xNNN" too
function                                             old     new   delta
bb_process_escape_sequence                           141     151     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-29 13:16:15 +01:00
Denys Vlasenko
480c7e5dfb libbb: @ in "\x3@" is not a valid hex digit
function                                             old     new   delta
bb_process_escape_sequence                           134     141      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-29 12:34:50 +01:00
Denys Vlasenko
c100535571 cat,nl: fix handling of open errors
$ cat -n does_not_exist; echo $?
cat: does_not_exist: No such file or directory
1

function                                             old     new   delta
print_numbered_lines                                 118     129     +11
nl_main                                              196     201      +5
cat_main                                             421     425      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 20/0)               Total: 20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-29 11:44:10 +01:00
Ron Yorston
71df2d3589 hush: allow hush to run embedded scripts
Embedded scripts require a shell to be present in the BusyBox
binary.  Allow either ash or hush to be used for this purpose.
If both are enabled ash takes precedence.

The size of the binary is unchanged in the default configuration:
both ash and hush are present but support for embedded scripts
isn't compiled into hush.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-27 16:13:07 +01:00
Denys Vlasenko
f69f207490 libbb: add comment on sha384
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-26 13:00:28 +01:00
Denys Vlasenko
26602b85a3 wget: print the final newline only for non-tty output
$ busybox wget URL 2>&1 | cat
Connecting to ....
install.iso          0% |                                | 2629k  0:02:05 ETA
install.iso          7% |**                              | 25.7M  0:00:23 ETA
install.iso         16% |*****                           | 54.1M  0:00:14 ETA
install.iso         20% |******                          | 67.4M  0:00:15 ETA
install.iso         25% |********                        | 81.0M  0:00:14 ETA
install.iso         30% |*********                       | 97.3M  0:00:13 ETA
install.iso         36% |***********                     |  117M  0:00:12 ETA
install.iso         41% |*************                   |  134M  0:00:11 ETA
install.iso         47% |***************                 |  152M  0:00:10 ETA
install.iso         54% |*****************               |  176M  0:00:08 ETA
install.iso         61% |*******************             |  200M  0:00:06 ETA
install.iso         66% |*********************           |  215M  0:00:06 ETA
install.iso         71% |**********************          |  231M  0:00:05 ETA
install.iso         75% |************************        |  244M  0:00:04 ETA
install.iso         79% |*************************       |  257M  0:00:03 ETA
install.iso         84% |***************************     |  275M  0:00:02 ETA
install.iso         91% |*****************************   |  297M  0:00:01 ETA
install.iso         99% |******************************* |  321M  0:00:00 ETA
install.iso        100% |********************************|  323M  0:00:00 ETA
  <-- no empty line here
$

function                                             old     new   delta
bb_progress_update                                   622     632     +10
progress_meter                                       152     158      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 16/0)               Total: 16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-23 19:14:52 +01:00
Ron Yorston
d1b2ae2d04 busybox: add '--show SCRIPT' option to display scripts
Add an option to allow the content of embedded scripts to be
displayed.  This includes applet scripts, custom scripts and the
.profile script.

function                                             old     new   delta
busybox_main                                         624     701     +77
find_script_by_name                                    -      24     +24
scripted_main                                         41      35      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 101/-6)             Total: 95 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-18 19:19:29 +01:00
Ron Yorston
3778898f97 Treat custom and applet scripts as applets
BusyBox has support for embedded shell scripts.  Two types can be
distinguished:  custom scripts and scripts implementing applets.

Custom scripts should be placed in the 'embed' directory at build
time.  They are given a default applet configuration and appear
as applets to the user but no further configuration is possible.

Applet scripts are integrated with the BusyBox build system and
are intended to be used to ship standard applets that just happen
to be implemented as scripts.  They can be configured at build time
and appear just like native applets.

Such scripts should be placed in the 'applets_sh' directory.  A stub
C program should be written to provide the usual applet configuration
details and placed in a suitable subsystem directory.  It may be
helpful to have a configuration option to enable any dependencies the
script requires:  see the 'nologin' applet for an example.

function                                             old     new   delta
scripted_main                                          -      41     +41
applet_names                                        2773    2781      +8
applet_main                                         1600    1604      +4
i2cdetect_main                                       672     674      +2
applet_suid                                          100     101      +1
applet_install_loc                                   200     201      +1
applet_flags                                         100     101      +1
packed_usage                                       33180   33179      -1
tryexec                                              159     152      -7
evalcommand                                         1661    1653      -8
script_names                                           9       -      -9
packed_scripts                                       123     114      -9
complete_cmd_dir_file                                826     811     -15
shellexec                                            271     254     -17
find_command                                        1007     990     -17
busybox_main                                         642     624     -18
run_applet_and_exit                                  100      78     -22
find_script_by_name                                   51       -     -51
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 6/9 up/down: 58/-174)          Total: -116 bytes
   text	   data	    bss	    dec	    hex	filename
 950034	    477	   7296	 957807	  e9d6f	busybox_old
 949918	    477	   7296	 957691	  e9cfb	busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-17 21:16:33 +01:00
Ron Yorston
c339c7f7b3 libarchive: add a function to unpack embedded data
Similar code to unpack embedded data is used to decompress usage
messages, embedded scripts and the config file (in the non-default
bbconfig applet).

Moving this code to a common function reduces the size of the default
build and hides more of the internals of libarchive.

function                                             old     new   delta
unpack_bz2_data                                        -     135    +135
bb_show_usage                                        137     157     +20
get_script_content                                    32      47     +15
unpack_scripts                                       119       -    -119
unpack_usage_messages                                124       -    -124
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/0 up/down: 170/-243)          Total: -73 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-02 14:14:51 +01:00
Denys Vlasenko
0575c9932d busybox: show embedded scripts in applet list
function                                             old     new   delta
busybox_main                                         624     642     +18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 13:58:16 +01:00
Ron Yorston
c9e161277e lineedit: autocompletion for embedded scripts
function                                             old     new   delta
complete_cmd_dir_file                                811     826     +15

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 12:51:10 +01:00
Ron Yorston
151de441e7 ash: recognize embedded scripts in SH_STANDALONE mode
function                                             old     new   delta
find_script_by_name                                    -      51     +51
shellexec                                            254     271     +17
find_command                                         990    1007     +17
evalcommand                                         1653    1661      +8
doCommands                                          2233    2222     -11
run_applet_and_exit                                  128     100     -28
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 6/4 up/down: 104/-52)            Total: 52 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 11:07:26 +01:00
Denys Vlasenko
aa2959c90d claenups for previous commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 10:28:04 +01:00
Denys Vlasenko
4f2ef4a836 ash: allow shell scripts to be embedded in the binary
To assist in the deployment of shell scripts it may be convenient
to embed them in the BusyBox binary.

'Embed scripts in the binary' takes any files in the directory
'embed', concatenates them with null separators, compresses them
and embeds them in the binary.

When scripts are embedded in the binary, scripts can be run as
'busybox SCRIPT [ARGS]' or by usual (sym)link mechanism.

embed/nologin is provided as an example.

function                                             old     new   delta
packed_scripts                                         -     123    +123
unpack_scripts                                         -      87     +87
ash_main                                            1103    1171     +68
run_applet_and_exit                                   78     128     +50
get_script_content                                     -      32     +32
script_names                                           -      10     +10
expmeta                                              663     659      -4
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 2/1 up/down: 370/-4)            Total: 366 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 10:15:13 +01:00
Rasmus Villemoes
656ca7bdd9 libbb/u_signal_names.c: don't check errno after bb_strtou
Since we're comparing the return value to a smallish integer anyway, we
might as well use that bb_strtou() returns UINT_MAX for malformed
input. Referencing errno is kinda bloaty on glibc.

While NSIG is not in POSIX, we do already rely on it being defined,
compile-time const and smallish, since arrays in struct globals_misc are
defined in terms of it.

function                                             old     new   delta
get_signum                                           312     286     -26

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-31 11:28:37 +01:00
Rasmus Villemoes
571e525a14 libbb: optionally honour libc provided SIGRTMIN/SIGRTMAX in get_signum()
When an application documents that it responds such and such to
SIGRTMIN+n, that almost always means with respect to the libc-provided
SIGRTMIN. Hence I disagree with the "more correct" in commit
7b276fc175. In any case, this is rather unfortunate:

36
34

(the first shell is bash). We probably can't change default behaviour
after 7 years, but at least we can provide a config option.

We avoid a little code generation (repeated calls to
__libc_current_sigrtmin) by stashing SIGRTMIN/SIGRTMAX in local
variables, but it does cost ~50 bytes. The next patch serves as penance
for that.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-31 11:13:55 +01:00
Denys Vlasenko
93ef5dd640 printf: fix printf "%u\n" +18446744073709551614
function                                             old     new   delta
conv_strtoll                                          19      32     +13
conv_strtoull                                         49      61     +12
bb_strtoll                                            89      84      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 25/-5)              Total: 20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30 23:24:18 +01:00
Bernhard Reutner-Fischer
3db4e7f84c printf: fix printing +-prefixed numbers
Thanks to Cristian Ionescu-Idbohrn for noticing.

Also fix "%d" '  42' to skip leading whitespace.

function                                             old     new   delta
print_direc                                          435     454     +19
bb_strtoll                                            99     103      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 23/0)               Total: 23 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2018-10-19 15:27:42 +02:00
Denys Vlasenko
349d72c19c unzip: use printable_string() for printing filenames
function                                             old     new   delta
unzip_main                                          2726    2792     +66
printable_string2                                      -      57     +57
identify                                            4329    4336      +7
expmeta                                              659     663      +4
add_interface                                         99     103      +4
beep_main                                            286     289      +3
changepath                                           192     194      +2
builtin_type                                         115     117      +2
devmem_main                                          469     470      +1
input_tab                                           1076    1074      -2
create_J                                            1821    1819      -2
poplocalvars                                         314     311      -3
doCommands                                          2222    2214      -8
do_load                                              918     902     -16
printable_string                                      57       9     -48
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 8/6 up/down: 146/-79)            Total: 67 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-30 16:56:56 +02:00
Denys Vlasenko
76832ff5c4 date: do not allow "month #20" and such, closes 11356
function                                             old     new   delta
parse_datestr                                        906     961     +55

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-23 20:27:32 +02:00
Chen Yu
05b18065ab remove_file: don't call rmdir if remove_file return failure
When deleting a directory, the directory should not be removed if the
file in the subdirectory fails to be deleted.

Background information:

When I tested the kernel using LTP (linux-test-project).I found the
mv command have some issue. The LTP test case use the mv command to
move the directory t1 in the cgroup file system to the /tmp directory.
becase files in the cgroup file system are not allowed to be removed.
so the mv reported "Permission denied", but I used the ls command to
view the results and found that the directory t1 had been removed
from the cgroup file system. For the same test case, I used the mv
tool in the GNU coreutils, and the directory t1 will not be removed.

the following testcase use busybox mv:

/ # mount -t cgroup -o cpu cgroup /cpu
/ # cd /cpu
/cpu # mkdir -p t1
/cpu # ls
cgroup.clone_children  cpu.cfs_period_us  cpu.stat  t1
cgroup.procs           cpu.cfs_quota_us   notify_on_release  tasks
cgroup.sane_behavior   cpu.shares         release_agent
/cpu # mv t1 /tmp
mv: can't remove 't1/cgroup.procs': Operation not permitted
mv: can't remove 't1/cpu.cfs_period_us': Operation not permitted
mv: can't remove 't1/cpu.stat': Operation not permitted
mv: can't remove 't1/cpu.shares': Operation not permitted
mv: can't remove 't1/cpu.cfs_quota_us': Operation not permitted
mv: can't remove 't1/tasks': Operation not permitted
mv: can't remove 't1/notify_on_release': Operation not permitted
mv: can't remove 't1/cgroup.clone_children': Operation not permitted
/cpu # ls
cgroup.clone_children  cpu.cfs_period_us  cpu.stat  cgroup.procs
cpu.cfs_quota_us       notify_on_release  tasks   cgroup.sane_behavior
cpu.shares             release_agent
/cpu #

This patch fixed it, don't call rmdir if remove_file return failure,
and under certain file systems, the mv could work normally.

Signed-off-by: Chen Yu <yu.chen3@zte.com.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-09 20:16:04 +02:00
Denys Vlasenko
28d91d754e libbb: fix potential NULL pointer use
function                                             old     new   delta
unicode_conv_to_printable2                           193     216     +23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-03 10:36:51 +02:00
Denys Vlasenko
3060992ec9 libbb: fix use-after-free in copy_file
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-03 10:25:29 +02:00
Denys Vlasenko
22a9951620 libbb: in xmalloc_fgets(), use size_t for bb_get_chunk_from_file()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-02 18:48:09 +02:00
Denys Vlasenko
0d598ab9f0 Revert "libbb: remove unnecessary variable in xmalloc_fgets"
The variable is in fact necessary.

    commit 2da9724b56
    Author: Quentin Rameau <quinq@fifth.space>
    Date:   Sun Apr 1 17:05:35 2018 +0200
        libbb: remove unnecessary variable in xmalloc_fgets

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-02 18:35:29 +02:00
Denys Vlasenko
6791140123 fix !CONFIG_FLOAT_DURATION build
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-26 16:32:16 +02:00
Denys Vlasenko
277e00ed12 Complie libbb/duration.c if ping[6] is selected
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-03 18:51:46 +02:00
Denys Vlasenko
4c20d9f2b0 extend fractional duration support to "top -d N.N" and "timeout"
function                                             old     new   delta
parse_duration_str                                     -     168    +168
sleep_for_duration                                     -     157    +157
top_main                                             885     928     +43
timeout_main                                         269     312     +43
handle_input                                         571     614     +43
duration_suffixes                                      -      40     +40
sfx                                                   40       -     -40
sleep_main                                           364      79    -285
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 3/1 up/down: 494/-325)          Total: 169 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-03 18:17:12 +02:00
Denys Vlasenko
41ef41b3e0 hush: fix nested redirects colliding with script fds
This necessitates switch from libc FILE api to a simple
homegrown replacement.
The change which fixes the bug here is the deleting of

	restore_redirected_FILEs();

line. It was prematurely moving (restoring) script fd#3.
The fix is: we don't even _want_ to restore scrit fds,
we are perfectly fine with them being moved.
The only reason we tried to restore them is that FILE api
did not allow moving of FILE->fd.

function                                             old     new   delta
refill_HFILE_and_getc                                  -      93     +93
hfopen                                                 -      90     +90
hfclose                                                -      66     +66
pseudo_exec_argv                                     591     597      +6
hush_main                                           1089    1095      +6
builtin_source                                       209     214      +5
save_fd_on_redirect                                  197     200      +3
setup_redirects                                      320     321      +1
fgetc_interactive                                    235     236      +1
i_peek_and_eat_bkslash_nl                             99      97      -2
expand_vars_to_list                                 1103    1100      -3
restore_redirects                                     99      52     -47
fclose_and_forget                                     57       -     -57
remember_FILE                                         63       -     -63
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 6/3 up/down: 271/-172)           Total: 99 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-24 16:54:41 +02:00
Denys Vlasenko
4c201c00a3 whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-17 15:04:17 +02:00
Denys Vlasenko
79fb6ac7a5 cp: optional --reflink support
function                                             old     new   delta
cp_main                                              428     512     +84
copy_file                                           1676    1742     +66

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-13 20:30:02 +02:00
Denys Vlasenko
253f555f01 usage: do not print trailing space for commands which have no arguments
function                                             old     new   delta
bb_show_usage                                        120     130     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-09 18:23:33 +02:00
Denys Vlasenko
e5d5f5b9a7 hexdump: fix short file of zero butes treated as dup
function                                             old     new   delta
bb_dump_dump                                        1466    1491     +25

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-03 16:29:06 +02:00
Denys Vlasenko
335766602b testsuite/mount.tests: fix false positive
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-28 14:10:00 +02:00
Denys Vlasenko
57dbe4d5ac libbb: crypt() in newer glibc requires include <crypt.h>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-27 09:45:20 +02:00
Kartik Agaram
43b17b1cd0 restore documentation on the build config language
Kconfig-language.txt was deleted in commit 4fa499a17b back in 2006.
Move to docs/ as suggested by Xabier Oneca:
  http://lists.busybox.net/pipermail/busybox/2014-May/080914.html
Also update references to it everywhere.

Signed-off-by: Kartik Agaram <akkartik@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-06 15:16:48 +02:00
Denys Vlasenko
bf7f103ffb whitespace fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-26 17:42:00 +02:00
Denys Vlasenko
747162109f realpath,readlink -f: coreutils compat, closes 11021
function                                             old     new   delta
xmalloc_realpath_coreutils                             -     121    +121

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-24 17:31:00 +02:00
Denys Vlasenko
2aeb201c97 libbb: new option FEATURE_ETC_SERVICES: if off, /etc/services reads often avoided
In practice, "wget http://host.com/" always uses port 80.
People explicitly set non-standard ports via options or parameters
("telnet 1.2.3.4 567" or "telnet 1.2.3.4 ftp") instead of modifying
/etc/services.

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-17 12:43:54 +02:00
Denys Vlasenko
058a153b69 less: fix fallout from "use common routine to set raw termios"
Testcase: (sleep 10; ls) | busybox less

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

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

function                                             old     new   delta
get_termios_and_make_raw                             108     115      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-16 10:24:48 +02:00
Denys Vlasenko
38ccd6af8a bzip2: fix two crashes on corrupted archives
As it turns out, longjmp'ing into freed stack is not healthy...

function                                             old     new   delta
unpack_usage_messages                                  -      97     +97
unpack_bz2_stream                                    369     409     +40
get_next_block                                      1667    1677     +10
get_bits                                             156     155      -1
start_bunzip                                         212     183     -29
bb_show_usage                                        181     120     -61
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/3 up/down: 147/-91)            Total: 56 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 20:05:04 +02:00
Denys Vlasenko
17058a06c4 libbb: switch bb_ask_noecho() to "mallocing" string return API
function                                             old     new   delta
bb_ask_noecho                                        313     330     +17
get_cred_or_die                                      125     115     -10
passwd_main                                          995     958     -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 17/-47)            Total: -30 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:50:30 +02:00
Denys Vlasenko
bae8fc4436 xargs: use bb_ask_y_confirmation_FILE() instead of homegrown copy
function                                             old     new   delta
bb_ask_y_confirmation_FILE                             -      83     +83
inetd_main                                          2033    2043     +10
udhcp_send_kernel_packet                             295     301      +6
rmescapes                                            306     310      +4
send_tree                                            353     355      +2
i2cdetect_main                                       674     672      -2
confirm_or_abort                                      43      38      -5
get_terminal_width_height                            242     234      -8
bb_ask_y_confirmation                                 76      10     -66
xargs_main                                           823     755     -68
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/5 up/down: 105/-149)          Total: -44 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:23:10 +02:00
Denys Vlasenko
77cb6b99a4 libbb: rename bb_ask -> bb_ask_noecho, bb_ask_confirmation -> bb_ask_y_confirmation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:08:12 +02:00
Denys Vlasenko
2f094ae821 telnet: move winsize detection closer to I/O loop, delete non-functioning debug code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:02:20 +02:00
Denys Vlasenko
2ab994f707 placate gcc-8.0.1 warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 18:26:33 +02:00
Denys Vlasenko
f5018dac21 hush: fix "unset PS1/PS2", and put them into initial variable set
"unset PS1/PS2" causes prompts to be empty strings

function                                             old     new   delta
hush_main                                           1031    1089     +58
goto_new_line                                         27      33      +6
fgetc_interactive                                    244     245      +1
unset_local_var                                      155     149      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 65/-6)              Total: 59 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 17:58:21 +02:00
Denys Vlasenko
899ae5337a libbb: new function bb_die_memory_exhausted
function                                             old     new   delta
bb_die_memory_exhausted                                -      10     +10
xstrdup                                               28      23      -5
xsetenv                                               27      22      -5
xrealloc                                              32      27      -5
xputenv                                               22      17      -5
xmalloc                                               30      25      -5
xfdopen_helper                                        40      35      -5
xasprintf                                             44      39      -5
wget_main                                           2387    2382      -5
open_socket                                           54      49      -5
glob_brace                                           419     414      -5
bb_get_chunk_from_file                               146     141      -5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/11 up/down: 10/-55)           Total: -45 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 19:59:37 +02:00
Quentin Rameau
e2afae6303 sed: prevent overflow of length from bb_get_chunk_from_file
This fragment did not work right:

                temp = bb_get_chunk_from_file(fp, &len);
                if (temp) {
                        /* len > 0 here, it's ok to do temp[len-1] */
                        char c = temp[len-1];

With "int len" _sign-extending_, temp[len-1] can refer to a wrong location
if len > 0x7fffffff.

Signed-off-by: Quentin Rameau <quinq@fifth.space>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 19:51:14 +02:00
Quentin Rameau
2da9724b56 libbb: remove unnecessary variable in xmalloc_fgets
Signed-off-by: Quentin Rameau <quinq@fifth.space>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 19:45:36 +02:00
Denys Vlasenko
e4defe826b libbb: use BUILD_BUG_ON in utoa_to_buf()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-28 17:12:56 +02:00
Sean MacLennan
d9aabfe578 make busybox more portable
Move some distro specific include files into the appropriate #ifdef
blocks to make the code more portable.

Signed-off-by: Sean MacLennan <seanm@seanm.ca>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-04 23:15:59 +01:00
Andy Shevchenko
cc222747ae libbb: Use return value from is_prefixed_with()
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5 (-5)
Function                                     old     new   delta
skip_dev_pfx                                  30      25      -5
Total: Before=779966, After=779961, chg -0.00%

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-27 13:35:40 +01:00
Ron Yorston
23286900da lineedit: allow window size tracking to be disabled
function                                             old     new   delta
lineedit_read_key                                    269     261      -8
win_changed                                           47       -     -47
read_line_input                                     3884    3821     -63
cmdedit_setwidth                                      63       -     -63
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/2 up/down: 0/-181)           Total: -181 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-25 20:09:54 +01:00
Denys Vlasenko
2af5e3fac3 libbb: compile capability code only if FEATURE_SETPRIV_CAPABILITIES or RUN_INIT
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-21 20:13:39 +01:00
Denys Vlasenko
edccc982e5 progress meter: add disabled code for a more stable ETA
Compiles to ~25 bytes if enabled.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-13 16:48:52 +01:00
Denys Vlasenko
ba3b9dbf06 libbb: introduce and use bb_getsockname()
function                                             old     new   delta
bb_getsockname                                         -      18     +18
xrtnl_open                                            88      83      -5
do_iplink                                           1216    1209      -7
arping_main                                         1686    1668     -18
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/3 up/down: 18/-30)            Total: -12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-11 14:55:46 +01:00
Denys Vlasenko
47529d3f16 libbb: shrink wget/tftp progress indicator code a bit more
This makes size display 5-char wide instead of 6-char, but now it's smarter
(can show sizes in "12.3M" format).

function                                             old     new   delta
bb_progress_update                                   654     622     -32

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-07 23:48:34 +01:00
Denys Vlasenko
ab843e3244 libbb: shrink wget/tftp progress indicator code for 32-bit
function                                             old     new   delta
bb_progress_update                                   756     654    -102

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-07 17:47:39 +01:00
Denys Vlasenko
1267770a9d fix compile failure in previous commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-06 18:01:39 +01:00
Denys Vlasenko
5cdd120f0c unzip: do not set directory mode to 0777
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882177

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-06 17:59:32 +01:00
Denys Vlasenko
ddacb03e87 libbb: commonalize a bit of little-endian CRC32 table generation code
function                                             old     new   delta
global_crc32_new_table_le                              -      11     +11
crc32_new_table_le                                     -       9      +9
inflate_unzip_internal                               560     556      -4
flash_eraseall_main                                  823     819      -4
unpack_xz_stream                                    2403    2394      -9
lzop_main                                            121     112      -9
gzip_main                                            187     178      -9
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/5 up/down: 20/-35)            Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-01 10:56:19 +01:00
Denys Vlasenko
cca7c611f2 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>
2018-01-12 13:21:33 +01:00
Denys Vlasenko
7367a949a6 libbb: compile obscure() only if FEATURE_PASSWD_WEAK_CHECK=y
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-04 15:21:25 +01:00
Denys Vlasenko
82d1c1f84a randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-12-31 17:30:02 +01:00
Denys Vlasenko
0a67722140 lineedit: get terminal width before printing prompt
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-11-08 13:38:12 +01:00
Denys Vlasenko
c3797d40a1 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>
2017-11-08 12:35:02 +01:00
James Clarke
518fb3ba19 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>
2017-10-30 16:06:50 +01:00