-
-
Notifications
You must be signed in to change notification settings - Fork 939
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
Added SshCommand.InputStream to allow writing to stdin of SshCommand #1293
Added SshCommand.InputStream to allow writing to stdin of SshCommand #1293
Conversation
Excluded MD5 tests on net462 because I get System.InvalidOperationException: 'This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.' SshdConfig: do not throw for "Include", just do nothing. Modified failing dos2unix parameters in Dockerfile.TestServer. Forceing LF line ending for key files used by integration tests, otherwise using them causes error. SftpClientTest.Test_Sftp_Multiple_Async_Upload_And_Download_10Files_5MB_Each times out for maxFiles=10, decreasing to 2 to make the test pass.
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs
Outdated
Show resolved
Hide resolved
It looks good to me! But I need more time to test it! Do you have a specific function in mind that you want to implement using this functionality? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should send channel EOF in Write
. How about calling it only in Dispose
and initialising InputStream
lazily, something like:
var cmd = ...
using (cmd.InputStream) // This initialises InputStream
{
myStream.CopyTo(cmd.InputStream);
} // This disposes InputStream and sends EOF
?
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs
Outdated
Show resolved
Hide resolved
… SshCommand.InputStream with CreateInputStream to emphasise that a (disposable) resource is created here. EndExecute also closes the _inputStream to make sure that EOF is sent (in case the user forgot to dispose the input stream). Added more unit tests: sending the input one byte at a time, not disposing the input stream, calling CreateInputStream before BeginExecute or AfterEndExecute throws exception.
…SH.NET into SshCommandInputStream
I had a very specific use case: I had to call some legacy system that is implemented as a set of SSH commands and one of the commands requires sending a file via input stream. These changes made it work. |
Thanks a lot @WojciechNagorski and @Rob-Hague for the comments and suggestions!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Shall I do a squash+rebase onto develop before merging the PR? |
It will be merged with "Squash and merge" so it is not necessary (it requires a CODEOWNERS approval before it can merge) |
There is a build problem:
|
This issue has been fixed in the 2024.0.0 version. |
Changes:
I you have recommendations for further unit tests, please advise.
I started the work by trying to run all unit tests on my dev machine to see if they all pass. Unfortunately a lot of them failed, so I had to make the following modifications (see the changes in my first commit in this PR):
If you know a better fix for any of the above modifications, please advise.