aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/telnet.c
AgeCommit message (Collapse)Author
2021-05-01telnet: just use dprintf() for IAC sequences.Elliott Hughes
I don't see the need for the separate buffer, and just using dprintf() directly is less code. The only downside really is having to get the right number of `%c`s in your format string.
2021-04-24telnet: various fixes.Elliott Hughes
This got a bit out of hand. All I wanted to fix was the CR conversion to get this part of https://tools.ietf.org/html/rfc854 right: Therefore, the sequence "CR LF" must be treated as a single "new line" character and used whenever their combined action is intended; the sequence "CR NUL" must be used where a carriage return alone is actually desired; and the CR character must be avoided in other contexts. This rule gives assurance to systems which must decide whether to perform a "new line" function or a multiple-backspace that the TELNET stream contains a character following a CR that will allow a rational decision. But to understand the code well enough to do that, and to fix it so that it works when IAC or CR sequences are split across multiple reads, I ended up rewriting a lot: * Add punctuation in help. * Remove duplicated #include. * Remove some unnecessary globals, enlarge the global buffers, and keep state for correct IAC sequence processing across reads. * Reduce code duplication and rewrite bits that made no sense. * Handle entering/exiting raw mode more uniformly. * Fix the prompt (the character count was wrong). * Allow ^]^D (like BSD telnet) as well as ^]e to exit, and look less like we crashed when doing so. * Simplify the IAC sequence handling, but more importantly work correctly when a sequence is split across multiple reads. * Use more of the existing "x" functions from lib. (And remove code that was duplicating what the "x" functions they'd just called had already done.) * Show "Connected to". * Better signal handling. I'm still not happy with TELOPT_ECHO and TELOPT_SGA in handle_wwdd(), but don't (yet) understand them well enough to simplify them further. On the bright side, I think TELOPT_NAWS is a lot clearer now. It also occurs to me now I'm looking at the diff that although the IAC output code is now better than it was, it probably still isn't pulling its weight and might better be replaced by printf(). ...but this patch has already gotten way out of hand!
2021-01-26getty/telnet/tftpd: minor cleanup.Elliott Hughes
Remove STDIN_FILENO and use FLAG(). Use xsetspeed() rather than have a duplicate table. Inline getty's print_prompt(). There's still a lot of cleanup needed here, in particular use of toybuf and removal of the inappropriately-named HOSTNAME_SIZE (and ideally sharing that logic with login(1) which already contains a better implementation of it).
2020-07-05toys.h already includes poll.hRob Landley
2019-07-11bind/connect cleanup.Elliott Hughes
Rename the existing xbind/xconnect to xbindany/xconnectany, to make room for new xbind/xconnect that are more like 'x' versions of the regular bind and connect. Move explicit bind/connect callers over to xbind/xconnect. Of the affected commands, only netcat is actually used by Android. It was the most recent patch to netcat that made the lack of a more traditional xbind/xconnect apparent.
2017-07-17Split out xgetaddrinfo() from xconnect()Rob Landley
2015-08-05Tweak xconnect: socket can be a string (ala "ftp") from /etc/services.Rob Landley
Still need a rethink on how to handle socket/bind/connect sequence.
2015-08-03Factor out xconnect(), plus some other small cleanups to telnet.c.Rob Landley
2014-05-21Make telnet use generic_signal(), minor in-passing cleanups.Rob Landley
2013-12-23telnet and telnetd from Ashwini Sharma's guys.Rob Landley