janmojzis / tinyssh

TinySSH is small server (less than 100000 words of code)
Creative Commons Zero v1.0 Universal
1.44k stars 79 forks source link

ControlMaster triggers BUG: (protocol error){channel.c:57} #59

Closed trentbuck closed 2 years ago

trentbuck commented 3 years ago

Initially reported (by me) downstream: https://bugs.debian.org/995146 Forwarding here because I reproduced it with 20210601 much quicker than I expected. See the attached transcript for the exact openssh CLI options I used. transcript.txt

trentbuck commented 3 years ago

PS: if making ControlMaster work is nontrivial, I think it's sufficient to just give a clear error and what the user should do about it (e.g. tell openssh/ansible/tramp.el/... not to use ControlMaster).

janmojzis commented 3 years ago

Hello, thanks for bugreport. Here: https://github.com/janmojzis/tinyssh/commit/70bded32344d87824f737bb65e8f5d56fe94181b is the fix. New channel is correctly rejected instead of closing the connection.

janmojzis commented 3 years ago

Can You please independently confirm if the fix works for You?

trentbuck commented 3 years ago

Sorry for the delayed response. I confirm your fix https://github.com/janmojzis/tinyssh/commit/70bded32344d87824f737bb65e8f5d56fe94181b works for me. When re-running the test SSH commands, the first client remains open, and the second one now does this, indicating correct automatic fallback to non-muxed mode:

mux_client_request_session: session request failed: Session open refused by peer
Warning: Permanently added '[localhost]:2022' (ED25519) to the list of known hosts.
ControlSocket /home/twb/.ssh/master-1cba28b29465b90338a34530bde6867ca490e3de already exists, disabling multiplexing
root@main:~# 
janmojzis commented 2 years ago

Fixed in version 20220101.