summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2020-01-18remove now-unused Binding traitWez Furlong
2020-01-18Make properly Send safeWez Furlong
In earlier iterations I accidentally removed Send from Session and then later restored it in an unsafe way. This commit restructures the bindings so that each of the objects holds a reference to the appropriate thing to keep everything alive safely, without awkward lifetimes to deal with. The key to this is that the underlying Session is tracked by an Arc<Mutex<>>, with the related objects ensuring that they lock this before they call into the underlying API. In order to make this work, I've had to adjust the API around iterating both known hosts and agent identities: previously these would iterate over internal references but with this shift there isn't a reasonable way to make that safe. The strategy is instead to return a copy of the host/identity data and then later look up the associated raw pointer when needed. The purist in me feels that the copy feels slightly wasteful, but the realist justifies this with the observation that the cardinality of both known hosts and identities is typically small enough that the cost of this is in the noise compared to actually doing the crypto+network ops. I've removed a couple of error code related helpers from some of the objects: those were really internal APIs and were redundant with methods exported by the Error type anyway. Fixes: https://github.com/alexcrichton/ssh2-rs/issues/154 Refs: https://github.com/alexcrichton/ssh2-rs/issues/137
2020-01-18rename unwrap_inner_or_err to get_innerbold
2020-01-18rename unwrap_raw_or_err to get_rawbold
2020-01-18simplify function signaturebold
2020-01-18eliminate conditionals when enforce blocking in destructorsbold
2020-01-18use take instead of as_refbold
2020-01-18set ssh2 to blocking when dropping sftp and filebold
2020-01-18make set_blocking and is_blocking available for inner sessionbold
2020-01-18add shutdown and close methodsbold
This commit exposes the `shutdown` method of `Sft` and `close` method of `File` to free resources. Previously this was done synchronously and therefor not usable in async wrappers. Whith the methods exposed they can be polled until success. If successful a flag is set to notify the destructor that no resources need to be freed anymore. However, if resources were not cleaned up by calling `close` or `shutdown` the destructor will clean up synchronously.
2020-01-18derive clone for sessionbold
2020-01-18derive Debug and Clone for PtyModesbold
2020-01-11let compiler figure out the correct typebold
2020-01-11cargo fmtbold
2020-01-11let compiler figure out the correct typebold
2020-01-11simplify unwrap_or_else argumentbold
2020-01-11make retrieving last session error privatebold
2020-01-11return correct errorsbold
2020-01-03cargo fmtbold
2020-01-03export block directionsbold
2019-12-08map TIMEOUT -> std::io::ErrorKind::TimedOutWez Furlong
Closes: https://github.com/alexcrichton/ssh2-rs/issues/141
2019-12-08improve docsWez Furlong
2019-12-08A PtyModes helper for specifying terminal modesWez Furlong
Closes: https://github.com/alexcrichton/ssh2-rs/issues/145
2019-10-20fix warning in doc buildWez Furlong
2019-10-20Make Session be `Send` againWez Furlong
Refs: https://github.com/alexcrichton/ssh2-rs/issues/137
2019-10-20complete deletion of src/test.rsWez Furlong
I think this was overlooked in c95e6ea1e74f82f1a889302978e37a7baf4073cf
2019-10-20fixup documentation on Session::newWez Furlong
Refs: https://github.com/alexcrichton/ssh2-rs/issues/137
2019-10-02Clarify docs of Session to refer to set_tcp_stream(), not handshake()Akshay Narayan
2019-09-15replace use of try! with ? operatorWez Furlong
This fixes the CI build with nightly, as we have deny(warnings) enabled.
2019-08-02tighten up `Session::rc`Wez Furlong
Previously, this function could return None even if passed an error result. This could happen in situations where no error had been recorded against the session object, but where libssh2 had returned an error condition anyway. It was also possible for the prior implementation to return the wrong information in a similar situation: if an error had been recorded against the session, that error would be returned rather than the current error code. This commit tidies up the implementation of this function by always returning an `Error` object that corresponds to the provided `rc` parameter. If the last error message recorded against the `Session` has a matching error value then that error message will be used, otherwise we'll synthesize one just from the error code.
2019-08-02handle_extended_dataWez Furlong
Add a function to configure how extended data streams are to be handled. This allows for merging stderr to stdout, or discarding it.
2019-08-01ignore the panic result from the keyboard promptWez Furlong
There's not a lot we can do about it.
2019-08-01don't allow panics to escape the prompt callbackWez Furlong
This avoids the potential for UB if the callback panics; Rust doesn't specify what happens if a panic unwinds back into C code.
2019-08-01fixup rustdocsWez Furlong
2019-08-01move tcpstream assignment to its own functionWez Furlong
The recent move to take ownership of TcpStream exposed an issue with the `handshake` method: if the stream is non-blocking then it may take several attempts to handshake, but only the first one is able to transfer ownership. My initial thought was just to make the TcpStream a required parameter to `new`, but we have some tests that work with known hosts and the ssh agent that don't require a tcpstream. I'm going to review those and see if there is a cleaner overall solution, but that will likely require more substantial API changes. For now, the simplest change is to add a separate `set_tcp_stream` function to make the stream ownership transfer explicit and distinct from the handshake. Refs: https://github.com/alexcrichton/ssh2-rs/issues/17
2019-07-31limit the number of responses from keyboard interactive promptWez Furlong
This makes it safer to accidentally return more than the requested number of responses from the prompt callback. Refs: https://github.com/alexcrichton/ssh2-rs/issues/65
2019-07-31Support keyboard-interactive authenticationWez Furlong
Refs: https://github.com/alexcrichton/ssh2-rs/issues/65
2019-07-31Fix scp_recv ABI issue on WindowsWez Furlong
* Adopt scp_recv2 instead, which uses compatible 64-bit stat types * Mark scp_recv as deprecated * small version bump Fixes https://github.com/alexcrichton/ssh2-rs/issues/109 Refs https://github.com/alexcrichton/ssh2-rs/pull/117 Co-authored-by: Joyce Babu <joyce@ennexa.com>
2019-07-30improve handshake error reporting on windowsWez Furlong
I'm hitting a kex protocol error when talking from windows->ubuntu 19 and that wasn't getting reported as an error on the client side because the `rc` function only emits an error if one has been recorded against the session object, despite being reported via the parameter. I think it's worth revisiting this more broadly, but for now, let's report this error in the handshake case.
2019-07-29Make channel tests more robust to stderr outputWez Furlong
At the start of feb 2019 the tests started to fail on macos on Travis. No changes were made to the repo, so the problem must be environmental. It turns out that the server was emitting stderr output, and since the tests were not consuming stderr, this made `channel.eof()` always return false. The resolution is to drain both stdout and stderr in the tests before making assertions with `channel.eof()`. I've also updated the doc comment on `channel.eof()` to reflect this, as it is a bit of a sharp edge.
2019-07-29adjust std usage for rust 1.26 compatWez Furlong
2019-07-29Map EAGAIN errors appropriatelyWez Furlong
When the channel is set to non-blocking mode, take care to map the underlying ssh2 error code to the WouldBlock error kind so that embedding applications can correctly handle that situation.
2019-07-29fixup doc testsWez Furlong
`cargo test --all` (which only appears safe to run in the CI environment) doesn't get as far as `cargo test --doc` so I overlooked these.
2019-07-29Avoid panic when SSH_USERAUTH_NONE succeedsWez Furlong
This is an alternative take on addressing this issue: Refs: https://github.com/alexcrichton/ssh2-rs/pull/104
2019-07-29remove SessionBinding traitWez Furlong
I'd gradually removed the usage of it while I was hacking through with my lifetime changes. I suppose it could be added back but I confess that I removed it because I found it confusing and it didn't look like it would fit on my first pass through the code.
2019-07-29KnownHosts no longer borrows Session eitherWez Furlong
2019-07-29Agent no longer borrows session eitherWez Furlong
2019-07-29Channel, Sftp no longer borrow SessionWez Furlong
Instead the internal session is kept alive via Rc Refs: https://github.com/alexcrichton/ssh2-rs/issues/53
2019-07-29Session::handshake now takes ownership of TcpStreamWez Furlong
Refs: https://github.com/alexcrichton/ssh2-rs/issues/17
2019-07-29Session::new() now returns Result rather than OptionWez Furlong
Refs: https://github.com/alexcrichton/ssh2-rs/issues/96 This is a breaking change, so bump the package version