为什么“终端速度”是“终端速度”? 从 Java 生成时,本机 linux telnet 客户端 0,0 的问题(以及如何修复它)?
当 telnet 进程是由 Java 程序创建时,我无法使用 telnet 登录 HPUX 主机。
当我从命令行(从 bash)远程登录到 HPUX 主机时,我可以登录并使用会话。
当我从 Java 生成 telnet 进程时,发生了一些奇怪的事情。 系统会提示我输入用户名并提交。 我还收到输入密码的提示。 但由于某种原因,telnet 服务器不等待密码; 它在发送之前退出会话。
查看wireshark中的交换,我发现一旦telnet客户端发送密码提示的ACK,服务器就会发送FIN数据包,终止初始化会话。
我在提示密码之前的握手中看到的差异之一是服务器要求终端速度。 当从命令行运行telnet时,它发送的终端速度是38400,38400。 从 Java 运行 telnet 时,终端速度为 0,0。
查看 telnet 客户端的源代码,我发现 telnet 客户端发送的“终端速度”的来源之一是 cfgetospeed()/cfgetispeed() API 的输出。 根据这个,0波特率的含义是“挂断”,这就是 HPUX telnetd 进程解释它的方式。
我运行的是 Linux Fedora Core 6。
I'm unable to login to an HPUX host using telnet when the telnet process is created by a Java program.
When I telnet to the HPUX host from the command line (from bash), I am able to login and use the session.
When I spawn the telnet process from Java, something strange happens. I am prompted for the username and submit it. I also get the prompt for the password. But for some reason the telnet server does not wait for the password; it quits the session before it is sent.
Looking at the exchange in wireshark, I see that as soon as the telnet client sends an ACK for the password prompt, the server sends a FIN packet, terminating the initializing session.
One of the differences I can see in the handshaking leading up to the password prompt is that the server asks for the terminal speed. When running telnet from the command line, the terminal speed it sends is 38400,38400. When running telnet from Java, the terminal speed is 0,0.
Looking at the source code of a telnet client, I found that one source of the "terminal speed" sent by the telnet client is the output of the cfgetospeed()/cfgetispeed() APIs. According to this, a meaning of 0 baud rate is "hang up", which is how it looks like the HPUX telnetd process is interpreting it.
I'm running from Linux Fedora Core 6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑 $TERM 环境变量间接用于确定速度,并且在从 Java 生成它时未设置。
如果不是这样,您还可以尝试通过 bash 启动 telnet,即从 Java 启动 bash 并向其发送 telnet 命令行。 这应该提供与手动启动时完全相同的环境。
I suspect that the $TERM environment variable is indirectly used to determine the speed, and is not set when spawning it from Java.
If that's not it, you could also try launching telnet through bash, i.e. start bash from Java and send it the telnet command line. That should provide exactly the same environment as when you launch it manually.