Commit Graph

13443 Commits

Author SHA1 Message Date
Pascal Bellard
d3633b7e9c fatattr: new applet
function                                             old     new   delta
fatattr_main                                           -     281    +281
packed_usage                                       29821   29871     +50
bit_to_char                                            -      10     +10
applet_names                                        2472    2480      +8
applet_main                                         1436    1440      +4
applet_nameofs                                       718     720      +2
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 4/0 up/down: 355/0)             Total: 355 bytes

Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-30 13:06:39 +02:00
Denys Vlasenko
a9dc7c2f59 lzop: add overflow check
See CVE-2014-4607
http://www.openwall.com/lists/oss-security/2014/06/26/20

function                                             old     new   delta
lzo1x_decompress_safe                               1010    1031     +21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-30 10:14:34 +02:00
Michael Gernoth
1b487ea8a6 stat: fix printing selinux context and null-dereference
busybox stat tries to always print the selinux context, even if it
is not requested which leads to a segmentation fault due to
dereferencing a null-pointer.

This also changes the format-string used to print the context to
so it actually produces useful output.

Signed-off-by: Michael Gernoth <michael@gernoth.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-27 14:08:29 +02:00
Denys Vlasenko
9d7cbdeee3 ftpd: do not use root_fd if we are not in chroot
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-27 13:53:35 +02:00
Denys Vlasenko
27c290f7f2 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>
2014-06-27 12:37:00 +02:00
Denys Vlasenko
a6ae999b3b 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>
2014-06-27 12:24:39 +02:00
Denys Vlasenko
5f8daefb83 awk: fix handling of "if ... break ; else ..." - closes 7226
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-26 16:40:28 +02:00
Denys Vlasenko
0b0ccd4570 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>
2014-06-26 12:07:48 +02:00
Richard Genoud
2a870d091e 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>
2014-06-25 17:38:30 +02:00
Richard Genoud
8feb25956f 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>
2014-06-25 17:37:01 +02:00
Richard Genoud
f17fbe1d36 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>
2014-06-25 17:37:01 +02:00
Richard Genoud
cbf3bfa57a 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>
2014-06-25 16:37:37 +02:00
Denys Vlasenko
de3cae1348 ftpd: support deprecated XPWD command
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-25 16:23:59 +02:00
Denys Vlasenko
5aeae36e2b libbb: fix compile failure if both ARG_MAX and _SC_ARG_MAX are defined
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-25 15:39:27 +02:00
Isaac Dunham
ea23c25e96 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>
2014-06-22 20:44:25 +02:00
Bartosz Golaszewski
3ed81cf052 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>
2014-06-22 16:30:41 +02:00
Bartosz Golaszewski
5d2e409ef8 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>
2014-06-22 14:01:13 +02:00
Denys Vlasenko
f92f1d0181 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>
2014-06-22 13:54:40 +02:00
Denys Vlasenko
6be3a5242c 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>
2014-06-19 11:32:11 +02:00
Bartosz Golaszewski
14158b4127 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>
2014-06-17 17:09:41 +02:00
Denys Vlasenko
85090c162b udhcpc: make hostname sanitization optional. Closes 3979
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-16 00:17:00 +02:00
Joshua Judson Rosen
9aa6ffb22b 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>
2014-06-02 03:11:40 +02:00
Joshua Judson Rosen
b905d6c2ea 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>
2014-06-02 03:11:39 +02:00
Joshua Judson Rosen
1b90e031c3 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>
2014-06-02 03:11:38 +02:00
Denys Vlasenko
fd0640e5a1 modprobe-small: fix safe_strncpy truncating last char of module name
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-26 15:01:13 +02:00
Denys Vlasenko
17f8418ea7 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>
2014-05-19 16:23:50 +02:00
Denys Vlasenko
539e2802eb getty: explain when setsid() fails. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-11 00:00:52 +02:00
Denys Vlasenko
62a40a0448 Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox 2014-05-11 00:00:51 +02:00
Denys Vlasenko
d257608a84 trylink: emit names of linked executables
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-04 17:35:31 +02:00
Tito Ragusa
a875d59d24 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>
2014-05-04 17:35:31 +02:00
Denys Vlasenko
e3366d696c trylink: emit names of linked executables
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-03 16:35:15 +02:00
Timo Teräs
1e3cce6814 which: rewrite
function                                             old     new   delta
which_main                                           237     212     -25

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-03 16:34:36 +02:00
Denys Vlasenko
e765b5ac34 libbb: rename execable -> executable. No code changes
English speakers complained that it sounded awfully broken.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 17:15:58 +02:00
Denys Vlasenko
15a357e596 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>
2014-05-02 17:08:29 +02:00
Denys Vlasenko
a4476eb654 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>
2014-05-02 12:46:15 +02:00
Denys Vlasenko
d8290c2ef0 libbb: fix thinko in rtc_xopen()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 09:07:16 +02:00
Denys Vlasenko
528808fa7b 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>
2014-05-02 09:05:03 +02:00
Denys Vlasenko
fe33683c8b Fix compile failures
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 07:18:55 +02:00
Denys Vlasenko
43b8a1cc38 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>
2014-04-30 17:38:27 +02:00
Denys Vlasenko
d5929d602e 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>
2014-04-30 14:49:52 +02:00
Denys Vlasenko
3dfe0ae5a8 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>
2014-04-30 14:48:28 +02:00
Denys Vlasenko
01a1a967c9 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>
2014-04-30 14:47:28 +02:00
Denys Vlasenko
07e5555a8f 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>
2014-04-21 16:59:36 +02:00
Denys Vlasenko
5a21c8550e ntpd: fix wrong delay value in one of the printed messages
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-20 13:04:23 +02:00
Denys Vlasenko
d531f93f64 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>
2014-04-19 19:00:16 +02:00
Denys Vlasenko
6116cb23cc 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>
2014-04-19 16:17:27 +02:00
Denys Vlasenko
5fd3ddfb24 modprobe-small: fix help messages for aliased module-related applets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-19 15:04:39 +02:00
Denys Vlasenko
e152cb8189 adjtimex: make its help text and printed data a bit less cryptic
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-17 11:29:34 +02:00
Denys Vlasenko
eb9f485b07 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>
2014-04-16 19:51:34 +02:00
Denys Vlasenko
3fa97af7cc 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>
2014-04-15 11:43:29 +02:00