Commit Graph

16300 Commits

Author SHA1 Message Date
Denys Vlasenko
ad29ba73ee httpd: require "HTTP/xyz" at the end of request line
function                                             old     new   delta
handle_incoming_and_exit                            2379    2362     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-17)             Total: -17 bytes
   text	   data	    bss	    dec	    hex	filename
 981787	    485	   7296	 989568	  f1980	busybox_old
 981779	    485	   7296	 989560	  f1978	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 13:59:58 +02:00
Ron Yorston
d1a2fa2a4e ash: catch error in arithmetic expansion in PS1
Setting PS1 to:

   PS1='$((123+))'

causes the shell to enter an infinite error loop:

   sh: arithmetic syntax error

Catch any exception raised by expandarg() in expandstr() and allow
processing to continue.

function                                             old     new   delta
expandstr                                            262     344     +82
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 82/0)               Total: 82 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 13:21:34 +02:00
Ron Yorston
48645b8350 ash: prevent error in backquotes in PS1 from exiting shell
Setting PS1 to:

   PS1='`xxx(`'

causes the shell to terminate with the error:

   sh: syntax error: unexpected end of file (expecting ")")

This happens because old-style backquotes require the input to be reread
and thus call setinputstring() a second time.  Prevent the problem by
unwinding all recently opened files in expandstr().

function                                             old     new   delta
unwindfiles                                            -      22     +22
expandstr                                            247     262     +15
forkchild                                            631     625      -6
evalcommand                                         1694    1685      -9
ash_main                                            1346    1336     -10
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/3 up/down: 37/-25)             Total: 12 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 13:21:34 +02:00
Chen Qi
32c8ce4def dc.tests: fix two test case to also depend on DC_BIG
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 12:30:11 +02:00
Alexander Vickberg
049670fbbe httpd: pass authorization header to CGI if not Basic
Pass the Authorization header to CGI if not of type Basic. This will
make it possible for CGI to verify authorization headers of type
Bearer <token>.

function                                             old     new   delta
handle_incoming_and_exit                            2370    2379      +9

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-18 10:06:39 +02:00
Alexander Vickberg
210b52476c httpd: When sending gzipped content use content-length header
Today for gzipped content httpd is using a header with name
Transfer-Length. However I can't find a header with that name in the
standards. Instead use Content-Length.

function                                             old     new   delta
.rodata                                           157940  157936      -4
send_headers                                         980     939     -41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-45)             Total: -45 bytes

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-17 11:34:49 +02:00
Ron Yorston
1d37186fe2 ash: add bash-compatible EPOCH variables
Bash 5.0 added the dynamic variable EPOCHSECONDS and EPOCHREALTIME
which return the number of seconds since the Unix Epoch as an
integer or float.  These are useful for logging or tracing.

function                                             old     new   delta
change_epoch                                           -      78     +78
.rodata                                           175167  175235     +68
varinit_data                                         264     312     +48
change_seconds                                         -      24     +24
change_realtime                                        -      24     +24
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 2/0 up/down: 242/0)             Total: 242 bytes
   text	   data	    bss	    dec	    hex	filename
 938508	   4203	   1888	 944599	  e69d7	busybox_old
 938702	   4203	   1888	 944793	  e6a99	busybox_unstripped

v2: Cast tv_sec and tv_usec to unsigned quantities.
    Add brackets to macros.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 18:29:52 +02:00
Ron Yorston
d96c69d876 ash: an unset dynamic variable should not be dynamic
Commit b28d4c346 (ash: [VAR] Move unsetvar functionality into setvareq)
dropped the code that caused dynamic variables to lose their special
properties when unset.  Add it back again.

function                                             old     new   delta
setvareq                                             346     360     +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 14/0)               Total: 14 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 18:29:52 +02:00
Ron Yorston
a81700bc08 hush: add bash-compatible EPOCH variables
Bash 5.0 added the dynamic variable EPOCHSECONDS and EPOCHREALTIME
which return the number of seconds since the Unix Epoch as an
integer or float.  These are useful for logging or tracing.

function                                             old     new   delta
get_local_var_value                                  207     302     +95
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 95/0)               Total: 95 bytes
   text	   data	    bss	    dec	    hex	filename
 938702	   4203	   1888	 944793	  e6a99	busybox_old
 938797	   4203	   1888	 944888	  e6af8	busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 18:29:52 +02:00
Denys Vlasenko
2efa726b22 httpd: extract query string only after proxying check
function                                             old     new   delta
handle_incoming_and_exit                            2398    2370     -28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 13:35:56 +02:00
Denys Vlasenko
62ba9e5ac3 httpd: make rmt_ip variable local
function                                             old     new   delta
handle_incoming_and_exit                            2385    2398     +13
if_ip_denied_send_HTTP_FORBIDDEN_and_exit             51      54      +3
get_line                                             110     106      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-4)              Total: 12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 13:18:12 +02:00
Denys Vlasenko
44f5b6a1cb httpd: check denied IPs even before reading 1st query line
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 12:59:20 +02:00
Denys Vlasenko
c69f648457 httpd: do not decode URL and headers if proxying - send all verbatim
function                                             old     new   delta
handle_incoming_and_exit                            2566    2385    -181

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 12:45:26 +02:00
Denys Vlasenko
cf695976c7 httpd: remove duplicate "decode URL escape sequences" code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 11:58:28 +02:00
Denys Vlasenko
fba665a888 httpd: put all headers into environment as HTTP_UPPERCASED_HEADER=val
Set up environment variables before running the CGI script.
The variables will be named HTTP_<filtered_name> where the <filtered_name>
is the header name capitalized and all characters not matching
[a-z] | [A-Z] | [0-9] replaced with '_'.

function                                             old     new   delta
http_response                                         80      88      +8
http_response_type                                    20      22      +2
send_headers                                         718     715      -3
parse_conf                                          1481    1478      -3
get_line                                             128     110     -18
cgi_io_loop_and_exit                                 599     569     -30
send_cgi_and_exit                                    882     738    -144
handle_incoming_and_exit                            2793    2592    -201
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/6 up/down: 10/-399)          Total: -389 bytes
   text	   data	    bss	    dec	    hex	filename
 982178	    485	   7296	 989959	  f1b07	busybox_old
 981675	    485	   7296	 989456	  f1910	busybox_unstripped

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 11:37:02 +02:00
Denys Vlasenko
d0ae4103dd httpd: fix handling of EOF in get_line()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 11:07:37 +02:00
Denys Vlasenko
ff36bec49b httpd: add missing {}
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 10:14:50 +02:00
Denys Vlasenko
bae8f7eaf2 httpd: do not percent-decode URI if proxying
The proxying is documented as follows:

P:/url:[http://]hostname[:port]/new/path

Howeverm urlcopy is not a true copy anymore when it is fdprint'ed
to proxy_fd, this is because percent_decode_in_place() is called
after the copy is created.

This breaks reverse proxying all URIs containing percent
encoded spaces, e.g. - because a decoded URI will be printed out
to proxy_fd instead of the original.

The fix keeps the logic in place to canonicalize the uri first,
before reverse proxying (one could argue that the uri
should be proxied completely unaltered, except for the prefix
rewrite).

function                                             old     new   delta
handle_incoming_and_exit                            2752    2792     +40

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 10:07:33 +02:00
Denys Vlasenko
02d650e159 httpd: fix proxy headers passing - full_write() instead of write()
function                                             old     new   delta
handle_incoming_and_exit                            2763    2752     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-14 20:46:57 +02:00
Denys Vlasenko
51792e126b httpd: if remote IP is denied, send FORBIDDEN reply earlier
While at it, fix sighup_handler to not clobber errno.

function                                             old     new   delta
send_HTTP_FORBIDDEN_and_exit_if_denied_ip              -      47     +47
sighup_handler                                        15      30     +15
handle_incoming_and_exit                            2791    2763     -28
checkPermIP                                           48       -     -48
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 62/-76)            Total: -14 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-14 19:57:13 +02:00
Denys Vlasenko
60bf77f7e7 udhcpc6: code shrink
function                                             old     new   delta
d6_read_interface                                    593     582     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-14 17:01:10 +02:00
Denys Vlasenko
0d75e8b797 udhcpc6: add a few comments, no code changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 19:43:15 +02:00
Denys Vlasenko
cc45cbcca4 udhcpc6: make it enabled in defconfig
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 17:32:40 +02:00
Rolf Eike Beer
7180d9ed86 examples/udhcp/simple.script: fix resolv.conf update if it is a dangling symlink
If /etc/resolv.conf is a symlink to a tmpfs and the actual file does not
already exist, "readlink -f" will not detect it as symlink. Explicitely check
for that condition before and touch the file, making the other code work as
intended.

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 16:58:00 +02:00
Antoine Girard-Vallée
0e7bd69bb5 udhcp: add 100 and 101 dhcp options for ipv4
Support for the IEEE timezone string and timezone database strings (100
and 101 options respectively) is added for ipv4, conforming to RFC-4833.

The two options are passed to hook scripts in the variables tzstr and
tzdbstr.

function                                             old     new   delta
dhcp_option_strings                                  280     294     +14
dhcp_optflags                                         76      80      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 18/0)               Total: 18 bytes

Signed-off-by: Antoine Girard-Vallée <antoine.girard-vallee@savoirfairelinux.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 16:27:26 +02:00
Denys Vlasenko
2945822f86 brctl: add TODO: "showmacs BR"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 15:48:31 +02:00
Denys Vlasenko
9435608804 brctl: simplify str_to_jiffies()
function                                             old     new   delta
write_uint                                             -      96     +96
brctl_main                                           721     678     -43
write_ulong                                           96       -     -96
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 96/-139)           Total: -43 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 14:17:55 +02:00
Denys Vlasenko
dc1b2d4356 brctl: convert remaining commands to work via /sys
function                                             old     new   delta
write_ulong                                            -      96     +96
show_bridge                                          310     338     +28
static.ops                                             3       -      -3
arm_ioctl                                             20       -     -20
packed_usage                                       33344   33315     -29
brctl_main                                           885     721    -164
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 1/2 up/down: 124/-216)          Total: -92 bytes
   text	   data	    bss	    dec	    hex	filename
 982112	    485	   7296	 989893	  f1ac5	busybox_old
 982157	    485	   7296	 989938	  f1af2	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 13:58:06 +02:00
Denys Vlasenko
c5150e9ce7 brctl: make "show" command retrieve data from /sys
ioctl interface is obsolete and has no 32/64 compat shim,
making "brctl show" fail for 32-bit userspace and 64-bit kernel.

function                                             old     new   delta
show_bridge                                            -     310    +310
read_file                                              -      64     +64
if_indextoname                                       117       -    -117
brctl_main                                          1183     885    -298
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/1 up/down: 374/-415)          Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-12 18:52:31 +02:00
Ron Yorston
e2026381be stat: reduce storage for human-readable filesystem names
function                                             old     new   delta
static.humanname                                       -     236    +236
static.fstype                                          -     140    +140
print_statfs                                         339     341      +2
static.humantypes                                    288       -    -288
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/0 up/down: 378/-288)           Total: 90 bytes
   text	   data	    bss	    dec	    hex	filename
 982183	    485	   7296	 989964	  f1b0c	busybox_old
 982152	    485	   7296	 989933	  f1aed	busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-12 12:00:38 +02:00
Bernhard Reutner-Fischer
c6c19c31c1 ipaddress: remove unused variable no_link
ipaddress.c: In function ‘ipaddr_list_or_flush’:
ipaddress.c:427:6: warning: variable ‘no_link’ set but not used [-Wunused-but-set-variable]

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2019-04-07 18:09:37 +02:00
Denys Vlasenko
1e474d3d93 service examples: if iface do not exist, retry upping it
I've had a case of a machine where eth0 was appearing a bit later
after the boot, and appearing _downed_. ifplugd then fails to detect
"link up". Thus, depending on how service startup
("ip link set dev eth0 up") races with driver initialization,
ethernet randomly fails to initialize on boot.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-05 18:41:48 +02:00
Denys Vlasenko
43d09e79db chrt: fix for SCHED_RESET_ON_FORK bit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-05 16:59:07 +02:00
Denys Vlasenko
ae5ca6fc41 chrt: do not segfault if policy number is unknown
While at it, improve help text

function                                             old     new   delta
packed_usage                                       33319   33344     +25
policy_name                                            -      22     +22
show_min_max                                          59      64      +5
chrt_main                                            432     429      -3
policies                                              72       -     -72
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/1 up/down: 52/-75)            Total: -23 bytes
   text	   data	    bss	    dec	    hex	filename
 982150	    485	   7296	 989931	  f1aeb	busybox_old
 982183	    485	   7296	 989964	  f1b0c	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-05 12:03:48 +02:00
Denys Vlasenko
29c2dcfe1c telnetd: whitespace fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-04 16:54:14 +02:00
Denys Vlasenko
c6a8965297 telnetd: better AYT handling
function                                             old     new   delta
telnetd_main                                        1792    1837     +45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-04 16:00:23 +02:00
Martin Lewis
93594b1197 telnetd: Added support for AYT IAC command.
Fixed a TODO in AYT IAC handling by replying back with a NOP.

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-04 15:44:36 +02:00
Thomas De Schampheleire
2b6282117f top: provide cmdline argument '-H' to enable thread scanning by default
In particular useful when you want to evaluate the threads in batch mode:
    top -Hbn1

function                                             old     new   delta
top_main                                             928     941     +13
packed_usage                                       33317   33319      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 15/0)               Total: 15 bytes

Signed-off-by: Philippe Belet <philippe.belet@nokia.com>
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-04 14:14:24 +02:00
Denys Vlasenko
a3ce161363 vi: revert change in how "end of file list" is deteced - fixes 'q' in bare "vi"
function                                             old     new   delta
vi_main                                              273     272      -1
colon                                               2853    2852      -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-2)               Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-03 16:35:23 +02:00
Denys Vlasenko
e1a1b64f43 vi: code shrink
function                                             old     new   delta
new_screen                                            84      75      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-03 16:30:50 +02:00
Ron Yorston
3e61b59ef3 vi: avoid build failure in non-default case
If vi is built with FEATURE_VI_USE_SIGNALS disabled and
FEATURE_VI_WIN_RESIZE enabled new_screen() is used without a
declaration.  Move the function to avoid this.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-03 16:20:13 +02:00
Denys Vlasenko
2f28b2bdbb fsync,sync: merge into one source module
With FEATURE_SYNC_FANCY not set:

function                                             old     new   delta
fsync_main                                           130     123      -7

With FEATURE_SYNC_FANCY set, should be much larger code size savings.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-02 14:55:29 +02:00
Denys Vlasenko
4f74bb6059 fsync,sync: make them similar
sync: add O_NOCTTY
fsync: drop O_NOATIME, add O_NONBLOCK, set exitcode to 1 if fsync() fails,
    update --help message to be similar to sync.
both: reformat code to minimize "diff -u sync.c fsync.c":
    in particular, they use same open() flags now

function                                             old     new   delta
fsync_main                                           126     130      +4
packed_usage                                       33316   33317      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 5/0)                 Total: 5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-02 14:39:56 +02:00
Ron Yorston
e48559eae3 ash: distinguish 'wait -n' from other bashisms
Add a specific define to indicate which bash compatibility code
implements 'wait -n'.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-02 13:43:40 +02:00
Denys Vlasenko
8939359180 vi: rename save_argc -> cmdline_filecnt
function                                             old     new   delta
vi_main                                              272     273      +1
colon                                               2852    2853      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-02 12:45:30 +02:00
Denys Vlasenko
bbacd03ccc vi: restore capability to remember insertion cmds for "."
function                                             old     new   delta
modifying_cmds                                        17      22      +5
get_one_char                                         103      98      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-5)                Total: 0 bytes
   text	   data	    bss	    dec	    hex	filename
 982121	    485	   7296	 989902	  f1ace	busybox_old
 982094	    485	   7296	 989875	  f1ab3	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-02 11:50:25 +02:00
Denys Vlasenko
b29dce4bc2 vi: code shrink
function                                             old     new   delta
get_input_line                                       172     175      +3
char_insert                                          444     447      +3
rawmode                                               36      24     -12
edit_file                                            644     626     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 6/-30)             Total: -24 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-01 17:17:02 +02:00
Denys Vlasenko
26f5e9d21c vi: convert more /**/ comments to //
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-01 16:42:30 +02:00
Denys Vlasenko
2a57608f67 vi: code shrink
function                                             old     new   delta
get_one_char                                         108     103      -5
edit_file                                            651     644      -7
do_cmd                                              4696    4688      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-20)             Total: -20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-01 16:15:51 +02:00
Denys Vlasenko
6ce60b9cca vi: use vsnprintf to format status line
This is the last use of "vsprintf" in busybox:

function                                             old     new   delta
status_line_bold                                      72      77      +5
status_line                                           40      45      +5
vsprintf                                              23       -     -23
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/0 up/down: 10/-23)            Total: -13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-01 15:41:05 +02:00