oweals/busybox.git
5 years agofsync,sync: make them similar
Denys Vlasenko [Tue, 2 Apr 2019 12:39:56 +0000 (14:39 +0200)]
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>
5 years agoash: distinguish 'wait -n' from other bashisms
Ron Yorston [Sun, 31 Mar 2019 08:27:09 +0000 (09:27 +0100)]
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>
5 years agovi: rename save_argc -> cmdline_filecnt
Denys Vlasenko [Tue, 2 Apr 2019 10:45:30 +0000 (12:45 +0200)]
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>
5 years agovi: restore capability to remember insertion cmds for "."
Denys Vlasenko [Tue, 2 Apr 2019 09:50:25 +0000 (11:50 +0200)]
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>
5 years agovi: code shrink
Denys Vlasenko [Mon, 1 Apr 2019 15:17:02 +0000 (17:17 +0200)]
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>
5 years agovi: convert more /**/ comments to //
Denys Vlasenko [Mon, 1 Apr 2019 14:38:06 +0000 (16:38 +0200)]
vi: convert more /**/ comments to //

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: code shrink
Denys Vlasenko [Mon, 1 Apr 2019 14:15:51 +0000 (16:15 +0200)]
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>
5 years agovi: use vsnprintf to format status line
Denys Vlasenko [Mon, 1 Apr 2019 13:41:05 +0000 (15:41 +0200)]
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>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 12:18:02 +0000 (14:18 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 12:08:00 +0000 (14:08 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 12:02:37 +0000 (14:02 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 11:59:38 +0000 (13:59 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 11:55:27 +0000 (13:55 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: fix ^Z not always working as intended
Denys Vlasenko [Mon, 1 Apr 2019 10:29:27 +0000 (12:29 +0200)]
vi: fix ^Z not always working as intended

function                                             old     new   delta
tstp_handler                                          64      71      +7
text_yank                                             54      56      +2
vi_main                                              280     272      -8
do_cmd                                              4705    4696      -9
colon                                               2861    2852      -9
cont_handler                                          66       -     -66
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/3 up/down: 9/-92)             Total: -83 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: install SIGINT handler _after_ restart setjmp is initialized
Denys Vlasenko [Mon, 1 Apr 2019 09:58:11 +0000 (11:58 +0200)]
vi: install SIGINT handler _after_ restart setjmp is initialized

While at it, sanitized comment style, deleted wrong ones, renamed signal
handlers to <sig>_handler(), slightly optimized "cursor home+clear screen".

function                                             old     new   delta
cont_handler                                           -      66     +66
tstp_handler                                           -      64     +64
winch_handler                                          -      60     +60
int_handler                                            -      32     +32
edit_file                                            648     651      +3
redraw                                                52      43      -9
catch_sig                                             32       -     -32
winch_sig                                             60       -     -60
suspend_sig                                           64       -     -64
cont_sig                                              66       -     -66
------------------------------------------------------------------------------
(add/remove: 4/4 grow/shrink: 1/1 up/down: 225/-231)           Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoblockdev: code shrink
Denys Vlasenko [Sat, 30 Mar 2019 19:07:21 +0000 (20:07 +0100)]
blockdev: code shrink

function                                             old     new   delta
bdcmd_names                                            -      82     +82
bdcmd_ioctl                                            -      44     +44
bdcmd_flags                                            -      11     +11
blockdev_main                                        273     258     -15
bdcommands                                           176       -    -176
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 0/1 up/down: 137/-191)          Total: -54 bytes
   text    data     bss     dec     hex filename
 982326     485    7296  990107   f1b9b busybox_old
 982272     485    7296  990053   f1b65 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoip: Fix ip -o link
Stefan Sørensen [Sat, 30 Mar 2019 17:24:46 +0000 (18:24 +0100)]
ip: Fix ip -o link

Commit db169f253854db572c0c2b7e3d74ebbe6afdb97f breaks the "ip -o link"
command, no output is displayed.. Fix by only excluding the link info if
in oneline mode and if the address family is not AF_PACKET.

function                                             old     new   delta
ipaddr_list_or_flush                                1232    1202     -30

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: allow manual screen update if SIGWINCH isn't supported
Ron Yorston [Wed, 20 Mar 2019 11:00:28 +0000 (11:00 +0000)]
vi: allow manual screen update if SIGWINCH isn't supported

On platforms that don't support SIGWINCH vi can be configured
with FEATURE_VI_USE_SIGNALS disabled and FEATURE_VI_WIN_RESIZE
enabled.  This allows the user to force an update with ^L when
the screen is resized.

However, because the SIGWINCH handler hasn't run the virtual
screen buffer won't have been updated and the display becomes
corrupted.  Fix this by calling new_screen() if necessary.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoman: add "/usr/share/man" as another default MANPATH, fix col override
Denys Vlasenko [Sat, 30 Mar 2019 16:27:09 +0000 (17:27 +0100)]
man: add "/usr/share/man" as another default MANPATH, fix col override

function                                             old     new   delta
static.mpl                                             -      12     +12
packed_usage                                       33307   33316      +9
man_main                                             857     851      -6
add_MANPATH                                          148     138     -10
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 21/-16)              Total: 5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: mark scripted_main() as externally visible
Ron Yorston [Sat, 30 Mar 2019 07:47:12 +0000 (07:47 +0000)]
libbb: mark scripted_main() as externally visible

Building with individual binaries enabled fails when embedded
script applets are included:

   /tmp/ccIvMFZg.o: In function `main':
   applet.c:(.text.main+0x20): undefined reference to `scripted_main'

Mark scripted_main() as externally visible.

Reported-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: code shrink, proper printf formatting for strlen()
Denys Vlasenko [Fri, 29 Mar 2019 13:40:01 +0000 (14:40 +0100)]
vi: code shrink, proper printf formatting for strlen()

function                                             old     new   delta
yank_delete                                           98      99      +1
what_reg                                              34      33      -1
text_yank                                             56      54      -2
end_cmd_q                                             17      14      -3
do_cmd                                              4718    4705     -13
colon                                               2875    2861     -14
edit_file                                            668     648     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 1/-53)             Total: -52 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: fix "wait -n" to wait for a _job_, not a _process_
Denys Vlasenko [Wed, 27 Mar 2019 17:34:10 +0000 (18:34 +0100)]
hush: fix "wait -n" to wait for a _job_, not a _process_

function                                             old     new   delta
checkjobs                                            163     183     +20
process_wait_result                                  449     463     +14
leave_var_nest_level                                  98     107      +9
enter_var_nest_level                                  32      38      +6
set_vars_and_save_old                                147     150      +3
builtin_local                                         53      56      +3
builtin_wait                                         322     323      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/0 up/down: 56/0)               Total: 56 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: add "wait -n" bashism
Denys Vlasenko [Wed, 27 Mar 2019 14:51:42 +0000 (15:51 +0100)]
ash: add "wait -n" bashism

function                                             old     new   delta
waitcmd                                              205     288     +83
dowait                                               405     444     +39
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 122/0)             Total: 122 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agontpd: do not create pid file if not backgrounded
Denys Vlasenko [Wed, 27 Mar 2019 12:37:40 +0000 (13:37 +0100)]
ntpd: do not create pid file if not backgrounded

function                                             old     new   delta
ntp_init                                             995    1021     +26
ntpd_main                                           1267    1257     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 26/-10)             Total: 16 bytes

Reported by Alfonso Ranieri <alforan@tin.it>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: add "wait -n" bashism
Denys Vlasenko [Tue, 26 Mar 2019 17:34:06 +0000 (18:34 +0100)]
hush: add "wait -n" bashism

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoman: don't skip default path which appears in config file
Ron Yorston [Fri, 22 Mar 2019 16:25:32 +0000 (16:25 +0000)]
man: don't skip default path which appears in config file

If the MANPATH environment variable isn't set a provisional default
path of /usr/man is placed in man_path_list.  This is only used if a
configuration file doesn't contain an alternative path.

If a configuration file lists the default path first:

   MANPATH /usr/man:/usr/share/man

add_MANPATH() sees that the default entry is already present and skips
it.  As a result man_path_list only contains the second and subsequent
components of the configured MANPATH.

In such cases the path should not be skipped.

function                                             old     new   delta
add_MANPATH                                          170     183     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 13/0)               Total: 13 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agots: do call localtime() when neither -s nor -i specified
Denys Vlasenko [Tue, 26 Mar 2019 10:51:21 +0000 (11:51 +0100)]
ts: do call localtime() when neither -s nor -i specified

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agots: use gettimeofday - we don't use nanoseconds here
Denys Vlasenko [Tue, 26 Mar 2019 10:44:48 +0000 (11:44 +0100)]
ts: use gettimeofday - we don't use nanoseconds here

function                                             old     new   delta
ts_main                                              398     376     -22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agots: replace overlapping strcpy with shorter code
Denys Vlasenko [Tue, 26 Mar 2019 10:41:35 +0000 (11:41 +0100)]
ts: replace overlapping strcpy with shorter code

function                                             old     new   delta
ts_main                                              401     398      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agots: fix incorrect (copy-pasted) copyright attribution
Denys Vlasenko [Tue, 26 Mar 2019 10:12:15 +0000 (11:12 +0100)]
ts: fix incorrect (copy-pasted) copyright attribution

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agots: new applet
Denys Vlasenko [Tue, 26 Mar 2019 10:02:31 +0000 (11:02 +0100)]
ts: new applet

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodo not duplicate CONFIG_PID_FILE_PATH and ".pid" strings
Denys Vlasenko [Sun, 17 Mar 2019 18:47:52 +0000 (19:47 +0100)]
do not duplicate CONFIG_PID_FILE_PATH and ".pid" strings

   text    data     bss     dec     hex filename
 981737     485    7296  989518   f194e busybox_old
 981704     485    7296  989485   f192d busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoFix off by one error in FAT16 <=> FAT32 detection
Thomas Frauendorfer [Tue, 5 Mar 2019 16:04:34 +0000 (17:04 +0100)]
Fix off by one error in FAT16 <=> FAT32 detection

cluster_count is compared against FAT16_MAX, which is defined as 0xfff4
That is the maximum number of cluster a FAT16 can have.

For reference also check the  hardware whitepaper from Microsoft
FAT: General Overview of On-Disk Format, version 1.03 page 15

Signed-off-by: Thomas Frauendorfer <tf@miray.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agowatch: support fractional -n SEC
Denys Vlasenko [Tue, 12 Mar 2019 17:56:51 +0000 (18:56 +0100)]
watch: support fractional -n SEC

function                                             old     new   delta
watch_main                                           212     232     +20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoxargs: mention -E STR in --help
Denys Vlasenko [Sun, 10 Mar 2019 13:29:03 +0000 (14:29 +0100)]
xargs: mention -E STR in --help

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoscripts/echo.c: resolve implicit declaration of function 'dup2'
Nicolas Hüppelshäuser [Tue, 5 Mar 2019 10:54:23 +0000 (11:54 +0100)]
scripts/echo.c: resolve implicit declaration of function 'dup2'

Signed-off-by: Nicolas Hüppelshäuser <nicolas.hueppelshaeuser@emlix.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotop: tweak --help
Denys Vlasenko [Wed, 27 Feb 2019 15:45:39 +0000 (16:45 +0100)]
top: tweak --help

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc: don't exit after backgrounding on -n -b
Andrey Mazo [Fri, 22 Feb 2019 21:46:19 +0000 (16:46 -0500)]
udhcpc: don't exit after backgrounding on -n -b

Currently, running "udhcpc -n -b" causes udhcpc to go to background and
then exit after some time unless a lease is obtained.

It's not very useful to do so
as the calling process doesn't know
if the lease was obtained or not anyway.

The code actually tries to favor "-b" over "-n",
but doesn't clear "-n" flag while clearing "-b" after backgrounding.

So, clear "-n" flag after going into background.
This effectively makes "-b" override "-n" completely
and "-n -b" behave the same as "-b".

This allows to override default "-n" option, passed to udhcpc by ifupdown,
without recompiling busybox.

URL: https://bugs.busybox.net/11691

Signed-off-by: Andrey Mazo <ahippo@yandex.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc: tweak --help
Denys Vlasenko [Wed, 27 Feb 2019 07:17:07 +0000 (08:17 +0100)]
udhcpc: tweak --help

function                                             old     new   delta
packed_usage                                       33324   33315      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: eval: avoid leaking memory associated with redirections. Closes 7748
Ron Yorston [Mon, 25 Feb 2019 08:29:38 +0000 (08:29 +0000)]
ash: eval: avoid leaking memory associated with redirections. Closes 7748

The following constructs result in ever-increasing memory usage:

   while true; do { true; } </dev/null; done
   while true; do ( true; ) </dev/null; done

For comparison, bash displays static memory usage in both cases.

This has been fixed in dash by commit 2bc6caa.  The maintainer
writes:

   I have simplified evaltree so that it simply sets the stack mark
   unconditionally.  This allows us to remove the stack marks in the
   functions called by evaltree.

Closes BusyBox bug 7748.

function                                             old     new   delta
evaltree                                             606     632     +26
evalcommand                                         1724    1696     -28
evalcase                                             382     351     -31
evalfor                                              230     196     -34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 26/-93)            Total: -67 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodu: don't count duplicate arguments. Closes 5288
Ron Yorston [Sat, 16 Feb 2019 10:22:31 +0000 (10:22 +0000)]
du: don't count duplicate arguments. Closes 5288

Since coreutils 8.6 (2010-10-15) du no longer counts duplicate arguments.

Revert the relevant part of commit 618a3027ed (du: fix "du /dir /dir"
case).

function                                             old     new   delta
du_main                                              302     297      -5
reset_ino_dev_hashtable                               78       -     -78
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-83)             Total: -83 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agontpd: increase SLEW_THRESHOLD from 0.125 to 0.5
Denys Vlasenko [Fri, 15 Feb 2019 13:32:08 +0000 (14:32 +0100)]
ntpd: increase SLEW_THRESHOLD from 0.125 to 0.5

Linux kernel supports it since ~2006

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodd: add 'oflag=append'
Rostislav Skudnov [Wed, 6 Feb 2019 11:57:15 +0000 (11:57 +0000)]
dd: add 'oflag=append'

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoi2c_tools.c: i2ctransfer
Nikolaus Voss [Mon, 11 Feb 2019 10:30:52 +0000 (11:30 +0100)]
i2c_tools.c: i2ctransfer

Call i2c_set_slave_addr() unconditionally as busy checking
is skipped depending on force argument.
Clarify usage texts for -f and -a flags.

Signed-off-by: Nikolaus Voss <nv@vosn.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: further fixes to undo after autoindent
Ron Yorston [Mon, 11 Feb 2019 08:29:15 +0000 (08:29 +0000)]
vi: further fixes to undo after autoindent

Commit bb983f30e (vi: fix faulty undo after autoinsert) has a
number of problems:

- The commit message refers to 'autoinsert' when it really means
  'autoindent'.

- The indentation of undo_push_insert() was incorrect.

- Most seriously the commit only fixed the problem for cases where
  the indentation was exactly one character.  This is because undo_push()
  only allows single characters to be queued for UNDO_INS_QUEUED.

  Lifting this restriction allows the example given in the previous
  commit message (with a three character indent) to work.

function                                             old     new   delta
undo_push                                            406     435     +29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 29/0)               Total: 29 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoi2ctransfer: new applet
Nikolaus Voss [Sun, 10 Feb 2019 18:56:41 +0000 (19:56 +0100)]
i2ctransfer: new applet

i2ctransfer sends and receives user defined i2c messages

v2: apply Xabier's comments: add -a option, don't decrement argc,
    use bb_show_usage() and xzalloc()
v3: fix possible out of bound access to msgs[nmsgs]

Reviewed-by: Xabier Oneca -- xOneca <xoneca@gmail.com>
Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosysctl: fix compatibility with procps sysctl
Aaro Koskinen [Fri, 8 Feb 2019 15:30:24 +0000 (16:30 +0100)]
sysctl: fix compatibility with procps sysctl

Busybox sysctl is incompatible with procps when '.' appears in
directory name, mostly happens with VLANs.

        busybox syntax (since 2008): net.ipv4.conf.eth0.100.mc_forwarding
         procps syntax (since 2002): net.ipv4.conf.eth0/100.mc_forwarding
                 (supported by both: net/ipv4/conf/eth0.100/mc_forwarding)

Use procps syntax for output; for input, allow both.

function                                             old     new   delta
sysctl_dots_to_slashes                                86     143     +57
sysctl_act_on_setting                                443     453     +10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 67/0)               Total: 67 bytes

Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosysctl: do slash/dot conversions only on name, not value part
Denys Vlasenko [Fri, 8 Feb 2019 15:02:39 +0000 (16:02 +0100)]
sysctl: do slash/dot conversions only on name, not value part

function                                             old     new   delta
sysctl_dots_to_slashes                                71      86     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosysctl: on EIO ("sysctl net.ipv6.conf.all.stable_secret") set nonzero exitcode
Denys Vlasenko [Fri, 8 Feb 2019 13:59:06 +0000 (14:59 +0100)]
sysctl: on EIO ("sysctl net.ipv6.conf.all.stable_secret") set nonzero exitcode

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosysctl: avoid stat() on every item if in -w mode
Denys Vlasenko [Fri, 8 Feb 2019 13:27:21 +0000 (14:27 +0100)]
sysctl: avoid stat() on every item if in -w mode

function                                             old     new   delta
sysctl_act_recursive                                 163     167      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosysctl: allow setting empty values
Denys Vlasenko [Fri, 8 Feb 2019 13:02:59 +0000 (14:02 +0100)]
sysctl: allow setting empty values

function                                             old     new   delta
sysctl_act_on_setting                                451     445      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: fix replacement of single character with CR
Ron Yorston [Sun, 3 Feb 2019 14:01:58 +0000 (14:01 +0000)]
vi: fix replacement of single character with CR

Currently if the 'r' command is followed by a carriage return a
literal CR replaces the current character.

Fix this so that:

- a new line is inserted
- the autoindent setting is respected
- the cursor is placed at the start of the new line

function                                             old     new   delta
do_cmd                                              5052    5060      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 8/0)                 Total: 8 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: fix faulty undo after autoinsert
Ron Yorston [Sun, 3 Feb 2019 10:13:17 +0000 (10:13 +0000)]
vi: fix faulty undo after autoinsert

Enable autoinsert and enter the following with an indent of three
spaces:

   line 1
   line 2

Using 'u' to undo the last insert results in:

   line1e 2

The insertion of the indent hasn't been properly recorded.

Since recording insertions is a common operation add a convenience
function, undo_push_insert(), to handle this and use it to record
the autoindent correctly.

function                                             old     new   delta
undo_push_insert                                       -      36     +36
string_insert                                        133     129      -4
char_insert                                          518     473     -45
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 36/-49)            Total: -13 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agochcon: Fix typo in ACTION_RECURSE
Rostislav Skudnov [Wed, 6 Feb 2019 11:57:29 +0000 (11:57 +0000)]
chcon: Fix typo in ACTION_RECURSE

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodhcp service example: rewrite "private network to mask" as case statement
Denys Vlasenko [Fri, 8 Feb 2019 09:37:05 +0000 (10:37 +0100)]
dhcp service example: rewrite "private network to mask" as case statement

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodhcp service example: cater for servers hot giving subnet and/or router
Denys Vlasenko [Tue, 5 Feb 2019 16:48:24 +0000 (17:48 +0100)]
dhcp service example: cater for servers hot giving subnet and/or router

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolineedit: fix SEGV in isk, hexedit, ed, closes 11661
Denys Vlasenko [Mon, 4 Feb 2019 15:16:30 +0000 (16:16 +0100)]
lineedit: fix SEGV in isk, hexedit, ed, closes 11661

fdisk, hexedit and ed calls read_line_edit in libbb/lineedit.c with NULL
as first argument. On line 2373 of lineedit.c of busybox version 1.29.3,
state->hist_file is referenced without checking the state->flag.

This causes segmentation fault on fdisk, hexedit and ed on ARM Cortex-A9.
It somehow works on x86_64.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoservice examples: do not respawn supplicant too often
Denys Vlasenko [Sat, 2 Feb 2019 18:06:19 +0000 (19:06 +0100)]
service examples: do not respawn supplicant too often

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogrep: short-circuit -v to bail out on first match
Ari Sundholm [Mon, 28 Jan 2019 17:41:12 +0000 (19:41 +0200)]
grep: short-circuit -v to bail out on first match

A small optimization. There is no need to try matching the current
input line against any further patterns if a match was already
found and -v is specified.

function                                             old     new   delta
grep_file                                           1463    1440     -23

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Niko Vähäsarja <niko@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogrep: fix -x -v with certain pattern orders
Ari Sundholm [Tue, 29 Jan 2019 13:42:57 +0000 (14:42 +0100)]
grep: fix -x -v with certain pattern orders

We found out that busybox -x -v is a bit broken:

ari@ari-thinkpad:~/busybox$ echo '  aa bb cc' | ./busybox grep -x -e 'aa.*' -e '.*bb.*'
  aa bb cc
ari@ari-thinkpad:~/busybox$ echo '  aa bb cc' | ./busybox grep -x -v -e 'aa.*' -e '.*bb.*'
ari@ari-thinkpad:~/busybox$ echo '  aa bb cc' | ./busybox grep -x -e '.*aa.*' -e 'bb.*'
  aa bb cc
ari@ari-thinkpad:~/busybox$ echo '  aa bb cc' | ./busybox grep -x -v -e '.*aa.*' -e 'bb.*'
  aa bb cc

Last one is wrong.

This patch fixes the issue by making sure that the variable 'found'
never makes a transition from 1 to 0, as this would mean that
grep previously found a match on this input line.

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Niko Vähäsarja <niko@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: implement pass-by-reference code from upstream
Denys Vlasenko [Fri, 25 Jan 2019 13:24:03 +0000 (14:24 +0100)]
bc: implement pass-by-reference code from upstream

function                                             old     new   delta
zxc_program_popResultAndCopyToVar                    298     493    +195
bc_vec_pushIndex                                       -      75     +75
zxc_vm_process                                       859     928     +69
xc_program_dereference                                 -      66     +66
bc_vec_npush                                           -      65     +65
zbc_num_s                                            239     249     +10
zxc_program_num                                     1024    1032      +8
zbc_num_divmod                                       150     156      +6
xc_program_search                                    143     146      +3
zxc_program_assign                                   392     389      -3
zdc_program_execStr                                  520     517      -3
xc_program_pushVar                                   198     195      -3
zxc_program_exec                                    4101    4092      -9
zbc_program_call                                     318     308     -10
zbc_func_insert                                      120     104     -16
zbc_parse_stmt_possibly_auto                        1460    1439     -21
bc_vec_push                                           53      12     -41
xc_parse_pushIndex                                    61      18     -43
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 6/9 up/down: 497/-149)          Total: 348 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agologin: close PAM session on errors as well, not only on success
Denys Vlasenko [Tue, 22 Jan 2019 16:00:14 +0000 (17:00 +0100)]
login: close PAM session on errors as well, not only on success

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoip link: Fix vlan proto, closes 8261 and 11638
Bernhard Reutner-Fischer [Tue, 22 Jan 2019 10:11:15 +0000 (11:11 +0100)]
ip link: Fix vlan proto, closes 8261 and 11638

The proto has to be passed in network byte-order.
While at it allow for
 ip link add link eth0 name eth0.2.24 type vlan proto 802.1ad id 24
 ip link del link eth0 name eth0.2.24 type vlan proto 802.1ad id 24
The del was lacking a dev_str and thus errored out. Fix by using
name/dev counterpart as fallback.

The proto identifier 802.1Q was not recognized, just it's lowercase
variant, fix that too.

function                                             old     new   delta
do_add_or_delete                                    1275    1376    +101
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 101/0)             Total: 101 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
5 years agoip link: fix mismatched enums in vlan_parse_opt(), closes 11631
Denys Vlasenko [Tue, 22 Jan 2019 09:07:50 +0000 (10:07 +0100)]
ip link: fix mismatched enums in vlan_parse_opt(), closes 11631

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agowget: detect when the length of received file is less than advertised
Denys Vlasenko [Mon, 21 Jan 2019 12:53:26 +0000 (13:53 +0100)]
wget: detect when the length of received file is less than advertised

function                                             old     new   delta
retrieve_file_data                                   579     596     +17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosed: code shrink
Denys Vlasenko [Mon, 21 Jan 2019 12:49:28 +0000 (13:49 +0100)]
sed: code shrink

function                                             old     new   delta
parse_file_cmd                                       115      94     -21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosed: Fix backslash parsing for 'w' command arg
Brian Foley [Wed, 2 Jan 2019 21:09:45 +0000 (13:09 -0800)]
sed: Fix backslash parsing for 'w' command arg

If there's any whitespace between w and the filename, parse_file_cmd
writes to the wrong offset when trying to fix up backslashes.

This can be seen in the asan build with busybox sed -e 'w 0\\'

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoawk: Fix overly permissive func arg list parsing
Brian Foley [Mon, 7 Jan 2019 02:32:59 +0000 (18:32 -0800)]
awk: Fix overly permissive func arg list parsing

It allows things like 'func f(a b)' and 'func f(a,)' which GNU awk forbids.

function                                             old     new   delta
parse_program                                        327     367     +40
chain_expr                                            40      67     +27
parse_expr                                           891     915     +24
EMSG_TOO_FEW_ARGS                                     30      18     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 91/-12)             Total: 79 bytes

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoawk: Syntax error if delete isn't given an arg.
Brian Foley [Tue, 1 Jan 2019 21:40:59 +0000 (13:40 -0800)]
awk: Syntax error if delete isn't given an arg.

Unlike exit and return, delete strictly requires an arg, and derefs a
null pointer if executed without one.

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoawk: Guard pointer chasing when parsing ternary expressions.
Brian Foley [Tue, 1 Jan 2019 21:40:58 +0000 (13:40 -0800)]
awk: Guard pointer chasing when parsing ternary expressions.

Avoids an uninit pointer deref for some malformed ternary exprs.

Add a test that would crash in busybox before this fix.

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agocapability: fix string comparison in cap_name_to_number
Mark Marshall [Fri, 18 Jan 2019 08:10:34 +0000 (09:10 +0100)]
capability: fix string comparison in cap_name_to_number

The result of strcasecmp was being used incorrectly.  This function
returns 0 if the strings match.

Signed-off-by: Mark Marshall <mark.marshall@omicronenergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agowget: remove empty if/endif preprocessor directive pair
Denys Vlasenko [Fri, 18 Jan 2019 22:15:20 +0000 (23:15 +0100)]
wget: remove empty if/endif preprocessor directive pair

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoservice examples: ifplugd -M to prevents frequent respawning
Denys Vlasenko [Fri, 18 Jan 2019 13:14:07 +0000 (14:14 +0100)]
service examples: ifplugd -M to prevents frequent respawning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agocheckstack.pl: tweak bfin re
Bernhard Reutner-Fischer [Fri, 18 Jan 2019 08:56:19 +0000 (09:56 +0100)]
checkstack.pl: tweak bfin re

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
5 years agocheckstack: pull from upstream
Bernhard Reutner-Fischer [Thu, 17 Jan 2019 21:21:53 +0000 (22:21 +0100)]
checkstack: pull from upstream

merge upstream changes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
5 years agocheckstack.pl: fix arch autodetection
Bernhard Reutner-Fischer [Thu, 17 Jan 2019 20:53:53 +0000 (21:53 +0100)]
checkstack.pl: fix arch autodetection

chomp trailing newlines

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
5 years agowget: don't notify on download begin and end if quiet
Martin Lewis [Thu, 10 Jan 2019 12:59:30 +0000 (13:59 +0100)]
wget: don't notify on download begin and end if quiet

When printing notification on download start and end,
mistakenly, it didn't respect the quiet option

function                                             old     new   delta
retrieve_file_data                                   561     579     +18
wget_main                                           2432    2437      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 23/0)               Total: 23 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoUpdate examples/udhcp/udhcpd.conf
Denys Vlasenko [Tue, 15 Jan 2019 12:19:01 +0000 (13:19 +0100)]
Update examples/udhcp/udhcpd.conf

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostart-stop-daemon: fix "both -x and -a" case: -a does override argv[0]
Denys Vlasenko [Mon, 14 Jan 2019 14:00:49 +0000 (15:00 +0100)]
start-stop-daemon: fix "both -x and -a" case: -a does override argv[0]

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostart-stop-daemon: create pidfile before parent exits, closes 8596
Denys Vlasenko [Mon, 14 Jan 2019 13:45:18 +0000 (14:45 +0100)]
start-stop-daemon: create pidfile before parent exits, closes 8596

This removes DAEMON_DOUBLE_FORK flag from bb_daemonize_or_rexec(),
as SSD was the only user.

Also includes fix for -S: now works without -a and -x,
does not print pids
(compat with "start-stop-daemon (OpenRC) 0.34.11 (Gentoo Linux)").

function                                             old     new   delta
start_stop_daemon_main                              1018    1084     +66
add_interface                                         99     103      +4
fail_hunk                                            139     136      -3
bb_daemonize_or_rexec                                205     183     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 70/-25)             Total: 45 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoadduser: fix a bug of getpwnam() overwriting shell name, closes 8586
Denys Vlasenko [Sat, 12 Jan 2019 10:51:58 +0000 (11:51 +0100)]
adduser: fix a bug of getpwnam() overwriting shell name, closes 8586

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotls: code shrink
Denys Vlasenko [Thu, 10 Jan 2019 19:18:02 +0000 (20:18 +0100)]
tls: code shrink

function                                             old     new   delta
lm_add                                                82      78      -4
curve25519                                           793     786      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-11)             Total: -11 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agonslookup: return exitcode 1 on resolution errors
Denys Vlasenko [Wed, 9 Jan 2019 12:38:57 +0000 (13:38 +0100)]
nslookup: return exitcode 1 on resolution errors

function                                             old     new   delta
nslookup_main                                        757     760      +3
send_queries                                        1690    1677     -13

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnet: placate compiler's warning
Denys Vlasenko [Wed, 9 Jan 2019 12:12:58 +0000 (13:12 +0100)]
telnet: placate compiler's warning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodate: improve help text for -D
Denys Vlasenko [Wed, 9 Jan 2019 11:58:52 +0000 (12:58 +0100)]
date: improve help text for -D

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: code shrink
Denys Vlasenko [Wed, 9 Jan 2019 10:17:19 +0000 (11:17 +0100)]
bc: code shrink

function                                             old     new   delta
xc_parse_pushInst_and_Index                            -      16     +16
zbc_parse_expr                                      1818    1816      -2
xc_parse_pushIndex                                    65      61      -4
zbc_parse_pushSTR                                     63      58      -5
zbc_parse_name                                       448     442      -6
xc_parse_pushNUM                                      74      67      -7
zdc_parse_expr                                       479     470      -9
bc_parse_pushJUMP_ZERO                                21      12      -9
bc_parse_pushJUMP                                     21      12      -9
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/8 up/down: 16/-51)            Total: -35 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: remove "empty expression" check/message, parsing fails in these cases anyway
Denys Vlasenko [Tue, 8 Jan 2019 18:32:38 +0000 (19:32 +0100)]
bc: remove "empty expression" check/message, parsing fails in these cases anyway

function                                             old     new   delta
zbc_parse_expr                                      1848    1818     -30

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: zbc_parse_expr_empty_ok() is unused except by zbc_parse_expr(), fold it in
Denys Vlasenko [Tue, 8 Jan 2019 18:29:35 +0000 (19:29 +0100)]
bc: zbc_parse_expr_empty_ok() is unused except by zbc_parse_expr(), fold it in

function                                             old     new   delta
zbc_parse_expr                                      1865    1848     -17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: disallow invalid syntax like "{ print 1 print 2 }"
Denys Vlasenko [Tue, 8 Jan 2019 17:08:48 +0000 (18:08 +0100)]
bc: disallow invalid syntax like "{ print 1 print 2 }"

statement parsing must NOT eat the terminator: caller needs to know
what it was, to correctly decide whether it is a valid one.

function                                             old     new   delta
zxc_program_read                                       -     234    +234
zdc_program_printStream                                -     144    +144
zbc_parse_stmt_possibly_auto                        1413    1460     +47
zxc_vm_process                                       869     859     -10
zxc_program_exec                                    4116    4101     -15
zdc_program_asciify                                  368       -    -368
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/2 up/down: 425/-393)           Total: 32 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agopasswd: initialize pointers correctly
Einar Jón [Tue, 8 Jan 2019 15:31:37 +0000 (16:31 +0100)]
passwd: initialize pointers correctly

Fix for running passwd as root (or sudo passwd $USER).
Crashed on call to free(orig) during cleanup.

Fix regression from commit 17058a06c4333fc0c492c168c8a971ebd0fd5a5a
Root user never changes the orig pointer, so when cleaning up, passwd tried to
free orig=(char*)""
Example: sudo passwd $USER
Changing password for xxx
New password:
Bad password: too short
Retype password:
Passwords don't match
free(): invalid pointer
Aborted

function                                             old     new   delta
passwd_main                                          958     961      +3

Signed-off-by: Einar Jón <tolvupostur@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotls: add comment about dl.fedoraproject.org needing secp256r1 ECC curve
Denys Vlasenko [Tue, 8 Jan 2019 15:09:41 +0000 (16:09 +0100)]
tls: add comment about dl.fedoraproject.org needing secp256r1 ECC curve

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc: when decoding DHCP_SUBNET, ensure it is 4 bytes long
Denys Vlasenko [Mon, 7 Jan 2019 14:33:42 +0000 (15:33 +0100)]
udhcpc: when decoding DHCP_SUBNET, ensure it is 4 bytes long

function                                             old     new   delta
udhcp_run_script                                     795     801      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcp: code shrink
Denys Vlasenko [Mon, 7 Jan 2019 14:23:18 +0000 (15:23 +0100)]
udhcp: code shrink

function                                             old     new   delta
attach_option                                        406     349     -57

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosleep: support "inf"
Denys Vlasenko [Mon, 7 Jan 2019 14:20:56 +0000 (15:20 +0100)]
sleep: support "inf"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobuild system: fix compiler warnings
Denys Vlasenko [Sun, 6 Jan 2019 19:12:16 +0000 (20:12 +0100)]
build system: fix compiler warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agofind: handle leading -- argument
Denys Vlasenko [Sun, 6 Jan 2019 18:58:18 +0000 (19:58 +0100)]
find: handle leading -- argument

function                                             old     new   delta
find_main                                            464     478     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnet: provide feedback after successful connect
Danijel Tasov [Sun, 6 Jan 2019 18:20:05 +0000 (19:20 +0100)]
telnet: provide feedback after successful connect

The real telnet provides some feedback:

Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.

We should do this to, because people are sitting there and think
a firewall is dropping packets.

function                                             old     new   delta
telnet_main                                         1270    1279      +9

Signed-off-by: Danijel Tasov <m@rbfh.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnetd: fix bad interaction with vhangup() from login
Denys Vlasenko [Sun, 6 Jan 2019 18:06:01 +0000 (19:06 +0100)]
telnetd: fix bad interaction with vhangup() from login

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnet: code shrink
Denys Vlasenko [Sun, 6 Jan 2019 17:45:38 +0000 (18:45 +0100)]
telnet: code shrink

function                                             old     new   delta
put_iac3_IAC_x_y_merged                                -      21     +21
put_iac4_msb_lsb                                       -      19     +19
put_iac2_msb_lsb                                       -      19     +19
put_iac                                               20      34     +14
iac_flush                                             32      36      +4
put_iac2_merged                                       46       -     -46
telnet_main                                         1492    1270    -222
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 2/1 up/down: 77/-268)          Total: -191 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnet: speed up processing of network input
Denys Vlasenko [Sun, 6 Jan 2019 17:41:11 +0000 (18:41 +0100)]
telnet: speed up processing of network input

function                                             old     new   delta
telnet_main                                         1482    1492     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>