oweals/busybox.git
10 years agodpkg-deb: cosmetic correction to usage text
Daniel Borca [Thu, 28 Nov 2013 11:38:25 +0000 (12:38 +0100)]
dpkg-deb: cosmetic correction to usage text

Signed-off-by: Daniel Borca <dborca@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosed: code shrink
Denys Vlasenko [Thu, 28 Nov 2013 11:08:51 +0000 (12:08 +0100)]
sed: code shrink

function                                             old     new   delta
get_next_line                                        246     250      +4
sed_main                                             671     662      -9
add_input_file                                        47       -     -47
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 4/-56)             Total: -52 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosed: open input files sequentially to avoid EMFILE
Denys Vlasenko [Thu, 28 Nov 2013 02:14:16 +0000 (03:14 +0100)]
sed: open input files sequentially to avoid EMFILE

Currently, sed pre-opens all files, which may cause EMFILE errors
on systems with low ulimit -n.  Change sed to open one file at a time.

function                                             old     new   delta
get_next_line                                        177     235     +58
sed_main                                             682     652     -30
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 58/-30)             Total: 28 bytes

Based on the patch by Daniel Borca <dborca@yahoo.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agohush: typo fixes in comments
Denys Vlasenko [Thu, 28 Nov 2013 00:50:01 +0000 (01:50 +0100)]
hush: typo fixes in comments

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoplatform: strchrnul is missing if __APPLE__
Daniel Borca [Tue, 26 Nov 2013 23:27:46 +0000 (00:27 +0100)]
platform: strchrnul is missing if __APPLE__

Signed-off-by: Daniel Borca <dborca@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agobuild system: use od -b instead of od -t x1
Denys Vlasenko [Tue, 26 Nov 2013 13:56:29 +0000 (14:56 +0100)]
build system: use od -b instead of od -t x1

od -t is not available in non-CONFIG_DESKTOPed busybox od

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoinit: halt on SIGPWR too
Bogdan Purcareata [Tue, 26 Nov 2013 12:54:48 +0000 (13:54 +0100)]
init: halt on SIGPWR too

Most init processes implement a handler for SIGPWR that gracefully
stops all child processes when shutting down a machine. Some other
technologies rely on this signal - e.g. Busybox powered LXC
containers.

This patch makes busybox init halt when receiving SIGPWR.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: add sketch of tentative 'better' passwd/group API
Denys Vlasenko [Tue, 26 Nov 2013 12:46:18 +0000 (13:46 +0100)]
libbb: add sketch of tentative 'better' passwd/group API

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agodevfsd: remove static variable
Denys Vlasenko [Tue, 26 Nov 2013 11:12:27 +0000 (12:12 +0100)]
devfsd: remove static variable

function                                             old     new   delta
static.msg                                             4       -      -4
get_uid_gid                                          114     107      -7
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-11)             Total: -11 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agobuild system: do not generate MAX_APPLET_NAME_LEN (unused)
Denys Vlasenko [Tue, 26 Nov 2013 11:03:24 +0000 (12:03 +0100)]
build system: do not generate MAX_APPLET_NAME_LEN (unused)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agologread: don't call shmdt() before exit, kernel does it for us.
Denys Vlasenko [Tue, 26 Nov 2013 11:02:18 +0000 (12:02 +0100)]
logread: don't call shmdt() before exit, kernel does it for us.

function                                             old     new   delta
logread_main                                         472     466      -6
interrupted                                           20       9     -11
error_exit                                            20       -     -20
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/2 up/down: 0/-37)             Total: -37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agologread: flush output. closes 6710
Denys Vlasenko [Tue, 26 Nov 2013 10:44:27 +0000 (11:44 +0100)]
logread: flush output. closes 6710

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoawk: fix a bug in argc counting in recent change
Denys Vlasenko [Thu, 21 Nov 2013 14:09:55 +0000 (15:09 +0100)]
awk: fix a bug in argc counting in recent change

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agorfkill: use new-style config/kbuild/applet
Denys Vlasenko [Wed, 20 Nov 2013 13:20:07 +0000 (14:20 +0100)]
rfkill: use new-style config/kbuild/applet

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotar: prevent empty file to be treated as valid tarball
Denys Vlasenko [Tue, 19 Nov 2013 16:17:48 +0000 (17:17 +0100)]
tar: prevent empty file to be treated as valid tarball

function                                             old     new   delta
tar_main                                             879     895     +16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofix a copy/paste error in last tar testcase name
Denys Vlasenko [Tue, 19 Nov 2013 15:56:26 +0000 (16:56 +0100)]
fix a copy/paste error in last tar testcase name

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotar: add a testcase for previous commit
Denys Vlasenko [Tue, 19 Nov 2013 13:52:02 +0000 (14:52 +0100)]
tar: add a testcase for previous commit

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotar: fix exitcode check for MMU-spawned unpacking helpers
Denys Vlasenko [Tue, 19 Nov 2013 13:44:04 +0000 (14:44 +0100)]
tar: fix exitcode check for MMU-spawned unpacking helpers

Testcase: tar xvzf EMPTY_FILE

function                                             old     new   delta
open_transformer                                     102     106      +4
get_header_tar                                      1781    1785      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: move nuke_str() from passwd into libbb
Denys Vlasenko [Tue, 19 Nov 2013 12:36:45 +0000 (13:36 +0100)]
libbb: move nuke_str() from passwd into libbb

function                                             old     new   delta
nuke_str                                               -      15     +15
ask_and_check_password_extended                      215     206      -9
init_main                                            781     771     -10
nuke_str                                              27       -     -27
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 15/-46)            Total: -31 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agocomment tweak
Denys Vlasenko [Tue, 19 Nov 2013 12:16:44 +0000 (13:16 +0100)]
comment tweak

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosulogin: use common password-checking routine.
Denys Vlasenko [Tue, 19 Nov 2013 12:09:06 +0000 (13:09 +0100)]
sulogin: use common password-checking routine.

This needed some extensions correct_passwd() function,
which got renamed ask_and_check_password() to better describe what it does.

function                                             old     new   delta
ask_and_check_password_extended                        -     215    +215
ask_and_check_password                                 -      12     +12
vlock_main                                           394     397      +3
sulogin_main                                         494     326    -168
correct_password                                     207       -    -207
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/1 up/down: 230/-375)         Total: -145 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoarchival/*: move "config:" snippets into .c files
Denys Vlasenko [Thu, 14 Nov 2013 10:39:00 +0000 (11:39 +0100)]
archival/*: move "config:" snippets into .c files

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoarchival/*: move "applet:" snippets into .c files, part 2
Denys Vlasenko [Thu, 14 Nov 2013 10:38:18 +0000 (11:38 +0100)]
archival/*: move "applet:" snippets into .c files, part 2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoarchival/*: move "applet:" snippets into .c files
Denys Vlasenko [Thu, 14 Nov 2013 08:54:24 +0000 (09:54 +0100)]
archival/*: move "applet:" snippets into .c files

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoarchival/*: move "kbuild:" snippets into .c files
Denys Vlasenko [Thu, 14 Nov 2013 08:53:52 +0000 (09:53 +0100)]
archival/*: move "kbuild:" snippets into .c files

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoswitch editors/* to embedded-in-source kbuild system
Denys Vlasenko [Wed, 13 Nov 2013 11:45:33 +0000 (12:45 +0100)]
switch editors/* to embedded-in-source kbuild system

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoawk: optionally support -e AWK_PROG
Sven-Göran Bergh [Tue, 12 Nov 2013 13:18:25 +0000 (14:18 +0100)]
awk: optionally support -e AWK_PROG

function                                             old     new   delta
awk_main                                             959     978     +19

Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agofstrim: use new-style config/kbuild/applet snippets; trim help text
Denys Vlasenko [Tue, 12 Nov 2013 11:09:14 +0000 (12:09 +0100)]
fstrim: use new-style config/kbuild/applet snippets; trim help text

function                                             old     new   delta
packed_usage                                       29546   29520     -26

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoudhcp: add PXELINUX config file option (code 209) definition
Jeremy Kerr [Tue, 12 Nov 2013 10:18:26 +0000 (11:18 +0100)]
udhcp: add PXELINUX config file option (code 209) definition

This change adds a definition for DHCP option 209. RFC 5071 defines code
209 as a configuration file for a PXE bootloader; this change uses
the string "pxeconffile" as its text identifier.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agofix "warning: ISO C90 forbids mixed declarations and code"
Denys Vlasenko [Tue, 12 Nov 2013 10:16:30 +0000 (11:16 +0100)]
fix "warning: ISO C90 forbids mixed declarations and code"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agofix bashisms in testsuite/
Michael Tokarev [Sun, 10 Nov 2013 21:01:38 +0000 (22:01 +0100)]
fix bashisms in testsuite/

These places use ${var/search/replace}, $((n++) and
`type -p' constructs which are not-so-standard.
Replace with equivalent constructs.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agofstrim: Needs to fire at the mp, not bd
Bernhard Reutner-Fischer [Sun, 10 Nov 2013 20:47:02 +0000 (21:47 +0100)]
fstrim: Needs to fire at the mp, not bd

It's a filesystem thing from this perspective.
+1b

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agofstrim: Indicate failure on error
Bernhard Reutner-Fischer [Sat, 9 Nov 2013 23:02:43 +0000 (00:02 +0100)]
fstrim: Indicate failure on error

+14b

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agofstrim: -17b
Bernhard Reutner-Fischer [Sat, 9 Nov 2013 22:13:17 +0000 (23:13 +0100)]
fstrim: -17b

Also, use the name of the block device we found, not necessarily the one
we got from the user:
fstrim -v /
/dev/sdj: 4711 bytes were trimmed

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agofstrim: New applet
Malek Degachi [Sat, 9 Nov 2013 20:27:27 +0000 (21:27 +0100)]
fstrim: New applet

fstrim applet is a port from util-linux.

"Trimming" your NAND/eMMC storage will restore the write performance
back to normal after having slow down issues on sequential write and
random write due to usage over time.

Good reading on subject:
http://forum.xda-developers.com/showthread.php?t=1971852

(with long options and CLEAN_UP turned on)
function                                             old     new   delta
.rodata                                           148494  148791    +297
fstrim_main                                            -     283    +283
fstrim_sfx                                             -     128    +128
packed_usage                                       28826   28903     +77
applet_main                                         2760    2768      +8
applet_names                                        2343    2350      +7
applet_nameofs                                       690     692      +2
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 5/0 up/down: 802/0)             Total: 802 bytes

Signed-off-by: Malek Degachi <malek-degachi@laposte.net>
Cc: Eugene San (eugenesan) <eugenesan@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agoash: Set SHLVL in ASH_BASH_COMPAT
Bernhard Reutner-Fischer [Fri, 8 Nov 2013 13:25:24 +0000 (14:25 +0100)]
ash: Set SHLVL in ASH_BASH_COMPAT

function                                             old     new   delta
ash_main                                            1456    1505     +49
.rodata                                           148488  148494      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 55/0)               Total: 55 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agoash: Use setvar2 some more
Bernhard Reutner-Fischer [Fri, 8 Nov 2013 13:12:13 +0000 (14:12 +0100)]
ash: Use setvar2 some more

(add/remove: 0/0 grow/shrink: 10/15 up/down: 13/-27)          Total: -14 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agoswaponoff: shrink
Bernhard Reutner-Fischer [Fri, 27 Sep 2013 11:39:41 +0000 (13:39 +0200)]
swaponoff: shrink

function                                             old     new   delta
.rodata                                           148469  148468      -1
swap_on_off_main                                     381     379      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-3)               Total: -3 bytes
   text    data     bss     dec     hex filename
 803030    4090    9504  816624   c75f0 busybox_old
 803027    4090    9504  816621   c75ed busybox_unstripped

11 years agoudhcpc: allow zero server-id. Closes 6614.
Denys Vlasenko [Sun, 3 Nov 2013 18:20:54 +0000 (19:20 +0100)]
udhcpc: allow zero server-id. Closes 6614.

function                                             old     new   delta
bcast_or_ucast                                         -      47     +47
udhcp_send_kernel_packet                             271     295     +24
udhcpc_main                                         2696    2705      +9
udhcp_send_raw_packet                                456     459      +3
send_release                                          90      76     -14
send_renew                                           105      77     -28
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/2 up/down: 83/-42)             Total: 41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoinit: fix illegal memory access when max message length is reached
Yuan-Hsiang Lee [Sat, 2 Nov 2013 23:13:16 +0000 (00:13 +0100)]
init: fix illegal memory access when max message length is reached

Signed-off-by: Yuan-Hsiang Lee <yhlee@ubnt.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agobootchartd: warn if .config looks wrong
Denys Vlasenko [Sat, 2 Nov 2013 23:07:31 +0000 (00:07 +0100)]
bootchartd: warn if .config looks wrong

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMakefile.custom: make "make release" delete .gitignore files too
Denys Vlasenko [Sat, 2 Nov 2013 21:06:36 +0000 (22:06 +0100)]
Makefile.custom: make "make release" delete .gitignore files too

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosed: fix "sed clusternewline" testcase
Denys Vlasenko [Wed, 30 Oct 2013 13:25:22 +0000 (14:25 +0100)]
sed: fix "sed clusternewline" testcase

function                                             old     new   delta
process_files                                       2197    2226     +29
flush_append                                          47      54      +7
get_next_line                                        184     189      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 41/0)               Total: 41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosed: document -E in help text
Denys Vlasenko [Wed, 30 Oct 2013 12:00:00 +0000 (13:00 +0100)]
sed: document -E in help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosed: fix memory leak in 'r FILE' command
Denys Vlasenko [Wed, 30 Oct 2013 09:22:47 +0000 (10:22 +0100)]
sed: fix memory leak in 'r FILE' command

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosed: accept -E as a synonym for -r
David A. Wheeler [Mon, 28 Oct 2013 23:52:48 +0000 (00:52 +0100)]
sed: accept -E as a synonym for -r

Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoudhcpc: make DHCP packets to have at least 300 DHCP bytes
Johannes Stezenbach [Mon, 28 Oct 2013 22:27:37 +0000 (23:27 +0100)]
udhcpc: make DHCP packets to have at least 300 DHCP bytes

Commit b8b72f02 removed all padding from DHCP packets
to fix operation with buggy servers which can't handle
maximum sized packets.  But it introduced a regression
with buggy routers which drop DHCP packets smaller
than 300 bytes (i.e. 342 byte ethernet packets).
Add back some padding to work around.

function                                             old     new   delta
udhcp_send_kernel_packet                             268     292     +24
udhcp_send_raw_packet                                462     473     +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 35/0)               Total: 35 bytes

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agolibbb: use <poll.h> instead of <sys/poll.h>
Thomas Petazzoni [Wed, 16 Oct 2013 17:59:45 +0000 (19:59 +0200)]
libbb: use <poll.h> instead of <sys/poll.h>

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agobloat-o-meter: add usage info
Bartosz Golaszewski [Wed, 16 Oct 2013 17:18:05 +0000 (19:18 +0200)]
bloat-o-meter: add usage info

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agotail compat: fix header printing for tail -f
Bartosz Golaszewski [Mon, 14 Oct 2013 18:11:55 +0000 (20:11 +0200)]
tail compat: fix header printing for tail -f

Makes tail -f for multiple files display the header only if another (ie. not
currently displayed) file changed.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agowget: if FEATURE_CLEAN_UP, free(ptr_to_globals)
Guilherme Maciel Ferreira [Wed, 16 Oct 2013 12:43:30 +0000 (14:43 +0200)]
wget: if FEATURE_CLEAN_UP, free(ptr_to_globals)

Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix some compiler warnings emitted by gcc-4.8.0
Denys Vlasenko [Wed, 16 Oct 2013 12:21:20 +0000 (14:21 +0200)]
Fix some compiler warnings emitted by gcc-4.8.0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoether-wake: shorten help text, reduce packet buffer size
Denys Vlasenko [Mon, 14 Oct 2013 17:04:20 +0000 (19:04 +0200)]
ether-wake: shorten help text, reduce packet buffer size

function                                             old     new   delta
ether_wake_main                                      726     727      +1
packed_usage                                       29468   29434     -34

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agowget: add support for connect timeout
Lauri Kasanen [Sat, 12 Oct 2013 19:47:07 +0000 (21:47 +0200)]
wget: add support for connect timeout

function                                             old     new   delta
open_socket                                           33      64     +31
wget_main                                           2182    2194     +12

Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoinit: better --help text
Denys Vlasenko [Sat, 12 Oct 2013 02:52:22 +0000 (04:52 +0200)]
init: better --help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoawk: fix length(array)
Denys Vlasenko [Sat, 12 Oct 2013 02:51:54 +0000 (04:51 +0200)]
awk: fix length(array)

function                                             old     new   delta
evaluate                                            3526    3548     +22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agowall,crontab: use xopen_as_uid_gid()
Ryan Mallon [Tue, 8 Oct 2013 12:53:29 +0000 (14:53 +0200)]
wall,crontab: use xopen_as_uid_gid()

This fixes a narrow security race in crontab.

function                                             old     new   delta
xopen_as_uid_gid                                       -      80     +80
seteuid                                                -      64     +64
setegid                                                -      64     +64
setreuid                                               -      37     +37
xseteuid                                               -      22     +22
xsetegid                                               -      22     +22
crontab_main                                         590     577     -13
setfsuid                                              33       -     -33
setfsgid                                              33       -     -33
wall_main                                            138     102     -36
open_as_user                                         109       -    -109

   text    data     bss     dec     hex filename
 893539     497    7568  901604   dc1e4 busybox_old
 893618     497    7568  901683   dc233 busybox_unstripped

Signed-off-by: Ryan Mallon <rmallon@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agolibbb: Add xsetegid(), xseteuid(), xopen_as_uid_gid() functions
Ryan Mallon [Tue, 8 Oct 2013 12:52:49 +0000 (14:52 +0200)]
libbb: Add xsetegid(), xseteuid(), xopen_as_uid_gid() functions

Signed-off-by: Ryan Mallon <rmallon@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agobunzip2: fix off-by-one check
Denys Vlasenko [Sun, 6 Oct 2013 20:53:14 +0000 (22:53 +0200)]
bunzip2: fix off-by-one check

stage3-armv7a_hardfp-20130209.tar.bz2, 149189948 bytes long,
md5sum b29ce23312e14eb15a143377d4a38473, was failing to unpack.

It so happened that this file has a run which exactly fills
the 90k buffer. The check was "size >= bufsize", apparently
it has to be ">".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agowall: access FILE under real user's credentials
Denys Vlasenko [Sun, 6 Oct 2013 13:14:25 +0000 (15:14 +0200)]
wall: access FILE under real user's credentials

While at it, move applet/config/kbuild bits into wall.c.
(This way, it's more visible that applet is suid'ed).

function                                             old     new   delta
wall_main                                             87     138     +51

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agotrylink: only prefix libs with -l
Mike Frysinger [Thu, 12 Sep 2013 04:29:40 +0000 (00:29 -0400)]
trylink: only prefix libs with -l

If our pkg-config queries pass back a flag like -pthread, the trylink
script will expand that to -l-pthread.  So change trylink to only add
the -l prefix to a value that doesn't have a - prefix already.

Reported-by: thaehaid@incognitomail.org
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agoloadkmap: explain what happens with K_ALLOCATED key value
Denys Vlasenko [Thu, 19 Sep 2013 15:56:59 +0000 (17:56 +0200)]
loadkmap: explain what happens with K_ALLOCATED key value

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agohttpd: make sire pfd[TO_CGI].revents is cleared before poll()
Denys Vlasenko [Wed, 18 Sep 2013 10:08:41 +0000 (12:08 +0200)]
httpd: make sire pfd[TO_CGI].revents is cleared before poll()

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoDocumentation update
Denys Vlasenko [Tue, 17 Sep 2013 14:24:01 +0000 (16:24 +0200)]
Documentation update

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodumpkmap: code shrink
Denys Vlasenko [Tue, 17 Sep 2013 12:16:25 +0000 (14:16 +0200)]
dumpkmap: code shrink

function                                             old     new   delta
dumpkmap_main                                        223     160     -63

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agohttpd: treat errors from stdin correctly.
Denys Vlasenko [Wed, 11 Sep 2013 12:59:21 +0000 (14:59 +0200)]
httpd: treat errors from stdin correctly.

Fron bug report:

If a CGI or proxied connection is rudely aborted (SIG_{KILL,BUS,SEGV})
then httpd will spin madly the poll loop in:

networking/httpd.c:1080
cgi_io_loop_and_exit()

Upon investigation I found that pfd[0].revents == 0x0018 (POLLHUP|POLLERR),
which leads to empty read, but the pfd[0].fd (STDIN_FILENO) is left open,
and in the FD list given to poll() which immediately returns to once
again inform the loop of (POLLHUP|POLLERR) condition of pfd[0].fd.
This continues until pfd[FROM_CGI].revents != 0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agotouch: add conditional support for -h
Denys Vlasenko [Wed, 11 Sep 2013 09:58:33 +0000 (11:58 +0200)]
touch: add conditional support for -h

Based on a patch by Andy <andy.padavan@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoar: better comment
Denys Vlasenko [Tue, 10 Sep 2013 14:27:08 +0000 (16:27 +0200)]
ar: better comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoar: read_num(): fix reading fields using the entire width
Peter Korsgaard [Tue, 10 Sep 2013 09:52:35 +0000 (11:52 +0200)]
ar: read_num(): fix reading fields using the entire width

ar fields are fixed length text strings (padded with spaces). Ensure
bb_strtou doesn't read past the field in case the full width is used.

The fields are only read once, so the simplest/smallest solution to me
seems to be to just pass the length to read_num() and then zero terminate
the string before passing it to bb_strtou. This does mean that the fields
MUST be read in reverse order, so some minor reshuffling was needed.

Bloat-o-meter:
function                                             old     new   delta
get_header_ar                                        394     414     +20
read_num                                              29      36      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 27/0)               Total: 27 bytes

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agotop: fix breakage introduced by previous commit
Denys Vlasenko [Fri, 6 Sep 2013 10:59:48 +0000 (12:59 +0200)]
top: fix breakage introduced by previous commit

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMake smart_ulltoa return pointer to end (allows for code shink in callers)
Denys Vlasenko [Fri, 6 Sep 2013 10:53:14 +0000 (12:53 +0200)]
Make smart_ulltoa return pointer to end (allows for code shink in callers)

function                                             old     new   delta
smart_ulltoa5                                        405     408      +3
smart_ulltoa4                                        273     276      +3
list_table                                          1113    1114      +1
scale                                                 36      34      -2
put_lu                                                55      53      -2
ulltoa6_and_space                                     19      14      -5
powertop_main                                       1470    1461      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoman: find posix man pages
John Spencer [Sun, 25 Aug 2013 21:38:25 +0000 (17:38 -0400)]
man: find posix man pages

Add the 0p/1p/3p sections to the search.

Signed-off-by: John Spencer <maillist-busybox@barfooze.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agofdisk: fix GPT size math errors
Jody Bruchon [Tue, 20 Aug 2013 15:42:06 +0000 (17:42 +0200)]
fdisk: fix GPT size math errors

Signed-off-by: Jody Bruchon <jody@jodybruchon.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agolineedit: use unicode_strwidth instead of unicode_strlen
Denys Vlasenko [Tue, 20 Aug 2013 14:13:05 +0000 (16:13 +0200)]
lineedit: use unicode_strwidth instead of unicode_strlen

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodd: code shrink
Denys Vlasenko [Tue, 20 Aug 2013 10:49:28 +0000 (12:49 +0200)]
dd: code shrink

function                                             old     new   delta
dd_main                                             1475    1469      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodd: code shrink
Denys Vlasenko [Tue, 20 Aug 2013 10:45:05 +0000 (12:45 +0200)]
dd: code shrink

function                                             old     new   delta
dd_main                                             1487    1475     -12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodd: code shrink
Denys Vlasenko [Tue, 20 Aug 2013 10:40:29 +0000 (12:40 +0200)]
dd: code shrink

function                                             old     new   delta
write_and_stats                                       78      99     +21
dd_main                                             1496    1487      -9
full_write_or_warn                                    42       -     -42
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 21/-51)            Total: -30 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodd: remove FIXME comment which is fixed now. No code changes
Denys Vlasenko [Tue, 20 Aug 2013 10:27:19 +0000 (12:27 +0200)]
dd: remove FIXME comment which is fixed now. No code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodd: code shrink
Denys Vlasenko [Tue, 20 Aug 2013 10:08:46 +0000 (12:08 +0200)]
dd: code shrink

function                                             old     new   delta
dd_main                                             1001     961     -40

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodd: fail if swab is attempted on odd-sized block
Denys Vlasenko [Tue, 20 Aug 2013 00:50:49 +0000 (02:50 +0200)]
dd: fail if swab is attempted on odd-sized block

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agolineedit: fix multi-line PS1 handling: calculate PS1 length from last \n
Denys Vlasenko [Mon, 19 Aug 2013 14:45:04 +0000 (16:45 +0200)]
lineedit: fix multi-line PS1 handling: calculate PS1 length from last \n

function                                             old     new   delta
parse_and_put_prompt                                 755     774     +19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agolineedit: improve Unicode handling (still buggy though)
Denys Vlasenko [Mon, 19 Aug 2013 14:44:05 +0000 (16:44 +0200)]
lineedit: improve Unicode handling (still buggy though)

function                                             old     new   delta
unicode_strlen                                         -      31     +31
read_line_input                                     3876    3879      +3
lineedit_read_key                                    255     246      -9
parse_and_put_prompt                                 785     755     -30
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 34/-39)             Total: -5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodd: fix example in a comment. No code changes.
Denys Vlasenko [Mon, 19 Aug 2013 08:30:55 +0000 (10:30 +0200)]
dd: fix example in a comment. No code changes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodd: support conv=swab
Denys Vlasenko [Mon, 19 Aug 2013 07:01:39 +0000 (09:01 +0200)]
dd: support conv=swab

function                                             old     new   delta
dd_main                                             1482    1520     +38
static.conv_words                                     28      33      +5
packed_usage                                       29377   29375      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodd: do not reuse local variables for unrelated values.
Denys Vlasenko [Mon, 19 Aug 2013 07:00:08 +0000 (09:00 +0200)]
dd: do not reuse local variables for unrelated values.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoiplink: comment out include <net/if_packet.h>
Denys Vlasenko [Fri, 16 Aug 2013 10:20:25 +0000 (12:20 +0200)]
iplink: comment out include <net/if_packet.h>

iplink.c includes net/if_packet.h, which (on GLIBC)
only defines struct sockaddr_pkt. this struct is not
used anywhere in the code, and removing the #include
makes compilation succeed with musl libc.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoinit: don't srop unterminated processes' entries during inittab reload
Paulius Zaleckas [Fri, 16 Aug 2013 10:01:58 +0000 (12:01 +0200)]
init: don't srop unterminated processes' entries during inittab reload

This feature was removed in 72c99af

It is useful when process is removed from inittab and later added
back, but never terminated. It prevents init from spawning duplicate.

function                                             old     new   delta
check_delayed_sigs                                   176     182      +6

Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoinit: don't use fixed size buffer for command
Denys Vlasenko [Fri, 16 Aug 2013 09:48:48 +0000 (11:48 +0200)]
init: don't use fixed size buffer for command

We store init actions forever. 256 bytes per action means that
a typical inittab of ~10 commands uses 2.5k just to remember
command strings - which are usually _much_ shorter than 256 bytes.

At a cost of a bit more code, it's possible to allocate
only actually needed amount.

function                                             old     new   delta
init_exec                                            224     248     +24
new_init_action                                      140     142      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agotar: fix tar -T to add entries in the exact order as the input list
SASAKI Suguru [Thu, 15 Aug 2013 10:19:29 +0000 (12:19 +0200)]
tar: fix tar -T to add entries in the exact order as the input list

This fixes tar to order files in tarball correctly in this case:

$ touch 1 2 3; echo -e '1\n2\n3' | tar -T- -c | tar t
1
2
3

Signed-off-by: SASAKI Suguru <suguru@sonik.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agofix build error with musl libc due to if_slip.h
Denys Vlasenko [Thu, 15 Aug 2013 07:54:51 +0000 (09:54 +0200)]
fix build error with musl libc due to if_slip.h

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agonetworking: fix potential overflow in ife_print6()
Nicolas Dichtel [Mon, 12 Aug 2013 15:09:59 +0000 (17:09 +0200)]
networking: fix potential overflow in ife_print6()

devname is used by fscanf to store a string specified by '%20s'.

Extract from the man for the '%s' specifier:
Matches a sequence of non-white-space characters; the next pointer must be a
pointer to character array that is long enough to hold the input sequence and
the terminating null byte ('\0'), which is added automatically. The input
string stops at white space or at the maximum field width, whichever occurs
first.

Hence, the right length is 20 + 1 for the '\0'.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoudhcpc: tweak help text more
Denys Vlasenko [Thu, 8 Aug 2013 10:45:45 +0000 (12:45 +0200)]
udhcpc: tweak help text more

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoudhcpc: tweak help text
Denys Vlasenko [Thu, 8 Aug 2013 10:33:18 +0000 (12:33 +0200)]
udhcpc: tweak help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoswapon: support "pri=NNN" in fstab
Tito Ragusa [Thu, 8 Aug 2013 08:21:27 +0000 (10:21 +0200)]
swapon: support "pri=NNN" in fstab

function                                             old     new   delta
swap_on_off_main                                     244     365    +121

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosetsid: code shrink, expanded comments
Denys Vlasenko [Wed, 7 Aug 2013 16:49:51 +0000 (18:49 +0200)]
setsid: code shrink, expanded comments

function                                             old     new   delta
setsid_main                                           56      53      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agolibbb: code shrink
Denys Vlasenko [Mon, 5 Aug 2013 22:41:06 +0000 (00:41 +0200)]
libbb: code shrink

function                                             old     new   delta
xmalloc_ttyname                                       46      42      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoudhcpc: tweak help text
Denys Vlasenko [Mon, 5 Aug 2013 00:21:36 +0000 (02:21 +0200)]
udhcpc: tweak help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosyslogd: use _PATH_LOG when available
Cédric Cabessa [Mon, 5 Aug 2013 00:09:16 +0000 (02:09 +0200)]
syslogd: use _PATH_LOG when available

Signed-off-by: Cédric Cabessa <ccabessa@genymobile.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoubi_tools: fix typo in strcpy
Paul B. Henson [Sun, 4 Aug 2013 19:07:20 +0000 (21:07 +0200)]
ubi_tools: fix typo in strcpy

Signed-off-by: Paul B. Henson <henson@acm.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoifplugd: use a larger netlink buffer
Tito Ragusa [Sun, 4 Aug 2013 16:08:40 +0000 (18:08 +0200)]
ifplugd: use a larger netlink buffer

function                                             old     new   delta
check_existence_through_netlink                      310     321     +11

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>