Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial output of remote telnet to local console #211

Closed
mfld-fr opened this issue May 13, 2018 · 3 comments
Closed

Partial output of remote telnet to local console #211

mfld-fr opened this issue May 13, 2018 · 3 comments
Assignees
Labels
bug Defect in the product fixed Defect corrected

Comments

@mfld-fr
Copy link
Contributor

mfld-fr commented May 13, 2018

While testing the fix to the select() weakness (see #208), I can observe a problem that looks closely linked to the one reported by @Mellvik in issue #133 about the console management.

I am using busybox telnet 127.0.0.1 2323 on the host and QEMU for ELKS target, with only ktcp and telnetd daemons. Sometimes part of the output of the remote command is directed to the ELKS console in QEMU, and not to the remote telnet client, even if not logged in !

In remote telnet client:

mfld@home /home/mfld/elks $ busybox telnet 127.0.0.1 2323
Welcome to the ELKS telnet server

login: root
# cd /bin
# 
# ls -l

-xr-x  1 root     root         8396  May 13 2018  banner
-rwxr-xr-x  1 root     root          648  May 13 2018  basename

And in local console (in QEMU):

ELKS 0.2.0

login: Telnetserver:accept connection
Commands entered by remote terminal:
># cd /bin
>ls -l
>-rwxr-xr-x  1 root    root        50652  May 13 2018  ash
-rwxr>

Here, the beginning of the ls -l command output goes to the local console, then the remaining goes to the remote telnet client.

@mfld-fr mfld-fr added the bug Defect in the product label May 13, 2018
@Mellvik
Copy link
Contributor

Mellvik commented May 14, 2018 via email

@mfld-fr
Copy link
Contributor Author

mfld-fr commented Jun 2, 2018

The observed bad behaviour is coming from a poor redirection implementation in telnetd. I revised that implementation with a cleaner code, but I detected two new problems on the master side of the pseudo-terminal.

First is that select() does not work, and second is that read() blocks when at least one character is available but when requesting more characters than available (not compliant to read manual page).

I also had to disable getty on virtual consoles 2 and 3 to get enough memory space for ktcp, telnetd, sh and its children, but that latest is not really a bug, rather a known limitation.

@mfld-fr mfld-fr self-assigned this Jun 2, 2018
mfld-fr added a commit to mfld-fr/elks that referenced this issue Jun 2, 2018
Cleanup of telnetd client loop.

Restore select for PTY master side.

Correct read / write behavior for PTY master side:
can return without blocking if less data available
in buffer than requested by the user.

Fixes ghaerr#211
@mfld-fr mfld-fr added the fixed Defect corrected label Jun 2, 2018
@mfld-fr
Copy link
Contributor Author

mfld-fr commented Jun 2, 2018

Server and PTY master side fixed. But the current implementation of telnetd is still poor : no login, no IAC handling, not able to restart another session, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect in the product fixed Defect corrected
Projects
None yet
Development

No branches or pull requests

2 participants