Commit Graph

14339 Commits

Author SHA1 Message Date
Ron Yorston
5ccb0e92fa ash: return exit status of nofork applets
The commit 'ash: eval: Return status in eval functions' changed how
exit status is handled in eval functions.  The case of nofork
applets was missed, resulting in the incorrect status potentially
being returned for nofork applets when FEATURE_SH_NOFORK is enabled.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-24 01:18:13 +02:00
Denys Vlasenko
6bbb48fadf examples: update var_service/README again
Added "ps -AH e" example

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 19:02:11 +02:00
Denys Vlasenko
e43000f2d4 typo fixes in doc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:48:05 +02:00
Denys Vlasenko
93ff2b4b5f examples: update var_service/README again
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:38:08 +02:00
Denys Vlasenko
ee2d19445b examples: update var_service/README
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:22:50 +02:00
Denys Vlasenko
662634b829 telnetd: ifdef out a buggy error handling code path
Here, not handling the error is would just eat one input 0xff char.
Correct handling would need even more corner case handling,
as-is buggy handling corrupts the buffer.
Since we just been told by kernel that pty is ready,
EAGAIN should not be happening here anyway.

function                                             old     new   delta
telnetd_main                                        1798    1785     -13

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-13 16:17:06 +02:00
Denys Vlasenko
85100a7067 cpio: fix restoration of file ownership, closes 9306
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-12 20:56:46 +02:00
Denys Vlasenko
57727d478d telnet: code shrink
put_iac2(w,c) is mostly used with constants, fold them into one arg

function                                             old     new   delta
put_iac2_merged                                        -      46     +46
telnet_main                                         1603    1583     -20
con_escape                                           285     257     -28
put_iac2                                              50       -     -50
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 46/-98)            Total: -52 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-12 20:42:58 +02:00
Denys Vlasenko
26d88d6bbd telnetd: add another handshake example in comments, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-12 20:09:22 +02:00
Denys Vlasenko
b6d421b635 telnetd: treat all 2-byte IACs in 240..249 range as NOPs.
A bit of future-proofing. Some of them can stand just being ignored.

function                                             old     new   delta
telnetd_main                                        1791    1798      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-12 19:41:33 +02:00
Denys Vlasenko
122c47ac02 telnetd: fix corner case of input processing of 0xff bytes
I managed to reproduce the bug, with some difficulty.

function                                             old     new   delta
telnetd_main                                        1780    1791     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-12 19:13:46 +02:00
Denys Vlasenko
0190c41bb2 telnetd: fix a corner case where CRLF->CR translation can misbehave
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-12 17:36:57 +02:00
Denys Vlasenko
2a54b3e86e telnetd: fix handling of short writes to pty
If a write to pty is short, remove_iacs() can be run on a buffer repeatedly.
This, for example, can eat 0xff chars (IACs, in telnet terms).

Rework the logic to handle IACs in a special "write to pty" function.

function                                             old     new   delta
telnetd_main                                        1662    1750     +88

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-12 14:54:10 +02:00
Denys Vlasenko
713b513353 more: accept and ignore a bunch of options
Alpine Linux stumbled over "more -s":
http://bugs.alpinelinux.org/issues/5190

function                                             old     new   delta
more_main                                            857     872     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-11 15:29:38 +02:00
Denys Vlasenko
3720a61daf ifupdown: rewrite state file atomically
By user's request.
Decided to not use fcntl(F_SETLKW) in lieu of problems with locking
on networked filesystems. The existence of /var/run/ifstate.new
is treated as a write lock. rename() provides atomicity.

function                                             old     new   delta
ifupdown_main                                       1019    1122    +103

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-09 23:04:16 +02:00
Denys Vlasenko
ec1ea16337 tcpsvd: don't keep shared fd open if fd limit is reached. closes 9331
Also, much improved help text.

function                                             old     new   delta
packed_usage                                       30652   30851    +199
tcpudpsvd_main                                      1782    1784      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-07 15:56:47 +02:00
Denys Vlasenko
561639a68c ash: all blocks in function node copying must be SHELL_ALIGNed
Previous commit probably introduced a bug:
non-matching size calculation in size counting and
actual copying caused by SHELL_ALIGN being applied differently!
This won't bite if string sizes are also SHELL_ALIGNed.
Thus fixing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-07 04:28:33 +02:00
Denys Vlasenko
d43be87591 ash testsuite: fix false positives
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-07 04:07:05 +02:00
Denys Vlasenko
4c438b5ba4 ash: get rid of two global data variables
function                                             old     new   delta
calcsize                                             126     147     +21
funcstring_end                                         -       4      +4
sizenodelist                                          28      24      -4
funcstringsize                                         4       -      -4
funcstring                                             4       -      -4
funcblocksize                                          4       -      -4
nodeckstrdup                                          48      39      -9
evaltree                                             828     788     -40
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 1/4 up/down: 25/-105)           Total: -40 bytes
   text	   data	    bss	    dec	    hex	filename
 943376	    916	  14292	 958584	  ea078	busybox_old
 943344	    916	  14284	 958544	  ea050	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-07 04:05:15 +02:00
Denys Vlasenko
f37e1155aa ash: comment out free(p) just before _exit, tweak some outdated comments
Planned to sync exitshell up to dash, turned out ours is better :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-07 03:17:28 +02:00
Denys Vlasenko
2972e2c4ac wget: there is no -s option in GNU Wget 1.18, we should be compatible
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-04 04:23:09 +02:00
Denys Vlasenko
a85740c8af dhcp: merge leases.c and static_leases.c into dhcpd.c
function                                             old     new   delta
send_offer                                           292     461    +169
udhcpd_main                                         1531    1588     +57
read_leases                                          330     332      +2
add_lease                                            314     312      -2
find_lease_by_mac                                     68       -     -68
find_free_or_expired_nip                             174       -    -174
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 3/1 up/down: 228/-244)          Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-04 00:56:58 +02:00
Denys Vlasenko
d2ae66cb3e dhcp: merge most of static_leases.c into dhcpd.c
function                                             old     new   delta
read_staticlease                                     121     222    +101
add_static_lease                                      48       -     -48
log_static_leases                                     68       -     -68
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/0 up/down: 101/-116)          Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-04 00:56:58 +02:00
Denys Vlasenko
2bf2931d52 dhcp: merge files.c into dhcpd.c
Added NOINLINE to two function, since my version of gcc would actualy increase
code size otherwise.

I see no size changes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-04 00:56:58 +02:00
Denys Vlasenko
095ddf7669 examples: add example of a DHCP server
As usual, by multiplying directories - "dhcpd_eth0", "dhcpd_wlan1"
you can run many servers on different interfaces.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 23:43:44 +02:00
Denys Vlasenko
7f0ebbc69e hush: add commented-out debug printouts in "memleak" built-in
Allocation addresses of malloc() are jittery,
thought I had a mem leak in hush, but it was malloc variability.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 17:42:53 +02:00
Denys Vlasenko
a769390da6 hush: fix a memory corruption when exported variable is modified
The construct such as this:

t=1
export t
t=new_value1

had a small probability of momentarily using free()d value.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 15:01:06 +02:00
Denys Vlasenko
04465dad66 hush: fix exitcode on exec failure with EACCES - should be 126
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 01:01:15 +02:00
Denys Vlasenko
c775f829db sh testsuite: add tests for exitcode on failure to exec
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 00:55:34 +02:00
Denys Vlasenko
2feaa227a4 shell: delete all msh tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 00:51:29 +02:00
Denys Vlasenko
9793fc576a hush testsuite: fix another false positive
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 00:14:26 +02:00
Denys Vlasenko
d3b4e5ec6a hust testsuite: fix a false positive
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 00:10:20 +02:00
Denys Vlasenko
a62bc80571 ash testsuite: add most of hust tests which pass for ash
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 00:06:55 +02:00
Denys Vlasenko
ce332a23a3 ash: [PARSER] Add nlprompt/nlnoprompt helpers
Upstream commit:

    Date: Mon, 29 Sep 2014 22:53:53 +0800
    [PARSER] Add nlprompt/nlnoprompt helpers

    This patch adds the nlprompt/nlnoprompt helpers to isolate code
    dealing with newlines and prompting.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 23:47:34 +02:00
Denys Vlasenko
80729a4472 whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 22:33:15 +02:00
Denys Vlasenko
db7f4c203b hush: add var4.tests, var5.tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 21:13:13 +02:00
Denys Vlasenko
61508d9624 hush: fix var3.tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 21:12:02 +02:00
Denys Vlasenko
ebedb9478d sh: do not print empty line at the end of "help" output
It's pointless.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 18:45:09 +02:00
Denys Vlasenko
df303ae117 sh testsuite: sync ash-redir/ and hush-redir/
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 18:32:52 +02:00
Denys Vlasenko
c7a774dde4 sh testsuite: sync ash-misc/source* and hush-misc/source*
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 18:23:14 +02:00
Denys Vlasenko
0ba99705a1 sh testsuite: sync ash-vars/ and hush-vars/
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 18:17:15 +02:00
Denys Vlasenko
e3354bc44a ash testsuite: update some of variable tests with newer versions from hush
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 18:08:04 +02:00
Denys Vlasenko
c4cf542c57 sh testsuite: create hush-redir/* and move files around
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 17:55:51 +02:00
Denys Vlasenko
1b73f8471a sh testsuite: create hush-heredoc/* and move files around
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 17:49:46 +02:00
Denys Vlasenko
5d6b8729ed hush testsuite: add many tests from ash testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 17:39:31 +02:00
Denys Vlasenko
888527ccee ash: undo "tokname hack"
dash has tokendlist[] array to decide which tokens end lists.
We store it as first byte of each tokname_array[i].

Switch to bit array, name it like dash (tokendlist), drop special
1st byte of tokname_array[i]. This brings us closer to dash, and
shrinks the binary, because many more string aliasing opportunities
are now open:

function                                             old     new   delta
pstrcmp1                                               -      16     +16
readtoken1                                          2852    2858      +6
list                                                 326     327      +1
pstrcmp                                               16      15      -1
tokname                                               45      42      -3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 23/-4)              Total: 19 bytes
   text	   data	    bss	    dec	    hex	filename
 943556	    916	  14292	 958764	  ea12c	busybox_old
 943463	    916	  14292	 958671	  ea0cf	busybox_unstripped
^^^^^^^ note this!

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 16:54:17 +02:00
Denys Vlasenko
bc1a00843f ash: placate gcc: "warning: ! is only applied to the left hand side of =="
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 15:31:33 +02:00
Denys Vlasenko
ae4bd34e6b hush testsuite: add glob_dir.tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 15:20:57 +02:00
Denys Vlasenko
8e2c9cc2fc ash: fix globbing bugs when using glibc glob()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 15:17:15 +02:00
Denys Vlasenko
37dc08b874 ash: style fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 04:38:07 +02:00