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

Error 5042 when using libssh2_channel_shell.vi. #9

Closed
sanch3z opened this issue Oct 8, 2024 · 6 comments
Closed

Error 5042 when using libssh2_channel_shell.vi. #9

sanch3z opened this issue Oct 8, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@sanch3z
Copy link

sanch3z commented Oct 8, 2024

Hi

whenever I try to open a shell with libssh2_channel_shell.vi I get error 5042. libssh2_session_last_error.vi converts this to error -43, Failed waiting for channel success.

I'm not sure if this is necessary but i do request a PTY via libssh2_channel_request_pty.vi.

When this happens, the server reports the following message:
session_shell_req: parse packet: Connection from user <user> <ip> port <port>: unexpected bytes remain after decoding

I looked at example C code and tried to port that to LabVIEW using this library. Am I missing something obvious that needs to be done in LabVIEW to make this work?

@logmanoriginal
Copy link
Owner

This looks like an issue in the transport layer between libssh2 and your server. In principle, this should work out of the box. Without the code it is difficult to say why it fails.

Please try the channel_request_pty example included with the library. It is based on the example from libssh2 and available from the example finder when using the directory view:

image

@logmanoriginal logmanoriginal added the question Further information is requested label Oct 9, 2024
@sanch3z
Copy link
Author

sanch3z commented Oct 9, 2024

I adapted the vi so that it requests a process of type shell instead of exec.

libssh2_channel_shell.vi returns the error mentioned before.

image

@logmanoriginal logmanoriginal added bug Something isn't working and removed question Further information is requested labels Oct 9, 2024
@logmanoriginal
Copy link
Owner

Good catch.

Took me a while to figure out what is wrong here. Turns out that libssh2_channel_process_startup only checks if message is defined and not whether message_len is greater than zero: https://github.com/libssh2/libssh2/blob/e2b2c026869f9c8b9d1881729007fb95007ef0fa/src/channel.c#L1568-L1569

        if(message)
            _libssh2_store_u32(&s, (uint32_t)message_len);

These are the extra bytes that cause the error. The fix is to provide NULL for message when message_len is zero. Fix incoming...

@logmanoriginal
Copy link
Owner

The fix is included in the latest release: https://github.com/logmanoriginal/lvssh2/releases/tag/0.3.0

Let me know if this fixes your issue.

@sanch3z
Copy link
Author

sanch3z commented Oct 11, 2024

This, indeed, fixes my issue, tysm.

Is there any way I can support your work?

@logmanoriginal
Copy link
Owner

Awesome, thanks for the feedback!

As for support, please don't hesitate to report further bugs an issues you may discover. I'm pretty confident in the stability of this library but sometimes there are strange behaviors like the one you discovered here.

Thanks again for reporting this issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants