Ron Yorston [Fri, 24 Jul 2015 13:28:08 +0000 (14:28 +0100)]
less: rearrange detection of non-regular files
Move the code to detect non-regular files to the point where the
file is being opened. If num_lines == READING_FILE guarantees
that the file is regular.
Detect when a file becomes unreadable between it first being opened
and the call to update_num_lines. Mark the file as being non-regular
so we don't try that again.
function old new delta
reinitialize 197 245 +48
update_num_lines 159 127 -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 48/-32) Total: 16 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Fri, 24 Jul 2015 13:27:42 +0000 (14:27 +0100)]
less: move code to count lines into a separate function
function old new delta
update_num_lines - 159 +159
m_status_print 409 266 -143
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 159/-143) Total: 16 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Tue, 21 Jul 2015 19:12:31 +0000 (20:12 +0100)]
less: fix numeric input
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Mike Frysinger [Thu, 30 Jul 2015 03:33:16 +0000 (23:33 -0400)]
echo: make escape sequences depend on fancy mode
Currently when you disable fancy echo, escape sequences are hardcoded
enabled (e.g. as if you used `echo -e` all the time). The opposite
behavior is more desirable (always disable -e support) because:
* This seems to contradict the spirit of the kconfig help text (where
it says enable support for -n/-e flags), although you could say that
we aren't supporting the -e flag directly as `echo -e` will show the
-e flag.
* POSIX makes escape sequences optional, and even says they are there
only on XSI-conformant systems.
* It saves space (~100 bytes on x86_64).
* It makes things faster!
* It makes it behave more like bash where you need an explicit -e flag
in order for escape sequences to be interpreted.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Linus Walleij [Mon, 27 Jul 2015 07:59:04 +0000 (09:59 +0200)]
fbset: fix rgba parsing
In commit
b5c7220e7b2b6611fe5beca494c67bfe51fcfafb
"fbset: respect rgba configuration lines in fb.modes"
I somehow managed to swap the offset/length markers around.
The man page for fb.modes says it should be offset/length
not length/offset as I was accidentally parsing it.
As my fb.modes file was also reversed I didn't notice
until I tried someone elses fb.modes file. Mea culpa.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Arthur Gautier [Tue, 28 Jul 2015 05:35:00 +0000 (05:35 +0000)]
udhcpc: dns labels can actually start with a number
While RFC1035 recommends a label not to start with a number, there is
actually no such limitation in dns. One may buy a domain name like
0x1.net and use it.
This commit remove this check and allow a user to use such domains.
Signed-off-by: Arthur Gautier <baloo@gandi.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Tue, 21 Jul 2015 20:28:09 +0000 (22:28 +0200)]
less: improvements to verbose status messages
Make verbose status messages (-m/-M flags) behave more like the
real `less` command:
- fix display of line numbers so they're correct whether lines are
being truncated (-S flag) or wrapped.
- don't display total lines or percentage when lines are read from
stdin: we don't have that information until we reach EOF. When
we do reach EOF the additional information is displayed.
- when lines are read from a file count the total number of lines
so that we can display percentages. Counting lines is avoided
until the information is actually needed. If the user pages to
EOF the separate read pass can be avoided entirely.
Fixes Bug 7586
function old new delta
m_status_print 195 382 +187
safe_lineno - 35 +35
reinitialize 172 182 +10
read_lines 675 685 +10
buffer_fill_and_print 178 169 -9
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 242/-9) Total: 233 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Tue, 21 Jul 2015 17:50:48 +0000 (19:50 +0200)]
sync: add support for -d -f FILE
Based on the patch by Ari Sundholm <ari@tuxera.com>
function old new delta
sync_main 20 163 +143
packed_usage 30653 30673 +20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 163/0) Total: 163 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Sun, 19 Jul 2015 21:12:51 +0000 (23:12 +0200)]
Remove old_e2fsprogs/*
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Sun, 19 Jul 2015 21:05:20 +0000 (23:05 +0200)]
libbb: add a function to make a copy of a region of memory
Introduce a library routine to package the idiom:
p = xmalloc(b, n);
memcpy(p, b, n);
and use it where possible. The example in traceroute used xzalloc
but it didn't need to.
function old new delta
xmemdup - 32 +32
last_main 834 826 -8
make_device 2321 2311 -10
common_traceroute_main 3698 3685 -13
readtoken1 3182 3168 -14
procps_scan 1222 1206 -16
forkchild 655 638 -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78) Total: -46 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Sun, 19 Jul 2015 20:41:09 +0000 (21:41 +0100)]
less: correctly account for tabs when rewrapping lines
Lines are rewrapped when the terminal width changes or line numbers
are enabled/disabled. The current calculation always adds eight to
the line length for a tab whereas it should only add enough to move
to the next tab stop.
This doesn't affect the display of lines, which is handled elsewhere
and gets tab stops right, but it does cause lines to be wrapped at
the wrong position.
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Sat, 18 Jul 2015 15:20:03 +0000 (16:20 +0100)]
less: fix display of line numbers
Line numbers are displayed incorrectly on lines that have a search
pattern highlighted. The problem can be fixed by moving the call to
lineno_str in print_found above the while loop that alters the value
of the line pointer. However, a more substantial rewrite results in
savings.
function old new delta
buffer_print 688 697 +9
.rodata 156077 156045 -32
lineno_str 85 - -85
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 9/-117) Total: -108 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Sun, 19 Jul 2015 10:12:29 +0000 (11:12 +0100)]
less: document -S flag and make it independently configurable
The -S flag, to cause long lines to be truncated, was enabled by
FEATURE_LESS_DASHCMD. This is non-obvious and -S is useful even
if the '-' command isn't enabled.
function old new delta
.rodata 156045 156077 +32
packed_usage 30223 30244 +21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 53/0) Total: 53 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Wed, 1 Jul 2015 15:46:18 +0000 (16:46 +0100)]
ash: use alloca to get rid of setjmp
Now that the only thing protected by setjmp/longjmp is the saved string,
we can allocate it on the stack to get rid of the jump.
Based on commit
bd35d8e from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu.
function old new delta
readtoken1 3182 3116 -66
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-66) Total: -66 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Mon, 13 Jul 2015 01:52:32 +0000 (03:52 +0200)]
fix file mode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Wed, 1 Jul 2015 15:45:40 +0000 (16:45 +0100)]
ash: remove parsebackquote flag
Commit
503a0b8 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu says:
>The parsebackquote flag is only used in a test where it always has the
>value zero. So we can remove it altogether.
The first statement is incorrect: parsebackquote is non-zero when
backquotes (as opposed to $(...)) are used for command substitution.
It is possible for the test to be executed with parsebackquote != 0 in
that case.
The test is question checks whether quotes have been closed, raising
the error "unterminated quoted string" if they haven't. There seems
to be no good reason to allow unclosed quotes within backquotes. Bash,
hush and dash (after commit
503a0b8) all treat the following as an error:
XX=`"pwd`
whereas BusyBox ash doesn't. It just ignores the unclosed quote and
executes pwd.
So, parsebackquote should be removed but not for the reason stated.
function old new delta
parsebackquote 1 - -1
readtoken1 3222 3182 -40
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-41) Total: -41 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Maninder Singh [Wed, 10 Jun 2015 03:47:27 +0000 (03:47 +0000)]
Removes stray empty line from code
This patch removes stray empty line from busybox code
reported by script find_stray_empty_lines
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Clayton Shotwell [Thu, 21 May 2015 19:48:35 +0000 (14:48 -0500)]
applets: Add installation of individual binaries
Adding support to install individual binaries if the option is
enabled. This also installs the shared libbusybox.so.* library.
Signed-off-by: Clayton Shotwell <clshotwe@rockwellcollins.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Wed, 1 Jul 2015 17:07:24 +0000 (19:07 +0200)]
ps: fix SEGV on narrow screens. closes 8176
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Wed, 1 Jul 2015 16:36:06 +0000 (18:36 +0200)]
ipaddress: better formatting, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Michael Tokarev [Wed, 20 May 2015 13:27:44 +0000 (16:27 +0300)]
ip addr: support change and replace commands
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Maninder Singh [Mon, 1 Jun 2015 10:40:09 +0000 (10:40 +0000)]
fix whitespaces
reported by script :- scripts/fix_ws.sh
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Maninder Singh [Mon, 1 Jun 2015 10:38:07 +0000 (10:38 +0000)]
fix if(p)/free(p) construct
No need of explicit NULL check before free.
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:32 +0000 (10:27 +0200)]
i2cdetect: use break instead of goto in list_i2c_busses_and_exit()
Since there are now more statements in the if block after the while loop
in list_i2c_busses_and_exit(), there's no need for a label.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:31 +0000 (10:27 +0200)]
i2cdump: code rework
Split i2cdump_main() into shorter functions. Simplify the code a bit.
Make block an array of ints so that we can store negative results of
read functions (fixes a bug found by Denys Vlasenko).
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:30 +0000 (10:27 +0200)]
i2cdetect: add a check for (mode == DETECT_MODE_AUTO)
We should only warn the user about addresses to be skipped if
(mode == DETECT_MODE_AUTO).
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:29 +0000 (10:27 +0200)]
i2cdetect: don't scan non-regular addresses without the '-a' option
Addresses 0x00-0x02 shouldn't be scanned by default. This patch makes
'first' default to 0x03 and only enables lower addresses if '-a' option
is passed
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Bartosz Golaszewski [Fri, 5 Jun 2015 08:27:28 +0000 (10:27 +0200)]
i2cdetect: don't die on addresses already in use by drivers
We can't use i2c_set_slave_addr() in i2cdetect, as we have to check for
EBUSY after calling ioctl(I2C_SLAVE) and print 'UU' on busy addresses
instead of bailing-out.
While we're at it: reorder definitions of local vars in i2cdetect_main().
function old new delta
i2cdetect_main 703 744 +41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 41/0) Total: 41 bytes
text data bss dec hex filename
826097 4164 9584 839845 cd0a5 busybox_old
826145 4164 9584 839893 cd0d5 busybox_unstripped
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Junling Zheng [Sun, 7 Jun 2015 00:32:23 +0000 (02:32 +0200)]
chown: fix help text
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ari Sundholm [Mon, 25 May 2015 13:16:11 +0000 (15:16 +0200)]
truncate: do not die when a file doesn't exist and no-create flag is on
Additionally, open(2) failures do not make the program die immediately.
This makes the behavior of the program match coreutils more closely.
function old new delta
truncate_main 161 221 +60
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Mon, 25 May 2015 12:30:52 +0000 (14:30 +0200)]
Print one less newline at the end of bb_show_usage()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Maninder Singh [Mon, 25 May 2015 11:46:36 +0000 (13:46 +0200)]
typo fixes
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Mon, 25 May 2015 11:31:25 +0000 (13:31 +0200)]
dc: fix "dc p" prinitng bogus data
function old new delta
check_under - 20 +20
print_no_pop 27 32 +5
pop 33 24 -9
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 25/-9) Total: 16 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Sun, 24 May 2015 16:01:53 +0000 (18:01 +0200)]
tc: fix print_rate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Mon, 18 May 2015 08:23:16 +0000 (10:23 +0200)]
hush: add recent ash tests to hush testsuite too (they all pass for hush)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Mon, 18 May 2015 08:13:21 +0000 (10:13 +0200)]
testsuite: add some tests for ash
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Mon, 18 May 2015 07:59:14 +0000 (09:59 +0200)]
ash: fix breakage of ${v/pat/str}
The commit
ash: move parse-time quote flag detection to run-time
breaks pattern substitution in parameter expansion. Fix this and
revise the code so that the different handling of the pattern and
the replacement string takes place in rmescapes rather than the
separate function parse_sub_pattern.
function old new delta
rmescapes 227 273 +46
static.qchars 3 4 +1
subevalvar 1177 1157 -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 47/-20) Total: 27 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Mon, 18 May 2015 07:57:51 +0000 (09:57 +0200)]
ash: move parse-time quote flag detection to run-time
Because the parser does not recursively parse parameter expansion
with respect to quotes, we can't accurately determine quote status at
parse time. This patch works around this by moving the quote detection
to run-time where we do interpret it recursively.
Test case:
foo=\\ echo "<${foo#[\\]}>"
Old result:
<\>
New result:
<>
Do not quote back slashes in parameter expansions outside quotes.
Test case:
a=/b/c/*
b=\\
echo ${a%$b*}
Old result:
/b/c/*
New result:
/b/c/
Based on commits
880d952,
7cfd8be,
0d7d660 and
a7c21a6 from
git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu
function old new delta
argstr 1164 1193 +29
memtodest 147 174 +27
subevalvar 1153 1177 +24
redirect 1279 1282 +3
dolatstr 5 7 +2
static.spclchars 10 9 -1
expandarg 962 960 -2
evalcase 273 271 -2
evalcommand 1204 1197 -7
rmescapes 236 227 -9
preglob 27 8 -19
evalvar 604 582 -22
cmdputs 389 334 -55
readtoken1 3163 3061 -102
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/9 up/down: 85/-219) Total: -134 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Mon, 18 May 2015 07:56:16 +0000 (09:56 +0200)]
ash: remove arithmetic expansion collapsing at parse time
Collapsing arithmetic expansion is incorrect when the inner arithmetic
expansion is a part of a parameter expansion.
Test case:
unset a
echo $((3 + ${a:=$((4 + 5))}))
echo $a
Old result:
12
(4 + 5)
New result:
12
9
Based on commit
bb777a6 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu
function old new delta
readtoken1 3180 3163 -17
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Mon, 18 May 2015 07:54:43 +0000 (09:54 +0200)]
ash: remove superfluous code in arithmetic mode
Based on commits
1a74845,
cfc3d6a and
ff13779 from
git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu
function old new delta
evalcommand 1197 1204 +7
localcmd 327 325 -2
readtoken1 3200 3180 -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 7/-22) Total: -15 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Mon, 18 May 2015 07:53:26 +0000 (09:53 +0200)]
ash: do not expand tilde in parameter expansion within quotes
Test case:
unset a
echo "${a:-~root}"
Old result:
/root
New result:
~root
Based on commit
170f44d from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu
function old new delta
evalvar 598 604 +6
parse_command 1440 1443 +3
localcmd 325 327 +2
readtoken1 3199 3200 +1
argstr 1180 1164 -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 12/-16) Total: -4 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Mon, 18 May 2015 07:51:35 +0000 (09:51 +0200)]
ash: perform tilde expansion in all parameter expansion words
Previously tilde expansion was not carried out for =?#% expansion words.
Test case:
a=~root:~root
echo ${a#~root}
Old result:
/root:/root
New result:
:/root
Based on commit
dd721f71 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu
function old new delta
subevalvar 1152 1153 +1
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Mon, 18 May 2015 07:49:28 +0000 (09:49 +0200)]
ash: code shrink around varvalue
Based on commit
c989d72 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu
function old new delta
strtodest - 40 +40
memtodest 123 147 +24
parse_command 1443 1440 -3
readtoken1 3205 3199 -6
argstr 1203 1180 -23
varvalue 788 660 -128
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/4 up/down: 64/-160) Total: -96 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Wed, 13 May 2015 00:20:14 +0000 (02:20 +0200)]
ash: explain what "local -" does
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Eugene Rudoy [Sun, 26 Apr 2015 21:32:00 +0000 (23:32 +0200)]
ash: consider "local -" case while iterating over local variables in mklocal.
fixes segfault introduced in
0a0acb55db8d7c4dec445573f1b0528d126b9e1f with functions using "local -".
test-case: f() { local -; local x; }; f
note: with this change applied multiple 'local -'s still cause multiple entries to be added to the localvars list.
this problem will be addressed in a separate commit.
Signed-off-by: Eugene Rudoy <gene.devel@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Daniel Thompson [Tue, 12 May 2015 06:56:04 +0000 (07:56 +0100)]
libbb: Enable support for !CONFIG_MULTIUSER
Linux recently gained a new config option, CONFIG_MULTIUSER, that makes
support for non-root users optional. This results in a number of syscalls
being disabled: setuid, setregid, setgid, setreuid, setresuid, getresuid,
setresgid, getresgid, setgroups, getgroups, setfsuid, setfsgid, capget,
capset.
Currently a number of busybox applets, including login, struggle to run
when CONFIG_MULTIUSER is disabled. Even the root user is unable to login:
login: can't set groups: Functi
This patch adds code to make change_identity() a nop on single user
systems. It works by recognising the signature errno value (ENOSYS, due
to the system calls being disabled) and, to avoid security risks, only
deploys when the current uid and target uid is the same.
After the patch is applied any attempt to switch to a non-root user will
fail. Thus a badly configured userspace (for example, one that tries to
start a daemon as a non-root user when the kernel cannot support this)
will report errors as one would expect.
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Bartosz Golaszewski [Mon, 11 May 2015 15:26:27 +0000 (17:26 +0200)]
i2c-tools: only try /dev/i2c/* if opening /dev/i2c-* fails with ENOENT
Trying to access /dev/i2c/* on every error after opening /dev/i2c-* can
mislead users who e.g. don't have root access. Instead of bailing-out
with "permission denied" we currently print "no such file or directory".
Fix it by trying open("/dev/i2c/%d") only if we got ENOENT.
Upstream i2cdetect tries to get any info it can from /sys and /proc even
when invoked by an unprivileged user, but we don't want to add unnecessary
bloat.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Bartosz Golaszewski [Mon, 11 May 2015 15:22:10 +0000 (17:22 +0200)]
i2c-tools: fix 'i2cdetect -l'
Calling 'i2cdetect -l' only displays usage and exits. Fix it by
correctly parsing command-line arguments.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Thiago Jung Bauermann [Mon, 11 May 2015 15:18:59 +0000 (17:18 +0200)]
bzcat.tests: Run both .gz and .bz2 tests, and add .Z tests
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Mon, 11 May 2015 14:55:16 +0000 (16:55 +0200)]
tar: do not try to decode GNU extended headers as pax headers
function old new delta
get_header_tar 1736 1692 -44
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Matt Whitlock [Sun, 3 May 2015 16:59:50 +0000 (18:59 +0200)]
Conditionalize Bionic workarounds on __ANDROID_API__
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Matt Whitlock [Sun, 3 May 2015 16:57:44 +0000 (18:57 +0200)]
Bionic lacks mempcpy; enable existing workaround
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Thiago Jung Bauermann [Sun, 3 May 2015 16:40:12 +0000 (18:40 +0200)]
libarchive: auto-detect .Z files as well
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Sun, 3 May 2015 16:24:33 +0000 (18:24 +0200)]
typo fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Andrew Fuller [Sun, 3 May 2015 16:18:25 +0000 (18:18 +0200)]
vi: basic undo feature shouldn't depend on yankmark
Currently basic undo functionality with the 'u' key depends on
FEATURE_VI_YANKMARK. These two features are separate, so we can remove this
dependency.
Signed-off-by: Andrew Fuller <abf@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Aaro Koskinen [Sun, 26 Apr 2015 12:22:05 +0000 (14:22 +0200)]
gzip: add support for compression levels 4-9
function old new delta
gzip_main 192 282 +90
static.gzip_level_config - 24 +24
packed_usage 30439 30459 +20
fill_window 216 220 +4
pack_gzip 1789 1729 -60
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 138/-60) Total: 78 bytes
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Matt Whitlock [Sun, 26 Apr 2015 11:14:50 +0000 (13:14 +0200)]
Bionic lacks tcdrain; provide a workaround
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Matt Whitlock [Sat, 25 Apr 2015 19:32:48 +0000 (21:32 +0200)]
Bionic lacks ttyname_r; provide a workaround
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Tue, 21 Apr 2015 14:00:41 +0000 (16:00 +0200)]
special-case {true,false,test} --help
This also removes their help texts.
function old new delta
run_applet_no_and_exit 442 452 +10
packed_usage 30713 30625 -88
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Bernhard Reutner-Fischer [Sun, 19 Apr 2015 21:45:17 +0000 (23:45 +0200)]
include: Fallback to UTMP unless there is UTMPX support
Fixes compilation against uClibc-0.9.30 for instance
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Ron Yorston [Sun, 19 Apr 2015 09:50:25 +0000 (10:50 +0100)]
libbb: remove unnecessary argument to nonblock_immune_read
The loop_on_EINTR argument to nonblock_immune_read is always set to 1.
function old new delta
xmalloc_reads 200 195 -5
pgetc 488 483 -5
argstr 1313 1308 -5
nonblock_immune_read 123 86 -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-52) Total: -52 bytes
Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Sun, 19 Apr 2015 16:55:12 +0000 (18:55 +0200)]
mdev: if a "future" mdev.seq is seen, do not overwrite it with ours
This was seen to happen if two mdevs are run in parallel,
mdev.seq is empty, and the "newer" one manages to write it first.
function old new delta
mdev_main 1366 1388 +22
atoll - 20 +20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Sun, 19 Apr 2015 16:54:49 +0000 (18:54 +0200)]
mdev: improve logging
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Sat, 18 Apr 2015 17:38:13 +0000 (19:38 +0200)]
hush: document buggy handling of duplicate "local"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Sat, 18 Apr 2015 17:36:38 +0000 (19:36 +0200)]
ash: fix handling of duplicate "local"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Fri, 17 Apr 2015 12:24:55 +0000 (14:24 +0200)]
sed: implement ",+N" range end
function old new delta
add_cmd 1115 1173 +58
process_files 2226 2253 +27
sed_main 696 702 +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 91/0) Total: 91 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Thu, 16 Apr 2015 10:44:02 +0000 (12:44 +0200)]
uevent: new applet
This applet listens on netlink socket with kernel's uevent messages.
Run-tested.
function old new delta
uevent_main - 416 +416
packed_usage 30671 30713 +42
applet_names 2531 2538 +7
applet_main 1468 1472 +4
RCVBUF - 4 +4
applet_nameofs 734 736 +2
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 4/0 up/down: 475/0) Total: 475 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Felix Fietkau [Thu, 9 Apr 2015 08:20:16 +0000 (10:20 +0200)]
find: fix regression in status processing for path arguments
Regression added in commit
14158b4127dba30466c50147b868a6a89702960b
"find: add optional support for '-exec ... {} +'"
This commit causes find to exit on the first path argument that was not
found, which breaks existing scripts and is incompatible to other
implementations.
Instead of exiting on the first failure, return EXIT_FAILURE at the end
if any error occurred.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Alfonso Ranieri [Tue, 14 Apr 2015 12:32:39 +0000 (14:32 +0200)]
volume_id: fix a buglet introduced by is_prefixed_with() conversion
Signed-off-by: Alfonso Ranieri <alforan@tin.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Tue, 14 Apr 2015 12:15:15 +0000 (14:15 +0200)]
build system: make CONFIG_EXTRA_LDFLAGS go to LDFLAGS, not EXTRA_LDFLAGS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Aaro Koskinen [Wed, 1 Apr 2015 21:55:17 +0000 (00:55 +0300)]
update copyright years
Copyright years seem to be out of date, e.g. coreutils/truncate.c
has Copyright (C) 2015.
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer [Thu, 2 Apr 2015 21:03:46 +0000 (23:03 +0200)]
*: Switch to POSIX utmpx API
UTMP is SVID legacy, UTMPX is mandated by POSIX.
Glibc and uClibc have identical layout of UTMP and UTMPX, both of these
libc treat _PATH_UTMPX as _PATH_UTMP so from a user-perspective nothing
changes except the names of the API entrypoints.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Denys Vlasenko [Tue, 31 Mar 2015 20:00:55 +0000 (22:00 +0200)]
update example ntp.script
Handle an interesting corner case when NTP server is reachable...
but on a different IP now.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Tue, 31 Mar 2015 19:46:26 +0000 (21:46 +0200)]
ftpd: change_identity() must be after chroot()
Otherwise chroot() doesn't work for non-root
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Thu, 26 Mar 2015 09:49:02 +0000 (10:49 +0100)]
typo fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Sun, 22 Mar 2015 17:00:32 +0000 (18:00 +0100)]
truncate: new applet
Add the actual new source file :(
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Vladislav Grishenko [Thu, 19 Mar 2015 11:19:35 +0000 (16:19 +0500)]
zcip: fix wrong comparison of source IP with our IP
Commit "zcip: fix link-local IP conflict detection" has introduced
wrong comparsion of source IP with our IP. This leads to a new IP
being picked unnecessarily on every incoming ARP packet.
Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ari Sundholm [Sun, 22 Mar 2015 16:55:38 +0000 (17:55 +0100)]
truncate: new applet
function old new delta
truncate_main - 161 +161
cwbkMG_suffixes - 128 +128
packed_usage 30443 30459 +16
applet_names 2512 2521 +9
applet_main 1456 1460 +4
parse_command 1460 1463 +3
applet_nameofs 728 730 +2
applet_install_loc 182 183 +1
dd_suffixes 112 - -112
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 10/3 up/down: 337/-133) Total: 204 bytes
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ari Sundholm [Wed, 4 Mar 2015 16:46:48 +0000 (18:46 +0200)]
dd: move suffix struct to xatonum.c
This way it can be used by other applets without duplication.
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Phil Sutter [Sun, 22 Mar 2015 16:36:20 +0000 (17:36 +0100)]
logread: implement dumpfollow mode of operation
This is basically a combination of the default (dump mode) and -f
(follow mode). Specifying -F makes logread first dump the log buffer and
then immediately start following it.
function old new delta
packed_usage 30412 30443 +31
logread_main 491 497 +6
Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Sun, 22 Mar 2015 16:08:51 +0000 (17:08 +0100)]
ifupdown: shrink a message
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Frank Bergmann [Fri, 13 Mar 2015 09:05:08 +0000 (10:05 +0100)]
ifupdown: correct ifstate update during 'ifup -a'. Closes 6212
When 'if -a' runs into an failure on an interface all further
interfaces won't be correctly updated in ifstate. This patch
inserts a new variable that only tracks the current interfaces
failure so that the write to ifstate can rely on this and not
the one for the functions return value.
Fixes https://bugs.busybox.net/show_bug.cgi?id=6212
Signed-off-by: Frank Bergmann <frank.frajasalo@googlemail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Mon, 16 Mar 2015 14:14:11 +0000 (14:14 +0000)]
ash: do not split the result of tilde expansion
A tilde expansion generates a valid pathname. Splitting it using IFS
either leaves it unchanged or changes it to something unintended.
Example:
IFS=m HOME=/tmp; printf "%s\n" ~
Based on this commit authored by Jilles Tjoelker:
http://git.kernel.org/cgit/utils/dash/dash.git/commit/?id=
834629283f6c629a4da05ef60bae9445c954a19a
Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Mike Frysinger [Mon, 16 Mar 2015 21:47:01 +0000 (17:47 -0400)]
trylink: respect compiler settings when probing features
The CPPFLAGS/CFLAGS settings might have features that matter, so make
sure we utilize them when testing the compiler.
URL: https://bugs.gentoo.org/471118
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Mike Frysinger [Mon, 16 Mar 2015 21:46:17 +0000 (17:46 -0400)]
trylink: use mktemp instead of hardcoding paths
This way we respect standard tempdir env vars and are guaranteed to
be unique.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Denys Vlasenko [Thu, 12 Mar 2015 20:15:34 +0000 (21:15 +0100)]
vi: make BACKSPACE and DELETE join lines at start/end of line
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Thu, 12 Mar 2015 19:18:51 +0000 (20:18 +0100)]
Use chomp to remove newlines
function old new delta
unix_do_one 548 540 -8
process_timer_stats 508 500 -8
process_irq_counts 532 524 -8
lpd_main 839 831 -8
hwclock_main 502 494 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-50) Total: -40 bytes
Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Ron Yorston [Thu, 12 Mar 2015 19:10:40 +0000 (20:10 +0100)]
od: fix printing of high-bit chars
Example: echo £ | od -c
Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Thu, 12 Mar 2015 16:48:34 +0000 (17:48 +0100)]
libbb: introduce and use is_prefixed_with()
function old new delta
is_prefixed_with - 18 +18
complete_username 78 77 -1
man_main 737 735 -2
fsck_device 429 427 -2
unpack_ar_archive 80 76 -4
strip_unsafe_prefix 105 101 -4
singlemount 1054 1050 -4
rtc_adjtime_is_utc 90 86 -4
resolve_mount_spec 88 84 -4
parse_one_line 1029 1025 -4
parse_conf 1460 1456 -4
may_wakeup 83 79 -4
loadkmap_main 219 215 -4
get_irqs_from_stat 103 99 -4
get_header_cpio 913 909 -4
findfs_main 79 75 -4
fbsplash_main 1230 1226 -4
load_crontab 776 771 -5
expand_vars_to_list 1151 1146 -5
date_main 881 876 -5
skip_dev_pfx 30 24 -6
make_device 2199 2193 -6
complete_cmd_dir_file 773 767 -6
run_applet_and_exit 715 708 -7
uudecode_main 321 313 -8
pwdx_main 197 189 -8
execute 568 560 -8
i2cdetect_main 1186 1176 -10
procps_scan 1242 1230 -12
procps_read_smaps 1017 1005 -12
process_module 746 734 -12
patch_main 1903 1891 -12
nfsmount 3572 3560 -12
stack_machine 126 112 -14
process_timer_stats 449 435 -14
match_fstype 111 97 -14
do_ipaddr 1344 1330 -14
open_list_and_close 359 343 -16
get_header_tar 1795 1779 -16
prepend_new_eth_table 340 323 -17
fsck_main 1811 1794 -17
find_iface_state 56 38 -18
dnsd_main 1321 1303 -18
base_device 179 158 -21
find_keyword 104 82 -22
handle_incoming_and_exit 2785 2762 -23
parse_and_put_prompt 774 746 -28
modinfo 347 317 -30
find_action 204 171 -33
update_passwd 1470 1436 -34
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/49 up/down: 18/-540) Total: -522 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Thu, 12 Mar 2015 14:30:46 +0000 (15:30 +0100)]
deluser: also remove user from /etc/group
function old new delta
update_passwd 1270 1470 +200
deluser_main 310 332 +22
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Alexander Korolkov [Thu, 12 Mar 2015 12:05:33 +0000 (13:05 +0100)]
arping: fix iface name in error messages
arping: interface eth0 not found: No such device
^^^^
This is because error template is formed before parsing command line arguments,
so it always uses default interface name "eth0".
Signed-off-by: Alexander Korolkov <alexander.korolkov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Wed, 11 Mar 2015 17:01:34 +0000 (18:01 +0100)]
patch: segfault fix. Closes 7916
Fix segfault on this case (malformed --- line):
-- dwarves.orig 2015-02-25 01:45:27.
753000000 +0000
+++ dwarves 2015-02-25 01:46:08.
199000000 +0000
@@ -1,7 +1,7 @@
Bashful
Doc
Dopey
-Grouchy
+Grumpy
Happy
Sleepy
Sneezy
function old new delta
patch_main 1903 1957 +54
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Isaac Dunham [Wed, 11 Mar 2015 15:07:24 +0000 (16:07 +0100)]
mount: -T OTHERTAB support
function old new delta
mount_main 1221 1241 +20
packed_usage 30616 30610 -6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Isaac Dunham <ibid.ag@gmail.com>
Denys Vlasenko [Thu, 5 Mar 2015 13:04:44 +0000 (14:04 +0100)]
ntpd: tweak help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Tue, 3 Mar 2015 12:10:30 +0000 (13:10 +0100)]
inetd: fix order of array index check and array access
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Mon, 2 Mar 2015 19:59:13 +0000 (20:59 +0100)]
ntpd: chnage help text about -l to say that it doesn't disable client code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Mon, 2 Mar 2015 16:39:13 +0000 (17:39 +0100)]
runsvdir: if pid==1, also intercept SIGINT for -s SCRIPT
function old new delta
runsvdir_main 1057 1064 +7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Mon, 2 Mar 2015 16:38:18 +0000 (17:38 +0100)]
runsvdir: do not block SIGCHLD around poll/sleep
There is no reason to do so. We do not even have SIGCHLD handler.
function old new delta
runsvdir_main 1077 1057 -20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko [Mon, 2 Mar 2015 16:37:31 +0000 (17:37 +0100)]
runsvdir: (almost) close a signal race
We could lose a signal while processing previous one
function old new delta
runsvdir_main 1088 1077 -11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Serj Kalichev [Mon, 23 Feb 2015 14:26:47 +0000 (15:26 +0100)]
acpid: fix logging
Without this patch acpid can't log the events at all. Moreover it tries
to truncate log file every time.
Signed-off-by: Serj Kalichev <serj.kalichev@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>