[git commit] telnetd: fix handshake: had one wrong, but harmless element
Denys Vlasenko
vda.linux at googlemail.com
Sun Feb 22 19:04:41 UTC 2026
commit: https://git.busybox.net/busybox/commit/?id=8738c3102f9614f3bfabbd615d963b9710d268b0
branch: https://git.busybox.net/busybox/log/?h=master
function old new delta
static.iacs_to_send 12 9 -3
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
networking/telnet.txt | 2 +-
networking/telnetd.c | 20 ++++++++++++++------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/networking/telnet.txt b/networking/telnet.txt
index 3a9304adb..87b1d1aa6 100644
--- a/networking/telnet.txt
+++ b/networking/telnet.txt
@@ -2,7 +2,7 @@
// IAC SE (240) End of subnegotiation parameters
// IAC NOP (241) No operation
// IAC DM (242) Data Mark (used with TCP urgent pointer)
-// IAC BRK (243) Break (simulate serial line break) - perhaps tcsendbreak(master_ptyfd, 0) [untested]?
+// IAC BRK (243) Break (simulate serial line break) - perhaps tcsendbreak(master_ptyfd)? [untested]
// IAC IP (244) Interrupt Process ("send SIGINT to foreground process group a-la ^C")
// IAC AO (245) Abort Output
// IAC AYT (246) Are You There
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 9251f804b..a67ae5512 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -866,13 +866,21 @@ static void make_new_session(ioloop_state_t *io, int sockrd)
* stuff that requires char-by-char support. */
{
static const char iacs_to_send[] ALIGN1 = {
- IAC, DO, TELOPT_ECHO,
- IAC, DO, TELOPT_NAWS,
- /* This requires telnetd.ctrlSQ.patch (incomplete) */
- /*IAC, DO, TELOPT_LFLOW,*/
- IAC, WILL, TELOPT_ECHO,
- IAC, WILL, TELOPT_SGA
+ IAC, WILL, TELOPT_ECHO, // "I will echo your chars"
+ // (Not really, _we_ won't - our programs in pty usually
+ // handle that. In practice, this says: "do not echo
+ // your user's input chars back to him _on your side_".)
+ IAC, WILL, TELOPT_SGA, // "I assume full-duplex, won't send GA's"
+ //IAC, DO, TELOPT_ECHO, //WRONG: "can you echo my chars to me"??
+ IAC, DO, TELOPT_NAWS, // "can you send me terminal size data?"
+ // This requires telnetd.ctrlSQ.patch (incomplete):
+ //IAC, DO, TELOPT_LFLOW,
};
+//Theoretically, our "WILL X" are requests and should only activate when client responds with "DO X".
+//However, we do not wait/check for "DO"s. Why?
+//There is nothing to "activate" on our side for TELOPT_ECHO.
+//For TELOPT_SGA, we don't even have code to support sending/understandig GAs,
+//so SGA is "always activated".
/* Just stuff it into TCP stream! (no error check...) */
safe_write(sockwr, iacs_to_send, sizeof(iacs_to_send));
}
More information about the busybox-cvs
mailing list