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

Race condition in sshd. #2852

Open
Foxboron opened this issue Jan 13, 2024 · 3 comments
Open

Race condition in sshd. #2852

Foxboron opened this issue Jan 13, 2024 · 3 comments
Labels
Bug Stuff that's wrong

Comments

@Foxboron
Copy link
Member

Describe the bug
When using x/crypto/ssh to connect with sshd there is no output from the session with CombinedOutput. And manually using OpenSSH to connect to sshd sometimes doesn't give any output back.

I suspect there is a race condition somewhere but I have not managed to figure out where.

To Reproduce
Start sshd and use x/crypto/ssh to open a session and use CombinedOutput. It will fail with EOF.

Expected behavior
The command should return something.

Additional context
N/A

@Foxboron Foxboron added the Bug Stuff that's wrong label Jan 13, 2024
@Foxboron
Copy link
Member Author

My running theory is that using e.Process.Wait instead of e.Wait() is the main issue, as we are exiting the before everything is written to stdout/stdin/stderr.

I'm at a loss on how we should properly fix this, but I'm wondering if just execing with CombinedOutput and then io.Copy it to c would be a better solution? Currently it seems e.Wait() chokes on the channel we are giving it.

@Foxboron
Copy link
Member Author

cc @bluecmd :)

@binjip978
Copy link
Contributor

I had similar issue with EOF when I was trying to write test for this command: #2963 and initially I was trying combinedOutput or Output and got only EOF. I tested sshd command with other ssh clients and saw no issues, but what seemed to work is to pipe Stdout and then I got an output. But still I have linux box where this test fails reliably :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Stuff that's wrong
Projects
None yet
Development

No branches or pull requests

2 participants