oweals/busybox.git
10 years agoftpd: for LIST, open current directory *in the child*
Denys Vlasenko [Fri, 27 Jun 2014 10:37:00 +0000 (12:37 +0200)]
ftpd: for LIST, open current directory *in the child*

Last change introduced an open fd leak. This is the fix.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoftpd: escape chroot prior to re-executing ls helper
Denys Vlasenko [Fri, 27 Jun 2014 10:24:39 +0000 (12:24 +0200)]
ftpd: escape chroot prior to re-executing ls helper

When we merely chdir to saved "real" root fd,
exec("proc/self/exe") works for static executables but not
for dynamic ones (they can't find their interpreter).

With this patch, we also *chroot* to real root.
As a bonus, this gives us proper usernames, timezone conversion
etc.

function                                             old     new   delta
popen_ls                                             203     259     +56
ftpd_main                                           2362    2366      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoawk: fix handling of "if ... break ; else ..." - closes 7226
Denys Vlasenko [Thu, 26 Jun 2014 14:40:28 +0000 (16:40 +0200)]
awk: fix handling of "if ... break ; else ..." - closes 7226

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoftpd: optimize writes of LIST results a bit
Denys Vlasenko [Thu, 26 Jun 2014 10:07:48 +0000 (12:07 +0200)]
ftpd: optimize writes of LIST results a bit

function                                             old     new   delta
handle_dir_common                                    201     207      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agonanddump: change default to --bb=skipbad
Richard Genoud [Wed, 25 Jun 2014 15:38:30 +0000 (17:38 +0200)]
nanddump: change default to --bb=skipbad

since mtd-utils 1.4.7, the default behaviour of nanddump is skipbad
(commit 2521d4f1b6b9866a9c89f3c11a4f6a3d763ff1d7)

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agonanddump: kill -b Omit bad block
Richard Genoud [Wed, 25 Jun 2014 15:33:34 +0000 (17:33 +0200)]
nanddump: kill -b Omit bad block

since mtd-utils 1.4.7, the omit bad block method has been removed.
(cf commit d8b8f780ec3c916f3990e9227d6bfbb22bf42ef8)

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agonanddump: add options --bb=skipbad and padbad
Richard Genoud [Tue, 24 Jun 2014 10:12:59 +0000 (12:12 +0200)]
nanddump: add options --bb=skipbad and padbad

In mtd-utils, the bad block options changed in favor of
--bb=[skipbad|padbad|dumpbad] and omitbad has been removed.

This patch add the --bb=skipbad and padbad methods to busybox' nanddump.
padbad is the current default behaviour.
The difference between skipbad and omitbad is this one:
On a 16K block NAND, if the 1st block of mtd0 is bad, we'll have:
nanddump  -b -l 16384 /dev/mtd0 | wc -c
0
nanddump  --bb=skipbad -l 16384 /dev/mtd0 | wc -c
16384 <- data from 1st good block

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agonanddump: correct rounding to next page (lead to infinite loop)
Richard Genoud [Tue, 24 Jun 2014 10:12:58 +0000 (12:12 +0200)]
nanddump: correct rounding to next page (lead to infinite loop)

The rounding to next page formula was wrong:
ex: (len | ~(meminfo->writesize - 1)) + 1;
len=128K
writesize=4K
(len | ~(meminfo->writesize - 1)) + 1 => 4 294 963 201 ?!

correct rounding formula:
((len - 1) | (meminfo->writesize - 1)) + 1 => 128K
len = 130K
((len - 1) | (meminfo->writesize - 1)) + 1 => 132K

modprobe nandsim parts="20,20" badblocks="22,23"

without patch:
nanddump  /dev/mtd1 | wc -c
[...] infinite loop

with the patch:
nanddump /dev/mtd1 | wc -c
327680

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoftpd: support deprecated XPWD command
Denys Vlasenko [Wed, 25 Jun 2014 14:23:59 +0000 (16:23 +0200)]
ftpd: support deprecated XPWD command

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: fix compile failure if both ARG_MAX and _SC_ARG_MAX are defined
Denys Vlasenko [Wed, 25 Jun 2014 13:39:27 +0000 (15:39 +0200)]
libbb: fix compile failure if both ARG_MAX and _SC_ARG_MAX are defined

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agounlink: new applet
Isaac Dunham [Sun, 22 Jun 2014 18:44:25 +0000 (20:44 +0200)]
unlink: new applet

function                                             old     new   delta
unlink_main                                            -      45     +45
packed_usage                                       29667   29686     +19

Signed-off-by: Isaac Dunham <ibid.ag@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agounit-tests: implement the unit-testing framework
Bartosz Golaszewski [Sun, 22 Jun 2014 14:30:41 +0000 (16:30 +0200)]
unit-tests: implement the unit-testing framework

This set of patches adds a simple unit-testing framework to Busybox

unit-tests: add some helper macros for unit-test framework implementation
unit-tests: implement the unit-testing framework
unit-tests: add basic documentation on writing the unit test cases
unit-tests: modify the Makefile 'test' target to run unit-tests too
unit-tests: add two example test cases
unit-tests: modify the existing strrstr test code to use the unit-test framework

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: use a wrapper around sysconf(_SC_CLK_TCK) to save a few bytes
Bartosz Golaszewski [Sun, 22 Jun 2014 12:01:13 +0000 (14:01 +0200)]
libbb: use a wrapper around sysconf(_SC_CLK_TCK) to save a few bytes

function                                             old     new   delta
bb_sc_clk_tck                                          -      10     +10
timescmd                                             118     113      -5
print_route                                         1763    1758      -5
mpstat_main                                         1288    1283      -5
iostat_main                                         1947    1942      -5
INET_setroute                                        879     871      -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/5 up/down: 10/-28)            Total: -18 bytes
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofind: use sysconf(_SC_ARG_MAX) to determine the command-line size limit
Denys Vlasenko [Sun, 22 Jun 2014 11:54:40 +0000 (13:54 +0200)]
find: use sysconf(_SC_ARG_MAX) to determine the command-line size limit

The find utility uses a hardcoded value of 32 * 1024 as the limit of
the command-line length when calling 'find -exec ... {} +'. This results
in over 4 times more execve() calls than in coreutils' find.

This patch uses the limit defined in system headers.

Based on the patch by  Bartosz Golaszewski <bartekgola@gmail.com>.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofind: exit code fixes for find -exec
Denys Vlasenko [Thu, 19 Jun 2014 09:32:11 +0000 (11:32 +0200)]
find: exit code fixes for find -exec

function                                             old     new   delta
func_exec                                            127     100     -27

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofind: add optional support for '-exec ... {} +'
Bartosz Golaszewski [Tue, 17 Jun 2014 15:09:17 +0000 (17:09 +0200)]
find: add optional support for '-exec ... {} +'

function                                             old     new   delta
do_exec                                                -     309    +309
parse_params                                        1416    1487     +71
find_main                                            342     406     +64
packed_usage                                       29958   30014     +56
func_exec                                            138     127     -11
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 500/-11)           Total: 489 bytes

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoudhcpc: make hostname sanitization optional. Closes 3979
Denys Vlasenko [Sun, 15 Jun 2014 22:17:00 +0000 (00:17 +0200)]
udhcpc: make hostname sanitization optional. Closes 3979

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosyslogd: Unify unlink/truncate + unlock log-rotation logic
Joshua Judson Rosen [Tue, 20 May 2014 05:02:20 +0000 (01:02 -0400)]
syslogd: Unify unlink/truncate + unlock log-rotation logic

Always unlink + reopen, rather than sometimes using ftruncate();
using a single code-path reduces the opportunity for either
mistakes or duplicate code.

Signed-off-by: Joshua Judson Rosen <jrosen@harvestai.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosyslogd: remember to un-writelock log-files even when called with "-b 0"
Joshua Judson Rosen [Tue, 20 May 2014 05:02:19 +0000 (01:02 -0400)]
syslogd: remember to un-writelock log-files even when called with "-b 0"

Signed-off-by: Joshua Judson Rosen <jrosen@harvestai.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosyslogd: avoid spurious ftrunctate() calls for "-b 0"
Joshua Judson Rosen [Tue, 20 May 2014 05:02:18 +0000 (01:02 -0400)]
syslogd: avoid spurious ftrunctate() calls for "-b 0"

Forgetting to re-set log_file->size after truncating to zero
discards log-data for the next 1 second following an oversize-induced purge,
when we shouldn't necessarily throw that data away.

Signed-off-by: Joshua Judson Rosen <jrosen@harvestai.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agomodprobe-small: fix safe_strncpy truncating last char of module name
Denys Vlasenko [Mon, 26 May 2014 13:01:13 +0000 (15:01 +0200)]
modprobe-small: fix safe_strncpy truncating last char of module name

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoAdd conditional support for -v / --verbose
Denys Vlasenko [Mon, 19 May 2014 14:23:50 +0000 (16:23 +0200)]
Add conditional support for -v / --verbose

With FEATURE_VERBOSE off, practically no size change.
With it on:

function                                             old     new   delta
remove_file                                          493     556     +63
install_main                                         719     765     +46
bb_make_directory                                    383     419     +36
rmdir_main                                           162     191     +29
copy_file                                           1516    1544     +28
mv_main                                              502     525     +23
cmp_main                                             677     693     +16
bbconfig_config_bz2                                 5264    5279     +15
mkdir_main                                           158     168     +10
install_longopts                                      66      76     +10
rm_main                                              167     175      +8
nexpr                                                840     846      +6
scan_tree                                            275     280      +5
fsck_main                                           1807    1811      +4
ed_main                                             2541    2545      +4
expand_one_var                                      1574    1575      +1
swap_on_off_main                                     420     418      -2
parse_command                                       1443    1440      -3
redirect                                            1279    1274      -5
do_load                                              946     918     -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 16/4 up/down: 304/-38)          Total: 266 bytes

Based on the patch by Igor Živković.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agogetty: explain when setsid() fails. no code changes
Denys Vlasenko [Sat, 10 May 2014 22:00:52 +0000 (00:00 +0200)]
getty: explain when setsid() fails. no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoMerge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox
Denys Vlasenko [Sat, 10 May 2014 22:00:51 +0000 (00:00 +0200)]
Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox

10 years agotrylink: emit names of linked executables
Denys Vlasenko [Sat, 3 May 2014 14:35:15 +0000 (16:35 +0200)]
trylink: emit names of linked executables

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agowhich: rewrite
Tito Ragusa [Sat, 3 May 2014 14:34:36 +0000 (16:34 +0200)]
which: rewrite

function                                             old     new   delta
which_main                                           237     212     -25

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotrylink: emit names of linked executables
Denys Vlasenko [Sat, 3 May 2014 14:35:15 +0000 (16:35 +0200)]
trylink: emit names of linked executables

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agowhich: rewrite
Timo Teräs [Sat, 3 May 2014 14:34:36 +0000 (16:34 +0200)]
which: rewrite

function                                             old     new   delta
which_main                                           237     212     -25

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: rename execable -> executable. No code changes
Denys Vlasenko [Fri, 2 May 2014 15:15:58 +0000 (17:15 +0200)]
libbb: rename execable -> executable. No code changes

English speakers complained that it sounded awfully broken.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: fix empty PATH components handling
Denys Vlasenko [Fri, 2 May 2014 15:08:29 +0000 (17:08 +0200)]
libbb: fix empty PATH components handling

function                                             old     new   delta
find_execable                                         81      86      +5
exists_execable                                       71      66      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agortcwake: fix incorrect (reversed) rtc/sys adjuestment; code shrink
Denys Vlasenko [Fri, 2 May 2014 10:46:15 +0000 (12:46 +0200)]
rtcwake: fix incorrect (reversed) rtc/sys adjuestment; code shrink

function                                             old     new   delta
rtcwake_main                                         482     462     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: fix thinko in rtc_xopen()
Denys Vlasenko [Fri, 2 May 2014 07:07:16 +0000 (09:07 +0200)]
libbb: fix thinko in rtc_xopen()

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: make rtc_xopen try harder on EBUSY
Denys Vlasenko [Fri, 2 May 2014 07:05:03 +0000 (09:05 +0200)]
libbb: make rtc_xopen try harder on EBUSY

function                                             old     new   delta
rtc_xopen                                             77     139     +62

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoFix compile failures
Denys Vlasenko [Fri, 2 May 2014 05:18:55 +0000 (07:18 +0200)]
Fix compile failures

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agocrond: implement "SHELL=prog" in crontab. Export LOGNAME as POSIX wants
Denys Vlasenko [Wed, 30 Apr 2014 15:38:27 +0000 (17:38 +0200)]
crond: implement "SHELL=prog" in crontab. Export LOGNAME as POSIX wants

function                                             old     new   delta
fork_job                                             343     456    +113
load_crontab                                         688     777     +89
crond_main                                          1456    1434     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 202/-22)           Total: 180 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agocrond: simplify logging code
Denys Vlasenko [Wed, 30 Apr 2014 12:49:52 +0000 (14:49 +0200)]
crond: simplify logging code

Slight change in behavior: now -l 5 will enable the same messages
formerly only enabled for -d 5. (Old behavior was non-sensical).

function                                             old     new   delta
reopen_logfile_to_stderr                               -      34     +34
log8                                                   -      26     +26
log7                                                   -      26     +26
log5                                                   -      26     +26
load_crontab                                         706     688     -18
rescan_crontab_dir                                   157     137     -20
crond_main                                          1486    1456     -30
fork_job                                             389     343     -46
crondlog                                             108      38     -70
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 0/5 up/down: 112/-184)          Total: -72 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: make syslog level for bb_error_msg's configurable. use it in crond
Denys Vlasenko [Wed, 30 Apr 2014 12:48:28 +0000 (14:48 +0200)]
libbb: make syslog level for bb_error_msg's configurable. use it in crond

function                                             old     new   delta
bb_verror_msg                                        380     386      +6
syslog_level                                           -       1      +1
crondlog                                             165     108     -57

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agocrond: tweak help text, make course less cryptic
Denys Vlasenko [Wed, 30 Apr 2014 12:47:28 +0000 (14:47 +0200)]
crond: tweak help text, make course less cryptic

function                                             old     new   delta
packed_usage                                       29736   29740      +4
crond_main                                          1485    1486      +1
load_crontab                                         712     706      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agomodprobe-small: (un)load all modules which match the alias, not only first one
Denys Vlasenko [Mon, 21 Apr 2014 14:59:36 +0000 (16:59 +0200)]
modprobe-small: (un)load all modules which match the alias, not only first one

Closes 627 and 7034.

Commonly seen case is (un)loading of an alias
which matches ata_generic and a more specific ata module.

For example:

modprobe [-r] pci:v00008086d00007010sv00000000sd00000000bc01sc01i80
(ata_generic and pata_acpi)

modprobe [-r] pci:v00001106d00000571sv00001509sd00009022bc01sc01i8a
(ata_generic and pata_via)

function                                             old     new   delta
process_module                                       615     728    +113
parse_module                                         309     395     +86
find_alias                                           621     653     +32
pathname_matches_modname                              78      79      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 232/0)             Total: 232 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agontpd: fix wrong delay value in one of the printed messages
Denys Vlasenko [Sun, 20 Apr 2014 11:04:23 +0000 (13:04 +0200)]
ntpd: fix wrong delay value in one of the printed messages

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agontpd: truly ignore high delay packet
Denys Vlasenko [Sat, 19 Apr 2014 17:00:16 +0000 (19:00 +0200)]
ntpd: truly ignore high delay packet

Before this cahnge, sometimes they were used after the next packet
from another peer was received, because we did updare some peer stats
from high delay packet before dropping it.

function                                             old     new   delta
recv_and_process_peer_pkt                            922     966     +44

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agomodprobe-small: remove redundant aliases from modules.dep.bb
Denys Vlasenko [Sat, 19 Apr 2014 14:17:27 +0000 (16:17 +0200)]
modprobe-small: remove redundant aliases from modules.dep.bb

function                                             old     new   delta
parse_module                                         309     395     +86

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agomodprobe-small: fix help messages for aliased module-related applets
Denys Vlasenko [Sat, 19 Apr 2014 13:04:39 +0000 (15:04 +0200)]
modprobe-small: fix help messages for aliased module-related applets

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoadjtimex: make its help text and printed data a bit less cryptic
Denys Vlasenko [Thu, 17 Apr 2014 09:29:34 +0000 (11:29 +0200)]
adjtimex: make its help text and printed data a bit less cryptic

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb/obscure.c: code shrink. Suggested by Tito.
Denys Vlasenko [Wed, 16 Apr 2014 17:51:34 +0000 (19:51 +0200)]
libbb/obscure.c: code shrink. Suggested by Tito.

function                                             old     new   delta
string_checker                                        97      92      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoash,hush: set $HOSTNAME is bash compat. Closes 7028
Denys Vlasenko [Tue, 15 Apr 2014 09:43:29 +0000 (11:43 +0200)]
ash,hush: set $HOSTNAME is bash compat. Closes 7028

function                                             old     new   delta
hush_main                                           1056    1128     +72
ash_main                                            1442    1487     +45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: provide usleep() fallback implementation
Bernhard Reutner-Fischer [Sun, 13 Apr 2014 14:37:57 +0000 (16:37 +0200)]
libbb: provide usleep() fallback implementation

POSIX.1-2008 removed the usleep function, provide a fallback
implementaion using the recommended nanosleep().

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoless: fix bugs discovered with "git log -p | less -m" on kernel tree
Denys Vlasenko [Mon, 7 Apr 2014 21:32:29 +0000 (23:32 +0200)]
less: fix bugs discovered with "git log -p | less -m" on kernel tree

function                                             old     new   delta
read_lines                                           685     733     +48

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agovi: some simplifications
Denys Vlasenko [Sat, 5 Apr 2014 20:57:46 +0000 (22:57 +0200)]
vi: some simplifications

function                                             old     new   delta
file_insert                                          301     315     +14
init_text_buffer                                     179     171      -8
colon                                               2889    2878     -11
file_size                                             37       -     -37
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 14/-56)            Total: -42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agovi: clear undo buffer when we change to another file
Denys Vlasenko [Thu, 3 Apr 2014 10:47:48 +0000 (12:47 +0200)]
vi: clear undo buffer when we change to another file

function                                             old     new   delta
init_text_buffer                                     156     190     +34
undo_push                                            360     382     +22
count_lines                                           74      72      -2
undo_pop                                             246     222     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 56/-26)             Total: 30 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agovi: undo code shrink
Denys Vlasenko [Wed, 2 Apr 2014 23:45:05 +0000 (01:45 +0200)]
vi: undo code shrink

function                                             old     new   delta
undo_push                                            414     395     -19
do_cmd                                              4803    4761     -42

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agovi: undo support for vi with intermediate queuing
Jody Bruchon [Wed, 2 Apr 2014 11:49:26 +0000 (13:49 +0200)]
vi: undo support for vi with intermediate queuing

function                                             old     new   delta
undo_push                                              -     411    +411
undo_pop                                               -     288    +288
do_cmd                                              4160    4426    +266
char_insert                                          363     483    +120
undo_queue_commit                                      -      61     +61
text_hole_delete                                     108     163     +55
string_insert                                         94     127     +33
colon                                               2864    2882     +18
yank_delete                                           92     101      +9
vi_main                                              273     280      +7
dot_scroll                                            88      93      +5
dot_right                                             29      34      +5
dot_prev                                              20      25      +5
dot_next                                              20      25      +5
dot_left                                              24      29      +5
dot_end                                               20      25      +5
dot_begin                                             20      25      +5
init_text_buffer                                     154     156      +2
text_hole_make                                       145     142      -3
file_insert                                          333     318     -15
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 15/2 up/down: 1305/-18)        Total: 1287 bytes

(without queuing it's ~870 bytes)

Signed-off-by: Jody Bruchon <jody@jodybruchon.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agobuild system: specify '-nostldlib' when linking to .o files
Drew Moseley [Wed, 2 Apr 2014 10:12:46 +0000 (12:12 +0200)]
build system: specify '-nostldlib' when linking to .o files

For certain cross build scenarios the LD variable is overridden
to use the gcc executive to ensure all the target tuning parameters
are used.  In these cases, the executive errors out as shown below
but since this step is only linking to a .o file the standard libs
are not needed.

    $ make LD=gcc applets/built-in.o
      LD      applets/built-in.o
    /usr/bin/ld: cannot find -lgcc_s
    /usr/bin/ld: cannot find -lgcc_s
    collect2: ld returned 1 exit status
    make[1]: *** [applets/built-in.o] Error 1
    make: *** [applets_dir] Error 2

Signed-off-by: Drew Moseley <drew_moseley@mentor.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoswapon/swapoff: -a returns 0 on ignored errors
Tito Ragusa [Tue, 1 Apr 2014 07:51:27 +0000 (09:51 +0200)]
swapon/swapoff: -a returns 0 on ignored errors

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoswapon/swapoff: size reduction, cleanup, fixes, improvements
Tito Ragusa [Mon, 31 Mar 2014 14:39:26 +0000 (16:39 +0200)]
swapon/swapoff: size reduction, cleanup, fixes, improvements

1) real swapon/swapoff handles also devices on the commandline with -a;
2) xstat(device)  in  swap_enable_disable aborts on error when cycling through
   fstab so some devices  are not handled;
3) duplicated code for ENABLE_FEATURE_SWAPON_DISCARD and
   ENABLE_FEATURE_SWAPON_PRI was moved to functions.
4) silence some error messages with -a;
5) minor cleanups and code refactoring reduced the size as per bloat-check:
6) I also added support for /proc/swaps handling to swapoff:
"When the -a flag is given, swapping is disabled on all known  swap  devices
 and  files  (as  found  in  /proc/swaps  or /etc/fstab)."
So now swapoff first cycles through  /proc/swaps and then through fstab
to swapoff all devices.

function                                             old     new   delta
set_discard_flag                                       -     106    +106
swap_enable_disable                                  147     238     +91
set_priority_flag                                      -      79     +79
retrieve_file_data                                   470     467      -3
swap_on_off_main                                     638     418    -220
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/2 up/down: 276/-223)           Total: 53 bytes

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agowget: fix a case where progress bar isn't updated if writes are very slow
Denys Vlasenko [Thu, 27 Mar 2014 15:50:29 +0000 (16:50 +0100)]
wget: fix a case where progress bar isn't updated if writes are very slow

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoadd discard option -d to swapon
Matt Whitlock [Sat, 22 Mar 2014 23:21:01 +0000 (19:21 -0400)]
add discard option -d to swapon

Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofix interaction of -a and -p options in swapon
Matt Whitlock [Sat, 22 Mar 2014 23:10:08 +0000 (19:10 -0400)]
fix interaction of -a and -p options in swapon

Swap entries in /etc/fstab inherit the priority specified on the command line unless they have 'pri' in their mount options.

Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoavoid calling bb_strtou twice in MIN macro expansion
Matt Whitlock [Sat, 22 Mar 2014 22:54:24 +0000 (18:54 -0400)]
avoid calling bb_strtou twice in MIN macro expansion

Also, the maximum allowable value of swap priority is technically SWAP_FLAG_PRIO_MASK >> SWAP_FLAG_PRIO_SHIFT.

Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agontpd: add optional support for /etc/ntp.conf
Denys Vlasenko [Sun, 23 Mar 2014 14:06:38 +0000 (15:06 +0100)]
ntpd: add optional support for /etc/ntp.conf

function                                             old     new   delta
add_peers                                              -      98     +98
packed_usage                                       29470   29511     +41
ntp_init                                             407     428     +21
pw_encrypt                                            14      27     +13
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 173/0)             Total: 173 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agodocs/new-applet-HOWTO.txt: tweak a bit
Denys Vlasenko [Mon, 17 Mar 2014 14:06:29 +0000 (15:06 +0100)]
docs/new-applet-HOWTO.txt: tweak a bit

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: fix a bad check for uclibc >= 0.9.31
Denys Vlasenko [Sun, 16 Mar 2014 19:53:40 +0000 (20:53 +0100)]
libbb: fix a bad check for uclibc >= 0.9.31

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agodocs: update new-applet-HOWTO.txt
Bartosz Golaszewski [Wed, 12 Mar 2014 21:43:50 +0000 (22:43 +0100)]
docs: update new-applet-HOWTO.txt

This patch adds some information about the gen_build_files.sh script and how
it allows to keep the Kbuild, Config.in etc. declarations in .c files.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoash: make "locak VAR" unset VAR (bash does that)
Denys Vlasenko [Sun, 16 Mar 2014 17:41:11 +0000 (18:41 +0100)]
ash: make "locak VAR" unset VAR (bash does that)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoscript: make it work even if fd 0 is closed
Denys Vlasenko [Sun, 16 Mar 2014 11:34:53 +0000 (12:34 +0100)]
script: make it work even if fd 0 is closed

Testcase:
script -q -c "echo hey" /dev/null 0>&-

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agobuild system: for "find", use POSIX not operator (!) instead of -not
Denys Vlasenko [Sun, 16 Mar 2014 11:05:58 +0000 (12:05 +0100)]
build system: for "find", use POSIX not operator (!) instead of -not

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosu: add a delay if the password is incorrect
Romain Naour [Sun, 16 Mar 2014 10:18:19 +0000 (11:18 +0100)]
su: add a delay if the password is incorrect

Signed-off-by: Romain Naour <romain.naour@openwide.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoash,hush: fix a thinko about 2^64-1 factorization
Denys Vlasenko [Sat, 15 Mar 2014 08:25:46 +0000 (09:25 +0100)]
ash,hush: fix a thinko about 2^64-1 factorization

function                                             old     new   delta
next_random                                          113     119      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agohush: make "true" built-in
Denys Vlasenko [Fri, 14 Mar 2014 11:43:57 +0000 (12:43 +0100)]
hush: make "true" built-in

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agorandom: cosmetic tweaks in debug code
Denys Vlasenko [Thu, 13 Mar 2014 12:03:27 +0000 (13:03 +0100)]
random: cosmetic tweaks in debug code

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoash,hush: improve randomness of $RANDOM, add easy-ish way to test it
Denys Vlasenko [Thu, 13 Mar 2014 11:52:43 +0000 (12:52 +0100)]
ash,hush: improve randomness of $RANDOM, add easy-ish way to test it

function                                             old     new   delta
next_random                                           68     113     +45
change_random                                        103     121     +18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoshuf: trim help text
Denys Vlasenko [Fri, 7 Mar 2014 13:41:53 +0000 (14:41 +0100)]
shuf: trim help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoshuf: do not use strings for -i RANGE case
Denys Vlasenko [Fri, 7 Mar 2014 13:32:39 +0000 (14:32 +0100)]
shuf: do not use strings for -i RANGE case

function                                             old     new   delta
shuf_main                                            482     496     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoshuf: improve help text
Bartosz Golaszewski [Fri, 7 Mar 2014 13:07:35 +0000 (14:07 +0100)]
shuf: improve help text

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoshuf: fix a segfault on 'shuf -e'
Bartosz Golaszewski [Fri, 7 Mar 2014 10:46:03 +0000 (11:46 +0100)]
shuf: fix a segfault on 'shuf -e'

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agouse [s]rand(), not [s]random()
Denys Vlasenko [Wed, 5 Mar 2014 17:58:15 +0000 (18:58 +0100)]
use [s]rand(), not [s]random()

rand() is the most standard C library function,
and on uclibc they are the same. I guess
they are the same in most todays' libc...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoshuf: new applet
Denys Vlasenko [Wed, 5 Mar 2014 17:56:20 +0000 (18:56 +0100)]
shuf: new applet

function                                             old     new   delta
shuf_main                                              -     478    +478
packed_usage                                       29571   29719    +148
applet_names                                        2460    2465      +5
applet_main                                         1428    1432      +4
applet_nameofs                                       714     716      +2
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 4/0 up/down: 637/0)             Total: 637 bytes

Based on the code by Bartosz Golaszewski <bartekgola@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoman: default to ascii
Denys Vlasenko [Mon, 3 Mar 2014 14:13:37 +0000 (15:13 +0100)]
man: default to ascii

Default to ascii instead of latin1. Otherwise man pages can be displayed
incorrectly. E.g. bullets show as "<B7>".

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoip link: add support for "address ETHADDR". Closes 4862
Denys Vlasenko [Sat, 1 Mar 2014 16:38:41 +0000 (17:38 +0100)]
ip link: add support for "address ETHADDR". Closes 4862

function                                             old     new   delta
do_iplink                                           2175    2289    +114

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agounlzma: add comments about possible bug from BZ 2689
Denys Vlasenko [Fri, 28 Feb 2014 14:42:10 +0000 (15:42 +0100)]
unlzma: add comments about possible bug from BZ 2689

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agounlzma: move some variables in "more local" scope
Denys Vlasenko [Fri, 28 Feb 2014 14:05:43 +0000 (15:05 +0100)]
unlzma: move some variables in "more local" scope

No code changes as verified by objdump

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoudhcpc: ignore NAKs from "wrong" servers. Closes 4267
Denys Vlasenko [Thu, 27 Feb 2014 17:15:50 +0000 (18:15 +0100)]
udhcpc: ignore NAKs from "wrong" servers. Closes 4267

function                                             old     new   delta
udhcpc_main                                         2716    2814     +98

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agols: make "ls -s DIR" show total too. Clases 4946
Denys Vlasenko [Thu, 27 Feb 2014 14:40:26 +0000 (15:40 +0100)]
ls: make "ls -s DIR" show total too. Clases 4946

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoxargs: fix compilation breakage
Denys Vlasenko [Thu, 27 Feb 2014 14:02:36 +0000 (15:02 +0100)]
xargs: fix compilation breakage

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agogrep: fix -w match if first match isn't a word, but second is. Closes 4520
Denys Vlasenko [Thu, 27 Feb 2014 13:56:12 +0000 (14:56 +0100)]
grep: fix -w match if first match isn't a word, but second is. Closes 4520

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoxargs: add support for -I and -i. Closes 493
Denys Vlasenko [Thu, 27 Feb 2014 10:17:06 +0000 (11:17 +0100)]
xargs: add support for -I and -i. Closes 493

function                                             old     new   delta
process_stdin_with_replace                             -     195    +195
xmalloc_substitute_string                              -     145    +145
xargs_main                                           808     884     +76
count_strstr                                           -      45     +45
packed_usage                                       29580   29571      -9
parse_params                                        1445    1416     -29
func_exec                                            285     138    -147
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 1/3 up/down: 461/-185)          Total: 276 bytes
   text    data     bss     dec     hex filename
 922156     932   17692  940780   e5aec busybox_old
 922440     932   17692  941064   e5c08 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofind: code shrink
Denys Vlasenko [Wed, 26 Feb 2014 14:27:10 +0000 (15:27 +0100)]
find: code shrink

function                                             old     new   delta
func_exec                                            306     285     -21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agonc: fix option bit positions. Closes 6926
Denys Vlasenko [Wed, 26 Feb 2014 12:58:59 +0000 (13:58 +0100)]
nc: fix option bit positions. Closes 6926

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agohwclock: fix setting of tz_minuteswest. Closes 5414
Denys Vlasenko [Tue, 25 Feb 2014 16:52:10 +0000 (17:52 +0100)]
hwclock: fix setting of tz_minuteswest. Closes 5414

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agobuild system: remove a dead link from Config help text
Denys Vlasenko [Tue, 25 Feb 2014 16:31:22 +0000 (17:31 +0100)]
build system: remove a dead link from Config help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agodu, copy_file: fix file matching on cramfs. Closes 5456
Denys Vlasenko [Tue, 25 Feb 2014 14:27:58 +0000 (15:27 +0100)]
du, copy_file: fix file matching on cramfs. Closes 5456

function                                             old     new   delta
is_in_ino_dev_hashtable                               88     108     +20
add_to_ino_dev_hashtable                             150     142      -8
reset_ino_dev_hashtable                               84      75      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 20/-17)              Total: 3 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: trivial code shrink
Denys Vlasenko [Tue, 25 Feb 2014 14:09:01 +0000 (15:09 +0100)]
libbb: trivial code shrink

function                                             old     new   delta
reset_ino_dev_hashtable                               84      74     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosysctl: do not error out showing write-only data. Closes 6386
Denys Vlasenko [Mon, 24 Feb 2014 16:28:43 +0000 (17:28 +0100)]
sysctl: do not error out showing write-only data. Closes 6386

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agowget: fix comment
Denys Vlasenko [Mon, 24 Feb 2014 16:20:40 +0000 (17:20 +0100)]
wget: fix comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agowget: add commented-out code to use ssl_helper instead of openssl
Denys Vlasenko [Sun, 23 Feb 2014 22:39:47 +0000 (23:39 +0100)]
wget: add commented-out code to use ssl_helper instead of openssl

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agonetworking/ssl_helper: experimental matrixssl-based ssl helper
Denys Vlasenko [Sun, 23 Feb 2014 22:31:13 +0000 (23:31 +0100)]
networking/ssl_helper: experimental matrixssl-based ssl helper

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agowget: add support for https using "openssl s_client" as a helper
Denys Vlasenko [Sat, 22 Feb 2014 13:12:29 +0000 (14:12 +0100)]
wget: add support for https using "openssl s_client" as a helper

www.kernel.org started redirecting http:// to https://
making https support mandatory for any auto build scripts.

function                                             old     new   delta
wget_main                                           2631    2971    +340
parse_url                                            409     471     +62
.rodata                                           115607  115626     +19
P_HTTPS                                                -       6      +6
P_HTTP                                                 -       5      +5
P_FTP                                                  -       4      +4
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 3/0 up/down: 436/0)             Total: 436 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoImprove examples/var_service READMEs
Denys Vlasenko [Fri, 21 Feb 2014 11:55:43 +0000 (12:55 +0100)]
Improve examples/var_service READMEs

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoKbuild: move CONFIG_PAM to general configuration
Bartosz Golaszewski [Tue, 11 Feb 2014 20:31:42 +0000 (21:31 +0100)]
Kbuild: move CONFIG_PAM to general configuration

Currently CONFIG_PAM depends on CONFIG_LOGIN, but is used by the httpd applet too.

This patch moves said option to general configuration, thus allowing to
compile httpd with PAM support independently from login.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoudhcpc: fix BPF filter. Hopefully fixes the root cause of 4598 and 6746
Denys Vlasenko [Wed, 19 Feb 2014 13:17:11 +0000 (14:17 +0100)]
udhcpc: fix BPF filter. Hopefully fixes the root cause of 4598 and 6746

Use a *signed* large positive value in BPF filter to indicate success.

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