[Bug 12736] New: Change telnet EoL to CR/NUL

bugzilla at busybox.net bugzilla at busybox.net
Thu Apr 2 09:39:06 UTC 2020


https://bugs.busybox.net/show_bug.cgi?id=12736

            Bug ID: 12736
           Summary: Change telnet EoL to CR/NUL
           Product: Busybox
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Networking
          Assignee: unassigned at busybox.net
          Reporter: kstaniek at gmail.com
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

There is a use case when you telnet to KVM serial console port and every new
line is interpreted and two new lines. The typical symptom is that during
authentication you can type username and when press enter it goes through
password prompt with empty password. The KVM uses netcat to connect virtual
serial port with TCP port instead of full telnetd implementation. There is no
way to change that behaviour with any configuration knobs. 

The she solution would be to remove the '\n' on new line.
I have tested the following diff:

diff --git a/networking/telnet.c b/networking/telnet.c
index 9fc85050b..be84515b7 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -236,7 +236,7 @@ static void handle_net_output(int len)
                         * like CR NUL - easier to talk to HTTP/SMTP servers.
                         */
                        *dst = '\r'; /* Enter -> CR LF */
-                       *++dst = '\n';
+                       /* *++dst = '\n'; */
                }
 #if 0
 /* putty's "special commands" mode does this: */

Just removing *++dst = '\n';

Maybe the solution would be to add the configuration option for telnet client
to chose between CR/LF or CR/NUL.

It seems the most popular inetutils-telnet uses CR/NUL;


Here is the example

root at csm-server:/root$ telnet -l root 172.26.228.210 26993

Entering character mode
Escape character is '^]'.    <- press ENTER



User Access Verification

Username: user   <- press ENTER (it takes user and password as empty string –
like you pressed enter twice)
Password:

User Access Verification <<< the authentication failed and moved to second
attempt

Username: user
Password:

So after investigation I could make a workaround with the following construct:

LP=12345 RA=172.26.228.210 RP=26993 ; ( echo -e '\r' | socat -u - TCP:$RA:$RP ;
socat TCP-LISTEN:$LP,reuseaddr,crnl TCP:$RA:$RP ) & sleep 1 ; telnet localhost
$LP

The above command spawns the socat process which builds the tunnel to remote
device (RA:RP) with cr<->crnl translation and makes it available as localport
LP and then it runs telnet to that tunnel on local machine.

Here is the result:

root at csm-server:/root$ LP=12345 RA=172.26.228.210 RP=26993 ; ( echo -e '\r' |
socat -u - TCP:$RA:$RP ; socat TCP-LISTEN:$LP,reuseaddr,crnl TCP:$RA:$RP ) &
sleep 1 ; telnet localhost $LP
[1] 714

Entering character mode
Escape character is '^]'.  << press ENTER


Username: user <<< press ENTER
Password:        <- type password and press ENTER


RP/0/RP0/CPU0:R1#

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list